diff options
Diffstat (limited to 'editors/code/src/client.ts')
-rw-r--r-- | editors/code/src/client.ts | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 7e7e909dd..2e3d4aba2 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts | |||
@@ -1,24 +1,18 @@ | |||
1 | import { homedir } from 'os'; | ||
2 | import * as lc from 'vscode-languageclient'; | 1 | import * as lc from 'vscode-languageclient'; |
3 | import { spawnSync } from 'child_process'; | ||
4 | 2 | ||
5 | import { window, workspace } from 'vscode'; | 3 | import { window, workspace } from 'vscode'; |
6 | import { Config } from './config'; | 4 | import { Config } from './config'; |
5 | import { ensureLanguageServerBinary } from './installation/language_server'; | ||
7 | 6 | ||
8 | export function createClient(config: Config): lc.LanguageClient { | 7 | export async function createClient(config: Config): Promise<null | lc.LanguageClient> { |
9 | // '.' Is the fallback if no folder is open | 8 | // '.' Is the fallback if no folder is open |
10 | // TODO?: Workspace folders support Uri's (eg: file://test.txt). | 9 | // TODO?: Workspace folders support Uri's (eg: file://test.txt). |
11 | // It might be a good idea to test if the uri points to a file. | 10 | // It might be a good idea to test if the uri points to a file. |
12 | const workspaceFolderPath = workspace.workspaceFolders?.[0]?.uri.fsPath ?? '.'; | 11 | const workspaceFolderPath = workspace.workspaceFolders?.[0]?.uri.fsPath ?? '.'; |
13 | 12 | ||
14 | const raLspServerPath = expandPathResolving(config.raLspServerPath); | 13 | const raLspServerPath = await ensureLanguageServerBinary(config.langServerSource); |
15 | if (spawnSync(raLspServerPath, ["--version"]).status !== 0) { | 14 | if (!raLspServerPath) return null; |
16 | window.showErrorMessage( | 15 | |
17 | `Unable to execute '${raLspServerPath} --version'\n\n` + | ||
18 | `Perhaps it is not in $PATH?\n\n` + | ||
19 | `PATH=${process.env.PATH}\n` | ||
20 | ); | ||
21 | } | ||
22 | const run: lc.Executable = { | 16 | const run: lc.Executable = { |
23 | command: raLspServerPath, | 17 | command: raLspServerPath, |
24 | options: { cwd: workspaceFolderPath }, | 18 | options: { cwd: workspaceFolderPath }, |
@@ -87,9 +81,3 @@ export function createClient(config: Config): lc.LanguageClient { | |||
87 | res.registerProposedFeatures(); | 81 | res.registerProposedFeatures(); |
88 | return res; | 82 | return res; |
89 | } | 83 | } |
90 | function expandPathResolving(path: string) { | ||
91 | if (path.startsWith('~/')) { | ||
92 | return path.replace('~', homedir()); | ||
93 | } | ||
94 | return path; | ||
95 | } | ||