Full-featured Chezmoi support for VS Code: source-attribute language detection, Go template syntax highlighting, live variable IntelliSense & hover, template linting, rendered preview, diff, apply-on-save, and SCM integration.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Automatic Language Detection: Resolves chezmoi source attributes (dot_, private_, executable_, run_once_, .tmpl, etc.) and sets the underlying VS Code language (e.g., dot_zshrc.tmpl → Shell Script, private_Library/.../foo.plist → XML) while keeping native language support.
Go Template Syntax Highlighting (Injection Grammar): Highlights {{ ... }} actions, comments ({{/* ... */}}), variables, keywords, and chezmoi/Sprig functions inside any base language.
Variable IntelliSense & Hover Values: Autocompletes .chezmoi.* and custom data variables from chezmoi data --format json and shows their actual resolved values on hover.
Template Function Autocomplete & Docs: Built-in documentation and snippets for Go text/template, Sprig, and chezmoi template functions.
Real-Time Template Diagnostics: Validates .tmpl files via chezmoi execute-template and highlights syntax/execution errors inline.
Live Rendered Preview: Open a side-by-side rendered preview of any .tmpl file that updates as you edit.
Diff, Apply & Optional Apply-on-Save: Diff current file against $HOME, apply a single file or all dotfiles, or enable chezmoi.applyOnSave.
Source Control (SCM) View: Displays pending changes from chezmoi status in VS Code's Source Control sidebar with side-by-side diffs and one-click apply.
Requirements
chezmoi installed and available on your PATH (or configured via chezmoi.executablePath).
Settings
chezmoi.executablePath — Path to the chezmoi binary (default: "chezmoi").
chezmoi.autoDetectLanguage — Auto-detect target language from chezmoi source attributes (default: true).
chezmoi.enableDiagnostics — Validate .tmpl files in real time with chezmoi execute-template (default: true).
chezmoi.diagnosticsDebounceMs — Debounce delay before validating while typing (default: 500).
chezmoi.applyOnSave — Automatically run chezmoi apply for the current file on save (default: false).
chezmoi.enableScm — Show pending chezmoi changes in the Source Control panel (default: true).
chezmoi.customLanguageMap — Custom target filename/extension to VS Code language ID mappings.