Skip to content

Commit

Permalink
add server path configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
cswimr committed Feb 1, 2025
1 parent 666b61e commit b47da29
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Added

- Added configuration `luau-lsp.server.path` (default: `""`) which allows the use of locally installed `luau-lsp` binaries. ([#897](https://github.com/JohnnyMorganz/luau-lsp/pull/897))

### Changed

- Sync to upstream Luau 0.659
Expand Down
5 changes: 5 additions & 0 deletions editors/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@
"scope": "window",
"default": "off"
},
"luau-lsp.server.path": {
"markdownDescription": "Path to the Luau LSP server binary. If not provided, uses the binary included in the extension.",
"type": "string",
"default": ""
},
"luau-lsp.ignoreGlobs": {
"markdownDescription": "Diagnostics will not be reported for any file matching these globs unless the file is currently open",
"type": "array",
Expand Down
26 changes: 21 additions & 5 deletions editors/code/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,27 @@ const startLanguageServer = async (context: vscode.ExtensionContext) => {
}
}

const serverBinPath = vscode.Uri.joinPath(
context.extensionUri,
"bin",
os.platform() === "win32" ? "server.exe" : "server",
).fsPath;
const serverBinConfig = vscode.workspace
.getConfiguration("luau-lsp.server")
.get("path", "");

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 b47da29

Please sign in to comment.