From 506b41ef5a017ecd563eddbbc0fe7da3e49820e0 Mon Sep 17 00:00:00 2001 From: Fendor Date: Thu, 4 Jan 2024 11:34:01 +0100 Subject: [PATCH] Fix vscode config generation --- hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs | 28 +++++++++---------- .../ghc94/vscode-extension-schema.golden.json | 2 +- .../ghc96/vscode-extension-schema.golden.json | 2 +- .../ghc98/vscode-extension-schema.golden.json | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs index 6111de4a48c..44e981ac28c 100644 --- a/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs +++ b/hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs @@ -107,28 +107,28 @@ pluginsToVSCodeExtensionSchema IdePlugins {..} = A.object $ mconcat $ singlePlug (PluginId pId) = pluginId genericSchema = let x = - [toKey' "diagnosticsOn" A..= schemaEntry "diagnostics" | configHasDiagnostics] - <> nubOrd (mconcat (handlersToGenericSchema <$> handlers)) + [toKey' "diagnosticsOn" A..= schemaEntry "diagnostics" True | configHasDiagnostics] + <> nubOrd (mconcat (handlersToGenericSchema configInitialGenericConfig <$> handlers)) in case x of -- If the plugin has only one capability, we produce globalOn instead of the specific one; -- otherwise we don't produce globalOn at all - [_] -> [toKey' "globalOn" A..= schemaEntry "plugin"] + [_] -> [toKey' "globalOn" A..= schemaEntry "plugin" (plcGlobalOn configInitialGenericConfig)] _ -> x dedicatedSchema = customConfigToDedicatedSchema configCustomConfig - handlersToGenericSchema (IdeMethod m DSum.:=> _) = case m of - SMethod_TextDocumentCodeAction -> [toKey' "codeActionsOn" A..= schemaEntry "code actions"] - SMethod_TextDocumentCodeLens -> [toKey' "codeLensOn" A..= schemaEntry "code lenses"] - SMethod_TextDocumentRename -> [toKey' "renameOn" A..= schemaEntry "rename"] - SMethod_TextDocumentHover -> [toKey' "hoverOn" A..= schemaEntry "hover"] - SMethod_TextDocumentDocumentSymbol -> [toKey' "symbolsOn" A..= schemaEntry "symbols"] - SMethod_TextDocumentCompletion -> [toKey' "completionOn" A..= schemaEntry "completions"] - SMethod_TextDocumentPrepareCallHierarchy -> [toKey' "callHierarchyOn" A..= schemaEntry "call hierarchy"] - _ -> [] - schemaEntry desc = + handlersToGenericSchema PluginConfig{..} (IdeMethod m DSum.:=> _) = case m of + SMethod_TextDocumentCodeAction -> [toKey' "codeActionsOn" A..= schemaEntry "code actions" plcCodeActionsOn] + SMethod_TextDocumentCodeLens -> [toKey' "codeLensOn" A..= schemaEntry "code lenses" plcCodeLensOn] + SMethod_TextDocumentRename -> [toKey' "renameOn" A..= schemaEntry "rename" plcRenameOn] + SMethod_TextDocumentHover -> [toKey' "hoverOn" A..= schemaEntry "hover" plcHoverOn] + SMethod_TextDocumentDocumentSymbol -> [toKey' "symbolsOn" A..= schemaEntry "symbols" plcSymbolsOn] + SMethod_TextDocumentCompletion -> [toKey' "completionOn" A..= schemaEntry "completions" plcCompletionOn] + SMethod_TextDocumentPrepareCallHierarchy -> [toKey' "callHierarchyOn" A..= schemaEntry "call hierarchy" plcCallHierarchyOn] + _ -> [] + schemaEntry desc defaultVal = A.object [ "scope" A..= A.String "resource", "type" A..= A.String "boolean", - "default" A..= True, + "default" A..= A.Bool defaultVal, "description" A..= A.String ("Enables " <> pId <> " " <> desc) ] withIdPrefix x = "haskell.plugin." <> pId <> "." <> x diff --git a/test/testdata/schema/ghc94/vscode-extension-schema.golden.json b/test/testdata/schema/ghc94/vscode-extension-schema.golden.json index 30c843b3d6d..3c6399a4ac9 100644 --- a/test/testdata/schema/ghc94/vscode-extension-schema.golden.json +++ b/test/testdata/schema/ghc94/vscode-extension-schema.golden.json @@ -256,7 +256,7 @@ "type": "boolean" }, "haskell.plugin.stan.globalOn": { - "default": true, + "default": false, "description": "Enables stan plugin", "scope": "resource", "type": "boolean" diff --git a/test/testdata/schema/ghc96/vscode-extension-schema.golden.json b/test/testdata/schema/ghc96/vscode-extension-schema.golden.json index 30c843b3d6d..3c6399a4ac9 100644 --- a/test/testdata/schema/ghc96/vscode-extension-schema.golden.json +++ b/test/testdata/schema/ghc96/vscode-extension-schema.golden.json @@ -256,7 +256,7 @@ "type": "boolean" }, "haskell.plugin.stan.globalOn": { - "default": true, + "default": false, "description": "Enables stan plugin", "scope": "resource", "type": "boolean" diff --git a/test/testdata/schema/ghc98/vscode-extension-schema.golden.json b/test/testdata/schema/ghc98/vscode-extension-schema.golden.json index 5950032867d..4a2b95c2769 100644 --- a/test/testdata/schema/ghc98/vscode-extension-schema.golden.json +++ b/test/testdata/schema/ghc98/vscode-extension-schema.golden.json @@ -172,7 +172,7 @@ "type": "boolean" }, "haskell.plugin.stan.globalOn": { - "default": true, + "default": false, "description": "Enables stan plugin", "scope": "resource", "type": "boolean"