From afe977dadd8bccbd3919b29a8b5beb5b8bfc6cdb Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 9 Mar 2025 12:06:59 +0100 Subject: 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 --- queries/roc/highlights.scm | 23 ++++++++++-------- queries/roc/indents.scm | 60 ++++++++++++++++++++++++++++++++++++++++++++++ queries/roc/injections.scm | 25 +++++++++++++++++++ queries/roc/locals.scm | 8 +++++++ 4 files changed, 106 insertions(+), 10 deletions(-) create mode 100644 queries/roc/indents.scm (limited to 'queries') 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 -- cgit v1.2.3-70-g09d2