mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-02 03:26:52 -04:00
feat!: drop modules, general refactor and cleanup
This commit is contained in:
parent
c13e28f894
commit
2c8f2f2fad
829 changed files with 4905 additions and 8010 deletions
14
runtime/queries/cpp/folds.scm
Normal file
14
runtime/queries/cpp/folds.scm
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
; inherits: c
|
||||
|
||||
[
|
||||
(for_range_loop)
|
||||
(class_specifier)
|
||||
(field_declaration
|
||||
type: (enum_specifier)
|
||||
default_value: (initializer_list))
|
||||
(template_declaration)
|
||||
(namespace_definition)
|
||||
(try_statement)
|
||||
(catch_clause)
|
||||
(lambda_expression)
|
||||
] @fold
|
||||
240
runtime/queries/cpp/highlights.scm
Normal file
240
runtime/queries/cpp/highlights.scm
Normal file
|
|
@ -0,0 +1,240 @@
|
|||
; inherits: c
|
||||
|
||||
((identifier) @field
|
||||
(#lua-match? @field "^m?_.*$"))
|
||||
|
||||
(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?
|
||||
|
||||
(((field_expression
|
||||
(field_identifier) @method)) @_parent
|
||||
(#has-parent? @_parent template_method function_declarator))
|
||||
|
||||
(field_declaration
|
||||
(field_identifier) @field)
|
||||
|
||||
(field_initializer
|
||||
(field_identifier) @property)
|
||||
|
||||
(function_declarator
|
||||
declarator: (field_identifier) @method)
|
||||
|
||||
(concept_definition
|
||||
name: (identifier) @type.definition)
|
||||
|
||||
(alias_declaration
|
||||
name: (type_identifier) @type.definition)
|
||||
|
||||
(auto) @type.builtin
|
||||
|
||||
(namespace_identifier) @namespace
|
||||
((namespace_identifier) @type
|
||||
(#lua-match? @type "^[%u]"))
|
||||
|
||||
(case_statement
|
||||
value: (qualified_identifier (identifier) @constant))
|
||||
|
||||
(using_declaration . "using" . "namespace" . [(qualified_identifier) (identifier)] @namespace)
|
||||
|
||||
(destructor_name
|
||||
(identifier) @method)
|
||||
|
||||
; functions
|
||||
(function_declarator
|
||||
(qualified_identifier
|
||||
(identifier) @function))
|
||||
(function_declarator
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(identifier) @function)))
|
||||
(function_declarator
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(identifier) @function))))
|
||||
((qualified_identifier
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(identifier) @function)))) @_parent
|
||||
(#has-ancestor? @_parent function_declarator))
|
||||
|
||||
(function_declarator
|
||||
(template_function
|
||||
(identifier) @function))
|
||||
|
||||
(operator_name) @function
|
||||
"operator" @function
|
||||
"static_assert" @function.builtin
|
||||
|
||||
(call_expression
|
||||
(qualified_identifier
|
||||
(identifier) @function.call))
|
||||
(call_expression
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(identifier) @function.call)))
|
||||
(call_expression
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(identifier) @function.call))))
|
||||
((qualified_identifier
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(identifier) @function.call)))) @_parent
|
||||
(#has-ancestor? @_parent call_expression))
|
||||
|
||||
(call_expression
|
||||
(template_function
|
||||
(identifier) @function.call))
|
||||
(call_expression
|
||||
(qualified_identifier
|
||||
(template_function
|
||||
(identifier) @function.call)))
|
||||
(call_expression
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(template_function
|
||||
(identifier) @function.call))))
|
||||
(call_expression
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(template_function
|
||||
(identifier) @function.call)))))
|
||||
((qualified_identifier
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(template_function
|
||||
(identifier) @function.call))))) @_parent
|
||||
(#has-ancestor? @_parent call_expression))
|
||||
|
||||
; methods
|
||||
(function_declarator
|
||||
(template_method
|
||||
(field_identifier) @method))
|
||||
(call_expression
|
||||
(field_expression
|
||||
(field_identifier) @method.call))
|
||||
|
||||
; constructors
|
||||
|
||||
((function_declarator
|
||||
(qualified_identifier
|
||||
(identifier) @constructor))
|
||||
(#lua-match? @constructor "^%u"))
|
||||
|
||||
((call_expression
|
||||
function: (identifier) @constructor)
|
||||
(#lua-match? @constructor "^%u"))
|
||||
((call_expression
|
||||
function: (qualified_identifier
|
||||
name: (identifier) @constructor))
|
||||
(#lua-match? @constructor "^%u"))
|
||||
|
||||
((call_expression
|
||||
function: (field_expression
|
||||
field: (field_identifier) @constructor))
|
||||
(#lua-match? @constructor "^%u"))
|
||||
|
||||
;; constructing a type in an initializer list: Constructor (): **SuperType (1)**
|
||||
((field_initializer
|
||||
(field_identifier) @constructor
|
||||
(argument_list))
|
||||
(#lua-match? @constructor "^%u"))
|
||||
|
||||
|
||||
; Constants
|
||||
|
||||
(this) @variable.builtin
|
||||
(null "nullptr" @constant.builtin)
|
||||
|
||||
(true) @boolean
|
||||
(false) @boolean
|
||||
|
||||
; Literals
|
||||
|
||||
(raw_string_literal) @string
|
||||
|
||||
; Keywords
|
||||
|
||||
[
|
||||
"try"
|
||||
"catch"
|
||||
"noexcept"
|
||||
"throw"
|
||||
] @exception
|
||||
|
||||
|
||||
[
|
||||
"class"
|
||||
"decltype"
|
||||
"explicit"
|
||||
"friend"
|
||||
"namespace"
|
||||
"override"
|
||||
"template"
|
||||
"typename"
|
||||
"using"
|
||||
"concept"
|
||||
"requires"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"co_await"
|
||||
] @keyword.coroutine
|
||||
|
||||
[
|
||||
"co_yield"
|
||||
"co_return"
|
||||
] @keyword.coroutine.return
|
||||
|
||||
[
|
||||
"public"
|
||||
"private"
|
||||
"protected"
|
||||
"virtual"
|
||||
"final"
|
||||
] @type.qualifier
|
||||
|
||||
[
|
||||
"new"
|
||||
"delete"
|
||||
|
||||
"xor"
|
||||
"bitand"
|
||||
"bitor"
|
||||
"compl"
|
||||
"not"
|
||||
"xor_eq"
|
||||
"and_eq"
|
||||
"or_eq"
|
||||
"not_eq"
|
||||
"and"
|
||||
"or"
|
||||
] @keyword.operator
|
||||
|
||||
"<=>" @operator
|
||||
|
||||
"::" @punctuation.delimiter
|
||||
|
||||
(template_argument_list
|
||||
["<" ">"] @punctuation.bracket)
|
||||
|
||||
(template_parameter_list
|
||||
["<" ">"] @punctuation.bracket)
|
||||
|
||||
(literal_suffix) @operator
|
||||
11
runtime/queries/cpp/indents.scm
Normal file
11
runtime/queries/cpp/indents.scm
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
; inherits: c
|
||||
|
||||
[
|
||||
(class_specifier)
|
||||
(condition_clause)
|
||||
] @indent.begin
|
||||
|
||||
((field_initializer_list) @indent.begin
|
||||
(#set! indent.start_at_same_line 1))
|
||||
(access_specifier) @indent.branch
|
||||
|
||||
13
runtime/queries/cpp/injections.scm
Normal file
13
runtime/queries/cpp/injections.scm
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
((preproc_arg) @injection.content
|
||||
(#set! injection.language "cpp"))
|
||||
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
((comment) @injection.content
|
||||
(#lua-match? @injection.content "/[*][!<*][^a-zA-Z]")
|
||||
(#set! injection.language "doxygen"))
|
||||
|
||||
(raw_string_literal
|
||||
delimiter: (raw_string_delimiter) @injection.language
|
||||
(raw_string_content) @injection.content)
|
||||
75
runtime/queries/cpp/locals.scm
Normal file
75
runtime/queries/cpp/locals.scm
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
; inherits: c
|
||||
|
||||
;; Parameters
|
||||
(variadic_parameter_declaration
|
||||
declarator: (variadic_declarator
|
||||
(identifier) @definition.parameter))
|
||||
(optional_parameter_declaration
|
||||
declarator: (identifier) @definition.parameter)
|
||||
;; Class / struct definitions
|
||||
(class_specifier) @scope
|
||||
|
||||
(reference_declarator
|
||||
(identifier) @definition.var)
|
||||
|
||||
(variadic_declarator
|
||||
(identifier) @definition.var)
|
||||
|
||||
(struct_specifier
|
||||
name: (qualified_identifier
|
||||
name: (type_identifier) @definition.type))
|
||||
|
||||
(class_specifier
|
||||
name: (type_identifier) @definition.type)
|
||||
|
||||
(concept_definition
|
||||
name: (identifier) @definition.type)
|
||||
|
||||
(class_specifier
|
||||
name: (qualified_identifier
|
||||
name: (type_identifier) @definition.type))
|
||||
|
||||
(alias_declaration
|
||||
name: (type_identifier) @definition.type)
|
||||
|
||||
;template <typename T>
|
||||
(type_parameter_declaration
|
||||
(type_identifier) @definition.type)
|
||||
(template_declaration) @scope
|
||||
|
||||
;; Namespaces
|
||||
(namespace_definition
|
||||
name: (namespace_identifier) @definition.namespace
|
||||
body: (_) @scope)
|
||||
|
||||
(namespace_definition
|
||||
name: (nested_namespace_specifier) @definition.namespace
|
||||
body: (_) @scope)
|
||||
|
||||
((namespace_identifier) @reference
|
||||
(#set! reference.kind "namespace"))
|
||||
|
||||
;; Function definitions
|
||||
(template_function
|
||||
name: (identifier) @definition.function) @scope
|
||||
|
||||
(template_method
|
||||
name: (field_identifier) @definition.method) @scope
|
||||
|
||||
(function_declarator
|
||||
declarator: (qualified_identifier
|
||||
name: (identifier) @definition.function)) @scope
|
||||
|
||||
(field_declaration
|
||||
declarator: (function_declarator
|
||||
(field_identifier) @definition.method))
|
||||
|
||||
(lambda_expression) @scope
|
||||
|
||||
;; Control structures
|
||||
(try_statement
|
||||
body: (_) @scope)
|
||||
|
||||
(catch_clause) @scope
|
||||
|
||||
(requires_expression) @scope
|
||||
Loading…
Add table
Add a link
Reference in a new issue