mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Encapsulate highlighting activation
This commit is contained in:
parent
17dda0972a
commit
7646dc046e
4 changed files with 24 additions and 35 deletions
|
@ -1,10 +1,30 @@
|
|||
import seedrandom = require('seedrandom');
|
||||
import * as vscode from 'vscode';
|
||||
import * as lc from 'vscode-languageclient';
|
||||
import * as seedrandom from 'seedrandom';
|
||||
|
||||
import * as scopes from './scopes';
|
||||
import * as scopesMapper from './scopes_mapper';
|
||||
|
||||
import { Server } from './server';
|
||||
import { Ctx } from './ctx';
|
||||
|
||||
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;
|
||||
|
||||
const params: lc.TextDocumentIdentifier = {
|
||||
uri: editor.document.uri.toString(),
|
||||
};
|
||||
const decorations = await ctx.client.sendRequest<Decoration[]>(
|
||||
'rust-analyzer/decorationsRequest',
|
||||
params,
|
||||
);
|
||||
Server.highlighter.setHighlights(editor, decorations);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export interface Decoration {
|
||||
range: lc.Range;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue