From 167ce6339fb672af9bfd9b5e21a4d18b2f4fb253 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sat, 23 May 2020 21:02:43 +0200 Subject: Add C++ highlights.scm --- queries/cpp/highlights.scm | 97 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 queries/cpp/highlights.scm (limited to 'queries/cpp') diff --git a/queries/cpp/highlights.scm b/queries/cpp/highlights.scm new file mode 100644 index 000000000..e3bce91cb --- /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_1-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) @function)) +(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 +(class_specifier) + +; Constants + +;(this) @constant.builtin +(this) @keyword +(nullptr) @constant + +(true) @boolean +(false) @boolean + +; Keywords + +"catch" @exception +"class" @keyword +"constexpr" @keyword +"delete" @operator +"explicit" @keyword +"final" @exception +"friend" @keyword +"mutable" @keyword +"namespace" @keyword +"noexcept" @keyword +"new" @operator +"override" @keyword +"private" @keyword +"protected" @keyword +"public" @keyword +"template" @keyword +"throw" @keyword +"try" @exception +"typename" @keyword +"using" @keyword +"virtual" @keyword -- cgit v1.2.3-70-g09d2 From 1badceea813d321d0d58319d5fc5dde07e98f18f Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sat, 23 May 2020 21:23:05 +0200 Subject: Add cpp/locals.scm --- queries/cpp/highlights.scm | 11 ++++++++--- queries/cpp/locals.scm | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 queries/cpp/locals.scm (limited to 'queries/cpp') diff --git a/queries/cpp/highlights.scm b/queries/cpp/highlights.scm index e3bce91cb..be79098c9 100644 --- a/queries/cpp/highlights.scm +++ b/queries/cpp/highlights.scm @@ -61,7 +61,11 @@ (match? @constructor "^[A-Z]")) (auto) @keyword -(class_specifier) + +;; Parameters +; normals +(parameter_list + (parameter_declaration) @parameter) ; Constants @@ -77,14 +81,14 @@ "catch" @exception "class" @keyword "constexpr" @keyword -"delete" @operator +"delete" @keyword "explicit" @keyword "final" @exception "friend" @keyword "mutable" @keyword "namespace" @keyword "noexcept" @keyword -"new" @operator +"new" @keyword "override" @keyword "private" @keyword "protected" @keyword @@ -95,3 +99,4 @@ "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..00268442c --- /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) -- cgit v1.2.3-70-g09d2 From 148ad160e8be09b29a2e9547f4814b85147639a6 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sat, 23 May 2020 21:50:52 +0200 Subject: Make =,~,! operators in C highlights --- queries/c/highlights.scm | 10 ++++++++++ queries/cpp/highlights.scm | 5 ----- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'queries/cpp') diff --git a/queries/c/highlights.scm b/queries/c/highlights.scm index e758b0ed4..307feb751 100644 --- a/queries/c/highlights.scm +++ b/queries/c/highlights.scm @@ -35,14 +35,20 @@ "->" @operator "!=" @operator "*" @operator +"/" @operator "&" @operator "&&" @operator "+" @operator "++" @operator "+=" @operator "<" @operator +"<=" @operator "==" @operator +"=" @operator +"~" @operator ">" @operator +">=" @operator +"!" @operator "||" @operator "." @delimiter @@ -79,4 +85,8 @@ (comment) @comment +;; Parameters +(parameter_list + (parameter_declaration) @parameter) + (ERROR) @error diff --git a/queries/cpp/highlights.scm b/queries/cpp/highlights.scm index be79098c9..d98099185 100644 --- a/queries/cpp/highlights.scm +++ b/queries/cpp/highlights.scm @@ -62,11 +62,6 @@ (auto) @keyword -;; Parameters -; normals -(parameter_list - (parameter_declaration) @parameter) - ; Constants ;(this) @constant.builtin -- cgit v1.2.3-70-g09d2 From a5fc7b13ccfbc189deea031e692ba14b0e686279 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sun, 7 Jun 2020 13:13:24 +0200 Subject: Update C/C++ highlights to new query syntax --- queries/c/highlights.scm | 5 +++-- queries/c/locals.scm | 2 +- queries/cpp/highlights.scm | 22 +++++++++++----------- queries/cpp/locals.scm | 4 ++-- 4 files changed, 17 insertions(+), 16 deletions(-) (limited to 'queries/cpp') diff --git a/queries/c/highlights.scm b/queries/c/highlights.scm index 3c2123383..568ebaffa 100644 --- a/queries/c/highlights.scm +++ b/queries/c/highlights.scm @@ -94,10 +94,10 @@ (sized_type_specifier) @type ((identifier) @type - (match? @type "^[A-Z]")) + (#match? @type "^[A-Z]")) ((identifier) @constant - (match? @constant "^[A-Z][A-Z\\d_]+$")) + (#match? @constant "^[A-Z][A-Z\\d_]+$")) (comment) @comment @@ -109,3 +109,4 @@ (identifier)) @parameter (ERROR) @error + diff --git a/queries/c/locals.scm b/queries/c/locals.scm index f7a4b84d2..505db5b57 100644 --- a/queries/c/locals.scm +++ b/queries/c/locals.scm @@ -17,7 +17,7 @@ (declaration declarator: (identifier) @definition.var) (enum_specifier - name: (*) @definition.type + name: (_) @definition.type (enumerator_list (enumerator name: (identifier) @definition.var))) diff --git a/queries/cpp/highlights.scm b/queries/cpp/highlights.scm index d98099185..68e5047ab 100644 --- a/queries/cpp/highlights.scm +++ b/queries/cpp/highlights.scm @@ -1,11 +1,11 @@ ((identifier) @field - (match? @field "^_")) + (#match? @field "^_")) ((identifier) @field - (match? @field "^m_")) + (#match? @field "^m_")) ((identifier) @field - (match? @field "_$")) + (#match? @field "_$")) ;(field_expression) @parameter ;; How to highlight this? (template_function @@ -21,12 +21,12 @@ (namespace_identifier) @constant ((namespace_identifier) @type - (match? @type "^[A-Z]")) + (#match? @type "^[A-Z]")) ((namespace_identifier) @constant - (match? @constant "^[A-Z][A-Z_1-9]*$")) + (#match? @constant "^[A-Z][A-Z_1-9]*$")) (destructor_name - name: (*) @function) + name: (_) @function) (function_declarator declarator: (scoped_identifier @@ -34,7 +34,7 @@ ((function_declarator declarator: (scoped_identifier name: (identifier) @constructor)) - (match? @constructor "^[A-Z]")) + (#match? @constructor "^[A-Z]")) (call_expression function: (scoped_identifier @@ -47,18 +47,18 @@ ((call_expression function: (scoped_identifier name: (identifier) @constructor)) -(match? @constructor "^[A-Z]")) +(#match? @constructor "^[A-Z]")) ((call_expression function: (field_expression - field: (field_identifier) @function)) -(match? @function "^[A-Z]")) + 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]")) + (#match? @constructor "^[A-Z]")) (auto) @keyword diff --git a/queries/cpp/locals.scm b/queries/cpp/locals.scm index 00268442c..061153c04 100644 --- a/queries/cpp/locals.scm +++ b/queries/cpp/locals.scm @@ -41,9 +41,9 @@ ;; Control structures (try_statement - body: (*) @scope) + body: (_) @scope) (catch_clause) @scope (destructor_name - name: (*) @constructor) + name: (_) @constructor) -- cgit v1.2.3-70-g09d2 From 8bc00cf02a5bc73541ba76ad8ea70fd928fffce2 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sun, 14 Jun 2020 15:12:38 +0200 Subject: Change regexes in C/C++ highlights --- queries/c/highlights.scm | 2 +- queries/cpp/highlights.scm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'queries/cpp') diff --git a/queries/c/highlights.scm b/queries/c/highlights.scm index 568ebaffa..0d718c223 100644 --- a/queries/c/highlights.scm +++ b/queries/c/highlights.scm @@ -97,7 +97,7 @@ (#match? @type "^[A-Z]")) ((identifier) @constant - (#match? @constant "^[A-Z][A-Z\\d_]+$")) + (#match? @constant "^[A-Z][A-Z0-9_]+$")) (comment) @comment diff --git a/queries/cpp/highlights.scm b/queries/cpp/highlights.scm index 68e5047ab..92909f4d9 100644 --- a/queries/cpp/highlights.scm +++ b/queries/cpp/highlights.scm @@ -23,7 +23,7 @@ ((namespace_identifier) @type (#match? @type "^[A-Z]")) ((namespace_identifier) @constant - (#match? @constant "^[A-Z][A-Z_1-9]*$")) + (#match? @constant "^[A-Z][A-Z_0-9]*$")) (destructor_name name: (_) @function) -- cgit v1.2.3-70-g09d2