https://github.com/rishvic/tree-sitter-nvmrc
nvmrc grammar for tree-sitter
https://github.com/rishvic/tree-sitter-nvmrc
Last synced: 11 days ago
JSON representation
nvmrc grammar for tree-sitter
- Host: GitHub
- URL: https://github.com/rishvic/tree-sitter-nvmrc
- Owner: rishvic
- License: mit
- Created: 2026-06-18T14:43:25.000Z (18 days ago)
- Default Branch: main
- Last Pushed: 2026-06-20T13:23:38.000Z (16 days ago)
- Last Synced: 2026-06-22T06:34:07.660Z (14 days ago)
- Language: JavaScript
- Size: 95.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# tree-sitter-nvmrc
[](https://github.com/rishvic/tree-sitter-nvmrc/actions/workflows/checks.yaml)
[](https://api.reuse.software/info/github.com/rishvic/tree-sitter-nvmrc)
[nvmrc](https://github.com/nvm-sh/nvm) grammar for
[tree-sitter](https://tree-sitter.github.io/tree-sitter/).
Parses `.nvmrc` files (the node-version files that
[nvm](https://github.com/nvm-sh/nvm) and compatible tools read). The grammar is
permissive: it splits each line into an optional `key`/`value` on the first `=`,
keeps `#` comments and surrounding whitespace as extras, and leaves validation
(e.g. rejecting bad version ranges) to downstream consumers.
See [`test/corpus/`](test/corpus) for the full set of examples that define the
grammar's behavior.
## References
- [nvm](https://github.com/nvm-sh/nvm): The reference implementation.
`nvm_process_nvmrc` in `nvm.sh` defines the parse: split into `key`/`value` on
the first `=`, keeping the remainder of the line verbatim as the value.
- [`nvmrc`](https://github.com/nvm-sh/nvmrc): An alternative npm parser that
instead splits the value into parts.
The grammar keeps enough structure to describe both interpretations.
## Development
Edit [`grammar.js`](grammar.js), then regenerate and test:
```sh
tree-sitter generate
tree-sitter test
```
The parser under `src/` is generated from `grammar.js`. Regenerate and commit it
alongside any grammar change.
## License
[MIT](LICENSE)
Bundled third-party MIT material is acknowledged in
[`THIRD-PARTY-NOTICES.txt`](THIRD-PARTY-NOTICES.txt).
This repository is [REUSE](https://reuse.software)-compliant; new files need an
SPDX header or a `.license` sidecar.