Update extension.ts

This commit is contained in:
Shunsuke Shibayama 2023-04-12 11:02:06 +09:00
parent bd626f5c3c
commit a21f44b27c
1 changed files with 5 additions and 3 deletions

View File

@ -11,7 +11,7 @@ let client: LanguageClient | undefined;
async function startLanguageClient(context: ExtensionContext) {
try {
const executablePath = (() => {
let executablePath = workspace
const executablePath = workspace
.getConfiguration("pylyzer")
.get<string>("executablePath", "");
return executablePath === "" ? "pylyzer" : executablePath;
@ -23,7 +23,7 @@ async function startLanguageClient(context: ExtensionContext) {
const smartCompletion = workspace.getConfiguration("pylyzer").get<boolean>("smartCompletion", true);
/* optional features */
const checkOnType = workspace.getConfiguration("pylyzer").get<boolean>("checkOnType", false);
let args = ["--server"];
const args = ["--server"];
if (!(enableDiagnostics && enableSemanticTokens && enableHover && smartCompletion) || (checkOnType || enableInlayHints)) {
args.push("--");
}
@ -51,7 +51,7 @@ async function startLanguageClient(context: ExtensionContext) {
args.push("--enable");
args.push("checkOnType");
}
let serverOptions: ServerOptions = {
const serverOptions: ServerOptions = {
command: executablePath,
args,
};
@ -69,6 +69,7 @@ async function startLanguageClient(context: ExtensionContext) {
window.showErrorMessage(
"Failed to start the pylyzer language server. Please make sure you have pylyzer installed.",
);
window.showErrorMessage(`Error: ${e}`);
}
}
@ -80,6 +81,7 @@ async function restartLanguageClient() {
await client.restart();
} catch (e) {
window.showErrorMessage("Failed to restart the pylyzer language server.");
window.showErrorMessage(`Error: ${e}`);
}
}