mirror of
https://github.com/neovim/neovim
synced 2025-07-26 00:01:46 +00:00
feat(treesitter): update C queries from upstream
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
; Lower priority to prefer @parameter when identifier appears in parameter_declaration.
|
; Lower priority to prefer @parameter when identifier appears in parameter_declaration.
|
||||||
((identifier) @variable (#set! "priority" 95))
|
((identifier) @variable (#set! "priority" 95))
|
||||||
|
(preproc_def (preproc_arg) @variable)
|
||||||
|
|
||||||
[
|
[
|
||||||
"default"
|
"default"
|
||||||
@ -16,6 +17,7 @@
|
|||||||
"sizeof"
|
"sizeof"
|
||||||
"offsetof"
|
"offsetof"
|
||||||
] @keyword.operator
|
] @keyword.operator
|
||||||
|
(alignof_expression . _ @keyword.operator)
|
||||||
|
|
||||||
"return" @keyword.return
|
"return" @keyword.return
|
||||||
|
|
||||||
@ -141,8 +143,9 @@
|
|||||||
(storage_class_specifier) @storageclass
|
(storage_class_specifier) @storageclass
|
||||||
|
|
||||||
[
|
[
|
||||||
(type_qualifier)
|
(type_qualifier)
|
||||||
(gnu_asm_qualifier)
|
(gnu_asm_qualifier)
|
||||||
|
"__extension__"
|
||||||
] @type.qualifier
|
] @type.qualifier
|
||||||
|
|
||||||
(linkage_specification
|
(linkage_specification
|
||||||
@ -157,13 +160,52 @@
|
|||||||
|
|
||||||
((identifier) @constant
|
((identifier) @constant
|
||||||
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
|
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
|
||||||
|
(preproc_def (preproc_arg) @constant
|
||||||
|
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
|
||||||
(enumerator
|
(enumerator
|
||||||
name: (identifier) @constant)
|
name: (identifier) @constant)
|
||||||
(case_statement
|
(case_statement
|
||||||
value: (identifier) @constant)
|
value: (identifier) @constant)
|
||||||
|
|
||||||
((identifier) @constant.builtin
|
((identifier) @constant.builtin
|
||||||
(#any-of? @constant.builtin "stderr" "stdin" "stdout"))
|
(#any-of? @constant.builtin
|
||||||
|
"stderr" "stdin" "stdout"
|
||||||
|
"__FILE__" "__LINE__" "__DATE__" "__TIME__"
|
||||||
|
"__STDC__" "__STDC_VERSION__" "__STDC_HOSTED__"
|
||||||
|
"__cplusplus" "__OBJC__" "__ASSEMBLER__"
|
||||||
|
"__BASE_FILE__" "__FILE_NAME__" "__INCLUDE_LEVEL__"
|
||||||
|
"__TIMESTAMP__" "__clang__" "__clang_major__"
|
||||||
|
"__clang_minor__" "__clang_patchlevel__"
|
||||||
|
"__clang_version__" "__clang_literal_encoding__"
|
||||||
|
"__clang_wide_literal_encoding__"
|
||||||
|
"__FUNCTION__" "__func__" "__PRETTY_FUNCTION__"
|
||||||
|
"__VA_ARGS__" "__VA_OPT__"))
|
||||||
|
(preproc_def (preproc_arg) @constant.builtin
|
||||||
|
(#any-of? @constant.builtin
|
||||||
|
"stderr" "stdin" "stdout"
|
||||||
|
"__FILE__" "__LINE__" "__DATE__" "__TIME__"
|
||||||
|
"__STDC__" "__STDC_VERSION__" "__STDC_HOSTED__"
|
||||||
|
"__cplusplus" "__OBJC__" "__ASSEMBLER__"
|
||||||
|
"__BASE_FILE__" "__FILE_NAME__" "__INCLUDE_LEVEL__"
|
||||||
|
"__TIMESTAMP__" "__clang__" "__clang_major__"
|
||||||
|
"__clang_minor__" "__clang_patchlevel__"
|
||||||
|
"__clang_version__" "__clang_literal_encoding__"
|
||||||
|
"__clang_wide_literal_encoding__"
|
||||||
|
"__FUNCTION__" "__func__" "__PRETTY_FUNCTION__"
|
||||||
|
"__VA_ARGS__" "__VA_OPT__"))
|
||||||
|
|
||||||
|
(attribute_specifier
|
||||||
|
(argument_list (identifier) @variable.builtin))
|
||||||
|
((attribute_specifier
|
||||||
|
(argument_list (call_expression
|
||||||
|
function: (identifier) @variable.builtin))))
|
||||||
|
|
||||||
|
((call_expression
|
||||||
|
function: (identifier) @function.builtin)
|
||||||
|
(#lua-match? @function.builtin "^__builtin_"))
|
||||||
|
((call_expression
|
||||||
|
function: (identifier) @function.builtin)
|
||||||
|
(#has-ancestor? @function.builtin attribute_specifier))
|
||||||
|
|
||||||
;; Preproc def / undef
|
;; Preproc def / undef
|
||||||
(preproc_def
|
(preproc_def
|
||||||
@ -196,6 +238,9 @@
|
|||||||
(parameter_declaration
|
(parameter_declaration
|
||||||
declarator: (identifier) @parameter)
|
declarator: (identifier) @parameter)
|
||||||
|
|
||||||
|
(parameter_declaration
|
||||||
|
declarator: (array_declarator) @parameter)
|
||||||
|
|
||||||
(parameter_declaration
|
(parameter_declaration
|
||||||
declarator: (pointer_declarator) @parameter)
|
declarator: (pointer_declarator) @parameter)
|
||||||
|
|
||||||
|
@ -1,5 +1,21 @@
|
|||||||
; ((preproc_arg) @injection.content
|
((preproc_def
|
||||||
; (#set! injection.language "c"))
|
(preproc_arg) @injection.content)
|
||||||
|
(#lua-match? @injection.content "\n")
|
||||||
|
(#set! injection.language "c"))
|
||||||
|
|
||||||
|
(preproc_function_def
|
||||||
|
(preproc_arg) @injection.content
|
||||||
|
(#set! injection.language "c"))
|
||||||
|
|
||||||
|
(preproc_call
|
||||||
|
(preproc_arg) @injection.content
|
||||||
|
(#set! injection.language "c"))
|
||||||
|
|
||||||
; ((comment) @injection.content
|
; ((comment) @injection.content
|
||||||
; (#set! injection.language "comment"))
|
; (#set! injection.language "comment"))
|
||||||
|
|
||||||
|
; TODO: add when asm is added
|
||||||
|
; (gnu_asm_expression assembly_code: (string_literal) @injection.content
|
||||||
|
; (#set! injection.language "asm"))
|
||||||
|
; (gnu_asm_expression assembly_code: (concatenated_string (string_literal) @injection.content)
|
||||||
|
; (#set! injection.language "asm"))
|
||||||
|
@ -580,9 +580,9 @@ describe('treesitter highlighting (C)', function()
|
|||||||
-- expect everything to have Constant highlight
|
-- expect everything to have Constant highlight
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
{12:int}{8: x = INT_MAX;} |
|
{12:int}{8: x = INT_MAX;} |
|
||||||
{8:#define READ_STRING(x, y) (char *)read_string((x), (size_t)(y))} |
|
{8:#define READ_STRING(x, y) (}{12:char}{8: *)read_string((x), (}{12:size_t}{8:)(y))} |
|
||||||
{8:#define foo void main() { \} |
|
{8:#define foo }{12:void}{8: main() { \} |
|
||||||
{8: return 42; \} |
|
{8: }{12:return}{8: 42; \} |
|
||||||
{8: }} |
|
{8: }} |
|
||||||
^ |
|
^ |
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
|
Reference in New Issue
Block a user