diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2025-03-09 12:06:59 +0100 |
|---|---|---|
| committer | Christian Clason <ch.clason+github@icloud.com> | 2025-03-09 19:26:47 +0100 |
| commit | afe977dadd8bccbd3919b29a8b5beb5b8bfc6cdb (patch) | |
| tree | cc7a1f8919f1680b64f1412d365373852b792902 /queries | |
| parent | bot(readme): update (diff) | |
| download | nvim-treesitter-afe977dadd8bccbd3919b29a8b5beb5b8bfc6cdb.tar nvim-treesitter-afe977dadd8bccbd3919b29a8b5beb5b8bfc6cdb.tar.gz nvim-treesitter-afe977dadd8bccbd3919b29a8b5beb5b8bfc6cdb.tar.bz2 nvim-treesitter-afe977dadd8bccbd3919b29a8b5beb5b8bfc6cdb.tar.lz nvim-treesitter-afe977dadd8bccbd3919b29a8b5beb5b8bfc6cdb.tar.xz nvim-treesitter-afe977dadd8bccbd3919b29a8b5beb5b8bfc6cdb.tar.zst nvim-treesitter-afe977dadd8bccbd3919b29a8b5beb5b8bfc6cdb.zip | |
feat(roc)!: bump parser and queries
Adapt to https://github.com/faldor20/tree-sitter-roc/pull/30
Also synchronize queries with upstream and add indents
Diffstat (limited to 'queries')
| -rw-r--r-- | queries/roc/highlights.scm | 23 | ||||
| -rw-r--r-- | queries/roc/indents.scm | 60 | ||||
| -rw-r--r-- | queries/roc/injections.scm | 25 | ||||
| -rw-r--r-- | queries/roc/locals.scm | 8 |
4 files changed, 106 insertions, 10 deletions
diff --git a/queries/roc/highlights.scm b/queries/roc/highlights.scm index 1f950cbc0..3fcc935ed 100644 --- a/queries/roc/highlights.scm +++ b/queries/roc/highlights.scm @@ -32,6 +32,12 @@ (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 @@ -41,8 +47,8 @@ [ "?" (arrow) - (back_arrow) - (backslash) + (fat_arrow) + "|" "," ":" ] @punctuation.delimiter @@ -59,6 +65,8 @@ [ "|" "&" + "<-" + ".." (operator) ] @operator @@ -92,10 +100,6 @@ "imports" ] @keyword.import -(backpassing_expr - assignee: (identifier_pattern - (identifier) @variable.parameter)) - (value_declaration (decl_left (identifier_pattern @@ -105,8 +109,7 @@ ;----tags---- (tags_type - (apply_type - (concrete_type) @constructor)) + (tag_type) @constructor) [ (tag) @@ -123,11 +126,11 @@ "dbg" @keyword.debug ;----function invocations ---- -(function_call_expr +(function_call_pnc_expr caller: (variable_expr (identifier) @function.call)) -(function_call_expr +(function_call_pnc_expr caller: (field_access_expr (identifier) @function.call .)) diff --git a/queries/roc/indents.scm b/queries/roc/indents.scm new file mode 100644 index 000000000..764e0e29e --- /dev/null +++ b/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) + (imports) + (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/queries/roc/injections.scm b/queries/roc/injections.scm index 326478351..509805b17 100644 --- a/queries/roc/injections.scm +++ b/queries/roc/injections.scm @@ -1,3 +1,28 @@ +;injection from function calls +(function_call_pnc_expr + (variable_expr + (identifier) @injection.language) + (const + [ + (multiline_string) + (string) + ] @injection.content) + (#any-eq? @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-eq? @injection.language + "json" "toml" "yaml" "xml" "sql" "lua" "js" "html" "css" "http" "jq" "latex" "md" "nix" "regex")) + ([ (line_comment) (doc_comment) diff --git a/queries/roc/locals.scm b/queries/roc/locals.scm index 134fe0119..29f04e990 100644 --- a/queries/roc/locals.scm +++ b/queries/roc/locals.scm @@ -35,6 +35,14 @@ (identifier_pattern (identifier) @local.definition) +(when_is_branch + pattern: (_ + (identifier_pattern + (identifier) @local.definition))) + +(spread_pattern + (identifier) @local.definition) + (identifier) @local.reference (tag_expr |
