about summary refs log tree commit diff
path: root/editors/code/src/client.ts
diff options
context:
space:
mode:
authorlf- <lf-@users.noreply.github.com>2020-12-30 01:17:25 -0800
committerlf- <lf-@users.noreply.github.com>2020-12-30 04:51:07 -0800
commitf7f6ac3554d0b5e380985b1a2070000bfd8ef77b (patch)
tree63d549ecaab44bccbcfc996660beeeb698951c67 /editors/code/src/client.ts
parente7d2b5888b8a7e632ae9080108ccbc450316fd86 (diff)
downloadrust-f7f6ac3554d0b5e380985b1a2070000bfd8ef77b.tar.gz
rust-f7f6ac3554d0b5e380985b1a2070000bfd8ef77b.zip
Add an option for extra env vars in the Code extension
Diffstat (limited to 'editors/code/src/client.ts')
-rw-r--r--editors/code/src/client.ts11
1 files changed, 9 insertions, 2 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index 63ab82dde7b..539e487ec96 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -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,