> For the complete documentation index, see [llms.txt](https://docs.vale.sh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vale.sh/keys/grammars.md).

# Grammars

Learn how Vale installs the grammars that read source code.

{% hint style="info" %}
Requires Vale v3.27.0 or later.
{% endhint %}

```ini
StylesPath = styles

Grammars = go, python
```

Vale lints the comments in [source code](https://docs.vale.sh/formats/code.md) by parsing the file with a [tree-sitter](https://tree-sitter.github.io/tree-sitter/) grammar, so a `//` inside a string isn't a comment and a doc comment is told apart from a note. The grammars are WebAssembly modules that Vale downloads rather than carries, and `vale sync` installs them:

* Without the key, the sections decide: a `[*.go]` or `[src/**/*.{py,rs}]` section installs the grammars for the extensions it names. A section that names none, such as `[*]`, implies none.
* `Grammars = go, python` installs those two, and nothing the sections imply.
* `Grammars = ALL` installs every grammar, about 13 MB.
* `Grammars = NONE` installs none.

Running `vale sync` places each one at `<StylesPath>/config/grammars/<name>.wasm`, fetched from the Vale release the binary is. The names are:

| Name         | Reads                                                     |
| ------------ | --------------------------------------------------------- |
| `bash`       | Shell scripts                                             |
| `c`          | C                                                         |
| `cpp`        | C++                                                       |
| `csharp`     | C#                                                        |
| `css`        | CSS                                                       |
| `elixir`     | Elixir                                                    |
| `elm`        | Elm, and Haskell                                          |
| `go`         | Go                                                        |
| `java`       | Java                                                      |
| `javascript` | JavaScript, and QML                                       |
| `julia`      | Julia                                                     |
| `kotlin`     | Kotlin                                                    |
| `lua`        | Lua                                                       |
| `php`        | PHP                                                       |
| `proto`      | Protocol Buffers                                          |
| `python`     | Python                                                    |
| `ruby`       | Ruby                                                      |
| `rust`       | Rust                                                      |
| `toml`       | TOML, through a [View](https://docs.vale.sh/keys/view.md) |
| `tsx`        | TSX                                                       |
| `typescript` | TypeScript                                                |
| `yaml`       | YAML, through a [View](https://docs.vale.sh/keys/view.md) |

## [Without a grammar](#without-a-grammar)

A code file whose grammar isn't installed is still linted: its comments are found by their delimiters, the way Vale read code before it used tree-sitter, and the run prints a warning once naming the grammar and the line that installs it:

```
W101 grammar "go" is not installed; add 'Grammars = go' to .vale.ini and run 'vale sync'; until then, comments are read by their delimiters
```

A `tree-sitter` [View](https://docs.vale.sh/topics/views.md) needs its grammar, since its queries have nothing to run on without one.

## [Offline use](#offline-use)

Two environment variables cover a machine that can't reach GitHub:

* `VALE_GRAMMARS_URL` points `vale sync` at a mirror: a URL serving the release's `grammar-<name>.zip` archives, or a directory holding them. An archive is also an ordinary [package](https://docs.vale.sh/keys/packages.md), so a path to one in `Packages` installs it too.
* `VALE_GRAMMARS_PATH` names a directory of `<name>.wasm` modules that Vale reads when the `StylesPath` has none, with no sync at all.

A grammar is compiled to native code the first time a machine runs it and the result kept in the user's cache directory, so only the first run pays for that.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.vale.sh/keys/grammars.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
