From 32048464ee3e3fe8c23ea4183f2fedc09a20b2b3 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Thu, 5 Sep 2019 09:26:03 +0000 Subject: [PATCH] [clangd][vscode] Add a flag to enable semantic highlighting in clangd Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67096 llvm-svn: 371038 --- .../clangd/clients/clangd-vscode/package.json | 5 +++++ .../clangd/clients/clangd-vscode/src/extension.ts | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/clangd/clients/clangd-vscode/package.json b/clang-tools-extra/clangd/clients/clangd-vscode/package.json index 52e59141b9f7..c2ef3f853e25 100644 --- 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 index 4cd7b0e51e02..330cf7ac262e 100644 --- a/clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts +++ b/clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts @@ -109,12 +109,14 @@ export function activate(context: vscode.ExtensionContext) { const clangdClient = new ClangdLanguageClient('Clang Language Server', serverOptions, clientOptions); - const semanticHighlightingFeature = + if (getConfig('semanticHighlighting')) { + const semanticHighlightingFeature = new semanticHighlighting.SemanticHighlightingFeature(clangdClient, - context); - context.subscriptions.push( + context); + context.subscriptions.push( vscode.Disposable.from(semanticHighlightingFeature)); - clangdClient.registerFeature(semanticHighlightingFeature); + clangdClient.registerFeature(semanticHighlightingFeature); + } console.log('Clang Language Server is now active!'); context.subscriptions.push(clangdClient.start()); context.subscriptions.push(vscode.commands.registerCommand(