mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-15 17:58:10 +00:00
As I was starting to try to play around with carbon, I wanted nvim integration. Unfortunately, a lot of the code in the integration had bitrotted, but not unbearably so, so I updated it 😄 It works now! Syntax highlighting and the LSP work out of the box with nvim 0.12 (and should also work on nvim 0.11) Hopefully all good that I did All The Commits, I come from the school of "every commit should do one thing" Closes #7821 --------- Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
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 runstree-sitter generate, allowing it to find the system-installed binary.--action_env=PATH: Passes your currentPATHto the build actions, ensuringtree-sittercan be found. Iftree-sitteris 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 yourHOMEenvironment variable, whichtree-sittermay need to locate its configuration or cache.
Editor Installation
Helix
- Install tree-sitter and Nodejs.
- Install Helix.
- Run
./helix.sh
Emacs
TODO