1- {-# LANGUAGE CPP #-}
21{-# LANGUAGE GADTs #-}
32{-# LANGUAGE OverloadedStrings #-}
43{-# LANGUAGE RecordWildCards #-}
@@ -11,29 +10,17 @@ import qualified Data.Aeson.Types as A
1110import Data.Default (def )
1211import qualified Data.Dependent.Map as DMap
1312import 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
2013import Data.Functor.Identity
14+ import qualified Data.HashMap.Lazy as Map
2115import Data.List (nub )
2216import Data.Maybe (fromJust )
2317import Data.Text (Text )
18+ import Ide.Compat (toKey )
2419import Ide.Plugin.Config
2520import Ide.Plugin.Properties (toDefaultJSON , toVSCodeExtensionSchema )
2621import Ide.Types
2722import Language.LSP.Types
2823
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-
3724-- Attention:
3825-- 'diagnosticsOn' will never be added into the default config or the schema,
3926-- since diagnostics emit in arbitrary shake rules -- we don't know
@@ -124,22 +111,22 @@ pluginsToVSCodeExtensionSchema IdePlugins {..} = A.object $ mconcat $ singlePlug
124111 (PluginId pId) = pluginId
125112 genericSchema =
126113 let x =
127- [withIdPrefix " diagnosticsOn" A. .= schemaEntry " diagnostics" | configHasDiagnostics]
114+ [toKey' " diagnosticsOn" A. .= schemaEntry " diagnostics" | configHasDiagnostics]
128115 <> nub (mconcat (handlersToGenericSchema <$> handlers))
129116 in case x of
130117 -- If the plugin has only one capability, we produce globalOn instead of the specific one;
131118 -- otherwise we don't produce globalOn at all
132- [_] -> [withIdPrefix " globalOn" A. .= schemaEntry " plugin" ]
119+ [_] -> [toKey' " globalOn" A. .= schemaEntry " plugin" ]
133120 _ -> x
134121 dedicatedSchema = customConfigToDedicatedSchema configCustomConfig
135122 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" ]
143130 _ -> []
144131 schemaEntry desc =
145132 A. object
@@ -148,4 +135,5 @@ pluginsToVSCodeExtensionSchema IdePlugins {..} = A.object $ mconcat $ singlePlug
148135 " default" A. .= True ,
149136 " description" A. .= A. String (" Enables " <> pId <> " " <> desc)
150137 ]
151- withIdPrefix x = toKey $ " haskell.plugin." <> pId <> " ." <> x
138+ withIdPrefix x = " haskell.plugin." <> pId <> " ." <> x
139+ toKey' = toJsonKey . withIdPrefix
0 commit comments