Skip to content

Commit

Permalink
Merge pull request haskell#3925 from fendor/enhance/vscode-exts-def-vals
Browse files Browse the repository at this point in the history
Make vscode-extension-schema honour default values
  • Loading branch information
fendor authored Jan 10, 2024
2 parents b645a99 + 4b01eb0 commit ade0e85
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
30 changes: 15 additions & 15 deletions hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,29 +108,29 @@ 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"]
SMethod_TextDocumentSemanticTokensFull -> [toKey' "semanticTokensOn" A..= schemaEntry "semantic tokens"]
_ -> []
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]
SMethod_TextDocumentSemanticTokensFull -> [toKey' "semanticTokensOn" A..= schemaEntry "semantic tokens" plcSemanticTokensOn]
_ -> []
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
"type": "boolean"
},
"haskell.plugin.semanticTokens.globalOn": {
"default": true,
"default": false,
"description": "Enables semanticTokens plugin",
"scope": "resource",
"type": "boolean"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
"type": "boolean"
},
"haskell.plugin.semanticTokens.globalOn": {
"default": true,
"default": false,
"description": "Enables semanticTokens plugin",
"scope": "resource",
"type": "boolean"
Expand All @@ -262,7 +262,7 @@
"type": "boolean"
},
"haskell.plugin.stan.globalOn": {
"default": true,
"default": false,
"description": "Enables stan plugin",
"scope": "resource",
"type": "boolean"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
"type": "boolean"
},
"haskell.plugin.semanticTokens.globalOn": {
"default": true,
"default": false,
"description": "Enables semanticTokens plugin",
"scope": "resource",
"type": "boolean"
Expand All @@ -262,7 +262,7 @@
"type": "boolean"
},
"haskell.plugin.stan.globalOn": {
"default": true,
"default": false,
"description": "Enables stan plugin",
"scope": "resource",
"type": "boolean"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@
"type": "boolean"
},
"haskell.plugin.semanticTokens.globalOn": {
"default": true,
"default": false,
"description": "Enables semanticTokens plugin",
"scope": "resource",
"type": "boolean"
},
"haskell.plugin.stan.globalOn": {
"default": true,
"default": false,
"description": "Enables stan plugin",
"scope": "resource",
"type": "boolean"
Expand Down

0 comments on commit ade0e85

Please sign in to comment.