mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
Retrieve current directory from workspaces
This commit is contained in:
parent
011bd4b2fc
commit
7185c594fe
1 changed files with 18 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
import * as lc from 'vscode-languageclient';
|
||||
|
||||
import { window } from 'vscode';
|
||||
import { window, workspace } from 'vscode';
|
||||
import { Config } from './config';
|
||||
import { Highlighter } from './highlighting';
|
||||
|
||||
|
@ -12,9 +12,25 @@ export class Server {
|
|||
public static start(
|
||||
notificationHandlers: Iterable<[string, lc.GenericNotificationHandler]>
|
||||
) {
|
||||
|
||||
// '.' Is the fallback if no folder is open
|
||||
// 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.
|
||||
let folder: string = '.';
|
||||
if (workspace.workspaceFolders !== undefined) {
|
||||
|
||||
folder = workspace
|
||||
.workspaceFolders[0].uri.fsPath
|
||||
.toString();
|
||||
|
||||
if (workspace.workspaceFolders.length > 1) {
|
||||
// Tell the user that we do not support multi-root workspaces yet
|
||||
window.showWarningMessage("Multi-root workspaces are not currently supported");
|
||||
}
|
||||
}
|
||||
|
||||
const run: lc.Executable = {
|
||||
command: this.config.raLspServerPath,
|
||||
options: { cwd: '.' }
|
||||
options: { cwd: folder }
|
||||
};
|
||||
const serverOptions: lc.ServerOptions = {
|
||||
run,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue