Skip to content

Commit 41e7caa

Browse files
committed
feat: add commands: CheckOnType, SmartCompletion
1 parent 20e6e21 commit 41e7caa

File tree

3 files changed

+34
-13
lines changed

3 files changed

+34
-13
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 16 additions & 6 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.11",
6+
"version": "0.1.12",
77
"engines": {
88
"vscode": "^1.70.0"
99
},
@@ -54,27 +54,37 @@
5454
"vscode-erg.ergpath.path": {
5555
"type": "string",
5656
"default": "",
57-
"description": "Path to `.erg` directory"
57+
"markdownDescription": "Path to `.erg` directory"
5858
},
5959
"vscode-erg.executablePath": {
6060
"type": "string",
6161
"default": "",
62-
"description": "Path to `erg` executable"
62+
"markdownDescription": "Path to `erg` executable"
6363
},
6464
"vscode-erg.lsp.inlayHints": {
6565
"type": "boolean",
6666
"default": true,
67-
"description": "Enable inlay hints"
67+
"markdownDescription": "Enable inlay hints"
6868
},
6969
"vscode-erg.lsp.semanticTokens": {
7070
"type": "boolean",
7171
"default": true,
72-
"description": "Enable semantic tokens"
72+
"markdownDescription": "Enable semantic tokens"
7373
},
7474
"vscode-erg.lsp.hover": {
7575
"type": "boolean",
7676
"default": true,
77-
"description": "Enable hover"
77+
"markdownDescription": "Enable hover"
78+
},
79+
"vscode-erg.lsp.smartCompletion": {
80+
"type": "boolean",
81+
"default": true,
82+
"markdownDescription": "Enable smart completion (see [ELS features](https://github.com/erg-lang/erg/blob/main/crates/els/doc/features.md))"
83+
},
84+
"vscode-erg.lsp.checkOnType": {
85+
"type": "boolean",
86+
"default": false,
87+
"markdownDescription": "Perform checking each time any character is entered. This improves the accuracy of completion, etc., but may slow down the execution of ELS"
7888
}
7989
}
8090
}

src/extension.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ async function startLanguageClient(context: ExtensionContext) {
1717
.get<string>("executablePath", "");
1818
return executablePath === "" ? "erg" : executablePath;
1919
})();
20-
const enableInlayHints = workspace.getConfiguration("vscode-erg").get<boolean>("lsp.inlayHints", true);
21-
const enableSemanticTokens = workspace.getConfiguration("vscode-erg").get<boolean>("lsp.semanticTokens", true);
22-
const enableHover = workspace.getConfiguration("vscode-erg").get<boolean>("lsp.hover", true);
2320
const buildFeatures = await (async () => {
2421
const buildFeaturesProcess = spawn(executablePath, ["--build-features"]);
2522
let buildFeatures = "";
@@ -28,9 +25,14 @@ async function startLanguageClient(context: ExtensionContext) {
2825
}
2926
return buildFeatures;
3027
})();
31-
let serverOptions: ServerOptions;
28+
const enableInlayHints = workspace.getConfiguration("vscode-erg").get<boolean>("lsp.inlayHints", true);
29+
const enableSemanticTokens = workspace.getConfiguration("vscode-erg").get<boolean>("lsp.semanticTokens", true);
30+
const enableHover = workspace.getConfiguration("vscode-erg").get<boolean>("lsp.hover", true);
31+
const smartCompletion = workspace.getConfiguration("vscode-erg").get<boolean>("lsp.smartCompletion", true);
32+
/* optional features */
33+
const checkOnType = workspace.getConfiguration("vscode-erg").get<boolean>("lsp.checkOnType", false);
3234
let args = ["--language-server"];
33-
if (!(enableInlayHints && enableSemanticTokens && enableHover)) {
35+
if (!(enableInlayHints && enableSemanticTokens && enableHover && smartCompletion) || checkOnType) {
3436
args.push("--");
3537
}
3638
if (!enableInlayHints) {
@@ -45,6 +47,15 @@ async function startLanguageClient(context: ExtensionContext) {
4547
args.push("--disable");
4648
args.push("hover");
4749
}
50+
if (!smartCompletion) {
51+
args.push("--disable");
52+
args.push("smartCompletion");
53+
}
54+
if (checkOnType) {
55+
args.push("--enable");
56+
args.push("checkOnType");
57+
}
58+
let serverOptions: ServerOptions;
4859
if (buildFeatures.includes("els")) {
4960
serverOptions = {
5061
command: executablePath,

0 commit comments

Comments
 (0)