// VSCODE-ZSH — ENGINEERING REPORT

VS Code / VSCodium support for zshrs · standalone TextMate grammar generated from the zshrs binary (137 builtins, 113 extensions, 245 special vars) · LSP via zshrs --lsp · verified with vscode-textmate

>_EXECUTIVE SUMMARY

vscode-zsh is the VS Code / VSCodium extension for zshrs — the first-ever Rust rewrite of zsh, a compiled, JIT'd, massively parallel shell. It ships a declarative language contribution (filetype, grammar, editor config), an LSP client that launches zshrs --lsp, and a TextMate grammar that is generated from the zshrs binary's own reflection tables.

Design principle: the grammar owns its own zshrs language id and source.zshrs scope — not a shellscript reskin, not a hand-picked subset. scripts/gen_grammar.sh dumps zshrs --dump-reflection (.builtins, .extensions, .special_vars, .keywords) from the live binary and emits a single source.zshrs grammar carrying the real shell surface. The zshrs world-first extensions get their own scope (support.function.extension.zshrs). Regenerate after a zshrs upgrade and it stays in sync.

137
Builtins scoped
113
Extensions (own scope)
245
Special variables
34
Control + decl keywords
1
TextMate grammar
3
Detection paths (ext + filename + shebang)
7
Tokenizer assertions
~9
Grammar size (KB)

~COMPONENTS

FileResponsibility
package.jsonExtension manifest — contributes.languages (id zshrs, zsh extensions + dotfile filenames, shebang firstLine), contributes.grammars (source.zshrs), contributes.configuration (LSP settings), and the vscode-languageclient dependency.
language-configuration.jsonLine comment #, brackets, auto-closing / surrounding pairs, word pattern, and brace-based indentationRules.
extension.jsActivates on onLanguage:zshrs and starts a LanguageClient running zshrs --lsp over stdio. Missing binary → one non-fatal warning; highlighting still works.
syntaxes/zshrs.tmLanguage.jsonGenerated TextMate grammar — comments, shebang, strings / here-docs, numbers, sigil variables, command substitution, control + declaration keywords, 137 builtins, 113 extensions, 245 special vars, and operators / pipes / redirects.
scripts/gen_grammar.shRegenerates the grammar from zshrs --dump-reflection. Builtins exclude keyword and extension names; names are emitted longest-first so the alternation never matches a prefix of a longer name.
scripts/tokenize_test.jsLoads the grammar under vscode-textmate + vscode-oniguruma (the engine VS Code itself uses) and asserts the scope of 7 sample tokens.

$SCOPE MAP

Token groupTextMate scopeSample
Control flowkeyword.control.zshrsif then fi for while case esac function return
Declarationsstorage.modifier.zshrstypeset local export declare readonly integer float
Builtins (137)support.function.builtin.zshrsbindkey autoload zstyle compadd setopt zle alias
Extensions (113)support.function.extension.zshrsbase64 async await barrier clone arch
Special variables (245)variable.language.zshrsPATH HOME PWD RANDOM
Sigil variablesvariable.other.zshrs$foo ${bar} $1 $? $@ $# $$
Operators / pipes / redirectskeyword.operator.zshrs| || && ;; > >> << >& =~
Literals & varsstring.* / constant.numeric / variable.*strings, here-docs, command substitution, sigils, numbers

#VERIFICATION

The generated grammar is loaded under the exact engine VS Code uses at runtime — vscode-textmate driving vscode-oniguruma — and a sample is tokenized with the resulting scopes asserted. This proves the builtin / extension / special-var alternations compile under oniguruma and classify tokens correctly, with extensions matched ahead of plain builtins so a name such as base64 resolves to support.function.extension.zshrs.

Sample tokenAsserted scope
typesetstorage.modifier.zshrs
forkeyword.control.zshrs
bindkeysupport.function.builtin.zshrs
base64 (extension)support.function.extension.zshrs
"^R" (double string)string.quoted.double.zshrs
$out (interpolated var)variable.other.interpolated.zshrs