diff options
Diffstat (limited to 'editors/code/src/highlighting.ts')
-rw-r--r-- | editors/code/src/highlighting.ts | 22 |
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 @@ | |||
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 | |||
4 | import * as scopes from './scopes'; | 5 | import * as scopes from './scopes'; |
5 | import * as scopesMapper from './scopes_mapper'; | 6 | import * as scopesMapper from './scopes_mapper'; |
6 | 7 | ||
7 | import { Server } from './server'; | 8 | import { Server } from './server'; |
9 | import { Ctx } from './ctx'; | ||
10 | |||
11 | export 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 | ||
9 | export interface Decoration { | 29 | export interface Decoration { |
10 | range: lc.Range; | 30 | range: lc.Range; |