> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vorto-editor.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Install and manage tree-sitter grammars in Vorto

> Install and manage tree-sitter grammars in Vorto from the CLI or the in-editor :grammar command, add custom [grammars.<name>] recipes for languages outside the built-in catalog, and manage query files.

Vorto uses [tree-sitter](https://tree-sitter.github.io) for syntax highlighting. Prebuilt binaries — the ones [mise](https://mise.jdx.dev), [Homebrew](https://brew.sh), and the [releases page](https://github.com/vorto-editor/vorto/releases) provide — ship with every built-in grammar already embedded, so highlighting works out of the box (see [below](#grammars-bundled-in-prebuilt-binaries)). If you installed with `cargo install` or built from source, no grammars are bundled: you install only the languages you need — from the command line with the `vorto grammar` subcommand, or from inside the editor with the [`:grammar` command](#installing-grammars-from-the-editor). Each grammar is fetched from its upstream Git repository and compiled into a shared library that Vorto loads at startup. The same commands also let you add languages beyond the built-in catalog, or refresh an embedded grammar's files, regardless of how you installed Vorto.

## Grammars bundled in prebuilt binaries

Release binaries are built with grammars for all [44 built-in languages](/languages/supported-languages) embedded. On first launch, Vorto extracts them into `~/.config/vorto/grammars/` and `~/.config/vorto/queries/` — no `vorto grammar install`, no network request, and no C compiler. From there they behave exactly like grammars you installed yourself: you can list, refresh, or remove them with the commands below.

A few details worth knowing:

* **Upgrades refresh them.** When you run a newer Vorto, it re-extracts the bundled set so updated grammar libraries and queries replace the old ones. It's a no-op once everything is already current.
* **Your overrides win.** If you've repointed a language with a `[grammars.<name>]` config entry, Vorto never overwrites it with the bundled copy — your recipe stays authoritative for that name.
* **`cargo` and source builds don't bundle.** The crates.io binary and a plain `cargo build` ship without embedded grammars, so on those you install grammars on demand as described below. (A source build *can* embed them — see [Install from source](/installation#install-from-source).)

## Where grammars are stored

Vorto reads its configuration from `$XDG_CONFIG_HOME/vorto/` (typically `~/.config/vorto/`). Installed grammars land in two subdirectories:

| Path                              | Contents                                               |
| --------------------------------- | ------------------------------------------------------ |
| `~/.config/vorto/grammars/`       | Compiled shared libraries (`.so`, `.dylib`, or `.dll`) |
| `~/.config/vorto/queries/<lang>/` | Query files (`highlights.scm`, `indents.scm`, etc.)    |

Both paths are printed at the top of `vorto grammar list` output so you always know where to look.

## Grammar commands

### List available grammars

```bash theme={null}
vorto grammar list
```

Prints every recipe grouped by install status, so you can see at a glance what's installed, what has a library but is missing queries, and what isn't installed yet. Custom recipes you've defined under `[grammars.*]` appear in their own **custom (from config)** section. For a detailed per-language breakdown — whether the compiled library is present and which query files are installed or only bundled (vendored inside the Vorto binary but not yet written to disk) — pass `-v`:

```bash theme={null}
vorto grammar list -v
```

### Install grammars

Build and install one or more grammars by name, or install all built-in grammars at once:

```bash theme={null}
# Install specific grammars
vorto grammar install rust python

# Install all built-in grammars
vorto grammar install --all
```

Vorto fetches the grammar source, compiles it in-process, and places the resulting library in `~/.config/vorto/grammars/`. It also writes the vendored query files to `~/.config/vorto/queries/<lang>/`. Grammars that are already fully installed are skipped automatically.

Multiple grammars are built in parallel, capped at your CPU count, so `--all` completes faster on multi-core machines.

<Note>
  Compilation happens in-process, so a C compiler (`clang` or `gcc`) needs to be on your `PATH` — if you installed Vorto with `cargo` or from source, you already have one. Should an install fail, see [Installing a C compiler](/troubleshooting#installing-a-c-compiler). (`git` fetches sources when no release tarball is published, and the `tree-sitter` CLI is only used as a fallback for the rare grammar that ships no pre-generated `parser.c`.)
</Note>

<Note>
  `install` also accepts the alias `add`: `vorto grammar add rust`.
</Note>

### Refresh query files only

```bash theme={null}
# Refresh queries for specific grammars
vorto grammar install-queries python

# Refresh queries for all built-in grammars
vorto grammar install-queries --all
```

This command overwrites the `.scm` files in `~/.config/vorto/queries/<lang>/` from Vorto's vendored bundle without rebuilding the compiled library. Use it when you want to pick up updated query files after upgrading Vorto, without the time cost of a full grammar recompile.

<Tip>
  `install-queries` also accepts the alias `refresh-queries`.
</Tip>

### Remove a grammar

```bash theme={null}
vorto grammar remove rust
```

Deletes the installed shared library for the named grammar from `~/.config/vorto/grammars/`. The command accepts multiple names and reports whether each grammar was installed or not. Query files under `~/.config/vorto/queries/<lang>/` are not removed; delete them manually if needed.

<Note>
  `remove` also accepts the aliases `rm` and `uninstall`.
</Note>

## Installing grammars from the editor

You don't have to drop to a shell to manage grammars. Run `:grammar` (or `:grammar list`) from the command prompt to open an interactive modal listing every recipe with its install status:

| Key       | Action                                                               |
| --------- | -------------------------------------------------------------------- |
| `j` / `k` | Move the selection (the arrow keys and `Ctrl-N` / `Ctrl-P` work too) |
| `Enter`   | Install the selected grammar                                         |
| `d`       | Remove the selected grammar                                          |
| `/`       | Filter the list as you type                                          |
| `Esc`     | Close the modal                                                      |

The modal stays open across installs, which run on a background thread. When an install finishes, the active buffer re-highlights automatically — no restart needed.

To find a grammar in a long list, press `/` and start typing — the list narrows to grammars whose name contains what you've typed (case-insensitive). `Enter` installs the highlighted match and leaves the filter input with the query still applied. `Esc` peels back one step at a time: out of the filter input, then clearing the query, then closing the modal.

You can also install or remove grammars inline:

```
:grammar install rust python
:grammar install --all
:grammar remove rust
```

The `:grammar` command appears in the which-key hint panel and supports Tab completion for its subcommands.

### Install on open

When you open a file whose language has an install recipe but whose grammar isn't on disk, Vorto shows a **install this grammar?** prompt instead of a highlight-failed error. Press `y` to install — the buffer lights up once the install completes — or `n` to dismiss and open the file as plain text. You can also move between the **Yes** and **No** buttons with the arrow keys (or `h` / `l` / `Tab`) and confirm the highlighted one with `Enter`; the prompt opens on **Yes**, so a bare `Enter` installs. Each grammar is asked about at most once per session, so opening more files of the same language stays quiet.

## How queries work

Tree-sitter queries are `.scm` files that tell the highlighter how to map syntax nodes to highlight groups. Vorto ships a vendored set of queries for every built-in grammar. When you run `vorto grammar install`, those files are written to `~/.config/vorto/queries/<lang>/` alongside the compiled library.

The query files Vorto uses include:

| File              | Purpose                                                                        |
| ----------------- | ------------------------------------------------------------------------------ |
| `highlights.scm`  | Syntax highlighting colours                                                    |
| `indents.scm`     | Indentation rules                                                              |
| `textobjects.scm` | Text-object motions (if present)                                               |
| `folds.scm`       | [Code folding](/editing/folding) regions (falls back to indentation if absent) |

You can replace any of these files with your own by overwriting them in the query directory. Run `vorto grammar install-queries <lang>` to restore the vendored versions.

## Grammars outside the built-in catalog

For languages without a built-in recipe, you have two options.

### Define a recipe in config

Add a `[grammars.<name>]` block to your `config.toml` and `vorto grammar install <name>` — and the in-editor `:grammar` command — will build it just like a built-in:

```toml theme={null}
[grammars.nim]
source  = "https://github.com/alaviss/tree-sitter-nim"
rev     = "abc123"   # optional: pin a tag, branch, or commit
subpath = "sub"      # optional: for a grammar inside a monorepo
```

| Field     | Description                                                                              |
| --------- | ---------------------------------------------------------------------------------------- |
| `source`  | Git URL of the grammar repository (alias: `src`). Required.                              |
| `rev`     | Tag, branch, or commit to pin. Omit to build the latest default branch.                  |
| `subpath` | Directory within the repository that holds the grammar, for monorepos that ship several. |

<Note>
  Custom recipes build the library, but Vorto has no vendored queries for them — only built-ins ship bundled `.scm` files. Supply your own query files in `~/.config/vorto/queries/<name>/` so highlighting has something to map against.
</Note>

### Install the library by hand

You can also skip recipes entirely: drop a compiled shared library directly into `~/.config/vorto/grammars/` and place your query files in `~/.config/vorto/queries/<lang>/`. The filename stem must match the language name in your `config.toml`.
