mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-21 01:29:59 +00:00
Add an option for extra env vars in the Code extension
This commit is contained in:
parent
e7d2b5888b
commit
f7f6ac3554
4 changed files with 21 additions and 3 deletions
|
@ -6,6 +6,10 @@ import { DocumentSemanticsTokensSignature, DocumentSemanticsTokensEditsSignature
|
|||
import { assert } from './util';
|
||||
import { WorkspaceEdit } from 'vscode';
|
||||
|
||||
export interface Env {
|
||||
[name: string]: string;
|
||||
}
|
||||
|
||||
function renderCommand(cmd: ra.CommandLink) {
|
||||
return `[${cmd.title}](command:${cmd.command}?${encodeURIComponent(JSON.stringify(cmd.arguments))} '${cmd.tooltip!}')`;
|
||||
}
|
||||
|
@ -27,14 +31,17 @@ async function semanticHighlightingWorkaround<R, F extends (...args: any[]) => v
|
|||
return res;
|
||||
}
|
||||
|
||||
export function createClient(serverPath: string, cwd: string): lc.LanguageClient {
|
||||
export function createClient(serverPath: string, cwd: string, extraEnv: Env): lc.LanguageClient {
|
||||
// '.' Is the fallback if no folder is open
|
||||
// TODO?: Workspace folders support Uri's (eg: file://test.txt).
|
||||
// It might be a good idea to test if the uri points to a file.
|
||||
|
||||
const newEnv = Object.assign({}, process.env);
|
||||
Object.assign(newEnv, extraEnv);
|
||||
|
||||
const run: lc.Executable = {
|
||||
command: serverPath,
|
||||
options: { cwd },
|
||||
options: { cwd, env: newEnv },
|
||||
};
|
||||
const serverOptions: lc.ServerOptions = {
|
||||
run,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue