Unnamed repository; edit this file 'description' to name the repository.
lsp: Declare supported `SymbolKind`s in client capabilities
In the spec, the `symbolKind` field in `DocumentSymbolClientCapabilities`
and `WorkspaceSymbolClientCapabilities` must be set with a `valueSet`
containing all supported values. The spec does not default to all values
defined in the spec in order to preserve backwards compatibility with
older spec versions. Instead of using `None` we need to declare support
for all symbols.
In the symbol picker code we only use the `SymbolKind` type to print the
symbol name. If we get an unknown `SymbolKind` we use the empty string
and print nothing, so we satisfy the spec's requirement:
> When [symbolKind] exists the client also guarantees that it will
> handle values outside its set gracefully and falls back to a default
> value when unknown.
| -rw-r--r-- | helix-lsp-types/src/lib.rs | 6 | ||||
| -rw-r--r-- | helix-lsp/src/client.rs | 11 |
2 files changed, 17 insertions, 0 deletions
diff --git a/helix-lsp-types/src/lib.rs b/helix-lsp-types/src/lib.rs index fd668de5..a1a87e1b 100644 --- a/helix-lsp-types/src/lib.rs +++ b/helix-lsp-types/src/lib.rs @@ -1273,6 +1273,12 @@ impl SymbolKind { } } +impl SymbolKind { + pub fn all() -> Vec<Self> { + (1..=26).map(Self).collect() + } +} + /// Specific capabilities for the `SymbolKind` in the `workspace/symbol` request. #[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 205f90e3..5b3518e8 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -589,6 +589,9 @@ impl Client { apply_edit: Some(true), symbol: Some(lsp::WorkspaceSymbolClientCapabilities { dynamic_registration: Some(false), + symbol_kind: Some(lsp::SymbolKindCapability { + value_set: Some(lsp::SymbolKind::all()), + }), ..Default::default() }), execute_command: Some(lsp::DynamicRegistrationClientCapabilities { @@ -723,6 +726,14 @@ impl Client { call_hierarchy: Some(lsp::DynamicRegistrationClientCapabilities { dynamic_registration: Some(false), }), + document_symbol: Some(lsp::DocumentSymbolClientCapabilities { + dynamic_registration: Some(false), + symbol_kind: Some(lsp::SymbolKindCapability { + value_set: Some(lsp::SymbolKind::all()), + }), + hierarchical_document_symbol_support: Some(false), + ..Default::default() + }), ..Default::default() }), window: Some(lsp::WindowClientCapabilities { |