Add a setting to disable custom syntax highlighting

This commit is contained in:
Adolfo Ochagavía 2018-09-29 21:27:41 +02:00
parent baaf027da0
commit 26108dde1c
2 changed files with 23 additions and 4 deletions

View File

@ -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",

View File

@ -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<Decoration>
highlights: Array<Decoration>
) {
if (!highlightingOn) {
return;
}
let byTag: Map<string, vscode.Range[]> = 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