Skip to content

Commit

Permalink
Add escriptPath configuration option (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikaka27 authored Sep 18, 2024
1 parent 34ac95f commit 040c81b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
13 changes: 9 additions & 4 deletions client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,18 @@ export async function get_client(context: ExtensionContext): Promise<LanguageCli
serverArgs.push("--log-dir", logPath);
}

let escriptPath = workspace.getConfiguration('erlang_ls').escriptPath;
if (escriptPath === "") {
escriptPath = 'escript';
}

let serverOptions: ServerOptions = {
command: 'escript',
command: escriptPath,
args: serverArgs,
transport: TransportKind.stdio
};

verifyExecutable(serverPath);
verifyExecutable(serverPath, escriptPath);

return new LanguageClient(
'erlang_ls',
Expand All @@ -117,8 +122,8 @@ export async function get_client(context: ExtensionContext): Promise<LanguageCli
);
}

export function verifyExecutable(serverPath: string) {
const res = spawnSync('escript', [serverPath, "--version"]);
export function verifyExecutable(serverPath: string, escriptPath: string) {
const res = spawnSync(escriptPath, [serverPath, "--version"]);
if (res.status !== 0) {
window.showErrorMessage('Could not start Language Server. Error: ' + res.stdout);
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ErlangDebugAdapterExecutableFactory implements vscode.DebugAdapterDescript
const erlangConfig = vscode.workspace;
const executable = erlangConfig.getConfiguration('erlang_ls').get<string>('dapPath') || '';

let command = 'escript';
const command = erlangConfig.getConfiguration('erlang_ls').get<string>('escriptPath') || 'escript';
let args;

if (executable.length > 0) {
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
"default": "",
"description": "Override the default path of the els_dap executable with a custom one."
},
"erlang_ls.escriptPath": {
"scope": "window",
"type": "string",
"default": "",
"description": "Override the default path of the escript executable with a custom one."
},
"erlang_ls.logPath": {
"scope": "window",
"type": "string",
Expand Down

0 comments on commit 040c81b

Please sign in to comment.