diff options
author | Christian Clason <c.clason@uni-graz.at> | 2023-03-31 16:11:17 +0200 |
---|---|---|
committer | Christian Clason <c.clason@uni-graz.at> | 2023-04-01 12:19:15 +0200 |
commit | 2a298f2e48eb081f2e3b58068af589b82fe76a18 (patch) | |
tree | c1e159eabb8459e9edede6cb7661175f1f8ee1cf /runtime/queries/c | |
parent | 90fdaf55c913d07bc80eec6442b02d8c001659b4 (diff) | |
download | rneovim-2a298f2e48eb081f2e3b58068af589b82fe76a18.tar.gz rneovim-2a298f2e48eb081f2e3b58068af589b82fe76a18.tar.bz2 rneovim-2a298f2e48eb081f2e3b58068af589b82fe76a18.zip |
fix(treesitter): update queries from nvim-treesitter
remove self-injection for C preprocessor macros (can be very slow)
Diffstat (limited to 'runtime/queries/c')
-rw-r--r-- | runtime/queries/c/highlights.scm | 115 | ||||
-rw-r--r-- | runtime/queries/c/injections.scm | 4 |
2 files changed, 76 insertions, 43 deletions
diff --git a/runtime/queries/c/highlights.scm b/runtime/queries/c/highlights.scm index 33e6df74ab..dee70f9cc7 100644 --- a/runtime/queries/c/highlights.scm +++ b/runtime/queries/c/highlights.scm @@ -1,22 +1,19 @@ -(identifier) @variable +; Lower priority to prefer @parameter when identifier appears in parameter_declaration. +((identifier) @variable (#set! "priority" 95)) [ - "const" "default" "enum" - "extern" - "inline" - "return" - "sizeof" - "static" "struct" "typedef" "union" - "volatile" "goto" - "register" ] @keyword +"sizeof" @keyword.operator + +"return" @keyword.return + [ "while" "for" @@ -32,7 +29,6 @@ "switch" ] @conditional -"#define" @constant.macro [ "#if" "#ifdef" @@ -41,10 +37,18 @@ "#elif" "#endif" (preproc_directive) -] @keyword +] @preproc + +"#define" @define "#include" @include +[ ";" ":" "," ] @punctuation.delimiter + +"..." @punctuation.special + +[ "(" ")" "[" "]" "{" "}"] @punctuation.bracket + [ "=" @@ -62,6 +66,7 @@ ">>" "->" + "." "<" "<=" @@ -88,35 +93,25 @@ "++" ] @operator +;; Make sure the comma operator is given a highlight group after the comma +;; punctuator so the operator is highlighted properly. +(comma_expression [ "," ] @operator) + [ (true) (false) ] @boolean -[ "." ";" ":" "," ] @punctuation.delimiter - -(conditional_expression [ "?" ":" ] @conditional) - - -[ "(" ")" "[" "]" "{" "}"] @punctuation.bracket +(conditional_expression [ "?" ":" ] @conditional.ternary) (string_literal) @string -(string_literal) @spell (system_lib_string) @string +(escape_sequence) @string.escape (null) @constant.builtin (number_literal) @number -(char_literal) @number +(char_literal) @character -(call_expression - function: (identifier) @function) -(call_expression - function: (field_expression - field: (field_identifier) @function)) -(function_declarator - declarator: (identifier) @function) -(preproc_function_def - name: (identifier) @function.macro) [ (preproc_arg) (preproc_defined) @@ -126,18 +121,32 @@ (statement_identifier) @label [ -(type_identifier) -(primitive_type) -(sized_type_specifier) -(type_descriptor) - ] @type + (type_identifier) + (sized_type_specifier) + (type_descriptor) +] @type + +(storage_class_specifier) @storageclass + +(type_qualifier) @type.qualifier + +(linkage_specification + "extern" @storageclass) -(declaration (type_qualifier) @type) -(cast_expression type: (type_descriptor) @type) -(sizeof_expression value: (parenthesized_expression (identifier) @type)) +(type_definition + declarator: (type_identifier) @type.definition) + +(primitive_type) @type.builtin ((identifier) @constant - (#match? @constant "^[A-Z][A-Z0-9_]+$")) + (#lua-match? @constant "^[A-Z][A-Z0-9_]+$")) +(enumerator + name: (identifier) @constant) +(case_statement + value: (identifier) @constant) + +((identifier) @constant.builtin + (#any-of? @constant.builtin "stderr" "stdin" "stdout")) ;; Preproc def / undef (preproc_def @@ -147,9 +156,20 @@ argument: (_) @constant (#eq? @_u "#undef")) +(call_expression + function: (identifier) @function.call) +(call_expression + function: (field_expression + field: (field_identifier) @function.call)) +(function_declarator + declarator: (identifier) @function) +(preproc_function_def + name: (identifier) @function.macro) + +(comment) @comment @spell -(comment) @comment -(comment) @spell +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) ;; Parameters (parameter_declaration @@ -158,7 +178,20 @@ (parameter_declaration declarator: (pointer_declarator) @parameter) -(preproc_params - (identifier)) @parameter +(preproc_params (identifier) @parameter) + +[ + "__attribute__" + "__cdecl" + "__clrcall" + "__stdcall" + "__fastcall" + "__thiscall" + "__vectorcall" + "_unaligned" + "__unaligned" + "__declspec" + (attribute_declaration) +] @attribute (ERROR) @error diff --git a/runtime/queries/c/injections.scm b/runtime/queries/c/injections.scm index 84ae33683e..3b99c7a444 100644 --- a/runtime/queries/c/injections.scm +++ b/runtime/queries/c/injections.scm @@ -1,5 +1,5 @@ -((preproc_arg) @injection.content - (#set! injection.language "c")) +; ((preproc_arg) @injection.content +; (#set! injection.language "c")) ; ((comment) @injection.content ; (#set! injection.language "comment")) |