mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 11:06:54 -04:00
fix(c)!: update C, CPP parsers and queries
also update derived parsers (arduino, cuda, glsl, hlsl, ispc, objc)
This commit is contained in:
parent
203981d288
commit
ad3805f5c3
7 changed files with 68 additions and 93 deletions
|
|
@ -6,7 +6,7 @@
|
|||
"revision": "80ea622cf952a0059e168e5c92a798b2f1925652"
|
||||
},
|
||||
"arduino": {
|
||||
"revision": "4de2f3e6235ee8659ecb7467c16ed13bde7fb272"
|
||||
"revision": "3446bac828d5db2a6cf60ab31813c02ab53547a7"
|
||||
},
|
||||
"astro": {
|
||||
"revision": "e122a8fcd07e808a7b873bfadc2667834067daf1"
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
"revision": "7f1a5df44861291d6951b6b2146a9fef4c226e14"
|
||||
},
|
||||
"c": {
|
||||
"revision": "6adee194587678b250608cdb808544f06bcd26e7"
|
||||
"revision": "ad095896dd223f1c22b85ac5ec84ab11fb732b07"
|
||||
},
|
||||
"c_sharp": {
|
||||
"revision": "1648e21b4f087963abf0101ee5221bb413107b07"
|
||||
|
|
@ -69,13 +69,13 @@
|
|||
"revision": "f4b3cbc8b0bd4e13035d39940fef09f1392e8739"
|
||||
},
|
||||
"cpp": {
|
||||
"revision": "0e7b7a02b6074859b51c1973eb6a8275b3315b1d"
|
||||
"revision": "f88bf81238ec2842682e4d1dac0acf3b43b686e9"
|
||||
},
|
||||
"css": {
|
||||
"revision": "5f2c94b897601b4029fedcce7db4c6d76ce8a128"
|
||||
},
|
||||
"cuda": {
|
||||
"revision": "c5befe09c99f5e88190574676ffa8eb29775d410"
|
||||
"revision": "2af3d43cd96dd3f3c3868095222c7f5e2462b3ab"
|
||||
},
|
||||
"cue": {
|
||||
"revision": "0deecf48944aa54bb73e5383ba8acfbf9f2c44b4"
|
||||
|
|
@ -174,7 +174,7 @@
|
|||
"revision": "d3031a8294bf331600d5046b1d14e690a0d8ba0c"
|
||||
},
|
||||
"glsl": {
|
||||
"revision": "7d76863f2126ed3b246fead68f9591760d546c94"
|
||||
"revision": "34e0657e37323874c6b67c718a0f83410c4602cf"
|
||||
},
|
||||
"go": {
|
||||
"revision": "8c8007eaee47702bb0291a3c7aeb004909baab4d"
|
||||
|
|
@ -219,7 +219,7 @@
|
|||
"revision": "02fa3b79b3ff9a296066da6277adfc3f26cbc9e0"
|
||||
},
|
||||
"hlsl": {
|
||||
"revision": "b8fab02e808bab41c49829fb5e4fb0ce7eab8d1a"
|
||||
"revision": "20c40a3f1bb68c596f56bb0c0290008b9d4f58dd"
|
||||
},
|
||||
"hocon": {
|
||||
"revision": "c390f10519ae69fdb03b3e5764f5592fb6924bcc"
|
||||
|
|
@ -243,7 +243,7 @@
|
|||
"revision": "1a0ce072ebf3afac7d5603d9a95bb7c9a6709b44"
|
||||
},
|
||||
"ispc": {
|
||||
"revision": "848e58874ffa2f7e540a6ec01ab9652b26995f37"
|
||||
"revision": "0bdbb03d9abde78d8be2f2199e57119b2c7f8fd7"
|
||||
},
|
||||
"janet_simple": {
|
||||
"revision": "bd9cbaf1ea8b942dfd58e68df10c9a378ab3d2b6"
|
||||
|
|
@ -345,7 +345,7 @@
|
|||
"revision": "1a305093569632de50f9a316ff843dcda25b4ef5"
|
||||
},
|
||||
"objc": {
|
||||
"revision": "6d876afade2d5e70d394aaf994321c78297e3607"
|
||||
"revision": "77e28aeaede824a5f4aa501fb5f3138ab1019b9f"
|
||||
},
|
||||
"ocaml": {
|
||||
"revision": "694c57718fd85d514f8b81176038e7a4cfabcaaf"
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@
|
|||
(preproc_else)
|
||||
(preproc_ifdef)
|
||||
(initializer_list)
|
||||
(gnu_asm_expression)
|
||||
] @fold
|
||||
|
||||
(compound_statement
|
||||
(compound_statement
|
||||
(compound_statement) @fold)
|
||||
|
|
|
|||
|
|
@ -8,9 +8,14 @@
|
|||
"typedef"
|
||||
"union"
|
||||
"goto"
|
||||
"asm"
|
||||
"__asm__"
|
||||
] @keyword
|
||||
|
||||
"sizeof" @keyword.operator
|
||||
[
|
||||
"sizeof"
|
||||
"offsetof"
|
||||
] @keyword.operator
|
||||
|
||||
"return" @keyword.return
|
||||
|
||||
|
|
@ -36,6 +41,8 @@
|
|||
"#else"
|
||||
"#elif"
|
||||
"#endif"
|
||||
"#elifdef"
|
||||
"#elifndef"
|
||||
(preproc_directive)
|
||||
] @preproc
|
||||
|
||||
|
|
@ -43,7 +50,7 @@
|
|||
|
||||
"#include" @include
|
||||
|
||||
[ ";" ":" "," ] @punctuation.delimiter
|
||||
[ ";" ":" "," "::" ] @punctuation.delimiter
|
||||
|
||||
"..." @punctuation.special
|
||||
|
||||
|
|
@ -98,8 +105,8 @@
|
|||
(comma_expression [ "," ] @operator)
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
(conditional_expression [ "?" ":" ] @conditional.ternary)
|
||||
|
|
@ -133,7 +140,10 @@
|
|||
|
||||
(storage_class_specifier) @storageclass
|
||||
|
||||
(type_qualifier) @type.qualifier
|
||||
[
|
||||
(type_qualifier)
|
||||
(gnu_asm_qualifier)
|
||||
] @type.qualifier
|
||||
|
||||
(linkage_specification
|
||||
"extern" @storageclass)
|
||||
|
|
@ -193,15 +203,15 @@
|
|||
|
||||
[
|
||||
"__attribute__"
|
||||
"__declspec"
|
||||
"__based"
|
||||
"__cdecl"
|
||||
"__clrcall"
|
||||
"__stdcall"
|
||||
"__fastcall"
|
||||
"__thiscall"
|
||||
"__vectorcall"
|
||||
"_unaligned"
|
||||
"__unaligned"
|
||||
"__declspec"
|
||||
(ms_pointer_modifier)
|
||||
(attribute_declaration)
|
||||
] @attribute
|
||||
|
||||
|
|
|
|||
|
|
@ -15,85 +15,46 @@
|
|||
(_) @indent.begin
|
||||
";" @indent.end)
|
||||
|
||||
(
|
||||
ERROR
|
||||
"for" "(" @indent.begin ";" ";" ")" @indent.end)
|
||||
(
|
||||
(for_statement
|
||||
body: (_) @_body
|
||||
) @indent.begin
|
||||
(#not-has-type? @_body compound_statement)
|
||||
)
|
||||
(ERROR
|
||||
"for" "(" @indent.begin ";" ";" ")" @indent.end)
|
||||
|
||||
(
|
||||
while_statement
|
||||
condition: (_) @indent.begin
|
||||
)
|
||||
(
|
||||
(while_statement
|
||||
body: (_) @_body
|
||||
) @indent.begin
|
||||
(#not-has-type? @_body compound_statement)
|
||||
)
|
||||
((for_statement
|
||||
body: (_) @_body) @indent.begin
|
||||
(#not-has-type? @_body compound_statement))
|
||||
|
||||
(while_statement
|
||||
condition: (_) @indent.begin)
|
||||
|
||||
((while_statement
|
||||
body: (_) @_body) @indent.begin
|
||||
(#not-has-type? @_body compound_statement))
|
||||
|
||||
(
|
||||
(if_statement)
|
||||
(ERROR "else") @indent.begin
|
||||
)
|
||||
.
|
||||
(ERROR "else" @indent.begin))
|
||||
|
||||
(
|
||||
if_statement
|
||||
condition: (_) @indent.begin
|
||||
)
|
||||
;; Make sure all cases of if-else are tagged with @indent.begin
|
||||
;; So we will offset the indents for the else case
|
||||
(
|
||||
(if_statement
|
||||
consequence: (compound_statement)
|
||||
"else" @indent.branch
|
||||
alternative:
|
||||
[
|
||||
[ "{" "}" ] @indent.branch
|
||||
(compound_statement ["{" "}"] @indent.branch)
|
||||
(_)
|
||||
]
|
||||
) @indent.begin
|
||||
)
|
||||
(
|
||||
(if_statement
|
||||
consequence: (_ ";" @indent.end) @_consequence
|
||||
) @indent.begin
|
||||
(#not-has-type? @_consequence compound_statement)
|
||||
)
|
||||
(
|
||||
(if_statement
|
||||
consequence: (_) @_consequence
|
||||
"else" @indent.branch
|
||||
alternative:
|
||||
[
|
||||
[ "{" "}" ] @indent.branch
|
||||
(compound_statement ["{" "}"] @indent.branch)
|
||||
(_)
|
||||
]
|
||||
)
|
||||
(#not-has-type? @_consequence compound_statement)
|
||||
)
|
||||
(if_statement
|
||||
condition: (_) @indent.begin)
|
||||
|
||||
;; Supports if without braces (but not both if-else without braces)
|
||||
((if_statement
|
||||
consequence:
|
||||
(_ ";" @indent.end) @_consequence
|
||||
(#not-has-type? @_consequence compound_statement)
|
||||
alternative:
|
||||
(else_clause
|
||||
"else" @indent.branch
|
||||
[
|
||||
(if_statement (compound_statement) @indent.dedent)? @indent.dedent
|
||||
(compound_statement)? @indent.dedent
|
||||
(_)? @indent.dedent
|
||||
]
|
||||
)?
|
||||
) @indent.begin)
|
||||
|
||||
(else_clause (_ . "{" @indent.branch))
|
||||
|
||||
;; Dedent for chaining if-else statements
|
||||
;; this will go recursively through each if-elseif
|
||||
;; if-elseif -> second `if` is dedented once, indented twice
|
||||
;; if-elseif-elseif -> third `if` is dedented twice, indented 3 times
|
||||
;; -> all are indented once
|
||||
(
|
||||
(if_statement
|
||||
consequence: (_)
|
||||
alternative:
|
||||
[
|
||||
(if_statement consequence: (compound_statement) @indent.dedent)
|
||||
(_)
|
||||
] @indent.dedent
|
||||
)
|
||||
)
|
||||
|
||||
(compound_statement "}" @indent.end)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
(preproc_arg) @c
|
||||
|
||||
(comment) @comment
|
||||
|
||||
; TODO: add when asm is added
|
||||
; (gnu_asm_expression assembly_code: (string_literal) @asm)
|
||||
; (gnu_asm_expression assembly_code: (concatenated_string (string_literal) @asm))
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@
|
|||
; Constants
|
||||
|
||||
(this) @variable.builtin
|
||||
(nullptr) @constant.builtin
|
||||
(null "nullptr" @constant.builtin)
|
||||
|
||||
(true) @boolean
|
||||
(false) @boolean
|
||||
|
|
|
|||
|
|
@ -55,6 +55,5 @@ int baz(int x){
|
|||
else
|
||||
x++;
|
||||
}
|
||||
else
|
||||
return x;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue