mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
YAGNI active_resolve_capabilities
This leaks a lot of LSP details into ide layer, which we want to avoid:
c9cec381bc/docs/dev (lsp-independence)
Additionally, all what this infra does is providing a toggle for
auto-import completion, but we already have one!
This commit is contained in:
parent
edf03548e3
commit
6e87828756
7 changed files with 32 additions and 78 deletions
|
@ -5,7 +5,6 @@
|
|||
//! completions if we are allowed to.
|
||||
|
||||
use ide_db::helpers::insert_use::MergeBehavior;
|
||||
use rustc_hash::FxHashSet;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct CompletionConfig {
|
||||
|
@ -15,32 +14,12 @@ pub struct CompletionConfig {
|
|||
pub add_call_argument_snippets: bool,
|
||||
pub snippet_cap: Option<SnippetCap>,
|
||||
pub merge: Option<MergeBehavior>,
|
||||
/// A set of capabilities, enabled on the client and supported on the server.
|
||||
pub active_resolve_capabilities: FxHashSet<CompletionResolveCapability>,
|
||||
}
|
||||
|
||||
/// A resolve capability, supported on the server.
|
||||
/// If the client registers any completion resolve capabilities,
|
||||
/// the server is able to render completion items' corresponding fields later,
|
||||
/// not during an initial completion item request.
|
||||
/// See https://github.com/rust-analyzer/rust-analyzer/issues/6366 for more details.
|
||||
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)]
|
||||
pub enum CompletionResolveCapability {
|
||||
Documentation,
|
||||
Detail,
|
||||
AdditionalTextEdits,
|
||||
}
|
||||
|
||||
impl CompletionConfig {
|
||||
pub fn allow_snippets(&mut self, yes: bool) {
|
||||
self.snippet_cap = if yes { Some(SnippetCap { _private: () }) } else { None }
|
||||
}
|
||||
|
||||
/// Whether the completions' additional edits are calculated when sending an initional completions list
|
||||
/// or later, in a separate resolve request.
|
||||
pub fn resolve_additional_edits_lazily(&self) -> bool {
|
||||
self.active_resolve_capabilities.contains(&CompletionResolveCapability::AdditionalTextEdits)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
|
@ -57,7 +36,6 @@ impl Default for CompletionConfig {
|
|||
add_call_argument_snippets: true,
|
||||
snippet_cap: Some(SnippetCap { _private: () }),
|
||||
merge: Some(MergeBehavior::Full),
|
||||
active_resolve_capabilities: FxHashSet::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue