Skip to content

Commit a3a210f

Browse files
committed
add option for disabling autoupdates
Installing the server via `cargo` overrides the local installation, even if it has a higher version. This is problematic if we want to test the LSP server inside VSCode, so now there option in settings to disable autoupdate.
1 parent 6e994dc commit a3a210f

2 files changed

Lines changed: 30 additions & 11 deletions

File tree

vscode/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@
6767
"type": "boolean",
6868
"default": false,
6969
"description": "Do not show missing LSP executable warning."
70+
},
71+
"simplicityhl.disableAutoupdate": {
72+
"type": "boolean",
73+
"default": false,
74+
"description": "Do not autoupdate LSP server."
7075
}
7176
}
7277
},

vscode/src/find_server.ts

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,17 @@ export async function ensureExecutable(
109109
const cargoPath = findExecutable("cargo");
110110
const config = workspace.getConfiguration("simplicityhl");
111111

112-
const suppressWarning = config.get<boolean>(
113-
"suppressMissingLspWarning",
114-
false,
115-
);
112+
let serverPath = findExecutable(command);
113+
114+
if (!cargoPath && !serverPath) {
115+
const suppressWarning = config.get<boolean>(
116+
"suppressMissingLspWarning",
117+
false,
118+
);
119+
if (suppressWarning) {
120+
return null;
121+
}
116122

117-
if (!cargoPath && !suppressWarning) {
118123
const choice = await window.showWarningMessage(
119124
`To use SimplicityHL language server, please install cargo`,
120125
"Learn more",
@@ -133,12 +138,21 @@ export async function ensureExecutable(
133138
}
134139

135140
if (cargoPath) {
136-
try {
137-
await installServer(command);
138-
return findExecutable(command);
139-
} catch (err) {
140-
window.showErrorMessage(err);
141-
return null;
141+
const disableAutoupdate = config.get<boolean>("disableAutoupdate", false);
142+
143+
const shouldInstallOrUpdate = (!serverPath) || !disableAutoupdate;
144+
145+
if (shouldInstallOrUpdate) {
146+
try {
147+
await installServer(command);
148+
149+
serverPath = findExecutable(command);
150+
} catch (err) {
151+
window.showErrorMessage(err);
152+
return null;
153+
}
142154
}
143155
}
156+
157+
return serverPath;
144158
}

0 commit comments

Comments
 (0)