diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2023-06-12 09:54:30 -0600 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2025-05-12 18:43:40 +0200 |
| commit | 692b051b09935653befdb8f7ba8afdb640adf17b (patch) | |
| tree | 167162b6b129ae04f68c5735078521a72917c742 /runtime/queries/roc | |
| parent | feat(c-family): inherit injections (diff) | |
| download | nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.gz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.bz2 nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.lz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.xz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.zst nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.zip | |
feat!: drop modules, general refactor and cleanup
Diffstat (limited to 'runtime/queries/roc')
| -rw-r--r-- | runtime/queries/roc/highlights.scm | 175 | ||||
| -rw-r--r-- | runtime/queries/roc/indents.scm | 60 | ||||
| -rw-r--r-- | runtime/queries/roc/injections.scm | 30 | ||||
| -rw-r--r-- | runtime/queries/roc/locals.scm | 49 |
4 files changed, 314 insertions, 0 deletions
diff --git a/runtime/queries/roc/highlights.scm b/runtime/queries/roc/highlights.scm new file mode 100644 index 000000000..4993017dc --- /dev/null +++ b/runtime/queries/roc/highlights.scm @@ -0,0 +1,175 @@ +;---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) + +;highlight module members as records instead of free variables +; avoids highlighting them as out-of-scope vars +(variable_expr + (module) + (identifier) @variable.member) + +;----comments---- +(line_comment) @comment @spell + +(doc_comment) @comment.documentation @spell + +;-----Punctuation---- +[ + "?" + (arrow) + (fat_arrow) + "|" + "," + ":" +] @punctuation.delimiter + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + "|" + "&" + "<-" + ".." + (operator) +] @operator + +(wildcard_pattern) @character.special + +[ + "if" + "then" + "else" +] @keyword.conditional + +[ + (implements) + (when) + (is) + (as) + "as" + (to) +] @keyword + +;----headers----- +[ + "app" + "expect" + "module" + "package" +] @keyword + +"import" @keyword.import + +(value_declaration + (decl_left + (identifier_pattern + (identifier) @function)) + (expr_body + (anon_fun_expr))) + +;----tags---- +(tags_type + (tag_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_pnc_expr + caller: (variable_expr + (identifier) @function.call)) + +(function_call_pnc_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) + (multiline_string) +] @string + +(char) @character diff --git a/runtime/queries/roc/indents.scm b/runtime/queries/roc/indents.scm new file mode 100644 index 000000000..9a08f2074 --- /dev/null +++ b/runtime/queries/roc/indents.scm @@ -0,0 +1,60 @@ +; (value_declaration(expr_body(anon_fun_expr)))@indent.ignore +[ + (when_is_expr) + (when_is_branch) + (record_expr) + (anon_fun_expr) + (list_expr) + (parenthesized_expr) + (function_call_pnc_expr) + (tuple_expr) + "import" + (exposes) + (exposes_list) + (exposing) + ;patterns + (record_pattern) + (tuple_pattern) + (list_pattern) + ;ability stuff + (ability_implementation) + (opaque_type_def) + ;types + (record_type) + (tags_type) + (record_expr) + (implements_implementation) + "{" + "(" + "[" +] @indent.begin + +; ((record_type) +; @indent.align +; (#set! indent.open_delimiter "{") +; (#set! indent.close_delimiter "}")) +; ((record_expr) +; @indent.align +; (#set! indent.open_delimiter "{") +; (#set! indent.close_delimiter "}")) +; ((tags_type) @indent.align +; (#set! indent.open_delimiter "[") +; (#set! indent.close_delimiter "]")) +; ((implements_implementation) @indent.align +; (#set! indent.open_delimiter "[") +; (#set! indent.close_delimiter "]")) +(expr_body) @indent.begin + +(ERROR + "=") @indent.begin + +(then) @indent.begin + +(else) @indent.begin + +[ + ; result:(_) + "]" + "}" + ")" +] @indent.branch diff --git a/runtime/queries/roc/injections.scm b/runtime/queries/roc/injections.scm new file mode 100644 index 000000000..5bc7576f8 --- /dev/null +++ b/runtime/queries/roc/injections.scm @@ -0,0 +1,30 @@ +;injection from function calls +(function_call_pnc_expr + (variable_expr + (identifier) @injection.language) + (const + [ + (multiline_string) + (string) + ] @injection.content) + (#any-of? @injection.language + "json" "toml" "yaml" "xml" "sql" "lua" "js" "html" "css" "http" "jq" "latex" "md" "nix" "regex")) + +;injection from piping function calls +(bin_op_expr + part: (const + [ + (multiline_string) + (string) + ] @injection.content) + part: (operator) + part: (variable_expr + (identifier) @injection.language) + (#any-of? @injection.language + "json" "toml" "yaml" "xml" "sql" "lua" "js" "html" "css" "http" "jq" "latex" "md" "nix" "regex")) + +([ + (line_comment) + (doc_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/roc/locals.scm b/runtime/queries/roc/locals.scm new file mode 100644 index 000000000..29f04e990 --- /dev/null +++ b/runtime/queries/roc/locals.scm @@ -0,0 +1,49 @@ +(expr_body) @local.scope + +(argument_patterns + (identifier_pattern + (identifier) @local.definition)) + +; (argument_patterns(long_identifier)@local.definition) +(exposes_list + (ident) @local.reference) + +(import_expr + (as) + (module) @local.definition) + +(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) + +(when_is_branch + pattern: (_ + (identifier_pattern + (identifier) @local.definition))) + +(spread_pattern + (identifier) @local.definition) + +(identifier) @local.reference + +(tag_expr + (tag)) @local.reference |
