Skip to content

Commit

Permalink
check if the configured server binary exists and fall back to the bun…
Browse files Browse the repository at this point in the history
…dled binary if it does not
  • Loading branch information
cswimr committed Jan 13, 2025
1 parent f0c5ca9 commit 1a8ba5f
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions editors/code/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,23 @@ const startLanguageServer = async (context: vscode.ExtensionContext) => {
.getConfiguration("luau-lsp.server")
.get("path", "");

const serverBinPath = serverBinConfig
? vscode.Uri.file(serverBinConfig).fsPath
: vscode.Uri.joinPath(
context.extensionUri,
"bin",
os.platform() === "win32" ? "server.exe" : "server",
).fsPath;
const uri = vscode.Uri.file(serverBinConfig);
let serverBinPath;

if (await utils.exists(uri)) {
serverBinPath = uri.fsPath;
} else {
if (serverBinConfig !== "") {
vscode.window.showWarningMessage(
`Server binary at path \`${serverBinConfig}\` does not exist, falling back to bundled binary`,
);
}
serverBinPath = vscode.Uri.joinPath(
context.extensionUri,
"bin",
os.platform() === "win32" ? "server.exe" : "server",
).fsPath;
}

const run: Executable = {
command: serverBinPath,
Expand Down

0 comments on commit 1a8ba5f

Please sign in to comment.