aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/highlighting.ts
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-12-30 19:29:21 +0000
committerAleksey Kladov <[email protected]>2019-12-30 20:32:04 +0000
commit7646dc046eb562276231de8ec6a4df1bc691cafc (patch)
tree3820a5c89a7b6317373fca4d68cab01912cc24f6 /editors/code/src/highlighting.ts
parent17dda0972a68dd88a766c223390317dc2cb3ea00 (diff)
Encapsulate highlighting activation
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;