diff --git a/clang-tools-extra/clangd/clients/clangd-vscode/package.json b/clang-tools-extra/clangd/clients/clangd-vscode/package.json --- a/clang-tools-extra/clangd/clients/clangd-vscode/package.json +++ b/clang-tools-extra/clangd/clients/clangd-vscode/package.json @@ -89,6 +89,11 @@ "clangd.trace": { "type": "string", "description": "Names a file that clangd should log a performance trace to, in chrome trace-viewer JSON format." + }, + "clangd.semanticHighlighting": { + "type": "boolean", + "default": "false", + "description": "Enable semantic highlighting in clangd" } } }, diff --git a/clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts b/clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts --- a/clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts +++ b/clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts @@ -110,7 +110,8 @@ const clangdClient = new ClangdLanguageClient('Clang Language Server', serverOptions, clientOptions); const semanticHighlightingFeature = - new semanticHighlighting.SemanticHighlightingFeature(); + new semanticHighlighting.SemanticHighlightingFeature( + getConfig('semanticHighlighting')); context.subscriptions.push( vscode.Disposable.from(semanticHighlightingFeature)); clangdClient.registerFeature(semanticHighlightingFeature); diff --git a/clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts b/clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts --- a/clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts +++ b/clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts @@ -58,6 +58,10 @@ highlighter: Highlighter; // Any disposables that should be cleaned up when clangd crashes. private subscriptions: vscode.Disposable[] = []; + // Whether the semantic highlighting feature is enabled in the extension. + private enable: boolean; + + constructor(enable: boolean) { this.enable = enable; } fillClientCapabilities(capabilities: vscodelc.ClientCapabilities) { // Extend the ClientCapabilities type and add semantic highlighting // capability to the object. @@ -65,7 +69,7 @@ {semanticHighlightingCapabilities?: {semanticHighlighting : boolean}} = capabilities.textDocument; textDocumentCapabilities.semanticHighlightingCapabilities = { - semanticHighlighting : true, + semanticHighlighting : this.enable, }; }