diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-12 10:23:47 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-12 10:23:47 +0000 |
commit | 97a87bf3a68338b1acc2b7a02dfa43096bf47e05 (patch) | |
tree | 1f61d8ba63823f243486f1a0a70c38f244ea9760 | |
parent | 65a9066115f3d2d150b4fcb46c1db65b2ac91832 (diff) | |
parent | 9fe3b36bdae52dabecc3989161162fc6d2a3dccb (diff) |
Merge #959
959: Retrieve current working directory from workspace r=matklad a=LDSpits
This PR improves the way the language client retrieves the current working directory by using the VSCode workspace API to get the path to the currently open directory.
If we find more than one directory we show a warning that "multi root workspaces are not supported yet" and pick the root path.
Any feedback is appreciated 😄
fixes #945
Co-authored-by: Lucas Spits <[email protected]>
-rw-r--r-- | editors/code/src/server.ts | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts index 50461b0c6..f319f148a 100644 --- a/editors/code/src/server.ts +++ b/editors/code/src/server.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as lc from 'vscode-languageclient'; | 1 | import * as lc from 'vscode-languageclient'; |
2 | 2 | ||
3 | import { window } from 'vscode'; | 3 | import { window, workspace } from 'vscode'; |
4 | import { Config } from './config'; | 4 | import { Config } from './config'; |
5 | import { Highlighter } from './highlighting'; | 5 | import { Highlighter } from './highlighting'; |
6 | 6 | ||
@@ -12,9 +12,23 @@ export class Server { | |||
12 | public static start( | 12 | public static start( |
13 | notificationHandlers: Iterable<[string, lc.GenericNotificationHandler]> | 13 | notificationHandlers: Iterable<[string, lc.GenericNotificationHandler]> |
14 | ) { | 14 | ) { |
15 | // '.' Is the fallback if no folder is open | ||
16 | // 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. | ||
17 | let folder: string = '.'; | ||
18 | if (workspace.workspaceFolders !== undefined) { | ||
19 | folder = workspace.workspaceFolders[0].uri.fsPath.toString(); | ||
20 | |||
21 | if (workspace.workspaceFolders.length > 1) { | ||
22 | // Tell the user that we do not support multi-root workspaces yet | ||
23 | window.showWarningMessage( | ||
24 | 'Multi-root workspaces are not currently supported' | ||
25 | ); | ||
26 | } | ||
27 | } | ||
28 | |||
15 | const run: lc.Executable = { | 29 | const run: lc.Executable = { |
16 | command: this.config.raLspServerPath, | 30 | command: this.config.raLspServerPath, |
17 | options: { cwd: '.' } | 31 | options: { cwd: folder } |
18 | }; | 32 | }; |
19 | const serverOptions: lc.ServerOptions = { | 33 | const serverOptions: lc.ServerOptions = { |
20 | run, | 34 | run, |