From 5e4068fabd2a8f405ed90a02755fa47b132096a9 Mon Sep 17 00:00:00 2001 From: Tyler Miller Date: Wed, 10 May 2023 04:12:26 -0700 Subject: [PATCH] fix: lua function declaration name highlighting 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. --- queries/lua/highlights.scm | 106 +++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 queries/lua/highlights.scm diff --git a/queries/lua/highlights.scm b/queries/lua/highlights.scm new file mode 100644 index 00000000..e06b7ad7 --- /dev/null +++ b/queries/lua/highlights.scm @@ -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) + ])