mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
Bring the implementation closer to VSCode snippet definitions
This commit is contained in:
parent
2b17da60db
commit
77cbf4adbc
9 changed files with 163 additions and 182 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
use ide_db::helpers::{insert_use::InsertUseConfig, SnippetCap};
|
||||
|
||||
use crate::snippet::{PostfixSnippet, Snippet};
|
||||
use crate::snippet::Snippet;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct CompletionConfig {
|
||||
|
@ -17,6 +17,18 @@ pub struct CompletionConfig {
|
|||
pub add_call_argument_snippets: bool,
|
||||
pub snippet_cap: Option<SnippetCap>,
|
||||
pub insert_use: InsertUseConfig,
|
||||
pub postfix_snippets: Vec<PostfixSnippet>,
|
||||
pub snippets: Vec<Snippet>,
|
||||
}
|
||||
|
||||
impl CompletionConfig {
|
||||
pub fn postfix_snippets(&self) -> impl Iterator<Item = (&str, &Snippet)> {
|
||||
self.snippets.iter().flat_map(|snip| {
|
||||
snip.postfix_triggers.iter().map(move |trigger| (trigger.as_str(), snip))
|
||||
})
|
||||
}
|
||||
pub fn prefix_snippets(&self) -> impl Iterator<Item = (&str, &Snippet)> {
|
||||
self.snippets.iter().flat_map(|snip| {
|
||||
snip.prefix_triggers.iter().map(move |trigger| (trigger.as_str(), snip))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue