@@ -12,16 +12,28 @@ import Data.Default (def)
1212import qualified Data.Dependent.Map as DMap
1313import qualified Data.Dependent.Sum as DSum
1414#if MIN_VERSION_aeson(2,0,0)
15+ import qualified Data.Aeson.Key as A.Key
1516import qualified Data.Aeson.KeyMap as Map
1617#else
17- import qualified Data.HasMap .Lazy as Map
18+ import qualified Data.HashMap .Lazy as Map
1819#endif
20+ import Data.Functor.Identity
1921import Data.List (nub )
22+ import Data.Maybe (fromJust )
23+ import Data.Text (Text )
2024import Ide.Plugin.Config
2125import Ide.Plugin.Properties (toDefaultJSON , toVSCodeExtensionSchema )
2226import Ide.Types
2327import Language.LSP.Types
2428
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+
2537-- Attention:
2638-- 'diagnosticsOn' will never be added into the default config or the schema,
2739-- since diagnostics emit in arbitrary shake rules -- we don't know
@@ -30,10 +42,10 @@ import Language.LSP.Types
3042-- | Generates a default 'Config', but remains only effective items
3143pluginsToDefaultConfig :: IdePlugins a -> A. Value
3244pluginsToDefaultConfig 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
3749 )
3850 " haskell"
3951 (unsafeValueToObject (A. toJSON defaultConfig))
@@ -57,7 +69,7 @@ pluginsToDefaultConfig IdePlugins {..} =
5769 -- }
5870 singlePlugin PluginDescriptor {pluginConfigDescriptor = ConfigDescriptor {.. }, .. } =
5971 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]
6173 where
6274 (PluginHandlers (DMap. toList -> handlers)) = pluginHandlers
6375 customConfigToDedicatedDefaultConfig (CustomConfig p) = toDefaultJSON p
@@ -136,4 +148,4 @@ pluginsToVSCodeExtensionSchema IdePlugins {..} = A.object $ mconcat $ singlePlug
136148 " default" A. .= True ,
137149 " description" A. .= A. String (" Enables " <> pId <> " " <> desc)
138150 ]
139- withIdPrefix x = " haskell.plugin." <> pId <> " ." <> x
151+ withIdPrefix x = toKey $ " haskell.plugin." <> pId <> " ." <> x
0 commit comments