Skip to content

Commit ade0e85

Browse files
authored
Merge pull request #3925 from fendor/enhance/vscode-exts-def-vals
Make vscode-extension-schema honour default values
2 parents b645a99 + 4b01eb0 commit ade0e85

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs

+15-15
Original file line numberDiff line numberDiff line change
@@ -108,29 +108,29 @@ pluginsToVSCodeExtensionSchema IdePlugins {..} = A.object $ mconcat $ singlePlug
108108
(PluginId pId) = pluginId
109109
genericSchema =
110110
let x =
111-
[toKey' "diagnosticsOn" A..= schemaEntry "diagnostics" | configHasDiagnostics]
112-
<> nubOrd (mconcat (handlersToGenericSchema <$> handlers))
111+
[toKey' "diagnosticsOn" A..= schemaEntry "diagnostics" True | configHasDiagnostics]
112+
<> nubOrd (mconcat (handlersToGenericSchema configInitialGenericConfig <$> handlers))
113113
in case x of
114114
-- If the plugin has only one capability, we produce globalOn instead of the specific one;
115115
-- otherwise we don't produce globalOn at all
116-
[_] -> [toKey' "globalOn" A..= schemaEntry "plugin"]
116+
[_] -> [toKey' "globalOn" A..= schemaEntry "plugin" (plcGlobalOn configInitialGenericConfig)]
117117
_ -> x
118118
dedicatedSchema = customConfigToDedicatedSchema configCustomConfig
119-
handlersToGenericSchema (IdeMethod m DSum.:=> _) = case m of
120-
SMethod_TextDocumentCodeAction -> [toKey' "codeActionsOn" A..= schemaEntry "code actions"]
121-
SMethod_TextDocumentCodeLens -> [toKey' "codeLensOn" A..= schemaEntry "code lenses"]
122-
SMethod_TextDocumentRename -> [toKey' "renameOn" A..= schemaEntry "rename"]
123-
SMethod_TextDocumentHover -> [toKey' "hoverOn" A..= schemaEntry "hover"]
124-
SMethod_TextDocumentDocumentSymbol -> [toKey' "symbolsOn" A..= schemaEntry "symbols"]
125-
SMethod_TextDocumentCompletion -> [toKey' "completionOn" A..= schemaEntry "completions"]
126-
SMethod_TextDocumentPrepareCallHierarchy -> [toKey' "callHierarchyOn" A..= schemaEntry "call hierarchy"]
127-
SMethod_TextDocumentSemanticTokensFull -> [toKey' "semanticTokensOn" A..= schemaEntry "semantic tokens"]
128-
_ -> []
129-
schemaEntry desc =
119+
handlersToGenericSchema PluginConfig{..} (IdeMethod m DSum.:=> _) = case m of
120+
SMethod_TextDocumentCodeAction -> [toKey' "codeActionsOn" A..= schemaEntry "code actions" plcCodeActionsOn]
121+
SMethod_TextDocumentCodeLens -> [toKey' "codeLensOn" A..= schemaEntry "code lenses" plcCodeLensOn]
122+
SMethod_TextDocumentRename -> [toKey' "renameOn" A..= schemaEntry "rename" plcRenameOn]
123+
SMethod_TextDocumentHover -> [toKey' "hoverOn" A..= schemaEntry "hover" plcHoverOn]
124+
SMethod_TextDocumentDocumentSymbol -> [toKey' "symbolsOn" A..= schemaEntry "symbols" plcSymbolsOn]
125+
SMethod_TextDocumentCompletion -> [toKey' "completionOn" A..= schemaEntry "completions" plcCompletionOn]
126+
SMethod_TextDocumentPrepareCallHierarchy -> [toKey' "callHierarchyOn" A..= schemaEntry "call hierarchy" plcCallHierarchyOn]
127+
SMethod_TextDocumentSemanticTokensFull -> [toKey' "semanticTokensOn" A..= schemaEntry "semantic tokens" plcSemanticTokensOn]
128+
_ -> []
129+
schemaEntry desc defaultVal =
130130
A.object
131131
[ "scope" A..= A.String "resource",
132132
"type" A..= A.String "boolean",
133-
"default" A..= True,
133+
"default" A..= A.Bool defaultVal,
134134
"description" A..= A.String ("Enables " <> pId <> " " <> desc)
135135
]
136136
withIdPrefix x = "haskell.plugin." <> pId <> "." <> x

test/testdata/schema/ghc92/vscode-extension-schema.golden.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@
250250
"type": "boolean"
251251
},
252252
"haskell.plugin.semanticTokens.globalOn": {
253-
"default": true,
253+
"default": false,
254254
"description": "Enables semanticTokens plugin",
255255
"scope": "resource",
256256
"type": "boolean"

test/testdata/schema/ghc94/vscode-extension-schema.golden.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@
250250
"type": "boolean"
251251
},
252252
"haskell.plugin.semanticTokens.globalOn": {
253-
"default": true,
253+
"default": false,
254254
"description": "Enables semanticTokens plugin",
255255
"scope": "resource",
256256
"type": "boolean"
@@ -262,7 +262,7 @@
262262
"type": "boolean"
263263
},
264264
"haskell.plugin.stan.globalOn": {
265-
"default": true,
265+
"default": false,
266266
"description": "Enables stan plugin",
267267
"scope": "resource",
268268
"type": "boolean"

test/testdata/schema/ghc96/vscode-extension-schema.golden.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@
250250
"type": "boolean"
251251
},
252252
"haskell.plugin.semanticTokens.globalOn": {
253-
"default": true,
253+
"default": false,
254254
"description": "Enables semanticTokens plugin",
255255
"scope": "resource",
256256
"type": "boolean"
@@ -262,7 +262,7 @@
262262
"type": "boolean"
263263
},
264264
"haskell.plugin.stan.globalOn": {
265-
"default": true,
265+
"default": false,
266266
"description": "Enables stan plugin",
267267
"scope": "resource",
268268
"type": "boolean"

test/testdata/schema/ghc98/vscode-extension-schema.golden.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,13 @@
172172
"type": "boolean"
173173
},
174174
"haskell.plugin.semanticTokens.globalOn": {
175-
"default": true,
175+
"default": false,
176176
"description": "Enables semanticTokens plugin",
177177
"scope": "resource",
178178
"type": "boolean"
179179
},
180180
"haskell.plugin.stan.globalOn": {
181-
"default": true,
181+
"default": false,
182182
"description": "Enables stan plugin",
183183
"scope": "resource",
184184
"type": "boolean"

0 commit comments

Comments
 (0)