aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/highlighting.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/highlighting.ts')
-rw-r--r--editors/code/src/highlighting.ts22
1 files changed, 21 insertions, 1 deletions
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts
index 4e224a54c..ced78adc1 100644
--- a/editors/code/src/highlighting.ts
+++ b/editors/code/src/highlighting.ts
@@ -1,10 +1,30 @@
1import seedrandom = require('seedrandom');
2import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
3import * as lc from 'vscode-languageclient'; 2import * as lc from 'vscode-languageclient';
3import * as seedrandom from 'seedrandom';
4
4import * as scopes from './scopes'; 5import * as scopes from './scopes';
5import * as scopesMapper from './scopes_mapper'; 6import * as scopesMapper from './scopes_mapper';
6 7
7import { Server } from './server'; 8import { Server } from './server';
9import { Ctx } from './ctx';
10
11export function activateHighlighting(ctx: Ctx) {
12 vscode.window.onDidChangeActiveTextEditor(
13 async (editor: vscode.TextEditor | undefined) => {
14 if (!editor || editor.document.languageId !== 'rust') return;
15 if (!Server.config.highlightingOn) return;
16
17 const params: lc.TextDocumentIdentifier = {
18 uri: editor.document.uri.toString(),
19 };
20 const decorations = await ctx.client.sendRequest<Decoration[]>(
21 'rust-analyzer/decorationsRequest',
22 params,
23 );
24 Server.highlighter.setHighlights(editor, decorations);
25 },
26 );
27}
8 28
9export interface Decoration { 29export interface Decoration {
10 range: lc.Range; 30 range: lc.Range;