Skip to content

Commit 2db25cb

Browse files
committed
Add cfg: lsp.semanticTokens & lsp.hover
1 parent 4b21a6c commit 2db25cb

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

package.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "vscode-erg",
44
"description": "Erg language support for Visual Studio Code",
55
"publisher": "erg-lang",
6-
"version": "0.1.9",
6+
"version": "0.1.10",
77
"engines": {
88
"vscode": "^1.70.0"
99
},
@@ -61,10 +61,20 @@
6161
"default": "",
6262
"description": "Path to `erg` executable"
6363
},
64-
"vscode-erg.lsp.inlayhints": {
64+
"vscode-erg.lsp.inlayHints": {
6565
"type": "boolean",
6666
"default": true,
6767
"description": "Enable inlay hints"
68+
},
69+
"vscode-erg.lsp.semanticTokens": {
70+
"type": "boolean",
71+
"default": true,
72+
"description": "Enable semantic tokens"
73+
},
74+
"vscode-erg.lsp.hover": {
75+
"type": "boolean",
76+
"default": true,
77+
"description": "Enable hover"
6878
}
6979
}
7080
}

src/extension.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ async function startLanguageClient(context: ExtensionContext) {
1616
.get<string>("executablePath", "");
1717
return executablePath === "" ? "erg" : executablePath;
1818
})();
19+
const enableInlayHints = workspace.getConfiguration("vscode-erg").get<boolean>("lsp.inlayHints", true);
20+
const enableSemanticTokens = workspace.getConfiguration("vscode-erg").get<boolean>("lsp.semanticTokens", true);
21+
const enableHover = workspace.getConfiguration("vscode-erg").get<boolean>("lsp.hover", true);
1922
const buildFeatures = await (async () => {
2023
const buildFeaturesProcess = spawn(executablePath, ["--build-features"]);
2124
let buildFeatures = "";
@@ -25,10 +28,26 @@ async function startLanguageClient(context: ExtensionContext) {
2528
return buildFeatures;
2629
})();
2730
let serverOptions: ServerOptions;
31+
let args = ["--language-server"];
32+
if (!(enableInlayHints && enableSemanticTokens && enableHover)) {
33+
args.push("--");
34+
}
35+
if (!enableInlayHints) {
36+
args.push("--disable");
37+
args.push("inlayHints");
38+
}
39+
if (!enableSemanticTokens) {
40+
args.push("--disable");
41+
args.push("semanticTokens");
42+
}
43+
if (!enableHover) {
44+
args.push("--disable");
45+
args.push("hover");
46+
}
2847
if (buildFeatures.includes("els")) {
2948
serverOptions = {
3049
command: executablePath,
31-
args: ["--language-server"],
50+
args,
3251
};
3352
} else {
3453
serverOptions = {

0 commit comments

Comments
 (0)