Skip to content

Commit

Permalink
fix: lua function declaration name highlighting
Browse files Browse the repository at this point in the history
Within a function declaration, the entire function name should be the
same color, regardless of whether it's a method etc., and including any
punctuation within. This change also introduces new treesitter-capture
highlight groups which may each be independently overridden by the user.

Note: in Neovim, groups like `@x.y.z` fallback to `@x` implicitly if
`@x.y.z` is not defined.
  • Loading branch information
tmillr committed May 13, 2023
1 parent 861245e commit 5e4068f
Showing 1 changed file with 106 additions and 0 deletions.
106 changes: 106 additions & 0 deletions queries/lua/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
(function_declaration
name: [
(dot_index_expression
table: [
(identifier)
;; some manual recursion (up to 8 fields) because ts queries don't
;; support recursion up to arbitrary depths currently
(dot_index_expression
table: [
(identifier)
(dot_index_expression
table: [
(identifier)
(dot_index_expression
table: [
(identifier)
(dot_index_expression
table: [
(identifier)
(dot_index_expression
table: [
(identifier)
(dot_index_expression
table: [
(identifier)
(dot_index_expression
table: [
(identifier)
(dot_index_expression)
] @function.namespace
"." @function.punctuation.delimiter
field: (identifier) @function.namespace)
] @function.namespace
"." @function.punctuation.delimiter
field: (identifier) @function.namespace)
] @function.namespace
"." @function.punctuation.delimiter
field: (identifier) @function.namespace)
] @function.namespace
"." @function.punctuation.delimiter
field: (identifier) @function.namespace)
] @function.namespace
"." @function.punctuation.delimiter
field: (identifier) @function.namespace)
] @function.namespace
"." @function.punctuation.delimiter
field: (identifier) @function.namespace)
] @function.namespace
"." @function.punctuation.delimiter
field: (identifier) @function.namespace)
] @function.namespace
"." @function.punctuation.delimiter
field: (identifier) @function)

(method_index_expression
table: [
(identifier)
;; some manual recursion (up to 8 fields) because ts queries don't
;; support recursion up to arbitrary depths currently
(dot_index_expression
table: [
(identifier)
(dot_index_expression
table: [
(identifier)
(dot_index_expression
table: [
(identifier)
(dot_index_expression
table: [
(identifier)
(dot_index_expression
table: [
(identifier)
(dot_index_expression
table: [
(identifier)
(dot_index_expression
table: [
(identifier)
(dot_index_expression)
] @method.namespace
"." @function.punctuation.delimiter
field: (identifier) @method.namespace)
] @method.namespace
"." @function.punctuation.delimiter
field: (identifier) @method.namespace)
] @method.namespace
"." @function.punctuation.delimiter
field: (identifier) @method.namespace)
] @method.namespace
"." @function.punctuation.delimiter
field: (identifier) @method.namespace)
] @method.namespace
"." @function.punctuation.delimiter
field: (identifier) @method.namespace)
] @method.namespace
"." @function.punctuation.delimiter
field: (identifier) @method.namespace)
] @method.namespace
"." @function.punctuation.delimiter
field: (identifier) @method.namespace)
] @method.namespace
":" @method.punctuation.delimiter
method: (identifier) @method)
])

0 comments on commit 5e4068f

Please sign in to comment.