Skip to content

Commit 382ae66

Browse files
committed
Use indentation from LSP options
1 parent f846a6a commit 382ae66

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

plugins/default/src/Ide/Plugin/Fourmolu.hs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Control.Exception
1313
import Data.Either.Extra
1414
import System.FilePath
1515

16+
import Control.Lens ((^.))
1617
import qualified Data.Text as T
1718
import Development.IDE as D
1819
import qualified DynFlags as D
@@ -27,6 +28,7 @@ import Language.Haskell.LSP.Messages (FromServerMessage (ReqShowMessage))
2728
import Ide.Types
2829
import Language.Haskell.LSP.Core
2930
import Language.Haskell.LSP.Types
31+
import Language.Haskell.LSP.Types.Lens
3032
import "fourmolu" Ormolu
3133

3234
-- ---------------------------------------------------------------------
@@ -40,7 +42,7 @@ descriptor plId =
4042
-- ---------------------------------------------------------------------
4143

4244
provider :: FormattingProvider IO
43-
provider lf ideState typ contents fp _ = withIndefiniteProgress lf title Cancellable $ do
45+
provider lf ideState typ contents fp fo = withIndefiniteProgress lf title Cancellable $ do
4446
ghc <- runAction "Fourmolu" ideState $ use GhcSession fp
4547
fileOpts <- case hsc_dflags . hscEnv <$> ghc of
4648
Nothing -> return []
@@ -55,7 +57,10 @@ provider lf ideState typ contents fp _ = withIndefiniteProgress lf title Cancell
5557
{ cfgDynOptions = fileOpts
5658
, cfgRegion = region
5759
, cfgDebug = True
58-
, cfgPrinterOpts = fillMissingPrinterOpts printerOpts defaultPrinterOpts
60+
, cfgPrinterOpts =
61+
fillMissingPrinterOpts
62+
(lspPrinterOpts <> printerOpts)
63+
defaultPrinterOpts
5964
}
6065

6166
loadConfigFile fp' >>= \case
@@ -87,6 +92,7 @@ provider lf ideState typ contents fp _ = withIndefiniteProgress lf title Cancell
8792
where
8893
fp' = fromNormalizedFilePath fp
8994
title = "Formatting " <> T.pack (takeFileName fp')
95+
lspPrinterOpts = mempty{poIndentation = Just $ fo ^. tabSize}
9096
region = case typ of
9197
FormatText ->
9298
RegionIndices Nothing Nothing

0 commit comments

Comments
 (0)