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