@@ -12,16 +12,28 @@ import Data.Default (def)
12
12
import qualified Data.Dependent.Map as DMap
13
13
import qualified Data.Dependent.Sum as DSum
14
14
#if MIN_VERSION_aeson(2,0,0)
15
+ import qualified Data.Aeson.Key as A.Key
15
16
import qualified Data.Aeson.KeyMap as Map
16
17
#else
17
- import qualified Data.HasMap .Lazy as Map
18
+ import qualified Data.HashMap .Lazy as Map
18
19
#endif
20
+ import Data.Functor.Identity
19
21
import Data.List (nub )
22
+ import Data.Maybe (fromJust )
23
+ import Data.Text (Text )
20
24
import Ide.Plugin.Config
21
25
import Ide.Plugin.Properties (toDefaultJSON , toVSCodeExtensionSchema )
22
26
import Ide.Types
23
27
import Language.LSP.Types
24
28
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
+
25
37
-- Attention:
26
38
-- 'diagnosticsOn' will never be added into the default config or the schema,
27
39
-- since diagnostics emit in arbitrary shake rules -- we don't know
@@ -30,10 +42,10 @@ import Language.LSP.Types
30
42
-- | Generates a default 'Config', but remains only effective items
31
43
pluginsToDefaultConfig :: IdePlugins a -> A. Value
32
44
pluginsToDefaultConfig IdePlugins {.. } =
33
- A. Object $
34
- Map. alter
35
- ( \ (unsafeValueToObject -> o) ->
36
- Just $ A. Object $ Map. insert " plugin" elems o -- inplace the "plugin" section with our 'elems', leaving others unchanged
45
+ A. Object $ runIdentity $
46
+ Map. alterF
47
+ ( \ (unsafeValueToObject . fromJust -> o) ->
48
+ Identity $ Just $ A. Object $ Map. insert " plugin" elems o -- inplace the "plugin" section with our 'elems', leaving others unchanged
37
49
)
38
50
" haskell"
39
51
(unsafeValueToObject (A. toJSON defaultConfig))
@@ -57,7 +69,7 @@ pluginsToDefaultConfig IdePlugins {..} =
57
69
-- }
58
70
singlePlugin PluginDescriptor {pluginConfigDescriptor = ConfigDescriptor {.. }, .. } =
59
71
let x = genericDefaultConfig <> dedicatedDefaultConfig
60
- in [pId A. .= A. object x | not $ null x]
72
+ in [(toKey pId) A. .= A. object x | not $ null x]
61
73
where
62
74
(PluginHandlers (DMap. toList -> handlers)) = pluginHandlers
63
75
customConfigToDedicatedDefaultConfig (CustomConfig p) = toDefaultJSON p
@@ -136,4 +148,4 @@ pluginsToVSCodeExtensionSchema IdePlugins {..} = A.object $ mconcat $ singlePlug
136
148
" default" A. .= True ,
137
149
" description" A. .= A. String (" Enables " <> pId <> " " <> desc)
138
150
]
139
- withIdPrefix x = " haskell.plugin." <> pId <> " ." <> x
151
+ withIdPrefix x = toKey $ " haskell.plugin." <> pId <> " ." <> x
0 commit comments