Skip to main content

Module snippets

Module snippets 

Source
Expand description

Snippet parsing + placeholder navigation primitives.

This module implements a pragmatic subset of TextMate / VS Code snippet syntax that is sufficient for kernel features like:

  • LSP completion items with insertTextFormat == 2 (snippets)
  • placeholder ($1, ${1:default}) navigation (tab / shift-tab)
  • best-effort handling of choices (${1|a,b,c|}) and variables (${TM_FILENAME:foo.rs})

Goals:

  • Keep the kernel UI-agnostic: no rendering, no popup UI for choices.
  • Prefer “do something reasonable” over rejecting malformed snippet text.
  • Express all ranges in character offsets (Rust char indices), consistent with the rest of editor-core.

Structs§

SnippetRange
A half-open character range (start..end) within a snippet’s expanded text.
SnippetSession
An active snippet session tracked in document coordinates.
SnippetTabstop
A numbered tabstop within a snippet.
SnippetTemplate
An expanded snippet template.

Functions§

parse_snippet
Parse a TextMate/VS Code-style snippet string into an expanded template.