mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-11 16:00:02 -04:00
highlights(cpp): add support for concepts
Requires https://github.com/tree-sitter/tree-sitter-cpp/pull/138
This commit is contained in:
parent
4cf688ee68
commit
db01c82b08
3 changed files with 28 additions and 2 deletions
|
|
@ -27,13 +27,13 @@
|
||||||
"revision": "4fd115d3bb7046cd094f21bfe5766c302dbf64cd"
|
"revision": "4fd115d3bb7046cd094f21bfe5766c302dbf64cd"
|
||||||
},
|
},
|
||||||
"cpp": {
|
"cpp": {
|
||||||
"revision": "e8dcc9d2b404c542fd236ea5f7208f90be8a6e89"
|
"revision": "049c2a4edeb6c19bacefb4d40aa03c6fdc175575"
|
||||||
},
|
},
|
||||||
"css": {
|
"css": {
|
||||||
"revision": "a03f1d2d1dfbf6f8e0fdca5f9ff030228241eb57"
|
"revision": "a03f1d2d1dfbf6f8e0fdca5f9ff030228241eb57"
|
||||||
},
|
},
|
||||||
"cuda": {
|
"cuda": {
|
||||||
"revision": "bc20ed7a36031437a69a88ef368af4b9f1ecec70"
|
"revision": "61de33bc41231a2e7c1970542c505a42d62c98eb"
|
||||||
},
|
},
|
||||||
"d": {
|
"d": {
|
||||||
"revision": "c2fbf21bd3aa45495fe13247e040ad5815250032"
|
"revision": "c2fbf21bd3aa45495fe13247e040ad5815250032"
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@
|
||||||
(function_declarator
|
(function_declarator
|
||||||
declarator: (field_identifier) @method)
|
declarator: (field_identifier) @method)
|
||||||
|
|
||||||
|
(concept_definition
|
||||||
|
name: (identifier) @type)
|
||||||
|
|
||||||
(namespace_identifier) @namespace
|
(namespace_identifier) @namespace
|
||||||
((namespace_identifier) @type
|
((namespace_identifier) @type
|
||||||
|
|
@ -123,6 +125,8 @@
|
||||||
"using"
|
"using"
|
||||||
"virtual"
|
"virtual"
|
||||||
"co_await"
|
"co_await"
|
||||||
|
"concept"
|
||||||
|
"requires"
|
||||||
(auto)
|
(auto)
|
||||||
] @keyword
|
] @keyword
|
||||||
|
|
||||||
|
|
|
||||||
22
tests/query/highlights/cpp/concepts.cpp
Normal file
22
tests/query/highlights/cpp/concepts.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
concept Derived = std::is_base_of<U, T>::value;
|
||||||
|
// ^ keyword
|
||||||
|
// ^ type
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
concept Hashable = requires(T a) {
|
||||||
|
// ^ keyword
|
||||||
|
// ^ parameter
|
||||||
|
// ^ type
|
||||||
|
{ std::hash<T>{}(a) } -> std::convertible_to<std::size_t>;
|
||||||
|
typename CommonType<T, U>; // CommonType<T, U> is valid and names a type
|
||||||
|
{ CommonType<T, U>{std::forward<T>(t)} };
|
||||||
|
{ CommonType<T, U>{std::forward<U>(u)} };
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
requires requires (T x) { x + x; } // ad-hoc constraint, note keyword used twice
|
||||||
|
// ^ keyword
|
||||||
|
T add(T a, T b) { return a + b; }
|
||||||
Loading…
Add table
Add a link
Reference in a new issue