diff options
Diffstat (limited to 'editors/code/src/client.ts')
-rw-r--r-- | editors/code/src/client.ts | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 116f41df6..f13ae07e1 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts | |||
@@ -4,6 +4,7 @@ import * as ra from '../src/lsp_ext'; | |||
4 | import * as Is from 'vscode-languageclient/lib/common/utils/is'; | 4 | import * as Is from 'vscode-languageclient/lib/common/utils/is'; |
5 | import { assert } from './util'; | 5 | import { assert } from './util'; |
6 | import { WorkspaceEdit } from 'vscode'; | 6 | import { WorkspaceEdit } from 'vscode'; |
7 | import { Workspace } from './ctx'; | ||
7 | 8 | ||
8 | export interface Env { | 9 | export interface Env { |
9 | [name: string]: string; | 10 | [name: string]: string; |
@@ -23,7 +24,7 @@ function renderHoverActions(actions: ra.CommandLinkGroup[]): vscode.MarkdownStri | |||
23 | return result; | 24 | return result; |
24 | } | 25 | } |
25 | 26 | ||
26 | export function createClient(serverPath: string, cwd: string, extraEnv: Env): lc.LanguageClient { | 27 | export function createClient(serverPath: string, workspace: Workspace, extraEnv: Env): lc.LanguageClient { |
27 | // '.' Is the fallback if no folder is open | 28 | // '.' Is the fallback if no folder is open |
28 | // TODO?: Workspace folders support Uri's (eg: file://test.txt). | 29 | // TODO?: Workspace folders support Uri's (eg: file://test.txt). |
29 | // It might be a good idea to test if the uri points to a file. | 30 | // It might be a good idea to test if the uri points to a file. |
@@ -33,7 +34,7 @@ export function createClient(serverPath: string, cwd: string, extraEnv: Env): lc | |||
33 | 34 | ||
34 | const run: lc.Executable = { | 35 | const run: lc.Executable = { |
35 | command: serverPath, | 36 | command: serverPath, |
36 | options: { cwd, env: newEnv }, | 37 | options: { env: newEnv }, |
37 | }; | 38 | }; |
38 | const serverOptions: lc.ServerOptions = { | 39 | const serverOptions: lc.ServerOptions = { |
39 | run, | 40 | run, |
@@ -43,9 +44,14 @@ export function createClient(serverPath: string, cwd: string, extraEnv: Env): lc | |||
43 | 'Rust Analyzer Language Server Trace', | 44 | 'Rust Analyzer Language Server Trace', |
44 | ); | 45 | ); |
45 | 46 | ||
47 | let initializationOptions = vscode.workspace.getConfiguration("rust-analyzer"); | ||
48 | if (workspace.kind === "Detached Files") { | ||
49 | initializationOptions = { "detachedFiles": workspace.files.map(file => file.uri.fsPath), ...initializationOptions }; | ||
50 | } | ||
51 | |||
46 | const clientOptions: lc.LanguageClientOptions = { | 52 | const clientOptions: lc.LanguageClientOptions = { |
47 | documentSelector: [{ scheme: 'file', language: 'rust' }], | 53 | documentSelector: [{ scheme: 'file', language: 'rust' }], |
48 | initializationOptions: vscode.workspace.getConfiguration("rust-analyzer"), | 54 | initializationOptions, |
49 | diagnosticCollectionName: "rustc", | 55 | diagnosticCollectionName: "rustc", |
50 | traceOutputChannel, | 56 | traceOutputChannel, |
51 | middleware: { | 57 | middleware: { |