Skip to content

Commit

Permalink
Merge pull request #114 from erlang-ls/113-show-server-stdout-in-case…
Browse files Browse the repository at this point in the history
…-of-starting-error

[#113] Show server stdout in case of starting error
  • Loading branch information
robertoaloi authored Oct 30, 2021
2 parents a2303f6 + 8cb5778 commit 36f53a0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions client/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as path from 'path';
import { workspace, ExtensionContext } from 'vscode';
import { workspace, ExtensionContext, window } from 'vscode';
import { spawnSync } from 'child_process';

import {
LanguageClient,
Expand Down Expand Up @@ -30,7 +31,7 @@ export async function get_client(context: ExtensionContext): Promise<LanguageCli

let logLevel = workspace.getConfiguration('erlang_ls').logLevel;

let serverArgs = [ serverPath, "--transport", "stdio", "--log-level", logLevel ];
let serverArgs = [ serverPath, "--log-level", logLevel ];

let logPath = workspace.getConfiguration('erlang_ls').logPath;
if (logPath !== "") {
Expand All @@ -43,10 +44,19 @@ export async function get_client(context: ExtensionContext): Promise<LanguageCli
transport: TransportKind.stdio
};

verifyExecutable(serverPath);

return new LanguageClient(
'erlang_ls',
'Erlang LS',
serverOptions,
clientOptions
);
}

export function verifyExecutable(serverPath: string) {
const res = spawnSync(serverPath, ["-version"]);
if (res.status !== 0) {
window.showErrorMessage('Could not start Language Server. Error: ' + res.stdout);
}
}

0 comments on commit 36f53a0

Please sign in to comment.