From 41e7caa64321448383f8f6719ba1ba5da1091f53 Mon Sep 17 00:00:00 2001 From: Shunsuke Shibayama Date: Fri, 3 Mar 2023 01:51:59 +0900 Subject: [PATCH] feat: add commands: `CheckOnType`, `SmartCompletion` --- package-lock.json | 4 ++-- package.json | 22 ++++++++++++++++------ src/extension.ts | 21 ++++++++++++++++----- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 50545b5..f9d30cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-erg", - "version": "0.1.11", + "version": "0.1.12", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-erg", - "version": "0.1.11", + "version": "0.1.12", "dependencies": { "vscode-languageclient": "^8.0.2" }, diff --git a/package.json b/package.json index 7ff9adc..7e2fb0c 100644 --- a/package.json +++ b/package.json @@ -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" }, @@ -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" } } } diff --git a/src/extension.ts b/src/extension.ts index 3c0e2a3..8c4da18 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -17,9 +17,6 @@ async function startLanguageClient(context: ExtensionContext) { .get("executablePath", ""); return executablePath === "" ? "erg" : executablePath; })(); - const enableInlayHints = workspace.getConfiguration("vscode-erg").get("lsp.inlayHints", true); - const enableSemanticTokens = workspace.getConfiguration("vscode-erg").get("lsp.semanticTokens", true); - const enableHover = workspace.getConfiguration("vscode-erg").get("lsp.hover", true); const buildFeatures = await (async () => { const buildFeaturesProcess = spawn(executablePath, ["--build-features"]); let buildFeatures = ""; @@ -28,9 +25,14 @@ async function startLanguageClient(context: ExtensionContext) { } return buildFeatures; })(); - let serverOptions: ServerOptions; + const enableInlayHints = workspace.getConfiguration("vscode-erg").get("lsp.inlayHints", true); + const enableSemanticTokens = workspace.getConfiguration("vscode-erg").get("lsp.semanticTokens", true); + const enableHover = workspace.getConfiguration("vscode-erg").get("lsp.hover", true); + const smartCompletion = workspace.getConfiguration("vscode-erg").get("lsp.smartCompletion", true); + /* optional features */ + const checkOnType = workspace.getConfiguration("vscode-erg").get("lsp.checkOnType", false); let args = ["--language-server"]; - if (!(enableInlayHints && enableSemanticTokens && enableHover)) { + if (!(enableInlayHints && enableSemanticTokens && enableHover && smartCompletion) || checkOnType) { args.push("--"); } if (!enableInlayHints) { @@ -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,