Move config to Ctx
This commit is contained in:
parent
e4b588868f
commit
433000be34
3 changed files with 5 additions and 7 deletions
|
|
@ -4,6 +4,7 @@ import { Server } from './server';
|
|||
import { Config } from './config';
|
||||
|
||||
export class Ctx {
|
||||
readonly config = new Config();
|
||||
private extCtx: vscode.ExtensionContext;
|
||||
|
||||
constructor(extCtx: vscode.ExtensionContext) {
|
||||
|
|
@ -14,10 +15,6 @@ export class Ctx {
|
|||
return Server.client;
|
||||
}
|
||||
|
||||
get config(): Config {
|
||||
return Server.config;
|
||||
}
|
||||
|
||||
get activeRustEditor(): vscode.TextEditor | undefined {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
return editor && editor.document.languageId === 'rust'
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
|||
ctx.overrideCommand('type', commands.onEnter);
|
||||
}
|
||||
|
||||
const startServer = () => Server.start();
|
||||
const startServer = () => Server.start(ctx.config);
|
||||
const reloadCommand = () => reloadServer(startServer);
|
||||
|
||||
vscode.commands.registerCommand('rust-analyzer.reload', reloadCommand);
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ function expandPathResolving(path: string) {
|
|||
}
|
||||
|
||||
export class Server {
|
||||
public static config = new Config();
|
||||
static config: Config;
|
||||
public static client: lc.LanguageClient;
|
||||
|
||||
public static async start() {
|
||||
public static async start(config: Config) {
|
||||
// '.' 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 = '.';
|
||||
|
|
@ -23,6 +23,7 @@ export class Server {
|
|||
folder = workspace.workspaceFolders[0].uri.fsPath.toString();
|
||||
}
|
||||
|
||||
this.config = config;
|
||||
const command = expandPathResolving(this.config.raLspServerPath);
|
||||
const run: lc.Executable = {
|
||||
command,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue