diff options
| author | nat-418 <93013864+nat-418@users.noreply.github.com> | 2024-03-31 19:43:49 +0200 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2024-04-01 11:19:45 +0200 |
| commit | 905fedfa28d294ebe4f696282b9b3710cf543086 (patch) | |
| tree | 0b8812df372c49dd5c2c74c6c85b59a24eee1830 /queries/roc | |
| parent | bot(lockfile): update djot, snakemake, v (diff) | |
| download | nvim-treesitter-905fedfa28d294ebe4f696282b9b3710cf543086.tar nvim-treesitter-905fedfa28d294ebe4f696282b9b3710cf543086.tar.gz nvim-treesitter-905fedfa28d294ebe4f696282b9b3710cf543086.tar.bz2 nvim-treesitter-905fedfa28d294ebe4f696282b9b3710cf543086.tar.lz nvim-treesitter-905fedfa28d294ebe4f696282b9b3710cf543086.tar.xz nvim-treesitter-905fedfa28d294ebe4f696282b9b3710cf543086.tar.zst nvim-treesitter-905fedfa28d294ebe4f696282b9b3710cf543086.zip | |
feat(roc): add new parser tree-sitter-roc
Diffstat (limited to 'queries/roc')
| -rw-r--r-- | queries/roc/highlights.scm | 189 | ||||
| -rw-r--r-- | queries/roc/injections.scm | 5 | ||||
| -rw-r--r-- | queries/roc/locals.scm | 40 |
3 files changed, 234 insertions, 0 deletions
diff --git a/queries/roc/highlights.scm b/queries/roc/highlights.scm new file mode 100644 index 000000000..d47c8770e --- /dev/null +++ b/queries/roc/highlights.scm @@ -0,0 +1,189 @@ +;---Most generic types--- +(module) @module + +(identifier) @variable + +(concrete_type) @type + +;---annotations---- +(annotation_type_def + (annotation_pre_colon + (identifier) @type)) + +(annotation_type_def + (annotation_pre_colon + (identifier) @function) + (function_type)) + +;----decleration types---- +(value_declaration + (decl_left + (identifier_pattern + (identifier) @variable.parameter))) + +;---records---- +(field_name) @variable.member + +(record_field_pattern + (_ + (identifier) @variable)) + +;matches the second identifier and all subsequent ones +(field_access_expr + (identifier) @variable.member) + +;----comments---- +(line_comment) @comment @spell + +(doc_comment) @comment.documentation @spell + +;-----Punctuation---- +[ + "?" + (arrow) + (back_arrow) + (backslash) + "," + ":" +] @punctuation.delimiter + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + "|" + "&" + (operator) +] @operator + +(wildcard_pattern) @constant.builtin + +[ + "if" + "then" + "else" +] @keyword.conditional + +[ + (implements) + (when) + (is) + "as" + (to) +] @keyword + +;----headers----- +(interface_header + (name) @type.definition) + +(imports + (imports_entry + (module) @module)) + +(packages + (record_pattern + (record_field_pattern + (field_name) @module))) + +(app_name) @string.special + +(import_path) @string.special.path + +[ + "app" + "packages" + "provides" + "interface" + "exposes" + "expect" +] @keyword + +[ + (import_as) + "imports" +] @keyword.import + +(backpassing_expr + assignee: (identifier_pattern + (identifier) @variable.parameter)) + +(value_declaration + (decl_left + (identifier_pattern + (identifier) @function)) + (expr_body + (anon_fun_expr))) + +;----tags---- +(tags_type + (apply_type + (concrete_type) @constructor)) + +[ + (tag) + (opaque_tag) +] @constructor + +;-----builtins---- +(variable_expr + (module) @module + (identifier) @boolean + (#any-of? @boolean "true" "false") + (#eq? @module "Bool")) + +"dbg" @keyword.debug + +;----function invocations ---- +(function_call_expr + caller: (variable_expr + (identifier) @function.call)) + +(function_call_expr + caller: (field_access_expr + (identifier) @function.call .)) + +(bin_op_expr + (operator + "|>") @operator + (variable_expr + (identifier) @function)) + +;----function arguments---- +(argument_patterns + (identifier_pattern + (identifier) @variable.parameter)) + +(argument_patterns + (_ + (identifier_pattern + (identifier) @variable.parameter))) + +(argument_patterns + (_ + (_ + (identifier_pattern + (identifier) @variable.parameter)))) + +;-----consts----- +[ + (int) + (uint) + (iint) + (xint) + (natural) +] @number + +[ + (decimal) + (float) +] @number.float + +(string) @string + +(char) @character diff --git a/queries/roc/injections.scm b/queries/roc/injections.scm new file mode 100644 index 000000000..326478351 --- /dev/null +++ b/queries/roc/injections.scm @@ -0,0 +1,5 @@ +([ + (line_comment) + (doc_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/queries/roc/locals.scm b/queries/roc/locals.scm new file mode 100644 index 000000000..71bb19407 --- /dev/null +++ b/queries/roc/locals.scm @@ -0,0 +1,40 @@ +(expr_body) @local.scope + +(argument_patterns + (identifier_pattern + (identifier) @local.definition)) + +; (argument_patterns(long_identifier)@local.definition) +(exposes_list + (ident) @local.reference) + +(opaque_type_def + (apply_type + (concrete_type) @local.definition.type)) + +(alias_type_def + (apply_type + (concrete_type) @local.definition.type)) + +(value_declaration + (decl_left + (identifier_pattern + (identifier) @local.definition.function)) + (expr_body + (anon_fun_expr))) + +(value_declaration + (decl_left + (identifier_pattern + (identifier) @local.definition.var))) + +(identifier_pattern + (identifier) @local.definition) + +(exposes + (ident) @local.reference) + +(identifier) @local.reference + +(tag_expr + (tag)) @local.reference |
