feature(vscode): resolve `lspBin` using a relative path
MODIFY
editors/vscode/package.json
editors/vscode/package.json
"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"
}
}
},
"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": {

MODIFY
editors/vscode/src/main.ts
editors/vscode/src/main.ts
@@ -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";
@@ -121,7 +123,18 @@ async function getServerPath(
const config = workspace.getConfiguration();
const explicitPath = config.get("rome.lspBin");
if (typeof explicitPath === "string" && 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];

feature(vscode): resolve `lspBin` using a relative path (#3224)