pub enum SnippetToken {
Literal(String),
Tabstop(u32),
Placeholder {
idx: u32,
default: SnippetBody,
},
Choice {
idx: u32,
options: Vec<ChoiceOption>,
},
Variable {
name: String,
default: Option<SnippetBody>,
},
Transform {
target: TransformTarget,
pattern: String,
replacement: String,
flags: String,
},
}Expand description
One token from a parsed snippet body.
Variants§
Literal(String)
Plain text that lands in the rendered output verbatim. Adjacent literal tokens are merged by the parser so a rendered body never has two literals in a row.
Tabstop(u32)
$N – bare tabstop. $0 is the final cursor position
(exited automatically); $1..$N are visited in order.
Placeholder
${N:default} – tabstop with default text. The default
can itself contain nested tokens (e.g. ${1:foo${2:bar}})
so users can place inner placeholders inside.
Choice
${N|opt1,opt2,opt3|} – pick from a fixed list. The
host’s choice-picker UI surfaces these on focus.
Variable
$NAME / ${NAME} / ${NAME:fallback} – variable
substitution. default runs only when the variable
resolves to None.
Transform
${N/pat/repl/flags} / ${NAME/pat/repl/flags} –
regex transformation on the bound text. v1 parses but
renders as the bound text un-transformed; full regex
support lands as polish (transformations are rare in
practice, and supporting the full regex format syntax
is its own feature).
Trait Implementations§
Source§impl Clone for SnippetToken
impl Clone for SnippetToken
Source§fn clone(&self) -> SnippetToken
fn clone(&self) -> SnippetToken
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more