@@ -13,6 +13,7 @@ import Control.Exception
1313import Data.Either.Extra
1414import System.FilePath
1515
16+ import Control.Lens ((^.) )
1617import qualified Data.Text as T
1718import Development.IDE as D
1819import qualified DynFlags as D
@@ -27,6 +28,7 @@ import Language.Haskell.LSP.Messages (FromServerMessage (ReqShowMessage))
2728import Ide.Types
2829import Language.Haskell.LSP.Core
2930import Language.Haskell.LSP.Types
31+ import Language.Haskell.LSP.Types.Lens
3032import "fourmolu" Ormolu
3133
3234-- ---------------------------------------------------------------------
@@ -40,7 +42,7 @@ descriptor plId =
4042-- ---------------------------------------------------------------------
4143
4244provider :: 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