1
- {-# LANGUAGE CPP #-}
2
1
{-# LANGUAGE GADTs #-}
3
2
{-# LANGUAGE OverloadedStrings #-}
4
3
{-# LANGUAGE RecordWildCards #-}
@@ -11,29 +10,17 @@ import qualified Data.Aeson.Types as A
11
10
import Data.Default (def )
12
11
import qualified Data.Dependent.Map as DMap
13
12
import qualified Data.Dependent.Sum as DSum
14
- #if MIN_VERSION_aeson(2,0,0)
15
- import qualified Data.Aeson.Key as A.Key
16
- import qualified Data.Aeson.KeyMap as Map
17
- #else
18
- import qualified Data.HashMap.Lazy as Map
19
- #endif
20
13
import Data.Functor.Identity
14
+ import qualified Data.HashMap.Lazy as Map
21
15
import Data.List (nub )
22
16
import Data.Maybe (fromJust )
23
17
import Data.Text (Text )
18
+ import Ide.Compat (toKey )
24
19
import Ide.Plugin.Config
25
20
import Ide.Plugin.Properties (toDefaultJSON , toVSCodeExtensionSchema )
26
21
import Ide.Types
27
22
import Language.LSP.Types
28
23
29
- #if MIN_VERSION_aeson(2,0,0)
30
- toKey :: Text -> A. Key
31
- toKey = A.Key. fromText
32
- #else
33
- toKey :: Text -> Text
34
- toKey = id
35
- #endif
36
-
37
24
-- Attention:
38
25
-- 'diagnosticsOn' will never be added into the default config or the schema,
39
26
-- since diagnostics emit in arbitrary shake rules -- we don't know
@@ -124,22 +111,22 @@ pluginsToVSCodeExtensionSchema IdePlugins {..} = A.object $ mconcat $ singlePlug
124
111
(PluginId pId) = pluginId
125
112
genericSchema =
126
113
let x =
127
- [withIdPrefix " diagnosticsOn" A. .= schemaEntry " diagnostics" | configHasDiagnostics]
114
+ [toKey' " diagnosticsOn" A. .= schemaEntry " diagnostics" | configHasDiagnostics]
128
115
<> nub (mconcat (handlersToGenericSchema <$> handlers))
129
116
in case x of
130
117
-- If the plugin has only one capability, we produce globalOn instead of the specific one;
131
118
-- otherwise we don't produce globalOn at all
132
- [_] -> [withIdPrefix " globalOn" A. .= schemaEntry " plugin" ]
119
+ [_] -> [toKey' " globalOn" A. .= schemaEntry " plugin" ]
133
120
_ -> x
134
121
dedicatedSchema = customConfigToDedicatedSchema configCustomConfig
135
122
handlersToGenericSchema (IdeMethod m DSum. :=> _) = case m of
136
- STextDocumentCodeAction -> [withIdPrefix " codeActionsOn" A. .= schemaEntry " code actions" ]
137
- STextDocumentCodeLens -> [withIdPrefix " codeLensOn" A. .= schemaEntry " code lenses" ]
138
- STextDocumentRename -> [withIdPrefix " renameOn" A. .= schemaEntry " rename" ]
139
- STextDocumentHover -> [withIdPrefix " hoverOn" A. .= schemaEntry " hover" ]
140
- STextDocumentDocumentSymbol -> [withIdPrefix " symbolsOn" A. .= schemaEntry " symbols" ]
141
- STextDocumentCompletion -> [withIdPrefix " completionOn" A. .= schemaEntry " completions" ]
142
- STextDocumentPrepareCallHierarchy -> [withIdPrefix " callHierarchyOn" A. .= schemaEntry " call hierarchy" ]
123
+ STextDocumentCodeAction -> [toKey' " codeActionsOn" A. .= schemaEntry " code actions" ]
124
+ STextDocumentCodeLens -> [toKey' " codeLensOn" A. .= schemaEntry " code lenses" ]
125
+ STextDocumentRename -> [toKey' " renameOn" A. .= schemaEntry " rename" ]
126
+ STextDocumentHover -> [toKey' " hoverOn" A. .= schemaEntry " hover" ]
127
+ STextDocumentDocumentSymbol -> [toKey' " symbolsOn" A. .= schemaEntry " symbols" ]
128
+ STextDocumentCompletion -> [toKey' " completionOn" A. .= schemaEntry " completions" ]
129
+ STextDocumentPrepareCallHierarchy -> [toKey' " callHierarchyOn" A. .= schemaEntry " call hierarchy" ]
143
130
_ -> []
144
131
schemaEntry desc =
145
132
A. object
@@ -148,4 +135,5 @@ pluginsToVSCodeExtensionSchema IdePlugins {..} = A.object $ mconcat $ singlePlug
148
135
" default" A. .= True ,
149
136
" description" A. .= A. String (" Enables " <> pId <> " " <> desc)
150
137
]
151
- withIdPrefix x = toKey $ " haskell.plugin." <> pId <> " ." <> x
138
+ withIdPrefix x = " haskell.plugin." <> pId <> " ." <> x
139
+ toKey' = toJsonKey . withIdPrefix
0 commit comments