diff options
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/package.json | 11 | ||||
-rw-r--r-- | editors/code/src/extension.ts | 16 |
2 files changed, 23 insertions, 4 deletions
diff --git a/editors/code/package.json b/editors/code/package.json index 0cfba5db6..305d6eaf1 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -109,6 +109,17 @@ | |||
109 | "when": "editorTextFocus && editorLangId == rust" | 109 | "when": "editorTextFocus && editorLangId == rust" |
110 | } | 110 | } |
111 | ], | 111 | ], |
112 | "configuration": { | ||
113 | "type": "object", | ||
114 | "title": "Rust Analyzer configuration", | ||
115 | "properties": { | ||
116 | "ra-lsp.highlightingOn": { | ||
117 | "type": "boolean", | ||
118 | "default": true, | ||
119 | "description": "Highlight Rust code (overrides built-in syntax highlighting)" | ||
120 | } | ||
121 | } | ||
122 | }, | ||
112 | "problemMatchers": [ | 123 | "problemMatchers": [ |
113 | { | 124 | { |
114 | "name": "rustc", | 125 | "name": "rustc", |
diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index c464ab5b2..dc1792e94 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts | |||
@@ -1,8 +1,6 @@ | |||
1 | 'use strict'; | 1 | 'use strict'; |
2 | import * as vscode from 'vscode'; | 2 | import * as vscode from 'vscode'; |
3 | import * as lc from 'vscode-languageclient' | 3 | import * as lc from 'vscode-languageclient' |
4 | import { DH_UNABLE_TO_CHECK_GENERATOR } from 'constants'; | ||
5 | |||
6 | 4 | ||
7 | let client: lc.LanguageClient; | 5 | let client: lc.LanguageClient; |
8 | 6 | ||
@@ -10,8 +8,14 @@ let uris = { | |||
10 | syntaxTree: vscode.Uri.parse('ra-lsp://syntaxtree') | 8 | syntaxTree: vscode.Uri.parse('ra-lsp://syntaxtree') |
11 | } | 9 | } |
12 | 10 | ||
11 | let highlightingOn = true; | ||
13 | 12 | ||
14 | export function activate(context: vscode.ExtensionContext) { | 13 | export function activate(context: vscode.ExtensionContext) { |
14 | let config = vscode.workspace.getConfiguration('ra-lsp'); | ||
15 | if (config.has('highlightingOn')) { | ||
16 | highlightingOn = config.get('highlightingOn') as boolean; | ||
17 | } | ||
18 | |||
15 | let textDocumentContentProvider = new TextDocumentContentProvider() | 19 | let textDocumentContentProvider = new TextDocumentContentProvider() |
16 | let dispose = (disposable: vscode.Disposable) => { | 20 | let dispose = (disposable: vscode.Disposable) => { |
17 | context.subscriptions.push(disposable); | 21 | context.subscriptions.push(disposable); |
@@ -232,14 +236,18 @@ const decorations: { [index: string]: vscode.TextEditorDecorationType } = (() => | |||
232 | 236 | ||
233 | function setHighlights( | 237 | function setHighlights( |
234 | editor: vscode.TextEditor, | 238 | editor: vscode.TextEditor, |
235 | highlihgs: Array<Decoration> | 239 | highlights: Array<Decoration> |
236 | ) { | 240 | ) { |
241 | if (!highlightingOn) { | ||
242 | return; | ||
243 | } | ||
244 | |||
237 | let byTag: Map<string, vscode.Range[]> = new Map() | 245 | let byTag: Map<string, vscode.Range[]> = new Map() |
238 | for (let tag in decorations) { | 246 | for (let tag in decorations) { |
239 | byTag.set(tag, []) | 247 | byTag.set(tag, []) |
240 | } | 248 | } |
241 | 249 | ||
242 | for (let d of highlihgs) { | 250 | for (let d of highlights) { |
243 | if (!byTag.get(d.tag)) { | 251 | if (!byTag.get(d.tag)) { |
244 | console.log(`unknown tag ${d.tag}`) | 252 | console.log(`unknown tag ${d.tag}`) |
245 | continue | 253 | continue |