Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add language support for rego (OpenPolicyAgent) #6415

Merged
merged 2 commits into from
Mar 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add language support for rego (OpenPolicyAgent)
jcmuller committed Mar 25, 2023
commit 494a532a02df9333dca301b69546c98767e34382
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
@@ -112,6 +112,7 @@
| r | ✓ | | | `R` |
| racket | ✓ | | | `racket` |
| regex | ✓ | | | |
| rego | ✓ | | | `regols` |
| rescript | ✓ | ✓ | | `rescript-language-server` |
| rmarkdown | ✓ | | ✓ | `R` |
| ron | ✓ | | ✓ | |
15 changes: 15 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
@@ -2383,3 +2383,18 @@ injection-regex = "vhdl"
[[grammar]]
name = "vhdl"
source = { git = "https://github.com/teburd/tree-sitter-vhdl", rev = "c57313adee2231100db0a7880033f6865deeadb2" }

[[language]]
name = "rego"
roots = []
scope = "source.rego"
injection-regex = "rego"
file-types = ["rego"]
auto-format = true
comment-token = "#"
language-server = { command = "regols" }
grammar = "rego"

[[grammar]]
name = "rego"
source = { git = "https://github.com/FallenAngel97/tree-sitter-rego", rev = "b2667c975f07b33be3ceb83bea5cfbad88095866" }
68 changes: 68 additions & 0 deletions runtime/queries/rego/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[
(import)
] @keyword.control.import

[
(package)
] @namespace

[
(with)
(as)
(every)
(some)
(in)
(default)
"null"
] @keyword.control

[
(not)
(if)
(contains)
(else)
] @keyword.control.conditional

[
(boolean)
] @constant.builtin.boolean

[
(assignment_operator)
(bool_operator)
(arith_operator)
(bin_operator)
] @operator

[
(string)
(raw_string)
] @string

(term (ref (var))) @variable

(comment) @comment.line

(number) @constant.numeric.integer

(expr_call func_name: (fn_name (var) @function .))

(expr_call func_arguments: (fn_args (expr) @variable.parameter))

(rule_args (term) @variable.parameter)

[
(open_paren)
(close_paren)
(open_bracket)
(close_bracket)
(open_curly)
(close_curly)
] @punctuation.bracket

(rule (rule_head (var) @function.method))

(rule
(rule_head (term (ref (var) @namespace)))
(rule_body (query (literal (expr (expr_infix (expr (term (ref (var)) @_output)))))) (#eq? @_output @namespace))
)
1 change: 1 addition & 0 deletions runtime/queries/rego/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(comment) @comment