diff options
Diffstat (limited to 'editors/code/src/highlighting.ts')
-rw-r--r-- | editors/code/src/highlighting.ts | 23 |
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 @@ | |||
1 | import seedrandom = require('seedrandom'); | ||
2 | import * as vscode from 'vscode'; | 1 | import * as vscode from 'vscode'; |
3 | import * as lc from 'vscode-languageclient'; | 2 | import * as lc from 'vscode-languageclient'; |
3 | import * as seedrandom_ from 'seedrandom'; | ||
4 | const seedrandom = seedrandom_; // https://github.com/jvandemo/generator-angular2-library/issues/221#issuecomment-355945207 | ||
5 | |||
4 | import * as scopes from './scopes'; | 6 | import * as scopes from './scopes'; |
5 | import * as scopesMapper from './scopes_mapper'; | 7 | import * as scopesMapper from './scopes_mapper'; |
6 | 8 | ||
7 | import { Server } from './server'; | 9 | import { Server } from './server'; |
10 | import { Ctx } from './ctx'; | ||
11 | |||
12 | export 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 | ||
9 | export interface Decoration { | 30 | export interface Decoration { |
10 | range: lc.Range; | 31 | range: lc.Range; |