mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-13 08:50:11 -04:00
Merge branch 'master' into feat/typescript-queries
* master: Change regexes in C/C++ highlights Update C/C++ highlights to new query syntax Add better highlighting for preprocessor functions in C highlights Add operators /=,*=,|=,&= to C highlights Add compound_statement to c queries Add punctuation.bracket/punctuation.delimiter to C highlights Make =,~,! operators in C highlights Add cpp/locals.scm Add @error highlight to c/highlights.scm Add C++ highlights.scm Introduce base languages for queries Add tree-sitter-regex feat(queries): allow for user overrides Update issue templates
This commit is contained in:
commit
4551b0e1c9
11 changed files with 330 additions and 11 deletions
|
|
@ -31,22 +31,42 @@
|
|||
|
||||
"--" @operator
|
||||
"-" @operator
|
||||
"-=" @operator
|
||||
"->" @operator
|
||||
"!=" @operator
|
||||
"*" @operator
|
||||
"/" @operator
|
||||
"&" @operator
|
||||
"&&" @operator
|
||||
"+" @operator
|
||||
"++" @operator
|
||||
"+=" @operator
|
||||
"<" @operator
|
||||
"<=" @operator
|
||||
"==" @operator
|
||||
"=" @operator
|
||||
"~" @operator
|
||||
">" @operator
|
||||
">=" @operator
|
||||
"!" @operator
|
||||
"||" @operator
|
||||
|
||||
"." @delimiter
|
||||
";" @delimiter
|
||||
"-=" @operator
|
||||
"+=" @operator
|
||||
"*=" @operator
|
||||
"/=" @operator
|
||||
"|=" @operator
|
||||
"&=" @operator
|
||||
|
||||
"." @punctuation.delimiter
|
||||
";" @punctuation.delimiter
|
||||
":" @punctuation.delimiter
|
||||
"," @punctuation.delimiter
|
||||
|
||||
"(" @punctuation.bracket
|
||||
")" @punctuation.bracket
|
||||
"[" @punctuation.bracket
|
||||
"]" @punctuation.bracket
|
||||
"{" @punctuation.bracket
|
||||
"}" @punctuation.bracket
|
||||
|
||||
(string_literal) @string
|
||||
(system_lib_string) @string
|
||||
|
|
@ -64,6 +84,8 @@
|
|||
declarator: (identifier) @function)
|
||||
(preproc_function_def
|
||||
name: (identifier) @function.macro)
|
||||
(preproc_arg) @function.macro
|
||||
; TODO (preproc_arg) @embedded
|
||||
|
||||
(field_identifier) @property
|
||||
(statement_identifier) @label
|
||||
|
|
@ -71,7 +93,20 @@
|
|||
(primitive_type) @type
|
||||
(sized_type_specifier) @type
|
||||
|
||||
((identifier) @type
|
||||
(#match? @type "^[A-Z]"))
|
||||
|
||||
((identifier) @constant
|
||||
(match? @constant "^[A-Z][A-Z\\d_]+$"))
|
||||
(#match? @constant "^[A-Z][A-Z0-9_]+$"))
|
||||
|
||||
(comment) @comment
|
||||
|
||||
;; Parameters
|
||||
(parameter_list
|
||||
(parameter_declaration) @parameter)
|
||||
|
||||
(preproc_params
|
||||
(identifier)) @parameter
|
||||
|
||||
(ERROR) @error
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
(declaration
|
||||
declarator: (identifier) @definition.var)
|
||||
(enum_specifier
|
||||
name: (*) @definition.type
|
||||
name: (_) @definition.type
|
||||
(enumerator_list
|
||||
(enumerator name: (identifier) @definition.var)))
|
||||
|
||||
|
|
@ -36,3 +36,4 @@
|
|||
(while_statement) @scope
|
||||
(translation_unit) @scope
|
||||
(function_definition) @scope
|
||||
(compound_statement) @scope ; a block in curly braces
|
||||
|
|
|
|||
97
queries/cpp/highlights.scm
Normal file
97
queries/cpp/highlights.scm
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
((identifier) @field
|
||||
(#match? @field "^_"))
|
||||
|
||||
((identifier) @field
|
||||
(#match? @field "^m_"))
|
||||
|
||||
((identifier) @field
|
||||
(#match? @field "_$"))
|
||||
|
||||
;(field_expression) @parameter ;; How to highlight this?
|
||||
(template_function
|
||||
name: (identifier) @function)
|
||||
|
||||
(template_method
|
||||
name: (field_identifier) @method)
|
||||
|
||||
(template_function
|
||||
name: (scoped_identifier
|
||||
name: (identifier) @function))
|
||||
|
||||
(namespace_identifier) @constant
|
||||
|
||||
((namespace_identifier) @type
|
||||
(#match? @type "^[A-Z]"))
|
||||
((namespace_identifier) @constant
|
||||
(#match? @constant "^[A-Z][A-Z_0-9]*$"))
|
||||
|
||||
(destructor_name
|
||||
name: (_) @function)
|
||||
|
||||
(function_declarator
|
||||
declarator: (scoped_identifier
|
||||
name: (identifier) @function))
|
||||
((function_declarator
|
||||
declarator: (scoped_identifier
|
||||
name: (identifier) @constructor))
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
(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? @function "^[A-Z]"))
|
||||
|
||||
;; constructing a type in a intizializer list: Constructor (): **SuperType (1)**
|
||||
((field_initializer
|
||||
(field_identifier) @constructor
|
||||
(argument_list))
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
(auto) @keyword
|
||||
|
||||
; Constants
|
||||
|
||||
;(this) @constant.builtin
|
||||
(this) @keyword
|
||||
(nullptr) @constant
|
||||
|
||||
(true) @boolean
|
||||
(false) @boolean
|
||||
|
||||
; Keywords
|
||||
|
||||
"catch" @exception
|
||||
"class" @keyword
|
||||
"constexpr" @keyword
|
||||
"delete" @keyword
|
||||
"explicit" @keyword
|
||||
"final" @exception
|
||||
"friend" @keyword
|
||||
"mutable" @keyword
|
||||
"namespace" @keyword
|
||||
"noexcept" @keyword
|
||||
"new" @keyword
|
||||
"override" @keyword
|
||||
"private" @keyword
|
||||
"protected" @keyword
|
||||
"public" @keyword
|
||||
"template" @keyword
|
||||
"throw" @keyword
|
||||
"try" @exception
|
||||
"typename" @keyword
|
||||
"using" @keyword
|
||||
"virtual" @keyword
|
||||
"::" @operator
|
||||
49
queries/cpp/locals.scm
Normal file
49
queries/cpp/locals.scm
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
|
||||
;; Class / struct defintions
|
||||
(class_specifier) @scope
|
||||
(struct_specifier) @scope
|
||||
|
||||
|
||||
(struct_specifier
|
||||
name: (type_identifier) @definition.type)
|
||||
|
||||
(struct_specifier
|
||||
name: (scoped_type_identifier
|
||||
name: (type_identifier) @definition.type) )
|
||||
|
||||
(class_specifier
|
||||
name: (type_identifier) @definition.type)
|
||||
|
||||
(class_specifier
|
||||
name: (scoped_type_identifier
|
||||
name: (type_identifier) @definition.type) )
|
||||
|
||||
;; Function defintions
|
||||
(template_function
|
||||
name: (identifier) @definition.function) @scope
|
||||
|
||||
(template_method
|
||||
name: (field_identifier) @definition.method) @scope
|
||||
|
||||
(template_function
|
||||
name: (scoped_identifier
|
||||
name: (identifier) @definition.function)) @scope
|
||||
|
||||
(function_declarator
|
||||
declarator: (scoped_identifier
|
||||
name: (type_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
|
||||
|
||||
(destructor_name
|
||||
name: (_) @constructor)
|
||||
29
queries/regex/highlights.scm
Normal file
29
queries/regex/highlights.scm
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
;; Forked from tree-sitter-regex
|
||||
;; The MIT License (MIT) Copyright (c) 2014 Max Brunsfeld
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"(?"
|
||||
"(?:"
|
||||
"(?<"
|
||||
">"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
(group_name) @property
|
||||
|
||||
[
|
||||
(identity_escape)
|
||||
(control_letter_escape)
|
||||
(character_class_escape)
|
||||
(control_escape)
|
||||
(start_assertion)
|
||||
(end_assertion)
|
||||
(boundary_assertion)
|
||||
(non_boundary_assertion)
|
||||
] @escape
|
||||
|
||||
[ "*" "+" "|" "=" "<=" "!" "<!" ] @operator
|
||||
Loading…
Add table
Add a link
Reference in a new issue