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.ts23
1 files changed, 22 insertions, 1 deletions
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts
index 4e224a54c..333319b85 100644
--- a/editors/code/src/highlighting.ts
+++ b/editors/code/src/highlighting.ts
@@ -1,10 +1,31 @@
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';
4const seedrandom = seedrandom_; // https://github.com/jvandemo/generator-angular2-library/issues/221#issuecomment-355945207
5
4import * as scopes from './scopes'; 6import * as scopes from './scopes';
5import * as scopesMapper from './scopes_mapper'; 7import * as scopesMapper from './scopes_mapper';
6 8
7import { Server } from './server'; 9import { Server } from './server';
10import { Ctx } from './ctx';
11
12export function activateHighlighting(ctx: Ctx) {
13 vscode.window.onDidChangeActiveTextEditor(
14 async (editor: vscode.TextEditor | undefined) => {
15 if (!editor || editor.document.languageId !== 'rust') return;
16 if (!ctx.config.highlightingOn) return;
17
18 const params: lc.TextDocumentIdentifier = {
19 uri: editor.document.uri.toString(),
20 };
21 const decorations = await ctx.client.sendRequest<Decoration[]>(
22 'rust-analyzer/decorationsRequest',
23 params,
24 );
25 Server.highlighter.setHighlights(editor, decorations);
26 },
27 );
28}
8 29
9export interface Decoration { 30export interface Decoration {
10 range: lc.Range; 31 range: lc.Range;