mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-21 12:50:09 -04:00
fix: make highlighting more specific for compound
This commit is contained in:
parent
94f89866ae
commit
161d822bee
1 changed files with 39 additions and 84 deletions
|
|
@ -10,12 +10,35 @@
|
||||||
|
|
||||||
(input_title) @keyword
|
(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
|
(input_key) @variable
|
||||||
|
|
||||||
(quoted_string) @string
|
(quoted_string) @string
|
||||||
|
|
||||||
(string) @string
|
(string) @string
|
||||||
|
|
||||||
|
(variable_name) @variable
|
||||||
|
|
||||||
|
; TODO: Add constraint choice and contraint flag
|
||||||
(constraint_content) @string
|
(constraint_content) @string
|
||||||
|
|
||||||
[
|
[
|
||||||
|
|
@ -40,92 +63,36 @@
|
||||||
"gzmt"
|
"gzmt"
|
||||||
] @type
|
] @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)
|
; General word values (LAST - lower priority)
|
||||||
(value_atom
|
(value_atom
|
||||||
(word) @number) ; Words used as values get same color as other values
|
(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
|
; Subblocks
|
||||||
(subblock
|
(subblock
|
||||||
name: (word) @module)
|
name: (word) @keyword)
|
||||||
|
|
||||||
(subblock
|
|
||||||
"end" @module)
|
|
||||||
|
|
||||||
|
; TODO: This needs to be made more precise
|
||||||
; Compound script highlighting - use node types instead of regexes
|
; Compound script highlighting - use node types instead of regexes
|
||||||
[
|
; [
|
||||||
(compound_script)
|
; (compound_script)
|
||||||
(compound_variable_declaration)
|
; (compound_variable_declaration)
|
||||||
(compound_step_block)
|
; (compound_step_block)
|
||||||
(compound_end)
|
; (compound_end)
|
||||||
(compound_for_loop)
|
; (compound_for_loop)
|
||||||
(compound_if_block)
|
; (compound_if_block)
|
||||||
] @keyword
|
; ] @keyword
|
||||||
|
|
||||||
(compound_variable_declaration
|
|
||||||
(variable_name) @variable)
|
|
||||||
|
|
||||||
(compound_variable_reference
|
|
||||||
(variable_name) @variable)
|
|
||||||
|
|
||||||
(compound_boolean) @boolean
|
(compound_boolean) @boolean
|
||||||
|
|
||||||
(compound_assignment
|
|
||||||
(variable_name) @variable)
|
|
||||||
|
|
||||||
; If/else condition components
|
; If/else condition components
|
||||||
(compound_condition) @keyword.conditional
|
(compound_condition) @keyword.conditional
|
||||||
|
|
||||||
(compound_comparison) @operator
|
(compound_comparison) @operator
|
||||||
|
|
||||||
; Array access
|
[
|
||||||
(compound_array_access
|
";"
|
||||||
(variable_name) @function)
|
","
|
||||||
|
] @punctuation.delimiter
|
||||||
";" @punctuation.delimiter
|
|
||||||
|
|
||||||
"," @punctuation.delimiter
|
|
||||||
|
|
||||||
[
|
[
|
||||||
"["
|
"["
|
||||||
|
|
@ -133,24 +100,12 @@
|
||||||
"{"
|
"{"
|
||||||
"}"
|
"}"
|
||||||
"&{"
|
"&{"
|
||||||
|
"("
|
||||||
|
")"
|
||||||
] @punctuation.bracket
|
] @punctuation.bracket
|
||||||
|
|
||||||
(compound_function_call
|
|
||||||
"(" @punctuation.bracket)
|
|
||||||
|
|
||||||
(compound_function_call
|
|
||||||
")" @punctuation.bracket)
|
|
||||||
|
|
||||||
; Parentheses in expressions and conditions
|
; Parentheses in expressions and conditions
|
||||||
; Function calls
|
; Function calls
|
||||||
(compound_function_call
|
(compound_function_call
|
||||||
(variable_name) @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)
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue