aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorJuan C. Müller2023-03-26 21:49:37 +0000
committerGitHub2023-03-26 21:49:37 +0000
commit5d7c90c5cfd6887fc0a43ee695d91f0166955a64 (patch)
tree9b742f42da11e0c72e6fd05b65dd2779b3564cff /runtime
parentabef92a9b341209aeae8802d30fc8c1f971a43df (diff)
Add language support for rego (OpenPolicyAgent) (#6415)
Diffstat (limited to 'runtime')
-rw-r--r--runtime/queries/rego/highlights.scm68
-rw-r--r--runtime/queries/rego/injections.scm2
2 files changed, 70 insertions, 0 deletions
diff --git a/runtime/queries/rego/highlights.scm b/runtime/queries/rego/highlights.scm
new file mode 100644
index 00000000..0ff6de55
--- /dev/null
+++ b/runtime/queries/rego/highlights.scm
@@ -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))
+)
diff --git a/runtime/queries/rego/injections.scm b/runtime/queries/rego/injections.scm
new file mode 100644
index 00000000..321c90ad
--- /dev/null
+++ b/runtime/queries/rego/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))