From d4e18d41bdb57d5540e6a6fecb61d8d1909f593c Mon Sep 17 00:00:00 2001 From: Tomas Sandven Date: Thu, 17 Aug 2023 00:00:43 +0200 Subject: [PATCH 1/3] Update tree-sitter-robot --- languages.toml | 2 +- runtime/queries/robot/highlights.scm | 64 ++++++++++++++++++++++------ 2 files changed, 51 insertions(+), 15 deletions(-) diff --git a/languages.toml b/languages.toml index d3cb402569e5..dc07bb2bd9d5 100644 --- a/languages.toml +++ b/languages.toml @@ -1567,7 +1567,7 @@ language-servers = [ "robotframework_ls" ] [[grammar]] name = "robot" -source = { git = "https://github.com/Hubro/tree-sitter-robot", rev = "f1142bfaa6acfce95e25d2c6d18d218f4f533927" } +source = { git = "https://github.com/Hubro/tree-sitter-robot", rev = "322e4cc65754d2b3fdef4f2f8a71e0762e3d13af" } [[language]] name = "r" diff --git a/runtime/queries/robot/highlights.scm b/runtime/queries/robot/highlights.scm index 60f416b7b699..152526f706c4 100644 --- a/runtime/queries/robot/highlights.scm +++ b/runtime/queries/robot/highlights.scm @@ -1,21 +1,57 @@ -(comment) @comment -(ellipses) @punctuation.delimiter - -(section_header) @keyword -(extra_text) @comment +[ + (comment) + (extra_text) +] @comment -(setting_statement) @keyword +[ + (section_header) + (setting_statement) + (keyword_setting) + (test_case_setting) +] @keyword (variable_definition (variable_name) @variable) - (keyword_definition (name) @function) -(keyword_definition (body (keyword_setting) @keyword)) +(test_case_definition (name) @function) + +(keyword_invocation (keyword) @function.call) +(ellipses) @punctuation.delimiter + +(text_chunk) @string +(inline_python_expression) @string.special +[ + (scalar_variable) + (list_variable) + (dictionary_variable) +] @variable + +; Control structures + +[ + "FOR" + "IN" + "IN RANGE" + "IN ENUMERATE" + "IN ZIP" + (break_statement) + (continue_statement) +] @repeat +(for_statement "END" @repeat) -(test_case_definition (name) @property) +"WHILE" @repeat +(while_statement "END" @repeat) -(keyword_invocation (keyword) @function) +[ + "IF" + "ELSE IF" +] @conditional +(if_statement "END" @conditional) +(if_statement (else_statement "ELSE" @conditional)) -(argument (text_chunk) @string) -(argument (scalar_variable) @string.special) -(argument (list_variable) @string.special) -(argument (dictionary_variable) @string.special) +[ + "TRY" + "EXCEPT" + "FINALLY" +] @exception +(try_statement "END" @exception) +(try_statement (else_statement "ELSE" @exception)) From 0f7d5116b060663378601699df407534da4ad3f5 Mon Sep 17 00:00:00 2001 From: Tomas Sandven Date: Thu, 17 Aug 2023 16:45:45 +0200 Subject: [PATCH 2/3] Update Robot highlights query for Helix --- runtime/queries/robot/highlights.scm | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/runtime/queries/robot/highlights.scm b/runtime/queries/robot/highlights.scm index 152526f706c4..4757d83f0d50 100644 --- a/runtime/queries/robot/highlights.scm +++ b/runtime/queries/robot/highlights.scm @@ -1,7 +1,7 @@ [ (comment) (extra_text) -] @comment +] @comment.single [ (section_header) @@ -14,7 +14,7 @@ (keyword_definition (name) @function) (test_case_definition (name) @function) -(keyword_invocation (keyword) @function.call) +(keyword_invocation (keyword) @function) (ellipses) @punctuation.delimiter (text_chunk) @string @@ -27,6 +27,8 @@ ; Control structures +"RETURN" @keyword.control.return + [ "FOR" "IN" @@ -35,23 +37,23 @@ "IN ZIP" (break_statement) (continue_statement) -] @repeat -(for_statement "END" @repeat) +] @keyword.control.repeat +(for_statement "END" @keyword.control.repeat) -"WHILE" @repeat -(while_statement "END" @repeat) +"WHILE" @keyword.control.repeat +(while_statement "END" @keyword.control.repeat) [ "IF" "ELSE IF" -] @conditional -(if_statement "END" @conditional) -(if_statement (else_statement "ELSE" @conditional)) +] @keyword.control.conditional +(if_statement "END" @keyword.control.conditional) +(if_statement (else_statement "ELSE" @keyword.control.conditional)) [ "TRY" "EXCEPT" "FINALLY" -] @exception -(try_statement "END" @exception) -(try_statement (else_statement "ELSE" @exception)) +] @keyword.control.exception +(try_statement "END" @keyword.control.exception) +(try_statement (else_statement "ELSE" @keyword.control.exception)) From bdad45060db643347676faf4b5359e43b521950a Mon Sep 17 00:00:00 2001 From: Tomas Sandven <597206+Hubro@users.noreply.github.com> Date: Fri, 18 Aug 2023 10:23:08 +0200 Subject: [PATCH 3/3] Change @comment.single to @comment Co-authored-by: Michael Davis --- runtime/queries/robot/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/queries/robot/highlights.scm b/runtime/queries/robot/highlights.scm index 4757d83f0d50..06e95798affb 100644 --- a/runtime/queries/robot/highlights.scm +++ b/runtime/queries/robot/highlights.scm @@ -1,7 +1,7 @@ [ (comment) (extra_text) -] @comment.single +] @comment [ (section_header)