aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-12-30 19:46:14 +0000
committerAleksey Kladov <[email protected]>2019-12-30 20:32:04 +0000
commitefbbc903e68aaf32ee1fba5537769070cd2d01e8 (patch)
tree7895d32c183bb8bf23ccf5a47011e4561c0db413
parent7646dc046eb562276231de8ec6a4df1bc691cafc (diff)
Add config to Ctx
-rw-r--r--editors/code/src/ctx.ts5
-rw-r--r--editors/code/src/highlighting.ts2
-rw-r--r--editors/code/src/inlay_hints.ts4
-rw-r--r--editors/code/src/main.ts8
4 files changed, 10 insertions, 9 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index c3a3583b5..ca4319064 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -1,6 +1,7 @@
1import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
2import * as lc from 'vscode-languageclient'; 2import * as lc from 'vscode-languageclient';
3import { Server } from './server'; 3import { Server } from './server';
4import { Config } from './config';
4 5
5export class Ctx { 6export class Ctx {
6 private extCtx: vscode.ExtensionContext; 7 private extCtx: vscode.ExtensionContext;
@@ -13,6 +14,10 @@ export class Ctx {
13 return Server.client; 14 return Server.client;
14 } 15 }
15 16
17 get config(): Config {
18 return Server.config;
19 }
20
16 get activeRustEditor(): vscode.TextEditor | undefined { 21 get activeRustEditor(): vscode.TextEditor | undefined {
17 const editor = vscode.window.activeTextEditor; 22 const editor = vscode.window.activeTextEditor;
18 return editor && editor.document.languageId === 'rust' 23 return editor && editor.document.languageId === 'rust'
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts
index ced78adc1..0f9271de2 100644
--- a/editors/code/src/highlighting.ts
+++ b/editors/code/src/highlighting.ts
@@ -12,7 +12,7 @@ export function activateHighlighting(ctx: Ctx) {
12 vscode.window.onDidChangeActiveTextEditor( 12 vscode.window.onDidChangeActiveTextEditor(
13 async (editor: vscode.TextEditor | undefined) => { 13 async (editor: vscode.TextEditor | undefined) => {
14 if (!editor || editor.document.languageId !== 'rust') return; 14 if (!editor || editor.document.languageId !== 'rust') return;
15 if (!Server.config.highlightingOn) return; 15 if (!ctx.config.highlightingOn) return;
16 16
17 const params: lc.TextDocumentIdentifier = { 17 const params: lc.TextDocumentIdentifier = {
18 uri: editor.document.uri.toString(), 18 uri: editor.document.uri.toString(),
diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts
index 4581e2278..fb8f135c3 100644
--- a/editors/code/src/inlay_hints.ts
+++ b/editors/code/src/inlay_hints.ts
@@ -30,9 +30,7 @@ export function activateInlayHints(ctx: Ctx) {
30 ); 30 );
31 ctx.pushCleanup( 31 ctx.pushCleanup(
32 vscode.workspace.onDidChangeConfiguration(_ => 32 vscode.workspace.onDidChangeConfiguration(_ =>
33 hintsUpdater.toggleHintsDisplay( 33 hintsUpdater.toggleHintsDisplay(ctx.config.displayInlayHints),
34 Server.config.displayInlayHints,
35 ),
36 ), 34 ),
37 ); 35 );
38 }); 36 });
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 45657532e..345ae0685 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -28,13 +28,11 @@ export async function activate(context: vscode.ExtensionContext) {
28 ctx.registerCommand('runSingle', commands.runSingle); 28 ctx.registerCommand('runSingle', commands.runSingle);
29 ctx.registerCommand('showReferences', commands.showReferences); 29 ctx.registerCommand('showReferences', commands.showReferences);
30 30
31 if (Server.config.enableEnhancedTyping) { 31 if (ctx.config.enableEnhancedTyping) {
32 ctx.overrideCommand('type', commands.onEnter); 32 ctx.overrideCommand('type', commands.onEnter);
33 } 33 }
34 34
35 const watchStatus = new StatusDisplay( 35 const watchStatus = new StatusDisplay(ctx.config.cargoWatchOptions.command);
36 Server.config.cargoWatchOptions.command,
37 );
38 ctx.pushCleanup(watchStatus); 36 ctx.pushCleanup(watchStatus);
39 37
40 activateHighlighting(ctx); 38 activateHighlighting(ctx);
@@ -63,7 +61,7 @@ export async function activate(context: vscode.ExtensionContext) {
63 vscode.window.showErrorMessage(e.message); 61 vscode.window.showErrorMessage(e.message);
64 } 62 }
65 63
66 if (Server.config.displayInlayHints) { 64 if (ctx.config.displayInlayHints) {
67 activateInlayHints(ctx); 65 activateInlayHints(ctx);
68 } 66 }
69} 67}