mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-02 11:36:54 -04:00
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.
160 lines
2.9 KiB
Scheme
160 lines
2.9 KiB
Scheme
; inherits: c
|
|
|
|
((identifier) @field
|
|
(#match? @field "^_"))
|
|
|
|
((identifier) @field
|
|
(#match? @field "^m_"))
|
|
|
|
((identifier) @field
|
|
(#match? @field "_$"))
|
|
|
|
(parameter_declaration
|
|
declarator: (reference_declarator) @parameter)
|
|
; function(Foo ...foo)
|
|
(variadic_parameter_declaration
|
|
declarator: (variadic_declarator
|
|
(_) @parameter))
|
|
; int foo = 0
|
|
(optional_parameter_declaration
|
|
declarator: (_) @parameter)
|
|
|
|
;(field_expression) @parameter ;; How to highlight this?
|
|
(template_function
|
|
name: (identifier) @function)
|
|
|
|
(((field_expression
|
|
(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))
|
|
|
|
|
|
((identifier) @type
|
|
(#match? @type "^[A-Z]")
|
|
(#not-has-parent? @type function_declarator))
|
|
|
|
(namespace_identifier) @namespace
|
|
((namespace_identifier) @type
|
|
(#match? @type "^[A-Z]"))
|
|
((namespace_identifier) @constant
|
|
(#match? @constant "^[A-Z][A-Z_0-9]*$"))
|
|
(namespace_definition
|
|
name: (identifier) @namespace)
|
|
|
|
(destructor_name
|
|
name: (_) @function)
|
|
|
|
(function_declarator
|
|
declarator: (scoped_identifier
|
|
name: (identifier) @function))
|
|
((function_declarator
|
|
declarator: (scoped_identifier
|
|
name: (identifier) @constructor))
|
|
(#match? @constructor "^[A-Z]"))
|
|
|
|
(operator_name) @function
|
|
|
|
(call_expression
|
|
function: (scoped_identifier
|
|
name: (identifier) @function))
|
|
|
|
(call_expression
|
|
function: (field_expression
|
|
field: (field_identifier) @function))
|
|
|
|
((call_expression
|
|
function: (scoped_identifier
|
|
name: (identifier) @constructor))
|
|
(#match? @constructor "^[A-Z]"))
|
|
|
|
((call_expression
|
|
function: (field_expression
|
|
field: (field_identifier) @constructor))
|
|
(#match? @constructor "^[A-Z]"))
|
|
|
|
;; constructing a type in a intizializer list: Constructor (): **SuperType (1)**
|
|
((field_initializer
|
|
(field_identifier) @constructor
|
|
(argument_list))
|
|
(#match? @constructor "^[A-Z]"))
|
|
|
|
|
|
; Constants
|
|
|
|
(this) @variable.builtin
|
|
(nullptr) @constant
|
|
|
|
(true) @boolean
|
|
(false) @boolean
|
|
|
|
; Literals
|
|
|
|
(raw_string_literal) @string
|
|
|
|
; Keywords
|
|
|
|
[
|
|
"try"
|
|
"catch"
|
|
"noexcept"
|
|
"throw"
|
|
] @exception
|
|
|
|
|
|
[
|
|
"class"
|
|
"decltype"
|
|
"constexpr"
|
|
"explicit"
|
|
"final"
|
|
"friend"
|
|
"mutable"
|
|
"namespace"
|
|
"override"
|
|
"private"
|
|
"protected"
|
|
"public"
|
|
"template"
|
|
"typename"
|
|
"using"
|
|
"virtual"
|
|
(auto)
|
|
] @keyword
|
|
|
|
[
|
|
"new"
|
|
"delete"
|
|
|
|
;; these keywords are not supported by the parser
|
|
;"eq"
|
|
;"not_eq"
|
|
;
|
|
;"compl"
|
|
;"and"
|
|
;"or"
|
|
;
|
|
;"bitand"
|
|
;"bitand_eq"
|
|
;"bitor"
|
|
;"bitor_eq"
|
|
;"xor"
|
|
;"xor_eq"
|
|
] @keyword.operator
|
|
|
|
"::" @operator
|
|
"..." @operator
|
|
|
|
; Annotations (not fully supported by parser)
|
|
|
|
((ERROR) @attribute
|
|
(#vim-match? @attribute "\[?\[.*\]\]?.*$"))
|
|
(attribute) @attribute
|