mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 15:54:15 +00:00
Add a setting to disable custom syntax highlighting
This commit is contained in:
parent
baaf027da0
commit
26108dde1c
@ -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",
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user