2
2
{-# LANGUAGE LambdaCase #-}
3
3
{-# LANGUAGE OverloadedStrings #-}
4
4
{-# LANGUAGE TypeApplications #-}
5
+ {-# LANGUAGE DataKinds #-}
6
+ {-# LANGUAGE OverloadedLabels #-}
5
7
6
8
module Ide.Plugin.Fourmolu (
7
9
descriptor ,
@@ -20,8 +22,8 @@ import Development.IDE hiding (pluginHandlers)
20
22
import Development.IDE.GHC.Compat as Compat hiding (Cpp )
21
23
import qualified Development.IDE.GHC.Compat.Util as S
22
24
import GHC.LanguageExtensions.Type (Extension (Cpp ))
23
- import Ide.Plugin.Config ( formattingCLI )
24
- import Ide.PluginUtils (makeDiffTextEdit )
25
+ import Ide.Plugin.Properties
26
+ import Ide.PluginUtils (makeDiffTextEdit , usePropertyLsp )
25
27
import Ide.Types
26
28
import Language.LSP.Server hiding (defaultConfig )
27
29
import Language.LSP.Types
@@ -32,22 +34,26 @@ import System.FilePath
32
34
import System.IO (stderr )
33
35
import System.Process.Text (readProcessWithExitCode )
34
36
35
- -- ---------------------------------------------------------------------
36
-
37
37
descriptor :: PluginId -> PluginDescriptor IdeState
38
38
descriptor plId =
39
39
(defaultPluginDescriptor plId)
40
- { pluginHandlers = mkFormattingHandlers provider
40
+ { pluginHandlers = mkFormattingHandlers $ provider plId
41
41
}
42
42
43
- -- ---------------------------------------------------------------------
43
+ properties :: Properties '[ 'PropertyKey " cli" 'TBoolean]
44
+ properties =
45
+ emptyProperties
46
+ & defineBooleanProperty
47
+ # cli
48
+ " Call out to `fourmolu` executable, rather than using the bundled library"
49
+ False
44
50
45
- provider :: FormattingHandler IdeState
46
- provider ideState typ contents fp fo = withIndefiniteProgress title Cancellable $ do
51
+ provider :: PluginId -> FormattingHandler IdeState
52
+ provider plId ideState typ contents fp fo = withIndefiniteProgress title Cancellable $ do
47
53
fileOpts <-
48
54
maybe [] (convertDynFlags . hsc_dflags . hscEnv)
49
55
<$> liftIO (runAction " Fourmolu" ideState $ use GhcSession fp)
50
- useCLI <- formattingCLI <$> getConfig
56
+ useCLI <- usePropertyLsp # cli plId properties
51
57
if useCLI
52
58
then liftIO
53
59
. fmap (join . first (mkError . show ))
0 commit comments