10802: Allow clients to configure the global workspace search limit r=Veykril a=knutwalker

Playing around with [helix](https://helix-editor.com) I realized that the global worksapce symbol search works different compared to vs-code.
Helix requires all possible symbols in one query and does no subsequent refinement searched.
This PR adds a configuration option to override the default search limit with the default being the currently hardocded value.
Helix users can increment this limit for their instance with a config like

```toml
[[language]]
name = "rust"
language-server = { command = "rust-analyzer" }
[language.config]
workspace = { symbol = { search = { limit = 65536 }}}
```

Other editors are not affected by this change.


Co-authored-by: Paul Horn <dev@knutwalker.engineer>
This commit is contained in:
bors[bot]
2022-04-03 12:03:46 +00:00
committed by GitHub
4 changed files with 29 additions and 8 deletions

View File

@@ -354,6 +354,10 @@ config_data! {
workspace_symbol_search_scope: WorkspaceSymbolSearchScopeDef = "\"workspace\"",
/// Workspace symbol search kind.
workspace_symbol_search_kind: WorkspaceSymbolSearchKindDef = "\"only_types\"",
/// Limits the number of items returned from a workspace symbol search (Defaults to 128).
/// Some clients like vs-code issue new searches on result filtering and don't require all results to be returned in the initial search.
/// Other clients requires all results upfront and might require a higher limit.
workspace_symbol_search_limit: usize = "128",
}
}
@@ -487,8 +491,10 @@ pub struct RunnablesConfig {
pub struct WorkspaceSymbolConfig {
/// In what scope should the symbol be searched in.
pub search_scope: WorkspaceSymbolSearchScope,
/// What kind of symbol is being search for.
/// What kind of symbol is being searched for.
pub search_kind: WorkspaceSymbolSearchKind,
/// How many items are returned at most.
pub search_limit: usize,
}
pub struct ClientCommandsConfig {
@@ -995,6 +1001,7 @@ impl Config {
WorkspaceSymbolSearchKindDef::OnlyTypes => WorkspaceSymbolSearchKind::OnlyTypes,
WorkspaceSymbolSearchKindDef::AllSymbols => WorkspaceSymbolSearchKind::AllSymbols,
},
search_limit: self.data.workspace_symbol_search_limit,
}
}
@@ -1298,6 +1305,7 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
match ty {
"bool" => set!("type": "boolean"),
"usize" => set!("type": "integer", "minimum": 0),
"String" => set!("type": "string"),
"Vec<String>" => set! {
"type": "array",