From 161d822beef87b0bb96eb653cdb302a12b3b90b1 Mon Sep 17 00:00:00 2001 From: Kalman Szenes Date: Mon, 18 Aug 2025 09:10:41 +0200 Subject: [PATCH] fix: make highlighting more specific for compound --- runtime/queries/orca/highlights.scm | 123 +++++++++------------------- 1 file changed, 39 insertions(+), 84 deletions(-) diff --git a/runtime/queries/orca/highlights.scm b/runtime/queries/orca/highlights.scm index 927f47bc6..13fc83161 100644 --- a/runtime/queries/orca/highlights.scm +++ b/runtime/queries/orca/highlights.scm @@ -10,12 +10,35 @@ (input_title) @keyword +[ + (variable_kw) + (end_kw) + ; for loop + (for_kw) + (from_kw) + (to_kw) + (do_kw) + (endfor_kw) + ; if else + (if_kw) + (then_kw) + (else_kw) + (endif_kw) + ; compound + (new_step_kw) + (step_end_kw) + (compound_end) + ] @keyword + (input_key) @variable (quoted_string) @string (string) @string +(variable_name) @variable + +; TODO: Add constraint choice and contraint flag (constraint_content) @string [ @@ -40,92 +63,36 @@ "gzmt" ] @type -; Variables (FIRST - higher priority than general rules) - using @function for prominence -(variable_ref - (variable_name) @variable) ; {r} in geometry blocks - -(variable_def - (variable_name) @variable) ; r in variable definitions - ; General word values (LAST - lower priority) (value_atom (word) @number) ; Words used as values get same color as other values -; Internal coordinate highlighting -(int_line - connect1: (integer) @operator - connect2: (integer) @operator - connect3: (integer) @operator) - -(int_line - (coord_value - (variable_ref) @operator)) - -; Zmatrix coordinate highlighting - alternating pattern like internal coords -(zmat_line2 - zmat_atom1: (integer) @operator) - -(zmat_line2 - (coord_value - (variable_ref) @operator)) - -(zmat_line3 - zmat_atom1: (integer) @operator - zmat_atom2: (integer) @operator) - -(zmat_line3 - (coord_value - (variable_ref) @operator)) - -(zmat_line4 - zmat_atom1: (integer) @operator - zmat_atom2: (integer) @operator - zmat_atom3: (integer) @operator) - -(zmat_line4 - (coord_value - (variable_ref) @operator)) - ; Subblocks (subblock - name: (word) @module) - -(subblock - "end" @module) + name: (word) @keyword) +; TODO: This needs to be made more precise ; Compound script highlighting - use node types instead of regexes -[ - (compound_script) - (compound_variable_declaration) - (compound_step_block) - (compound_end) - (compound_for_loop) - (compound_if_block) -] @keyword - -(compound_variable_declaration - (variable_name) @variable) - -(compound_variable_reference - (variable_name) @variable) +; [ +; (compound_script) +; (compound_variable_declaration) +; (compound_step_block) +; (compound_end) +; (compound_for_loop) +; (compound_if_block) +; ] @keyword (compound_boolean) @boolean -(compound_assignment - (variable_name) @variable) - ; If/else condition components (compound_condition) @keyword.conditional (compound_comparison) @operator -; Array access -(compound_array_access - (variable_name) @function) - -";" @punctuation.delimiter - -"," @punctuation.delimiter +[ + ";" + "," +] @punctuation.delimiter [ "[" @@ -133,24 +100,12 @@ "{" "}" "&{" + "(" + ")" ] @punctuation.bracket -(compound_function_call - "(" @punctuation.bracket) - -(compound_function_call - ")" @punctuation.bracket) - ; Parentheses in expressions and conditions ; Function calls (compound_function_call (variable_name) @function.call) -; Array assignments -(compound_array_assignment - (compound_array_access - (variable_name) @function)) - -; Variables in expressions - general pattern to catch all variable usage -(compound_primary_expr - (variable_name) @function)