Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/FallenAngel97/tree-sitter-rego
https://github.com/FallenAngel97/tree-sitter-rego
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/FallenAngel97/tree-sitter-rego
- Owner: FallenAngel97
- License: mit
- Created: 2022-03-28T06:16:20.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-06-12T15:02:08.000Z (7 months ago)
- Last Synced: 2024-06-12T20:57:08.998Z (7 months ago)
- Language: C
- Homepage: https://decodeapps.pp.ua/blog/post/rego-treesitter
- Size: 450 KB
- Stars: 8
- Watchers: 3
- Forks: 6
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-opa - tree-sitter-rego - Tree-sitter grammar for Rego ([blog](https://decodeapps.pp.ua/blog/post/rego-treesitter)) (IDE and Editor Integrations / Datasource Integrations Blogs and Articles)
README
# 🌳 Tree sitter implementation for rego language
This repository tries to cover the tree-sitter implementation for the [OPA Rego language](https://www.openpolicyagent.org/docs/latest/policy-language/)
You can use [NVM](https://github.com/nvm-sh/nvm) in order to load the Node version used to develop the grammar by issuing `nvm use`
Available scripts```bash
yarn generate # initializes parsing for the grammar.js file
yarn build # compiles the tree-sitter grammar
```Please, verify that your editor supports [EditorConfig plugin](https://editorconfig.org/), which is necessary to keep the development consistent.
This repository uses Github Actions, which help verify that the changes submitted can be unit-tested, built and deployed to a [Github Pages](https://fallenangel97.github.io/tree-sitter-rego/)List of TODO items:
- Introduce more unit tests covering the internal functions
- Add locals.scm## Local testing in browser
```
npx tree-sitter build-wasm
npx tree-sitter playground
```This will open locally http://127.0.0.1:8000/, where you can check your rules
directly in the browser## Local testing in NeoVim
To be able to locally verify the changes - you should modify your `init.lua` file
to point to your locally installed tree-sitter grammar```lua
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()parser_config.rego = {
install_info = {
url = "/home/user/Documents/tree-sitter-rego", -- local path or git repo
files = {"src/parser.c"},
-- optional entries:
branch = "master", -- default branch in case of git repo if different from master
generate_requires_npm = false, -- if stand-alone parser without npm dependencies
requires_generate_from_grammar = false, -- if folder contains pre-generated src/parser.c
},
filetype = "rego", -- if filetype does not match the parser name
}
```The live playground is available at: https://fallenangel97.github.io/tree-sitter-rego/
---
Powered by