Improve C++ Tree-sitter queries (#18016)
I made a few tree-sitter queries for improving the highlighting of C++. There is one query that I'm not totally certain about and would appreciate some feedback on it, the one that concerns attributes. Many editor only highlight the identifier as a keyword (This is the behavior implemented in this commit), while others, for example the tree-sitter plugin for neovim, tags the entire attribute for highlighting (double brackets included). I don't know which one is preferable. Here are screenshots of the two versions:   Release Notes: - Fixed C++ attributes identifiers being wrongly highlighed through the tag "variable" - C++ attribute identifiers (nodiscard,deprecated, noreturn, etc.. ) are now highlighted through the tag "keyword" - Changed C++ primitives types (void, bool, int, size_t, etc.. ) to no longer be highlighted with the tag "keyword", they can now be highlighted by the tag "type.primitive". - Added a tag "concept" for highlighting C++ concept identifiers. (This tag name has been chosen to be the same than the one returned by clangd's semantic tokens)
This commit is contained in:
parent
ed5eb725f9
commit
1f72069b42
1 changed files with 12 additions and 1 deletions
|
@ -2,6 +2,10 @@
|
||||||
(field_identifier) @property
|
(field_identifier) @property
|
||||||
(namespace_identifier) @namespace
|
(namespace_identifier) @namespace
|
||||||
|
|
||||||
|
(concept_definition
|
||||||
|
(identifier) @concept)
|
||||||
|
|
||||||
|
|
||||||
(call_expression
|
(call_expression
|
||||||
function: (qualified_identifier
|
function: (qualified_identifier
|
||||||
name: (identifier) @function))
|
name: (identifier) @function))
|
||||||
|
@ -64,6 +68,14 @@
|
||||||
|
|
||||||
(auto) @type
|
(auto) @type
|
||||||
(type_identifier) @type
|
(type_identifier) @type
|
||||||
|
type :(primitive_type) @type.primitive
|
||||||
|
|
||||||
|
(requires_clause
|
||||||
|
constraint: (template_type
|
||||||
|
name: (type_identifier) @concept))
|
||||||
|
|
||||||
|
(attribute
|
||||||
|
name: (identifier) @keyword)
|
||||||
|
|
||||||
((identifier) @constant
|
((identifier) @constant
|
||||||
(#match? @constant "^_*[A-Z][A-Z\\d_]*$"))
|
(#match? @constant "^_*[A-Z][A-Z\\d_]*$"))
|
||||||
|
@ -119,7 +131,6 @@
|
||||||
"using"
|
"using"
|
||||||
"virtual"
|
"virtual"
|
||||||
"while"
|
"while"
|
||||||
(primitive_type)
|
|
||||||
(sized_type_specifier)
|
(sized_type_specifier)
|
||||||
(storage_class_specifier)
|
(storage_class_specifier)
|
||||||
(type_qualifier)
|
(type_qualifier)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue