@@ -13,6 +13,7 @@ import Control.Exception
13
13
import Data.Either.Extra
14
14
import System.FilePath
15
15
16
+ import Control.Lens ((^.) )
16
17
import qualified Data.Text as T
17
18
import Development.IDE as D
18
19
import qualified DynFlags as D
@@ -27,6 +28,7 @@ import Language.Haskell.LSP.Messages (FromServerMessage (ReqShowMessage))
27
28
import Ide.Types
28
29
import Language.Haskell.LSP.Core
29
30
import Language.Haskell.LSP.Types
31
+ import Language.Haskell.LSP.Types.Lens
30
32
import "fourmolu" Ormolu
31
33
32
34
-- ---------------------------------------------------------------------
@@ -40,7 +42,7 @@ descriptor plId =
40
42
-- ---------------------------------------------------------------------
41
43
42
44
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
44
46
ghc <- runAction " Fourmolu" ideState $ use GhcSession fp
45
47
fileOpts <- case hsc_dflags . hscEnv <$> ghc of
46
48
Nothing -> return []
@@ -55,7 +57,10 @@ provider lf ideState typ contents fp _ = withIndefiniteProgress lf title Cancell
55
57
{ cfgDynOptions = fileOpts
56
58
, cfgRegion = region
57
59
, cfgDebug = True
58
- , cfgPrinterOpts = fillMissingPrinterOpts printerOpts defaultPrinterOpts
60
+ , cfgPrinterOpts =
61
+ fillMissingPrinterOpts
62
+ (lspPrinterOpts <> printerOpts)
63
+ defaultPrinterOpts
59
64
}
60
65
61
66
loadConfigFile fp' >>= \ case
@@ -87,6 +92,7 @@ provider lf ideState typ contents fp _ = withIndefiniteProgress lf title Cancell
87
92
where
88
93
fp' = fromNormalizedFilePath fp
89
94
title = " Formatting " <> T. pack (takeFileName fp')
95
+ lspPrinterOpts = mempty {poIndentation = Just $ fo ^. tabSize}
90
96
region = case typ of
91
97
FormatText ->
92
98
RegionIndices Nothing Nothing
0 commit comments