Skip to content

Commit

Permalink
feat: add commands: CheckOnType, SmartCompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
mtshiba committed Mar 2, 2023
1 parent 20e6e21 commit 41e7caa
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 16 additions & 6 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.11",
"version": "0.1.12",
"engines": {
"vscode": "^1.70.0"
},
Expand Down Expand Up @@ -54,27 +54,37 @@
"vscode-erg.ergpath.path": {
"type": "string",
"default": "",
"description": "Path to `.erg` directory"
"markdownDescription": "Path to `.erg` directory"
},
"vscode-erg.executablePath": {
"type": "string",
"default": "",
"description": "Path to `erg` executable"
"markdownDescription": "Path to `erg` executable"
},
"vscode-erg.lsp.inlayHints": {
"type": "boolean",
"default": true,
"description": "Enable inlay hints"
"markdownDescription": "Enable inlay hints"
},
"vscode-erg.lsp.semanticTokens": {
"type": "boolean",
"default": true,
"description": "Enable semantic tokens"
"markdownDescription": "Enable semantic tokens"
},
"vscode-erg.lsp.hover": {
"type": "boolean",
"default": true,
"description": "Enable hover"
"markdownDescription": "Enable hover"
},
"vscode-erg.lsp.smartCompletion": {
"type": "boolean",
"default": true,
"markdownDescription": "Enable smart completion (see [ELS features](https://github.com/erg-lang/erg/blob/main/crates/els/doc/features.md))"
},
"vscode-erg.lsp.checkOnType": {
"type": "boolean",
"default": false,
"markdownDescription": "Perform checking each time any character is entered. This improves the accuracy of completion, etc., but may slow down the execution of ELS"
}
}
}
Expand Down
21 changes: 16 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ 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 @@ -28,9 +25,14 @@ async function startLanguageClient(context: ExtensionContext) {
}
return buildFeatures;
})();
let serverOptions: ServerOptions;
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 smartCompletion = workspace.getConfiguration("vscode-erg").get<boolean>("lsp.smartCompletion", true);
/* optional features */
const checkOnType = workspace.getConfiguration("vscode-erg").get<boolean>("lsp.checkOnType", false);
let args = ["--language-server"];
if (!(enableInlayHints && enableSemanticTokens && enableHover)) {
if (!(enableInlayHints && enableSemanticTokens && enableHover && smartCompletion) || checkOnType) {
args.push("--");
}
if (!enableInlayHints) {
Expand All @@ -45,6 +47,15 @@ async function startLanguageClient(context: ExtensionContext) {
args.push("--disable");
args.push("hover");
}
if (!smartCompletion) {
args.push("--disable");
args.push("smartCompletion");
}
if (checkOnType) {
args.push("--enable");
args.push("checkOnType");
}
let serverOptions: ServerOptions;
if (buildFeatures.includes("els")) {
serverOptions = {
command: executablePath,
Expand Down

0 comments on commit 41e7caa

Please sign in to comment.