From 26108dde1caf958acd693ae5d43f7d1ad8db7f0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20Ochagav=C3=ADa?= Date: Sat, 29 Sep 2018 21:27:41 +0200 Subject: Add a setting to disable custom syntax highlighting --- editors/code/package.json | 11 +++++++++++ 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 @@ "when": "editorTextFocus && editorLangId == rust" } ], + "configuration": { + "type": "object", + "title": "Rust Analyzer configuration", + "properties": { + "ra-lsp.highlightingOn": { + "type": "boolean", + "default": true, + "description": "Highlight Rust code (overrides built-in syntax highlighting)" + } + } + }, "problemMatchers": [ { "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 @@ 'use strict'; import * as vscode from 'vscode'; import * as lc from 'vscode-languageclient' -import { DH_UNABLE_TO_CHECK_GENERATOR } from 'constants'; - let client: lc.LanguageClient; @@ -10,8 +8,14 @@ let uris = { syntaxTree: vscode.Uri.parse('ra-lsp://syntaxtree') } +let highlightingOn = true; export function activate(context: vscode.ExtensionContext) { + let config = vscode.workspace.getConfiguration('ra-lsp'); + if (config.has('highlightingOn')) { + highlightingOn = config.get('highlightingOn') as boolean; + } + let textDocumentContentProvider = new TextDocumentContentProvider() let dispose = (disposable: vscode.Disposable) => { context.subscriptions.push(disposable); @@ -232,14 +236,18 @@ const decorations: { [index: string]: vscode.TextEditorDecorationType } = (() => function setHighlights( editor: vscode.TextEditor, - highlihgs: Array + highlights: Array ) { + if (!highlightingOn) { + return; + } + let byTag: Map = new Map() for (let tag in decorations) { byTag.set(tag, []) } - for (let d of highlihgs) { + for (let d of highlights) { if (!byTag.get(d.tag)) { console.log(`unknown tag ${d.tag}`) continue -- cgit v1.2.3