From fd65cf518b6b0a5e9ab8f55c92e72c6faf91140c Mon Sep 17 00:00:00 2001 From: Jesse Sivonen Date: Wed, 31 Jul 2019 01:18:24 +0300 Subject: [PATCH] feat: exclude files from index according to files.exclude Passing exclude patterns requires support from the language server. --- src/extension.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/extension.ts b/src/extension.ts index b683da5..5c100b6 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -63,6 +63,19 @@ export async function activate(context: vscode.ExtensionContext): Promise return } + // Get excludes from workspace configuration: files.exclude + const exclude: string[] = []; + const filesConfig = vscode.workspace.getConfiguration('files'); + const _exclude = filesConfig.get<{[key: string]: boolean}>('exclude', {}); + for (const key in _exclude) { + if (_exclude.hasOwnProperty(key) && _exclude[key]) { + // Push the exclude pattern to the array. Note that we want to + // match the files under the excluded directory not the + // directory itself. + exclude.push(key + '/**'); + } + } + let client: LanguageClient const serverOptions = () => @@ -123,6 +136,9 @@ export async function activate(context: vscode.ExtensionContext): Promise // Notify the server about changes to PHP files in the workspace fileEvents: vscode.workspace.createFileSystemWatcher('**/*.php'), }, + initializationOptions: { + exclude, + }, } // Create the language client and start the client.