FallenAngel97 / tree-sitter-rego

Home Page:https://decodeapps.pp.ua/blog/post/rego-treesitter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🌳 Tree sitter implementation for rego language

This repository tries to cover the tree-sitter implementation for the OPA Rego language

Available scripts

yarn generate # initializes parsing for the grammar.js file
yarn build # compiles the tree-sitter grammar

Please, verify that your editor supports EditorConfig plugin, 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

List of TODO items:

  • Introduce more unit tests covering the internal functions
  • Add the loading of WASM file for the Github Actions pipeline
  • Add locals.scm

Local testing

To be able to locally verify the changes - you should modify your init.lua file to point to your locally installed tree-sitter grammar

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
}

Powered by

About

https://decodeapps.pp.ua/blog/post/rego-treesitter

License:MIT License


Languages

Language:C 97.7%Language:JavaScript 1.5%Language:Rust 0.5%Language:Scheme 0.1%Language:C++ 0.1%Language:Python 0.1%