From 1fd31f7f4cf6c65a407cb36b16a86c814c5783c3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 19 May 2021 13:28:58 +0300 Subject: feat: allow clients to feature detect symbol filtering --- crates/rust-analyzer/src/caps.rs | 1 + docs/dev/lsp-extensions.md | 28 ++++++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/crates/rust-analyzer/src/caps.rs b/crates/rust-analyzer/src/caps.rs index 3c87782f2..b2317618a 100644 --- a/crates/rust-analyzer/src/caps.rs +++ b/crates/rust-analyzer/src/caps.rs @@ -122,6 +122,7 @@ pub fn server_capabilities(client_caps: &ClientCapabilities) -> ServerCapabiliti "runnables": { "kinds": [ "cargo" ], }, + "workspaceSymbolScopeKindFiltering": true, })), } } diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index 2d3787d0f..3c4eacfeb 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md @@ -651,32 +651,36 @@ export const enum Direction { } ``` -## Lookup workspace symbol search scope and kind +## Workspace Symbols Filtering **Issue:** https://github.com/rust-analyzer/rust-analyzer/pull/7698 -This request is sent from client to server to search for workspace symbols filtered by an -optional search scope and / or an optional symbol kind. +**Experimental Server Capability:** `{ "workspaceSymbolScopeKindFiltering": boolean }` -**Method:** `workspace/symbol` +Extends the existing `workspace/symbol` request with ability to filter symbols by broad scope and kind of symbol. +If this capability is set, `workspace/symbol` parameter gains two new optional fields: -**Request:** `WorkspaceSymbolParams` - -**Response:** `SymbolInformation[] | null` ```typescript -interface lsp_ext.WorkspaceSymbolParams extends WorkspaceSymbolParams { +interface WorkspaceSymbolParams { + /** + * Return only the symbols defined in the specified scope. + */ searchScope?: WorkspaceSymbolSearchScope; + /** + * Return only the symbols of specified kinds. + */ searchKind?: WorkspaceSymbolSearchKind; + ... } const enum WorkspaceSymbolSearchScope { - Workspace = "Workspace", - WorkspaceAndDependencies = "WorkspaceAndDependencies" + Workspace = "workspace", + WorkspaceAndDependencies = "workspaceAndDependencies" } const enum WorkspaceSymbolSearchKind { - OnlyTypes = "OnlyTypes", - AllSymbols = "AllSymbols" + OnlyTypes = "onlyTypes", + AllSymbols = "allSymbols" } ``` -- cgit v1.2.3