Bring the implementation closer to VSCode snippet definitions
This commit is contained in:
@@ -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))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user