aboutsummaryrefslogtreecommitdiff
path: root/clangd/clients
diff options
context:
space:
mode:
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>2017-10-02 18:00:37 +0000
committerMarc-Andre Laperle <marc-andre.laperle@ericsson.com>2017-10-02 18:00:37 +0000
commit50cb6c2787b0bb81b05452559b7838e9fb790549 (patch)
tree19ad2721ce8ea58ee169310425a4fdebf50aaa87 /clangd/clients
parent6a357e39faeb520bfc94160140ce77bbc90fe3ad (diff)
downloadclang-tools-extra-50cb6c2787b0bb81b05452559b7838e9fb790549.tar.gz
[clangd] Handle workspace/didChangeWatchedFiles
Summary: The client can send notifications when it detects watched files have changed. This patch adds the protocol handling for this type of notification. For now, the notification will be passed down to the ClangdServer, but it will not be acted upon. However, this will become useful for the indexer to react to file changes. The events could also potentially be used to invalidate other caches (compilation database, etc). This change also updates the VSCode extension so that it sends the events. Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Reviewers: ilya-biryukov, Nebiroth Subscribers: ilya-biryukov Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D38422 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@314693 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clangd/clients')
-rw-r--r--clangd/clients/clangd-vscode/package.json5
-rw-r--r--clangd/clients/clangd-vscode/src/extension.ts8
2 files changed, 12 insertions, 1 deletions
diff --git a/clangd/clients/clangd-vscode/package.json b/clangd/clients/clangd-vscode/package.json
index 729297af..c048d965 100644
--- a/clangd/clients/clangd-vscode/package.json
+++ b/clangd/clients/clangd-vscode/package.json
@@ -51,6 +51,11 @@
"type": "string"
},
"description": "Arguments for clangd server"
+ },
+ "clangd.syncFileEvents": {
+ "type": "boolean",
+ "default": true,
+ "description": "Whether or not to send file events to clangd (File created, changed or deleted). This can be disabled for performance consideration."
}
}
}
diff --git a/clangd/clients/clangd-vscode/src/extension.ts b/clangd/clients/clangd-vscode/src/extension.ts
index c76e0a02..f89ddc97 100644
--- a/clangd/clients/clangd-vscode/src/extension.ts
+++ b/clangd/clients/clangd-vscode/src/extension.ts
@@ -18,18 +18,24 @@ function getConfig<T>(option: string, defaultValue?: any) : T {
export function activate(context: vscode.ExtensionContext) {
const clangdPath = getConfig<string>('path');
const clangdArgs = getConfig<string[]>('arguments');
+ const syncFileEvents = getConfig<boolean>('syncFileEvents', true);
const serverOptions: vscodelc.ServerOptions = { command: clangdPath, args: clangdArgs };
+ const cppFileExtensions: string[] = ['cpp', 'c', 'cc', 'cxx', 'c++', 'm', 'mm', 'h', 'hh', 'hpp', 'hxx', 'inc'];
+ const cppFileExtensionsPattern = cppFileExtensions.join();
const clientOptions: vscodelc.LanguageClientOptions = {
// Register the server for C/C++ files
- documentSelector: ['c', 'cc', 'cpp', 'h', 'hh', 'hpp'],
+ documentSelector: cppFileExtensions,
uriConverters: {
// FIXME: by default the URI sent over the protocol will be percent encoded (see rfc3986#section-2.1)
// the "workaround" below disables temporarily the encoding until decoding
// is implemented properly in clangd
code2Protocol: (uri: vscode.Uri) : string => uri.toString(true),
protocol2Code: (uri: string) : vscode.Uri => vscode.Uri.parse(uri)
+ },
+ synchronize: !syncFileEvents ? undefined : {
+ fileEvents: vscode.workspace.createFileSystemWatcher('**/*.{' + cppFileExtensionsPattern + '}')
}
};