packages feed

hls-stylish-haskell-plugin 2.0.0.1 → 2.1.0.0

raw patch · 2 files changed

+21/−20 lines, 2 filesdep +mtldep ~ghcidedep ~hls-plugin-apidep ~hls-test-utilsPVP ok

version bump matches the API change (PVP)

Dependencies added: mtl

Dependency ranges changed: ghcide, hls-plugin-api, hls-test-utils

API changes (from Hackage documentation)

Files

hls-stylish-haskell-plugin.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               hls-stylish-haskell-plugin-version:            2.0.0.1+version:            2.1.0.0 synopsis:           Integration with the Stylish Haskell code formatter description:   Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>@@ -20,8 +20,6 @@     location: https://github.com/haskell/haskell-language-server.git  library-  if impl(ghc >= 9.5)-    buildable: False   exposed-modules:  Ide.Plugin.StylishHaskell   hs-source-dirs:   src   build-depends:@@ -30,17 +28,16 @@     , filepath     , ghc     , ghc-boot-th-    , ghcide           == 2.0.0.1-    , hls-plugin-api   == 2.0.0.1+    , ghcide           == 2.1.0.0+    , hls-plugin-api   == 2.1.0.0     , lsp-types+    , mtl     , stylish-haskell  ^>=0.12 || ^>=0.13 || ^>=0.14.2     , text    default-language: Haskell2010  test-suite tests-  if impl(ghc >= 9.5)-    buildable: False   type:             exitcode-stdio-1.0   default-language: Haskell2010   hs-source-dirs:   test@@ -50,4 +47,4 @@     , base     , filepath     , hls-stylish-haskell-plugin-    , hls-test-utils              == 2.0.0.1+    , hls-test-utils              == 2.1.0.0
src/Ide/Plugin/StylishHaskell.hs view
@@ -1,22 +1,26 @@ {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ViewPatterns      #-} module Ide.Plugin.StylishHaskell   ( descriptor   , provider   ) where +import           Control.Monad.Except             (throwError) import           Control.Monad.IO.Class-import           Data.Text                       (Text)-import qualified Data.Text                       as T-import           Development.IDE                 hiding (pluginHandlers)-import           Development.IDE.GHC.Compat      (ModSummary (ms_hspp_opts),-                                                  extensionFlags)-import qualified Development.IDE.GHC.Compat.Util as Util+import           Data.Text                        (Text)+import qualified Data.Text                        as T+import           Development.IDE                  hiding (pluginHandlers)+import           Development.IDE.Core.PluginUtils+import           Development.IDE.GHC.Compat       (ModSummary (ms_hspp_opts),+                                                   extensionFlags)+import qualified Development.IDE.GHC.Compat.Util  as Util import           GHC.LanguageExtensions.Type+import           Ide.Plugin.Error                 (PluginError (PluginInternalError)) import           Ide.PluginUtils-import           Ide.Types                       hiding (Config)+import           Ide.Types                        hiding (Config) import           Language.Haskell.Stylish-import           Language.LSP.Types              as J+import           Language.LSP.Protocol.Types      as LSP import           System.Directory import           System.FilePath @@ -30,17 +34,17 @@ -- If the provider fails an error is returned that can be displayed to the user. provider :: FormattingHandler IdeState provider ide typ contents fp _opts = do-  dyn <- fmap (ms_hspp_opts . msrModSummary) $ liftIO $ runAction "stylish-haskell" ide $ use_ GetModSummary fp+  (msrModSummary -> ms_hspp_opts -> dyn) <- runActionE "stylish-haskell" ide $ useE GetModSummary fp   let file = fromNormalizedFilePath fp   config <- liftIO $ loadConfigFrom file   mergedConfig <- liftIO $ getMergedConfig dyn config   let (range, selectedContents) = case typ of         FormatText    -> (fullRange contents, contents)-        FormatRange r -> (normalize r, extractRange r contents)+        FormatRange r -> (normalize r, extractTextInRange (extendToFullLines r) contents)       result = runStylishHaskell file mergedConfig selectedContents   case result of-    Left  err -> return $ Left $ responseError $ T.pack $ "stylishHaskellCmd: " ++ err-    Right new -> return $ Right $ J.List [TextEdit range new]+    Left  err -> throwError $ PluginInternalError $ T.pack $ "stylishHaskellCmd: " ++ err+    Right new -> pure $ LSP.InL [TextEdit range new]   where     getMergedConfig dyn config       | null (configLanguageExtensions config)