diff options
author | Aleksey Kladov <[email protected]> | 2021-05-19 11:28:58 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-05-19 11:28:58 +0100 |
commit | 1fd31f7f4cf6c65a407cb36b16a86c814c5783c3 (patch) | |
tree | 2e98d1f0bdfc4d06f7381de7f87b025cab311d52 | |
parent | 49a5d6a8d4a5da296ead4c44ac43090b9b0e8034 (diff) |
feat: allow clients to feature detect symbol filtering
-rw-r--r-- | crates/rust-analyzer/src/caps.rs | 1 | ||||
-rw-r--r-- | 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 | |||
122 | "runnables": { | 122 | "runnables": { |
123 | "kinds": [ "cargo" ], | 123 | "kinds": [ "cargo" ], |
124 | }, | 124 | }, |
125 | "workspaceSymbolScopeKindFiltering": true, | ||
125 | })), | 126 | })), |
126 | } | 127 | } |
127 | } | 128 | } |
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 { | |||
651 | } | 651 | } |
652 | ``` | 652 | ``` |
653 | 653 | ||
654 | ## Lookup workspace symbol search scope and kind | 654 | ## Workspace Symbols Filtering |
655 | 655 | ||
656 | **Issue:** https://github.com/rust-analyzer/rust-analyzer/pull/7698 | 656 | **Issue:** https://github.com/rust-analyzer/rust-analyzer/pull/7698 |
657 | 657 | ||
658 | This request is sent from client to server to search for workspace symbols filtered by an | 658 | **Experimental Server Capability:** `{ "workspaceSymbolScopeKindFiltering": boolean }` |
659 | optional search scope and / or an optional symbol kind. | ||
660 | 659 | ||
661 | **Method:** `workspace/symbol` | 660 | Extends the existing `workspace/symbol` request with ability to filter symbols by broad scope and kind of symbol. |
661 | If this capability is set, `workspace/symbol` parameter gains two new optional fields: | ||
662 | 662 | ||
663 | **Request:** `WorkspaceSymbolParams` | ||
664 | |||
665 | **Response:** `SymbolInformation[] | null` | ||
666 | 663 | ||
667 | ```typescript | 664 | ```typescript |
668 | interface lsp_ext.WorkspaceSymbolParams extends WorkspaceSymbolParams { | 665 | interface WorkspaceSymbolParams { |
666 | /** | ||
667 | * Return only the symbols defined in the specified scope. | ||
668 | */ | ||
669 | searchScope?: WorkspaceSymbolSearchScope; | 669 | searchScope?: WorkspaceSymbolSearchScope; |
670 | /** | ||
671 | * Return only the symbols of specified kinds. | ||
672 | */ | ||
670 | searchKind?: WorkspaceSymbolSearchKind; | 673 | searchKind?: WorkspaceSymbolSearchKind; |
674 | ... | ||
671 | } | 675 | } |
672 | 676 | ||
673 | const enum WorkspaceSymbolSearchScope { | 677 | const enum WorkspaceSymbolSearchScope { |
674 | Workspace = "Workspace", | 678 | Workspace = "workspace", |
675 | WorkspaceAndDependencies = "WorkspaceAndDependencies" | 679 | WorkspaceAndDependencies = "workspaceAndDependencies" |
676 | } | 680 | } |
677 | 681 | ||
678 | const enum WorkspaceSymbolSearchKind { | 682 | const enum WorkspaceSymbolSearchKind { |
679 | OnlyTypes = "OnlyTypes", | 683 | OnlyTypes = "onlyTypes", |
680 | AllSymbols = "AllSymbols" | 684 | AllSymbols = "allSymbols" |
681 | } | 685 | } |
682 | ``` | 686 | ``` |