aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lua/nvim-treesitter/query_predicates.lua1
-rw-r--r--queries/c/highlights.scm4
-rw-r--r--queries/cpp/highlights.scm5
3 files changed, 7 insertions, 3 deletions
diff --git a/lua/nvim-treesitter/query_predicates.lua b/lua/nvim-treesitter/query_predicates.lua
index 18e1401d0..06c13aa02 100644
--- a/lua/nvim-treesitter/query_predicates.lua
+++ b/lua/nvim-treesitter/query_predicates.lua
@@ -54,6 +54,7 @@ local function has_ancestor(match, pattern, bufnr, pred)
end
return false
end
+
query.add_predicate('has-ancestor?', has_ancestor)
query.add_predicate('has-parent?', has_ancestor)
diff --git a/queries/c/highlights.scm b/queries/c/highlights.scm
index 96b43cf0d..cef57a005 100644
--- a/queries/c/highlights.scm
+++ b/queries/c/highlights.scm
@@ -119,7 +119,9 @@
] @function.macro
; TODO (preproc_arg) @embedded
-(field_identifier) @property
+(((field_expression
+ (field_identifier) @property)) @_parent
+ (not-has-parent? @_parent template_method function_declarator call_expression))
(statement_identifier) @label
[
diff --git a/queries/cpp/highlights.scm b/queries/cpp/highlights.scm
index 38f7c463d..e4936b98e 100644
--- a/queries/cpp/highlights.scm
+++ b/queries/cpp/highlights.scm
@@ -23,8 +23,9 @@
(template_function
name: (identifier) @function)
-(template_method
- name: (field_identifier) @method)
+(((field_expression
+ (field_identifier) @method)) @_parent
+ (has-parent? @_parent template_method function_declarator call_expression))
(template_function
name: (scoped_identifier