mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-18 11:20:07 -04:00
feat: add c3 (#7891)
This commit is contained in:
parent
71d2fd1bd4
commit
c59004f1e0
6 changed files with 530 additions and 0 deletions
1
SUPPORTED_LANGUAGES.md
generated
1
SUPPORTED_LANGUAGES.md
generated
|
|
@ -32,6 +32,7 @@ Language | Tier | Queries | Node | Maintainer
|
||||||
[bp](https://github.com/ambroisie/tree-sitter-bp)[^bp] | unstable | `HFIJL` | | @ambroisie
|
[bp](https://github.com/ambroisie/tree-sitter-bp)[^bp] | unstable | `HFIJL` | | @ambroisie
|
||||||
[brightscript](https://github.com/ajdelcimmuto/tree-sitter-brightscript) | unstable | `HFIJ ` | | @ajdelcimmuto
|
[brightscript](https://github.com/ajdelcimmuto/tree-sitter-brightscript) | unstable | `HFIJ ` | | @ajdelcimmuto
|
||||||
[c](https://github.com/tree-sitter/tree-sitter-c) | unstable | `HFIJL` | | @amaanq
|
[c](https://github.com/tree-sitter/tree-sitter-c) | unstable | `HFIJL` | | @amaanq
|
||||||
|
[c3](https://github.com/c3lang/tree-sitter-c3) | unstable | `HFIJ ` | | @cbuttner
|
||||||
[c_sharp](https://github.com/tree-sitter/tree-sitter-c-sharp) | unstable | `HF JL` | | @amaanq
|
[c_sharp](https://github.com/tree-sitter/tree-sitter-c-sharp) | unstable | `HF JL` | | @amaanq
|
||||||
[caddy](https://github.com/opa-oz/tree-sitter-caddy) | unmaintained | `HFIJ ` | | @opa-oz
|
[caddy](https://github.com/opa-oz/tree-sitter-caddy) | unmaintained | `HFIJ ` | | @opa-oz
|
||||||
[cairo](https://github.com/tree-sitter-grammars/tree-sitter-cairo) | unstable | `HFIJL` | | @amaanq
|
[cairo](https://github.com/tree-sitter-grammars/tree-sitter-cairo) | unstable | `HFIJL` | | @amaanq
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,14 @@ return {
|
||||||
maintainers = { '@amaanq' },
|
maintainers = { '@amaanq' },
|
||||||
tier = 2,
|
tier = 2,
|
||||||
},
|
},
|
||||||
|
c3 = {
|
||||||
|
install_info = {
|
||||||
|
revision = 'dce56ccc5d2731ac14a0f6bb3fd1666d994b2a25',
|
||||||
|
url = 'https://github.com/c3lang/tree-sitter-c3',
|
||||||
|
},
|
||||||
|
maintainers = { '@cbuttner' },
|
||||||
|
tier = 2,
|
||||||
|
},
|
||||||
c_sharp = {
|
c_sharp = {
|
||||||
install_info = {
|
install_info = {
|
||||||
revision = 'b5eb5742f6a7e9438bee22ce8026d6b927be2cd7',
|
revision = 'b5eb5742f6a7e9438bee22ce8026d6b927be2cd7',
|
||||||
|
|
|
||||||
35
runtime/queries/c3/folds.scm
Normal file
35
runtime/queries/c3/folds.scm
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
[
|
||||||
|
; Top-level declarations
|
||||||
|
(bitstruct_declaration)
|
||||||
|
(enum_declaration)
|
||||||
|
(faultdef_declaration)
|
||||||
|
(func_definition)
|
||||||
|
(import_declaration)+
|
||||||
|
(interface_declaration)
|
||||||
|
(macro_declaration)
|
||||||
|
(struct_declaration)
|
||||||
|
; Statements
|
||||||
|
(asm_block_stmt)
|
||||||
|
(case_stmt)
|
||||||
|
(defer_stmt)
|
||||||
|
(do_stmt)
|
||||||
|
(for_stmt)
|
||||||
|
(foreach_stmt)
|
||||||
|
(if_stmt)
|
||||||
|
(switch_stmt)
|
||||||
|
(while_stmt)
|
||||||
|
(ct_for_stmt)
|
||||||
|
(ct_foreach_stmt)
|
||||||
|
(ct_switch_stmt)
|
||||||
|
(ct_case_stmt)
|
||||||
|
(ct_if_stmt)
|
||||||
|
(ct_else_stmt)
|
||||||
|
; Comments
|
||||||
|
(block_comment)
|
||||||
|
(doc_comment)
|
||||||
|
; Initializer list
|
||||||
|
(initializer_list)
|
||||||
|
] @fold
|
||||||
|
|
||||||
|
(compound_stmt
|
||||||
|
(compound_stmt) @fold)
|
||||||
408
runtime/queries/c3/highlights.scm
Normal file
408
runtime/queries/c3/highlights.scm
Normal file
|
|
@ -0,0 +1,408 @@
|
||||||
|
; Punctuation
|
||||||
|
[
|
||||||
|
"("
|
||||||
|
")"
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
"{"
|
||||||
|
"}"
|
||||||
|
"[<"
|
||||||
|
">]"
|
||||||
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
[
|
||||||
|
";"
|
||||||
|
","
|
||||||
|
":"
|
||||||
|
"::"
|
||||||
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
; Constant
|
||||||
|
(const_ident) @constant
|
||||||
|
|
||||||
|
[
|
||||||
|
"true"
|
||||||
|
"false"
|
||||||
|
] @boolean
|
||||||
|
|
||||||
|
"null" @constant.builtin
|
||||||
|
|
||||||
|
; Variable
|
||||||
|
[
|
||||||
|
(ident)
|
||||||
|
(ct_ident)
|
||||||
|
(hash_ident)
|
||||||
|
] @variable
|
||||||
|
|
||||||
|
; 1) Member
|
||||||
|
(field_expr
|
||||||
|
field: (access_ident
|
||||||
|
(ident) @variable.member))
|
||||||
|
|
||||||
|
(struct_member_declaration
|
||||||
|
(ident) @variable.member)
|
||||||
|
|
||||||
|
(struct_member_declaration
|
||||||
|
(identifier_list
|
||||||
|
(ident) @variable.member))
|
||||||
|
|
||||||
|
(bitstruct_member_declaration
|
||||||
|
(ident) @variable.member)
|
||||||
|
|
||||||
|
(initializer_list
|
||||||
|
(initializer_element
|
||||||
|
(param_path
|
||||||
|
(param_path_element
|
||||||
|
(access_ident
|
||||||
|
(ident) @variable.member)))))
|
||||||
|
|
||||||
|
; 2) Parameter
|
||||||
|
(param
|
||||||
|
name: (_) @variable.parameter)
|
||||||
|
|
||||||
|
(trailing_block_param
|
||||||
|
(at_ident) @variable.parameter)
|
||||||
|
|
||||||
|
(call_arg_list
|
||||||
|
(call_arg
|
||||||
|
name: (_) @variable.parameter))
|
||||||
|
|
||||||
|
(enum_param
|
||||||
|
(ident) @variable.parameter)
|
||||||
|
|
||||||
|
; Keyword (from `c3c --list-keywords`)
|
||||||
|
[
|
||||||
|
"alias"
|
||||||
|
"asm"
|
||||||
|
"attrdef"
|
||||||
|
"catch"
|
||||||
|
"defer"
|
||||||
|
"try"
|
||||||
|
"var"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
[
|
||||||
|
"$alignof"
|
||||||
|
"$assert"
|
||||||
|
"$assignable"
|
||||||
|
"$case"
|
||||||
|
"$default"
|
||||||
|
"$defined"
|
||||||
|
"$echo"
|
||||||
|
"$else"
|
||||||
|
"$embed"
|
||||||
|
"$endfor"
|
||||||
|
"$endforeach"
|
||||||
|
"$endif"
|
||||||
|
"$endswitch"
|
||||||
|
"$eval"
|
||||||
|
"$evaltype"
|
||||||
|
"$error"
|
||||||
|
"$exec"
|
||||||
|
"$extnameof"
|
||||||
|
"$feature"
|
||||||
|
"$for"
|
||||||
|
"$foreach"
|
||||||
|
"$if"
|
||||||
|
"$include"
|
||||||
|
"$is_const"
|
||||||
|
"$nameof"
|
||||||
|
"$offsetof"
|
||||||
|
"$qnameof"
|
||||||
|
"$sizeof"
|
||||||
|
"$stringify"
|
||||||
|
"$switch"
|
||||||
|
"$typefrom"
|
||||||
|
"$typeof"
|
||||||
|
"$vacount"
|
||||||
|
"$vatype"
|
||||||
|
"$vaconst"
|
||||||
|
"$vaarg"
|
||||||
|
"$vaexpr"
|
||||||
|
"$vasplat"
|
||||||
|
] @keyword.directive
|
||||||
|
|
||||||
|
"assert" @keyword.debug
|
||||||
|
|
||||||
|
"fn" @keyword.function
|
||||||
|
|
||||||
|
"macro" @keyword.function
|
||||||
|
|
||||||
|
"return" @keyword.return
|
||||||
|
|
||||||
|
[
|
||||||
|
"import"
|
||||||
|
"module"
|
||||||
|
] @keyword.import
|
||||||
|
|
||||||
|
[
|
||||||
|
"bitstruct"
|
||||||
|
"enum"
|
||||||
|
"faultdef"
|
||||||
|
"interface"
|
||||||
|
"struct"
|
||||||
|
"typedef"
|
||||||
|
"union"
|
||||||
|
] @keyword.type
|
||||||
|
|
||||||
|
[
|
||||||
|
"case"
|
||||||
|
"default"
|
||||||
|
"else"
|
||||||
|
"if"
|
||||||
|
"nextcase"
|
||||||
|
"switch"
|
||||||
|
] @keyword.conditional
|
||||||
|
|
||||||
|
[
|
||||||
|
"break"
|
||||||
|
"continue"
|
||||||
|
"do"
|
||||||
|
"for"
|
||||||
|
"foreach"
|
||||||
|
"foreach_r"
|
||||||
|
"while"
|
||||||
|
] @keyword.repeat
|
||||||
|
|
||||||
|
[
|
||||||
|
"const"
|
||||||
|
"extern"
|
||||||
|
"inline"
|
||||||
|
"static"
|
||||||
|
"tlocal"
|
||||||
|
] @keyword.modifier
|
||||||
|
|
||||||
|
; Operator (from `c3c --list-operators`)
|
||||||
|
[
|
||||||
|
"&"
|
||||||
|
"!"
|
||||||
|
"~"
|
||||||
|
"|"
|
||||||
|
"^"
|
||||||
|
"="
|
||||||
|
">"
|
||||||
|
"/"
|
||||||
|
"."
|
||||||
|
"<"
|
||||||
|
"-"
|
||||||
|
"%"
|
||||||
|
"+"
|
||||||
|
"?"
|
||||||
|
"*"
|
||||||
|
"&&"
|
||||||
|
"!!"
|
||||||
|
"&="
|
||||||
|
"|="
|
||||||
|
"^="
|
||||||
|
"/="
|
||||||
|
".."
|
||||||
|
"?:"
|
||||||
|
"=="
|
||||||
|
">="
|
||||||
|
"=>"
|
||||||
|
"<="
|
||||||
|
"-="
|
||||||
|
"--"
|
||||||
|
"%="
|
||||||
|
"*="
|
||||||
|
"!="
|
||||||
|
"||"
|
||||||
|
"+="
|
||||||
|
"++"
|
||||||
|
"??"
|
||||||
|
"<<"
|
||||||
|
">>"
|
||||||
|
"..."
|
||||||
|
"<<="
|
||||||
|
">>="
|
||||||
|
"&&&"
|
||||||
|
"+++"
|
||||||
|
"|||"
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
(range_expr
|
||||||
|
":" @operator)
|
||||||
|
|
||||||
|
(foreach_cond
|
||||||
|
":" @operator)
|
||||||
|
|
||||||
|
(ct_foreach_cond
|
||||||
|
":" @operator)
|
||||||
|
|
||||||
|
(ternary_expr
|
||||||
|
[
|
||||||
|
"?"
|
||||||
|
":"
|
||||||
|
] @keyword.conditional.ternary)
|
||||||
|
|
||||||
|
(elvis_orelse_expr
|
||||||
|
[
|
||||||
|
"?:"
|
||||||
|
"??"
|
||||||
|
] @keyword.conditional.ternary)
|
||||||
|
|
||||||
|
; Literal
|
||||||
|
(integer_literal) @number
|
||||||
|
|
||||||
|
(real_literal) @number.float
|
||||||
|
|
||||||
|
(char_literal) @character
|
||||||
|
|
||||||
|
(bytes_literal) @number
|
||||||
|
|
||||||
|
; String
|
||||||
|
(string_literal) @string
|
||||||
|
|
||||||
|
(raw_string_literal) @string
|
||||||
|
|
||||||
|
; Escape Sequence
|
||||||
|
(escape_sequence) @string.escape
|
||||||
|
|
||||||
|
; Builtin (constants)
|
||||||
|
(builtin_const) @constant.builtin
|
||||||
|
|
||||||
|
; Type Property (from `c3c --list-type-properties`)
|
||||||
|
(type_access_expr
|
||||||
|
(access_ident
|
||||||
|
(ident) @variable.builtin
|
||||||
|
(#any-of? @variable.builtin
|
||||||
|
"alignof" "associated" "elements" "extnameof" "from_ordinal" "get" "inf" "is_eq" "is_ordered"
|
||||||
|
"is_substruct" "len" "lookup" "lookup_field" "max" "membersof" "methodsof" "min" "nan" "inner"
|
||||||
|
"kindof" "names" "nameof" "params" "paramsof" "parentof" "qnameof" "returns" "sizeof" "tagof"
|
||||||
|
"has_tagof" "values" "typeid")))
|
||||||
|
|
||||||
|
; Label
|
||||||
|
[
|
||||||
|
(label)
|
||||||
|
(label_target)
|
||||||
|
] @label
|
||||||
|
|
||||||
|
; Module
|
||||||
|
(module_resolution
|
||||||
|
(ident) @module)
|
||||||
|
|
||||||
|
(module_declaration
|
||||||
|
(path_ident
|
||||||
|
(ident) @module))
|
||||||
|
|
||||||
|
(import_declaration
|
||||||
|
(path_ident
|
||||||
|
(ident) @module))
|
||||||
|
|
||||||
|
; Attribute
|
||||||
|
(attribute
|
||||||
|
name: (at_ident) @attribute)
|
||||||
|
|
||||||
|
(at_type_ident) @attribute
|
||||||
|
|
||||||
|
(call_inline_attributes
|
||||||
|
(at_ident) @attribute)
|
||||||
|
|
||||||
|
(asm_block_stmt
|
||||||
|
(at_ident) @attribute)
|
||||||
|
|
||||||
|
; Type
|
||||||
|
[
|
||||||
|
(type_ident)
|
||||||
|
(ct_type_ident)
|
||||||
|
] @type
|
||||||
|
|
||||||
|
(base_type_name) @type.builtin
|
||||||
|
|
||||||
|
; Function Definition
|
||||||
|
(func_header
|
||||||
|
name: (_) @function)
|
||||||
|
|
||||||
|
(func_header
|
||||||
|
method_type: (_)
|
||||||
|
name: (_) @function.method)
|
||||||
|
|
||||||
|
(macro_header
|
||||||
|
name: (_) @function)
|
||||||
|
|
||||||
|
(macro_header
|
||||||
|
method_type: (_)
|
||||||
|
name: (_) @function.method)
|
||||||
|
|
||||||
|
; Function Call
|
||||||
|
(call_expr
|
||||||
|
function: (ident_expr
|
||||||
|
[
|
||||||
|
(ident)
|
||||||
|
(at_ident)
|
||||||
|
] @function.call))
|
||||||
|
|
||||||
|
(call_expr
|
||||||
|
function: (trailing_generic_expr
|
||||||
|
argument: (ident_expr
|
||||||
|
[
|
||||||
|
(ident)
|
||||||
|
(at_ident)
|
||||||
|
] @function.call)))
|
||||||
|
|
||||||
|
; Method call
|
||||||
|
(call_expr
|
||||||
|
function: (field_expr
|
||||||
|
field: (access_ident
|
||||||
|
[
|
||||||
|
(ident)
|
||||||
|
(at_ident)
|
||||||
|
] @function.method.call)))
|
||||||
|
|
||||||
|
; Method on type
|
||||||
|
(call_expr
|
||||||
|
function: (type_access_expr
|
||||||
|
field: (access_ident
|
||||||
|
[
|
||||||
|
(ident)
|
||||||
|
(at_ident)
|
||||||
|
] @function.method.call)))
|
||||||
|
|
||||||
|
; Builtin call
|
||||||
|
(call_expr
|
||||||
|
function: (builtin) @function.builtin)
|
||||||
|
|
||||||
|
; Asm
|
||||||
|
(asm_instr
|
||||||
|
[
|
||||||
|
(ident)
|
||||||
|
"int"
|
||||||
|
] @function.builtin)
|
||||||
|
|
||||||
|
(asm_expr
|
||||||
|
[
|
||||||
|
(ct_ident)
|
||||||
|
(ct_const_ident)
|
||||||
|
] @variable.builtin)
|
||||||
|
|
||||||
|
; Comment
|
||||||
|
[
|
||||||
|
(line_comment)
|
||||||
|
(block_comment)
|
||||||
|
] @comment @spell
|
||||||
|
|
||||||
|
(doc_comment) @comment.documentation
|
||||||
|
|
||||||
|
(doc_comment_text) @spell
|
||||||
|
|
||||||
|
(doc_comment_contract
|
||||||
|
name: (_) @attribute)
|
||||||
|
|
||||||
|
(doc_comment_contract
|
||||||
|
parameter: [
|
||||||
|
(ident)
|
||||||
|
(ct_ident)
|
||||||
|
(hash_ident)
|
||||||
|
] @variable.parameter
|
||||||
|
(#set! priority 110))
|
||||||
|
|
||||||
|
(doc_comment_contract
|
||||||
|
[
|
||||||
|
":"
|
||||||
|
"?"
|
||||||
|
] @comment.documentation
|
||||||
|
(#set! priority 110))
|
||||||
|
|
||||||
|
(doc_comment_contract
|
||||||
|
description: (_) @comment.documentation
|
||||||
|
(#set! priority 110))
|
||||||
73
runtime/queries/c3/indents.scm
Normal file
73
runtime/queries/c3/indents.scm
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
[
|
||||||
|
(compound_stmt)
|
||||||
|
(initializer_list)
|
||||||
|
(implies_body)
|
||||||
|
(struct_body)
|
||||||
|
(bitstruct_body)
|
||||||
|
(enum_body)
|
||||||
|
(interface_body)
|
||||||
|
(switch_body)
|
||||||
|
(ct_if_stmt)
|
||||||
|
(ct_for_stmt)
|
||||||
|
(ct_foreach_stmt)
|
||||||
|
(ct_switch_stmt)
|
||||||
|
] @indent.begin
|
||||||
|
|
||||||
|
([
|
||||||
|
(case_stmt)
|
||||||
|
(default_stmt)
|
||||||
|
(ct_case_stmt)
|
||||||
|
] @indent.begin
|
||||||
|
(#set! indent.immediate 1))
|
||||||
|
|
||||||
|
(expr_stmt
|
||||||
|
";" @indent.end) @indent.begin
|
||||||
|
|
||||||
|
(declaration
|
||||||
|
";" @indent.end) @indent.begin
|
||||||
|
|
||||||
|
(const_declaration
|
||||||
|
";" @indent.end) @indent.begin
|
||||||
|
|
||||||
|
(return_stmt
|
||||||
|
";" @indent.end) @indent.begin
|
||||||
|
|
||||||
|
(faultdef_declaration
|
||||||
|
";" @indent.end) @indent.begin
|
||||||
|
|
||||||
|
(macro_func_body
|
||||||
|
";" @indent.end)
|
||||||
|
|
||||||
|
[
|
||||||
|
")"
|
||||||
|
"}"
|
||||||
|
"$endfor"
|
||||||
|
"$endforeach"
|
||||||
|
"$endswitch"
|
||||||
|
"$endif"
|
||||||
|
] @indent.branch @indent.end
|
||||||
|
|
||||||
|
"$else" @indent.branch
|
||||||
|
|
||||||
|
([
|
||||||
|
(func_param_list)
|
||||||
|
(macro_param_list)
|
||||||
|
(enum_param_list)
|
||||||
|
(attribute_param_list)
|
||||||
|
(call_arg_list)
|
||||||
|
(paren_cond)
|
||||||
|
(for_cond)
|
||||||
|
(foreach_cond)
|
||||||
|
(paren_expr)
|
||||||
|
] @indent.align
|
||||||
|
(#set! indent.open_delimiter "(")
|
||||||
|
(#set! indent.close_delimiter ")"))
|
||||||
|
|
||||||
|
[
|
||||||
|
(block_comment)
|
||||||
|
(doc_comment)
|
||||||
|
(raw_string_literal)
|
||||||
|
(bytes_literal)
|
||||||
|
] @indent.auto
|
||||||
|
|
||||||
|
(string_literal) @indent.ignore
|
||||||
5
runtime/queries/c3/injections.scm
Normal file
5
runtime/queries/c3/injections.scm
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
([
|
||||||
|
(line_comment)
|
||||||
|
(block_comment)
|
||||||
|
] @injection.content
|
||||||
|
(#set! injection.language "comment"))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue