diff --git a/cabal.project b/cabal.project index e430c76dee..f36b736463 100644 --- a/cabal.project +++ b/cabal.project @@ -45,3 +45,8 @@ constraints: if impl(ghc >= 9.9) -- https://github.com/haskell/haskell-language-server/issues/4324 benchmarks: False +else + source-repository-package + type: git + location: https://github.com/jhrcek/stylish-haskell.git + tag: 0b1f3bb50d25c7c30171d080643bc8badbe1883c diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 0a325deaf6..47f00b75c1 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -1576,7 +1576,6 @@ library hls-stylish-haskell-plugin hs-source-dirs: plugins/hls-stylish-haskell-plugin/src build-depends: , base >=4.12 && <5 - , directory , filepath , ghc-boot-th , ghcide == 2.9.0.0 diff --git a/plugins/hls-stylish-haskell-plugin/src/Ide/Plugin/StylishHaskell.hs b/plugins/hls-stylish-haskell-plugin/src/Ide/Plugin/StylishHaskell.hs index a862e57fb8..fb3ac81cd0 100644 --- a/plugins/hls-stylish-haskell-plugin/src/Ide/Plugin/StylishHaskell.hs +++ b/plugins/hls-stylish-haskell-plugin/src/Ide/Plugin/StylishHaskell.hs @@ -25,7 +25,6 @@ import Ide.PluginUtils import Ide.Types hiding (Config) import Language.Haskell.Stylish import Language.LSP.Protocol.Types as LSP -import System.Directory import System.FilePath data Log @@ -78,12 +77,9 @@ provider recorder ide _token typ contents fp _opts = do -- | Recursively search in every directory of the given filepath for .stylish-haskell.yaml. -- If no such file has been found, return default config. loadConfigFrom :: FilePath -> IO Config -loadConfigFrom file = do - currDir <- getCurrentDirectory - setCurrentDirectory (takeDirectory file) - config <- loadConfig (makeVerbose False) Nothing - setCurrentDirectory currDir - pure config +loadConfigFrom file = + let configSearchStrategy = SearchFromDirectory (takeDirectory file) + in loadConfig (makeVerbose False) configSearchStrategy -- | Run stylish-haskell on the given text with the given configuration. runStylishHaskell :: FilePath -- ^ Location of the file being formatted. Used for error message