Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
feature(vscode): resolve lspBin using a relative path (#3224)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Sep 14, 2022
1 parent 8364d1c commit ef7803a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 3 additions & 3 deletions editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"null"
],
"default": null,
"markdownDescription": "The rome lsp server executable."
"markdownDescription": "The rome lsp server executable. If the path is relative, the workspace folder will be used as base path"
}
}
},
Expand All @@ -108,8 +108,8 @@
"package": "vsce package -o rome_lsp.vsix",
"build": "npm run compile -- --minify && npm run package",
"install-extension": "code --install-extension rome_lsp.vsix",
"format": "cargo run --bin rome format ./src/ ./scripts",
"format:rome": "rome format src scripts --write",
"format": "cargo run --bin rome format ./src/ ./scripts --write",
"pack:dev": "npm run compile && npm run package && npm run install-extension",
"tsc": "tsc"
},
"dependencies": {
Expand Down
15 changes: 14 additions & 1 deletion editors/vscode/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
ServerOptions,
StreamInfo,
} from "vscode-languageclient/node";
import { join, isAbsolute } from "path";
import { existsSync } from "fs";
import { setContextValue } from "./utils";
import { Session } from "./session";
import { syntaxTree } from "./commands/syntaxTree";
Expand Down Expand Up @@ -121,7 +123,18 @@ async function getServerPath(
const config = workspace.getConfiguration();
const explicitPath = config.get("rome.lspBin");
if (typeof explicitPath === "string" && explicitPath !== "") {
return explicitPath;
if (isAbsolute(explicitPath)) {
return explicitPath;
} else {
for (let i = 0; i < workspace.workspaceFolders.length; i++) {
const workspaceFolder = workspace.workspaceFolders[i];
const possiblePath = join(workspaceFolder.uri.path, explicitPath);
if (existsSync(possiblePath)) {
return possiblePath;
}
}
return undefined;
}
}

const triplet = PLATFORM_TRIPLETS[process.platform]?.[process.arch];
Expand Down

0 comments on commit ef7803a

Please sign in to comment.