mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 05:38:46 +00:00
Add a setting to disable custom syntax highlighting
This commit is contained in:
parent
baaf027da0
commit
26108dde1c
2 changed files with 23 additions and 4 deletions
|
@ -109,6 +109,17 @@
|
||||||
"when": "editorTextFocus && editorLangId == rust"
|
"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": [
|
"problemMatchers": [
|
||||||
{
|
{
|
||||||
"name": "rustc",
|
"name": "rustc",
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as lc from 'vscode-languageclient'
|
import * as lc from 'vscode-languageclient'
|
||||||
import { DH_UNABLE_TO_CHECK_GENERATOR } from 'constants';
|
|
||||||
|
|
||||||
|
|
||||||
let client: lc.LanguageClient;
|
let client: lc.LanguageClient;
|
||||||
|
|
||||||
|
@ -10,8 +8,14 @@ let uris = {
|
||||||
syntaxTree: vscode.Uri.parse('ra-lsp://syntaxtree')
|
syntaxTree: vscode.Uri.parse('ra-lsp://syntaxtree')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let highlightingOn = true;
|
||||||
|
|
||||||
export function activate(context: vscode.ExtensionContext) {
|
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 textDocumentContentProvider = new TextDocumentContentProvider()
|
||||||
let dispose = (disposable: vscode.Disposable) => {
|
let dispose = (disposable: vscode.Disposable) => {
|
||||||
context.subscriptions.push(disposable);
|
context.subscriptions.push(disposable);
|
||||||
|
@ -232,14 +236,18 @@ const decorations: { [index: string]: vscode.TextEditorDecorationType } = (() =>
|
||||||
|
|
||||||
function setHighlights(
|
function setHighlights(
|
||||||
editor: vscode.TextEditor,
|
editor: vscode.TextEditor,
|
||||||
highlihgs: Array<Decoration>
|
highlights: Array<Decoration>
|
||||||
) {
|
) {
|
||||||
|
if (!highlightingOn) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let byTag: Map<string, vscode.Range[]> = new Map()
|
let byTag: Map<string, vscode.Range[]> = new Map()
|
||||||
for (let tag in decorations) {
|
for (let tag in decorations) {
|
||||||
byTag.set(tag, [])
|
byTag.set(tag, [])
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let d of highlihgs) {
|
for (let d of highlights) {
|
||||||
if (!byTag.get(d.tag)) {
|
if (!byTag.get(d.tag)) {
|
||||||
console.log(`unknown tag ${d.tag}`)
|
console.log(`unknown tag ${d.tag}`)
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue