Expand description
Variable resolution for snippet expansion. The host fills
in a VariableContext with file / cursor / clipboard
info; the renderer asks the context for each $VAR it
encounters.
v1 supports the TextMate / VS Code built-in variable set:
| Variable | Resolves to |
|---|---|
TM_SELECTED_TEXT | last visual selection |
TM_CURRENT_LINE | current line text |
TM_CURRENT_WORD | word under cursor |
TM_LINE_INDEX | 0-based current line |
TM_LINE_NUMBER | 1-based current line |
TM_FILENAME | current filename (basename + ext) |
TM_FILENAME_BASE | filename without extension |
TM_DIRECTORY | containing directory absolute path |
TM_FILEPATH | absolute path to current file |
WORKSPACE_NAME | workspace folder basename |
WORKSPACE_FOLDER | workspace folder absolute path |
CLIPBOARD | current "+ register text |
CURRENT_YEAR / CURRENT_MONTH / CURRENT_DATE / CURRENT_HOUR / CURRENT_MINUTE / CURRENT_SECOND | timestamp components (zero-padded where conventional) |
CURRENT_DAY_NAME / CURRENT_DAY_NAME_SHORT / CURRENT_MONTH_NAME / CURRENT_MONTH_NAME_SHORT | named timestamp parts |
RANDOM | 6-digit random int |
RANDOM_HEX | 6-char random hex |
UUID | random UUID v4 |
LINE_COMMENT / BLOCK_COMMENT_START / BLOCK_COMMENT_END | per-major-mode comment strings (Phase 8) |
Unknown variables resolve to None (the renderer emits the
variable’s default body or the empty string).
Structs§
- Timestamp
Parts - Decomposed timestamp – supplied by the host (typically
derived from
chrono/timeif it’s already a dep) or computed at variable-resolve time. Tests usefixed_nowto pin output. - Variable
Context - Editor-supplied context the renderer consults to resolve
variable references. The host fills in the file / cursor
fields; timestamp + random / UUID values are computed at
expansion time inside
VariableContext::resolve.
Functions§
- builtin_
variables - Convenience:
VariableContextpopulated with the builtin timestamp + random sources but no editor-supplied fields. Useful for “expand this snippet outside an editor” flows (tests, examples, snippet authoring tools).