Skip to content

Add a Language ​

Help query: "How do I add a language?" / "How do I add tree-sitter / LSP for a language?"

Language packages live under user/lang/. Prefer the shared helper in user/lang/common.rs when it fits; otherwise implement package() and syntax_language() manually.

Module layout ​

  1. Create user/lang/<id>.rs
  2. Export package() and usually syntax_language()
  3. Register in user/lang/mod.rs:
    • pub mod <id>;
    • add to packages()
    • add to syntax_languages()
  4. Optional: add a LanguageServerSpec in user/lsp.rs language_servers()
  5. Build the user package

Package naming convention from the helper: lang-{language_id}, attach command lang-{id}.attach, hook lang.{id}.attached.

Using the common helper ​

The helper builds a standard attach command, file-open hook binding, and syntax configuration. Copy a recent language module that already uses common::package / common::syntax_language and adjust (for example user/lang/powershell.rs for .ps1/.psm1/.psd1 with PowerShell Editor Services in user/lsp.rs, or user/lang/terraform.rs for a tree-sitter dialect path plus terraform-ls document language ids):

  • language id / display name
  • file extensions
  • grammar source (including dialect subpaths when the grammar repo ships more than one language)
  • capture → theme token mappings
  • optional LanguageServerSpec document language id overrides when the server expects ids that differ from file extensions (for example .tfvars → terraform-vars)

Manual package sketch ​

rust
PluginPackage::new("lang-python", true, "Python language defaults.")
    .with_commands(vec![/* lang-python.attach */])
    .with_hook_declarations(vec![/* lang.python.attached */])
    .with_hook_bindings(vec![
        PluginHookBinding::new(
            "buffer.file-open",
            "lang-python.auto-attach",
            "lang-python.attach",
            Some(".py"),
        ),
    ])

Syntax-only languages ​

Some grammars register syntax without a full PluginPackage (for example commit message highlighting). Follow existing syntax_languages()-only patterns in user/lang/ when you do not need attach hooks.

LSP server ​

In user/lsp.rs, append a server spec for your language's binary and file types, then rebuild.

Verify ​

bash
cargo build -p volt-user
cargo run -p volt -- --bootstrap-demo
cargo run -p volt

Open a file with the new extension and confirm highlighting / LSP attach.

Volt — modal editor platform · docs optimized for in-editor help search