Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@
"default": "",
"markdownDescription": "Pass additional arguments to the language server."
},
"haskell.envVars": {
"scope": "resource",
"type": "object",
"default": {},
"markdownDescription": "Define environment variables for compilation/execution."
},
"haskell.updateBehavior": {
"scope": "machine",
"type": "string",
Expand Down
7 changes: 7 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ import { DocsBrowser } from './docsBrowser';
import { downloadHaskellLanguageServer } from './hlsBinaries';
import { directoryExists, executableExists, ExtensionLogger, resolvePathPlaceHolders } from './utils';

// Used for environment variables later on
interface IEnvVars {
[key: string]: string;
}

// The current map of documents & folders to language servers.
// It may be null to indicate that we are in the process of launching a server,
// in which case don't try to launch another one for that uri
Expand Down Expand Up @@ -212,8 +217,10 @@ async function activateServerForFolder(context: ExtensionContext, uri: Uri, fold
logger.info(`Activating the language server in the parent dir of the file: ${uri.fsPath}`);
}

const envVars: IEnvVars = workspace.getConfiguration('haskell', uri).envVars;
const exeOptions: ExecutableOptions = {
cwd: folder ? undefined : path.dirname(uri.fsPath),
env: Object.assign(process.env, envVars),
};

// We don't want empty strings in our args
Expand Down