diff options
| author | Aleksey Kladov <aleksey.kladov@gmail.com> | 2019-12-30 20:46:14 +0100 |
|---|---|---|
| committer | Aleksey Kladov <aleksey.kladov@gmail.com> | 2019-12-30 21:32:04 +0100 |
| commit | efbbc903e68aaf32ee1fba5537769070cd2d01e8 (patch) | |
| tree | 7895d32c183bb8bf23ccf5a47011e4561c0db413 /editors/code/src | |
| parent | 7646dc046eb562276231de8ec6a4df1bc691cafc (diff) | |
| download | rust-efbbc903e68aaf32ee1fba5537769070cd2d01e8.tar.gz rust-efbbc903e68aaf32ee1fba5537769070cd2d01e8.zip | |
Add config to Ctx
Diffstat (limited to 'editors/code/src')
| -rw-r--r-- | editors/code/src/ctx.ts | 5 | ||||
| -rw-r--r-- | editors/code/src/highlighting.ts | 2 | ||||
| -rw-r--r-- | editors/code/src/inlay_hints.ts | 4 | ||||
| -rw-r--r-- | editors/code/src/main.ts | 8 |
4 files changed, 10 insertions, 9 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index c3a3583b52d..ca431906445 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -1,6 +1,7 @@ import * as vscode from 'vscode'; import * as lc from 'vscode-languageclient'; import { Server } from './server'; +import { Config } from './config'; export class Ctx { private extCtx: vscode.ExtensionContext; @@ -13,6 +14,10 @@ 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' diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts index ced78adc110..0f9271de261 100644 --- a/editors/code/src/highlighting.ts +++ b/editors/code/src/highlighting.ts @@ -12,7 +12,7 @@ export function activateHighlighting(ctx: Ctx) { vscode.window.onDidChangeActiveTextEditor( async (editor: vscode.TextEditor | undefined) => { if (!editor || editor.document.languageId !== 'rust') return; - if (!Server.config.highlightingOn) return; + if (!ctx.config.highlightingOn) return; const params: lc.TextDocumentIdentifier = { uri: editor.document.uri.toString(), diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts index 4581e22782f..fb8f135c382 100644 --- a/editors/code/src/inlay_hints.ts +++ b/editors/code/src/inlay_hints.ts @@ -30,9 +30,7 @@ export function activateInlayHints(ctx: Ctx) { ); ctx.pushCleanup( vscode.workspace.onDidChangeConfiguration(_ => - hintsUpdater.toggleHintsDisplay( - Server.config.displayInlayHints, - ), + hintsUpdater.toggleHintsDisplay(ctx.config.displayInlayHints), ), ); }); diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 45657532e5f..345ae068566 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -28,13 +28,11 @@ export async function activate(context: vscode.ExtensionContext) { ctx.registerCommand('runSingle', commands.runSingle); ctx.registerCommand('showReferences', commands.showReferences); - if (Server.config.enableEnhancedTyping) { + if (ctx.config.enableEnhancedTyping) { ctx.overrideCommand('type', commands.onEnter); } - const watchStatus = new StatusDisplay( - Server.config.cargoWatchOptions.command, - ); + const watchStatus = new StatusDisplay(ctx.config.cargoWatchOptions.command); ctx.pushCleanup(watchStatus); activateHighlighting(ctx); @@ -63,7 +61,7 @@ export async function activate(context: vscode.ExtensionContext) { vscode.window.showErrorMessage(e.message); } - if (Server.config.displayInlayHints) { + if (ctx.config.displayInlayHints) { activateInlayHints(ctx); } } |
