mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-19 20:00:07 -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
|
||||
|
||||
[
|
||||
(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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue