mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-10 05:53:10 +00:00
Add config to Ctx
This commit is contained in:
parent
7646dc046e
commit
efbbc903e6
@ -1,6 +1,7 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as lc from 'vscode-languageclient';
|
import * as lc from 'vscode-languageclient';
|
||||||
import { Server } from './server';
|
import { Server } from './server';
|
||||||
|
import { Config } from './config';
|
||||||
|
|
||||||
export class Ctx {
|
export class Ctx {
|
||||||
private extCtx: vscode.ExtensionContext;
|
private extCtx: vscode.ExtensionContext;
|
||||||
@ -13,6 +14,10 @@ export class Ctx {
|
|||||||
return Server.client;
|
return Server.client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get config(): Config {
|
||||||
|
return Server.config;
|
||||||
|
}
|
||||||
|
|
||||||
get activeRustEditor(): vscode.TextEditor | undefined {
|
get activeRustEditor(): vscode.TextEditor | undefined {
|
||||||
const editor = vscode.window.activeTextEditor;
|
const editor = vscode.window.activeTextEditor;
|
||||||
return editor && editor.document.languageId === 'rust'
|
return editor && editor.document.languageId === 'rust'
|
||||||
|
@ -12,7 +12,7 @@ export function activateHighlighting(ctx: Ctx) {
|
|||||||
vscode.window.onDidChangeActiveTextEditor(
|
vscode.window.onDidChangeActiveTextEditor(
|
||||||
async (editor: vscode.TextEditor | undefined) => {
|
async (editor: vscode.TextEditor | undefined) => {
|
||||||
if (!editor || editor.document.languageId !== 'rust') return;
|
if (!editor || editor.document.languageId !== 'rust') return;
|
||||||
if (!Server.config.highlightingOn) return;
|
if (!ctx.config.highlightingOn) return;
|
||||||
|
|
||||||
const params: lc.TextDocumentIdentifier = {
|
const params: lc.TextDocumentIdentifier = {
|
||||||
uri: editor.document.uri.toString(),
|
uri: editor.document.uri.toString(),
|
||||||
|
@ -30,9 +30,7 @@ export function activateInlayHints(ctx: Ctx) {
|
|||||||
);
|
);
|
||||||
ctx.pushCleanup(
|
ctx.pushCleanup(
|
||||||
vscode.workspace.onDidChangeConfiguration(_ =>
|
vscode.workspace.onDidChangeConfiguration(_ =>
|
||||||
hintsUpdater.toggleHintsDisplay(
|
hintsUpdater.toggleHintsDisplay(ctx.config.displayInlayHints),
|
||||||
Server.config.displayInlayHints,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -28,13 +28,11 @@ export async function activate(context: vscode.ExtensionContext) {
|
|||||||
ctx.registerCommand('runSingle', commands.runSingle);
|
ctx.registerCommand('runSingle', commands.runSingle);
|
||||||
ctx.registerCommand('showReferences', commands.showReferences);
|
ctx.registerCommand('showReferences', commands.showReferences);
|
||||||
|
|
||||||
if (Server.config.enableEnhancedTyping) {
|
if (ctx.config.enableEnhancedTyping) {
|
||||||
ctx.overrideCommand('type', commands.onEnter);
|
ctx.overrideCommand('type', commands.onEnter);
|
||||||
}
|
}
|
||||||
|
|
||||||
const watchStatus = new StatusDisplay(
|
const watchStatus = new StatusDisplay(ctx.config.cargoWatchOptions.command);
|
||||||
Server.config.cargoWatchOptions.command,
|
|
||||||
);
|
|
||||||
ctx.pushCleanup(watchStatus);
|
ctx.pushCleanup(watchStatus);
|
||||||
|
|
||||||
activateHighlighting(ctx);
|
activateHighlighting(ctx);
|
||||||
@ -63,7 +61,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
|||||||
vscode.window.showErrorMessage(e.message);
|
vscode.window.showErrorMessage(e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Server.config.displayInlayHints) {
|
if (ctx.config.displayInlayHints) {
|
||||||
activateInlayHints(ctx);
|
activateInlayHints(ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user