Update language server client and configs

This commit is contained in:
Sofia 2025-08-02 19:19:29 +03:00
parent 8a71ce3629
commit 16082752e2
3 changed files with 23 additions and 20 deletions

3
reid-lsp/.gitignore vendored
View File

@ -3,4 +3,5 @@ node_modules
dist dist
package-lock.json package-lock.json
pnpm-lock.yaml pnpm-lock.yaml
tsconfig.tsbuildinfo tsconfig.tsbuildinfo
*.vsix

View File

@ -18,12 +18,20 @@ import {
let client: LanguageClient; let client: LanguageClient;
export function activate(context: ExtensionContext) { export function activate(context: ExtensionContext) {
const traceOutputChannel = window.createOutputChannel("Reid Language Server trace"); const configuration = workspace.getConfiguration('reid-language-server');
const command = process.env.SERVER_PATH || "reid-language-server"; let server_path: string = process.env.SERVER_PATH ?? configuration.get("language-server-path") ?? 'reid-language-server';
const regex = /\$(\w+)/;
while (regex.test(server_path)) {
let envVar = regex.exec(server_path)?.[1];
const envVal = envVar ? process.env[envVar] : undefined;
if (envVar === undefined || envVal === undefined) {
console.error(`No such environment variables as ${envVar}`);
}
server_path = server_path.replaceAll(`$${envVar}`, envVal ?? '');
}
const run: Executable = { const run: Executable = {
command, command: server_path,
options: { options: {
env: { env: {
...process.env, ...process.env,
@ -49,11 +57,15 @@ export function activate(context: ExtensionContext) {
// Create the language client and start the client. // Create the language client and start the client.
client = new LanguageClient( client = new LanguageClient(
'reid-lsp', 'reid-language-server',
'Reid Language Server', 'Reid Language Server',
serverOptions, serverOptions,
clientOptions clientOptions
); );
client.info(JSON.stringify(server_path));
client.info(`Loaded Reid Language Server from ${server_path}`);
workspace.onDidOpenTextDocument((e) => { workspace.onDidOpenTextDocument((e) => {
}); });

View File

@ -1,5 +1,5 @@
{ {
"name": "reid-lsp", "name": "reid-language-server",
"displayName": "Reid Language Server", "displayName": "Reid Language Server",
"description": "Language Server Extension for Reid", "description": "Language Server Extension for Reid",
"version": "0.1.0", "version": "0.1.0",
@ -32,21 +32,11 @@
"type": "object", "type": "object",
"title": "reid-language-server", "title": "reid-language-server",
"properties": { "properties": {
"nrs-language-server.trace.server": { "reid-language-server.language-server-path": {
"type": "string", "type": "string",
"scope": "window", "scope": "window",
"enum": [ "default": "$HOME/.cargo/bin/reid-lsp",
"off", "description": "Path to the Reid Language Server executable"
"messages",
"verbose"
],
"enumDescriptions": [
"No traces",
"Error only",
"Full log"
],
"default": "off",
"description": "Traces the communication between VS Code and the language server."
} }
} }
}, },