Files
carbon-lang/utils/tree_sitter
Chandler CarruthandRichard Smith 94d2c1c6d4 Make proposal filenames use 6 digits and include the title (#7245)
We've talked about adding the title to the filename several times over
the years and it seems really valuable. This requires us to compute a
"slug" for the title spelling that can be part of the filename.

Beyond that, we crossed 7000 recently, and so it seems likely that we
will need to add digits sooner rather than later here, so this goes
ahead and moves us to 6 digits so we don't have to adjust again for a
reasonable length of time.

To implement this and ensure we can sustain it going forward this adds a
tool to our pre-commit that validates (and corrects if needed) the
filename.

In order to update everything and keep links working, there are a _lot_
of changes, but the most interesting for direct review are in
`proposals/scripts`.

Assisted-by: Antigravity with Gemini

---------

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2026-05-29 00:55:04 +00:00
..
2025-04-11 19:58:54 +00:00

Tree-sitter grammar for Carbon

Tree-sitter is currently used for syntax highlighting in supported editors.

Development

We use a non-hermetic tree-sitter invocation, so it must be installed locally. To install tree-sitter, run:

npm install -g tree-sitter-cli

Building and Testing

To build and test changes to the grammar using Bazel, provide specific flags to allow the build to access the system tree-sitter binary and environment.

bazel test //utils/tree_sitter:string_tests \
  --strategy=Genrule=local \
  --action_env=PATH \
  --action_env=HOME
  • --strategy=Genrule=local: Disables sandboxing for the genrule that runs tree-sitter generate, allowing it to find the system-installed binary.
  • --action_env=PATH: Passes your current PATH to the build actions, ensuring tree-sitter can be found. If tree-sitter is not in your default PATH, you can specify it explicitly, for example: --action_env=PATH=/path/to/tree-sitter/bin:$PATH.
  • --action_env=HOME: Passes your HOME environment variable, which tree-sitter may need to locate its configuration or cache.

Editor Installation

Helix

  1. Install tree-sitter and Nodejs.
  2. Install Helix.
  3. Run ./helix.sh

Emacs

TODO