aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Drouhard <john@jmdtech.org>2020-11-19 09:50:47 -0600
committerStephan Seitz <stephan.lauf@yahoo.de>2020-11-20 14:03:06 +0100
commit33ffdce6906b0946a6503c73b7fc71250cc938aa (patch)
tree14eff59a360286bc955caf2f5b359ae28abcb80a
parentTernary (diff)
downloadnvim-treesitter-33ffdce6906b0946a6503c73b7fc71250cc938aa.tar
nvim-treesitter-33ffdce6906b0946a6503c73b7fc71250cc938aa.tar.gz
nvim-treesitter-33ffdce6906b0946a6503c73b7fc71250cc938aa.tar.bz2
nvim-treesitter-33ffdce6906b0946a6503c73b7fc71250cc938aa.tar.lz
nvim-treesitter-33ffdce6906b0946a6503c73b7fc71250cc938aa.tar.xz
nvim-treesitter-33ffdce6906b0946a6503c73b7fc71250cc938aa.tar.zst
nvim-treesitter-33ffdce6906b0946a6503c73b7fc71250cc938aa.zip
c/cpp highlights: Fix field declarations and initializers
After a recent fix for #446, declarations in class/struct definitions stopped being marked as properties or methods. This fix will add property highlights to field declarations, and method highlight to field function declarations.
-rw-r--r--queries/c/highlights.scm5
-rw-r--r--queries/cpp/highlights.scm6
2 files changed, 11 insertions, 0 deletions
diff --git a/queries/c/highlights.scm b/queries/c/highlights.scm
index ccda6632c..af4012810 100644
--- a/queries/c/highlights.scm
+++ b/queries/c/highlights.scm
@@ -122,6 +122,11 @@
(((field_expression
(field_identifier) @property)) @_parent
(#not-has-parent? @_parent template_method function_declarator call_expression))
+
+(((field_identifier) @property)
+ (#has-ancestor? @property field_declaration)
+ (#not-has-ancestor? @property function_declarator))
+
(statement_identifier) @label
[
diff --git a/queries/cpp/highlights.scm b/queries/cpp/highlights.scm
index 05d50426a..81e4c544d 100644
--- a/queries/cpp/highlights.scm
+++ b/queries/cpp/highlights.scm
@@ -27,6 +27,12 @@
(field_identifier) @method)) @_parent
(#has-parent? @_parent template_method function_declarator call_expression))
+(field_initializer
+ (field_identifier) @property)
+
+(function_declarator
+ declarator: (field_identifier) @method)
+
(template_function
name: (scoped_identifier
name: (identifier) @function))