Skip to content

Commit

Permalink
Add cfg: lsp.semanticTokens & lsp.hover
Browse files Browse the repository at this point in the history
  • Loading branch information
mtshiba committed Feb 3, 2023
1 parent 4b21a6c commit 2db25cb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "vscode-erg",
"description": "Erg language support for Visual Studio Code",
"publisher": "erg-lang",
"version": "0.1.9",
"version": "0.1.10",
"engines": {
"vscode": "^1.70.0"
},
Expand Down Expand Up @@ -61,10 +61,20 @@
"default": "",
"description": "Path to `erg` executable"
},
"vscode-erg.lsp.inlayhints": {
"vscode-erg.lsp.inlayHints": {
"type": "boolean",
"default": true,
"description": "Enable inlay hints"
},
"vscode-erg.lsp.semanticTokens": {
"type": "boolean",
"default": true,
"description": "Enable semantic tokens"
},
"vscode-erg.lsp.hover": {
"type": "boolean",
"default": true,
"description": "Enable hover"
}
}
}
Expand Down
21 changes: 20 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ async function startLanguageClient(context: ExtensionContext) {
.get<string>("executablePath", "");
return executablePath === "" ? "erg" : executablePath;
})();
const enableInlayHints = workspace.getConfiguration("vscode-erg").get<boolean>("lsp.inlayHints", true);
const enableSemanticTokens = workspace.getConfiguration("vscode-erg").get<boolean>("lsp.semanticTokens", true);
const enableHover = workspace.getConfiguration("vscode-erg").get<boolean>("lsp.hover", true);
const buildFeatures = await (async () => {
const buildFeaturesProcess = spawn(executablePath, ["--build-features"]);
let buildFeatures = "";
Expand All @@ -25,10 +28,26 @@ async function startLanguageClient(context: ExtensionContext) {
return buildFeatures;
})();
let serverOptions: ServerOptions;
let args = ["--language-server"];
if (!(enableInlayHints && enableSemanticTokens && enableHover)) {
args.push("--");
}
if (!enableInlayHints) {
args.push("--disable");
args.push("inlayHints");
}
if (!enableSemanticTokens) {
args.push("--disable");
args.push("semanticTokens");
}
if (!enableHover) {
args.push("--disable");
args.push("hover");
}
if (buildFeatures.includes("els")) {
serverOptions = {
command: executablePath,
args: ["--language-server"],
args,
};
} else {
serverOptions = {
Expand Down

0 comments on commit 2db25cb

Please sign in to comment.