aboutsummaryrefslogtreecommitdiffstats
path: root/queries/cpp
diff options
context:
space:
mode:
authorSteven Sojka <Steven.Sojka@tdameritrade.com>2020-06-15 07:05:20 -0500
committerSteven Sojka <Steven.Sojka@tdameritrade.com>2020-06-15 07:05:20 -0500
commit4551b0e1c914f8f0dabdec4010c86c163c08fee2 (patch)
tree09f781e5970756fb5a092a37fcbc4274f9664b10 /queries/cpp
parentfeat(queries): add typescript and javascript queries (diff)
parentMerge pull request #63 from theHamsta/cpp-locals (diff)
downloadnvim-treesitter-4551b0e1c914f8f0dabdec4010c86c163c08fee2.tar
nvim-treesitter-4551b0e1c914f8f0dabdec4010c86c163c08fee2.tar.gz
nvim-treesitter-4551b0e1c914f8f0dabdec4010c86c163c08fee2.tar.bz2
nvim-treesitter-4551b0e1c914f8f0dabdec4010c86c163c08fee2.tar.lz
nvim-treesitter-4551b0e1c914f8f0dabdec4010c86c163c08fee2.tar.xz
nvim-treesitter-4551b0e1c914f8f0dabdec4010c86c163c08fee2.tar.zst
nvim-treesitter-4551b0e1c914f8f0dabdec4010c86c163c08fee2.zip
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
Diffstat (limited to 'queries/cpp')
-rw-r--r--queries/cpp/highlights.scm97
-rw-r--r--queries/cpp/locals.scm49
2 files changed, 146 insertions, 0 deletions
diff --git a/queries/cpp/highlights.scm b/queries/cpp/highlights.scm
new file mode 100644
index 000000000..92909f4d9
--- /dev/null
+++ b/queries/cpp/highlights.scm
@@ -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
diff --git a/queries/cpp/locals.scm b/queries/cpp/locals.scm
new file mode 100644
index 000000000..061153c04
--- /dev/null
+++ b/queries/cpp/locals.scm
@@ -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)