aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/package.json11
-rw-r--r--editors/code/src/extension.ts16
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';
2import * as vscode from 'vscode'; 2import * as vscode from 'vscode';
3import * as lc from 'vscode-languageclient' 3import * as lc from 'vscode-languageclient'
4import { DH_UNABLE_TO_CHECK_GENERATOR } from 'constants';
5
6 4
7let client: lc.LanguageClient; 5let 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
11let highlightingOn = true;
13 12
14export function activate(context: vscode.ExtensionContext) { 13export 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
233function setHighlights( 237function 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