mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-21 12:50:09 -04:00
v2
This commit is contained in:
parent
6c017d033e
commit
30259100b1
7 changed files with 150 additions and 513 deletions
2
SUPPORTED_LANGUAGES.md
generated
2
SUPPORTED_LANGUAGES.md
generated
|
|
@ -21,7 +21,7 @@ Language | Tier | Queries | Node | Maintainer
|
|||
[astro](https://github.com/virchau13/tree-sitter-astro) | unstable | `HFIJL` | | @virchau13
|
||||
[authzed](https://github.com/mleonidas/tree-sitter-authzed) | unstable | `H J ` | | @mattpolzin
|
||||
[awk](https://github.com/Beaglefoot/tree-sitter-awk) | unstable | `H J ` | |
|
||||
[b](https://github.com/VoxelPrismatic/tree-sitter-b) | unstable | `HFIJL` | |
|
||||
[b](https://github.com/VoxelPrismatic/tree-sitter-b) | unstable | `H ` | | @voxelprismatic
|
||||
[bash](https://github.com/tree-sitter/tree-sitter-bash) | unstable | `HF JL` | | @TravonteD
|
||||
[bass](https://github.com/vito/tree-sitter-bass) | unstable | `HFIJL` | | @amaanq
|
||||
[beancount](https://github.com/polarmutex/tree-sitter-beancount) | unstable | `HF J ` | | @polarmutex
|
||||
|
|
|
|||
|
|
@ -77,9 +77,11 @@ return {
|
|||
},
|
||||
b = {
|
||||
install_info = {
|
||||
revision = '3ca711959415190d02e056ba0d754716984e0c91',
|
||||
revision = '23f515392632d6f010926a3257fa095c041eea6e',
|
||||
url = 'https://github.com/VoxelPrismatic/tree-sitter-b',
|
||||
branch = 'v2',
|
||||
},
|
||||
maintainers = { '@VoxelPrismatic' },
|
||||
tier = 2,
|
||||
},
|
||||
bash = {
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
[
|
||||
(for_statement)
|
||||
(if_statement)
|
||||
(while_statement)
|
||||
(do_statement)
|
||||
(switch_statement)
|
||||
(case_statement)
|
||||
(function_definition)
|
||||
(struct_specifier)
|
||||
(enum_specifier)
|
||||
(comment)
|
||||
(preproc_if)
|
||||
(preproc_elif)
|
||||
(preproc_else)
|
||||
(preproc_ifdef)
|
||||
(preproc_function_def)
|
||||
(initializer_list)
|
||||
(gnu_asm_expression)
|
||||
(preproc_include)+
|
||||
] @fold
|
||||
|
||||
(compound_statement
|
||||
(compound_statement) @fold)
|
||||
|
|
@ -1,26 +1,40 @@
|
|||
; Lower priority to prefer @variable.parameter when identifier appears in parameter_declaration.
|
||||
(_
|
||||
lhs: (linker) @comment
|
||||
target: (linker) @markup.strong @diff.plus
|
||||
rhs: (linker) @comment)
|
||||
|
||||
(linker
|
||||
target: (link_name) @markup.strong @diff.minus) @comment
|
||||
|
||||
((identifier) @variable
|
||||
(#set! priority 95))
|
||||
|
||||
((identifier) @constant
|
||||
(#set! priority 103)
|
||||
(#match? @constant "^[A-Z0-9_\\-]+$"))
|
||||
|
||||
((identifier) @constant
|
||||
(#set! priority 103)
|
||||
(#match? @constant "args"))
|
||||
|
||||
(comment) @comment
|
||||
|
||||
[
|
||||
"default"
|
||||
"goto"
|
||||
"asm"
|
||||
"__asm__"
|
||||
] @keyword
|
||||
|
||||
(type_identifier) @keyword.type
|
||||
|
||||
"auto" @keyword.type
|
||||
|
||||
(alignof_expression
|
||||
.
|
||||
_ @keyword.operator)
|
||||
"auto"
|
||||
"extrn"
|
||||
] @keyword.type
|
||||
|
||||
"return" @keyword.return
|
||||
|
||||
"while" @keyword.repeat
|
||||
|
||||
(goto_statement
|
||||
token: "goto" @keyword
|
||||
name: (rvalue) @label)
|
||||
|
||||
(label_statement
|
||||
name: (_) @label)
|
||||
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
|
|
@ -29,207 +43,145 @@
|
|||
] @keyword.conditional
|
||||
|
||||
[
|
||||
";"
|
||||
":"
|
||||
","
|
||||
"."
|
||||
"::"
|
||||
] @punctuation.delimiter
|
||||
(op_binary)
|
||||
(op_unary)
|
||||
(op_assign)
|
||||
(op_incdec)
|
||||
] @keyword.operator
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
"="
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"+"
|
||||
"%"
|
||||
"~"
|
||||
"|"
|
||||
"&"
|
||||
"^"
|
||||
"<<"
|
||||
">>"
|
||||
"->"
|
||||
"<"
|
||||
"<="
|
||||
">="
|
||||
">"
|
||||
"=="
|
||||
"!="
|
||||
"!"
|
||||
"&&"
|
||||
"||"
|
||||
"--"
|
||||
"++"
|
||||
] @operator
|
||||
|
||||
[
|
||||
"=-"
|
||||
"=+"
|
||||
"=*"
|
||||
"=/"
|
||||
"=%"
|
||||
"=|"
|
||||
"=&"
|
||||
"=^"
|
||||
"=>>"
|
||||
"=<<"
|
||||
"=>="
|
||||
"=<="
|
||||
] @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
|
||||
|
||||
(conditional_expression
|
||||
[
|
||||
"?"
|
||||
":"
|
||||
] @keyword.conditional.ternary)
|
||||
(rune_literal) @character
|
||||
|
||||
(string_literal) @string
|
||||
|
||||
(system_lib_string) @string
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
(null) @constant.builtin
|
||||
|
||||
(number_literal) @number
|
||||
|
||||
(char_literal) @character
|
||||
(define_function
|
||||
name: (identifier) @function.method)
|
||||
|
||||
((field_expression
|
||||
(field_identifier) @property) @_parent
|
||||
(#not-has-parent? @_parent template_method function_declarator call_expression))
|
||||
(call
|
||||
name: (identifier) @function.method @function.method.call)
|
||||
|
||||
(field_designator) @property
|
||||
; Standard libraries
|
||||
((identifier) @function.builtin
|
||||
(#set! priority 105)
|
||||
(#any-of? @function.builtin
|
||||
"char" "chdir" "chmod" "chown" "close" "creat" "ctime" "execl" "execv" "exit" "fork" "fstat"
|
||||
"getchar" "getuid" "gtty" "lchar" "link" "mkdir" "open" "printf" "printn" "putchar" "read"
|
||||
"setuid" "stat" "stty" "unlink" "wait" "write" "main"))
|
||||
|
||||
((field_identifier) @property
|
||||
(#has-ancestor? @property field_declaration)
|
||||
(#not-has-ancestor? @property function_declarator))
|
||||
((identifier) @function.builtin
|
||||
(#set! priority 105)
|
||||
(#any-of? @function.builtin "assert")
|
||||
(#has-ancestor? @function.builtin program_c_assert_h))
|
||||
|
||||
(statement_identifier) @label
|
||||
((identifier) @function.builtin
|
||||
(#set! priority 105)
|
||||
(#any-of? @function.builtin
|
||||
"isalnum" "isalpha" "isascii4" "isblank" "iscntrl" "isdigit" "isgraph" "islower" "isprint"
|
||||
"ispunct" "isspace" "isupper" "toascii" "tolower" "toupper")
|
||||
(#has-ancestor? @function.builtin program_c_ctype_h))
|
||||
|
||||
(declaration
|
||||
type: (type_identifier) @_type
|
||||
declarator: (identifier) @label
|
||||
(#eq? @_type "__label__"))
|
||||
((identifier) @function.builtin
|
||||
(#set! priority 105)
|
||||
(#any-of? @function.builtin "nl_langinfo4")
|
||||
(#has-ancestor? @function.builtin program_c_langinfo_h))
|
||||
|
||||
(storage_class_specifier) @keyword.modifier
|
||||
((identifier) @function.builtin
|
||||
(#set! priority 105)
|
||||
(#any-of? @function.builtin
|
||||
"acos" "asin" "atan" "atan2" "ceil" "cos" "cosh" "erf" "erfc" "exp" "fabs" "floor" "fmod"
|
||||
"frexp" "gamma" "hypot" "j0" "j1" "jn" "ldexp" "log" "log10" "modf" "nextafter" "nextafterl"
|
||||
"nexttoward" "nexttowardl" "pow" "quantexpd32" "quantexpd64" "quantexpd128" "quantized32"
|
||||
"quantized64" "quantized128" "samequantumd32" "samequantumd64" "samequantumd128" "sin" "sinh"
|
||||
"sqrt" "tan" "tanh" "y0" "y1" "yn")
|
||||
(#has-ancestor? @function.builtin program_c_math_h))
|
||||
|
||||
[
|
||||
(type_qualifier)
|
||||
(gnu_asm_qualifier)
|
||||
"__extension__"
|
||||
] @keyword.modifier
|
||||
((identifier) @function.builtin
|
||||
(#set! priority 105)
|
||||
(#any-of? @function.builtin "catclose6" "catgets6" "catopen6")
|
||||
(#has-ancestor? @function.builtin program_c_nl_types_h))
|
||||
|
||||
(type_definition
|
||||
declarator: (type_identifier) @type.definition)
|
||||
((identifier) @function.builtin
|
||||
(#set! priority 105)
|
||||
(#any-of? @function.builtin "regcomp" "regerror" "regexec" "regfree")
|
||||
(#has-ancestor? @function.builtin program_c_regex_h))
|
||||
|
||||
(primitive_type) @type.builtin
|
||||
((identifier) @function.builtin
|
||||
(#set! priority 105)
|
||||
(#any-of? @function.builtin "longjmp" "setjmp")
|
||||
(#has-ancestor? @function.builtin program_c_setjmp_h))
|
||||
|
||||
(sized_type_specifier
|
||||
_ @type.builtin
|
||||
type: _?)
|
||||
((identifier) @function.builtin
|
||||
(#set! priority 105)
|
||||
(#any-of? @function.builtin "raise" "signal")
|
||||
(#has-ancestor? @function.builtin program_c_signal_h))
|
||||
|
||||
((identifier) @constant
|
||||
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
|
||||
((identifier) @function.builtin
|
||||
(#set! priority 105)
|
||||
(#any-of? @function.builtin
|
||||
"va_arg" "va_copy" "va_end" "va_start" "vfprintf" "vfscanf" "vfwprintf6" "vfwscanf" "vprintf"
|
||||
"vscanf" "vsprintf" "vsscanf" "vswprintf" "vwprintf6" "wctob")
|
||||
(#has-ancestor? @function.builtin program_c_stdarg_h))
|
||||
|
||||
(enumerator
|
||||
name: (identifier) @constant)
|
||||
((identifier) @function.builtin
|
||||
(#set! priority 105)
|
||||
(#any-of? @function.builtin
|
||||
"btowc" "clearerr" "fclose" "fdopen5" "feof" "ferror" "fflush1" "fgetc1" "fgetpos1" "fgets1"
|
||||
"fgetwc6" "fgetws6" "fileno5" "fopen" "fprintf" "fputc1" "fputs1" "fputwc6" "fputws6" "fread"
|
||||
"freopen" "fscanf" "fseek1" "fsetpos1" "ftell1" "fwide6" "fwprintf6" "fwrite" "fwscanf6" "getc1"
|
||||
"getchar1" "gets" "getwc6" "perror" "printf" "putc1" "putchar1" "puts" "putwc6" "remove"
|
||||
"rename" "rewind1" "scanf" "setbuf" "setvbuf" "snprintf" "sprintf" "sscanf" "tmpfile" "tmpnam"
|
||||
"ungetc1" "ungetwc6" "vfprintf" "vfscanf" "vfwprintf6" "vfwscanf" "vprintf" "vscanf" "vsprintf"
|
||||
"vsnprintf" "vsscanf" "vswscanf" "vwscanf")
|
||||
(#has-ancestor? @function.builtin program_c_stdio_h))
|
||||
|
||||
(case_statement
|
||||
value: (identifier) @constant)
|
||||
((identifier) @function.builtin
|
||||
(#set! priority 105)
|
||||
(#any-of? @function.builtin
|
||||
"abort" "abs" "atexit" "atof" "atoi" "atol" "bsearch" "calloc" "div" "exit" "free" "getenv"
|
||||
"labs" "ldiv" "malloc" "mblen" "mbstowcs" "mbtowc" "putenv" "qsort" "rand" "rand_r" "realloc"
|
||||
"srand" "strtod" "strtod32" "strtod64" "strtod128" "strtof" "strtol" "strtold" "strtoul"
|
||||
"system" "wcstombs" "wctomb")
|
||||
(#has-ancestor? @function.builtin program_c_stdlib_h))
|
||||
|
||||
((identifier) @constant.builtin
|
||||
; format-ignore
|
||||
(#any-of? @constant.builtin
|
||||
"args"
|
||||
))
|
||||
((identifier) @function.builtin
|
||||
(#set! priority 105)
|
||||
(#any-of? @function.builtin
|
||||
"memchr" "memcmp" "memcpy" "memmove" "memset" "strcat" "strchr" "strcmp" "strcoll" "strcpy"
|
||||
"strcspn" "strerror" "strlen" "strncat" "strncmp" "strncpy" "strpbrk" "strrchr" "strspn"
|
||||
"strstr" "strtok" "strtok_r" "strxfrm")
|
||||
(#has-ancestor? @function.builtin program_c_string_h))
|
||||
|
||||
(attribute_specifier
|
||||
(argument_list
|
||||
(identifier) @variable.builtin))
|
||||
((identifier) @function.builtin
|
||||
(#set! priority 105)
|
||||
(#any-of? @function.builtin "strcasecmp" "strncasecmp")
|
||||
(#has-ancestor? @function.builtin program_c_strings_h))
|
||||
|
||||
(attribute_specifier
|
||||
(argument_list
|
||||
(call_expression
|
||||
function: (identifier) @variable.builtin)))
|
||||
((identifier) @function.builtin
|
||||
(#set! priority 105)
|
||||
(#any-of? @function.builtin
|
||||
"asctime" "asctime_r" "clock" "ctime" "ctime64" "ctime_r" "ctime64_r" "difftime" "difftime64"
|
||||
"gmtime" "gmtime64" "gmtime_r" "gmtime64_r" "localtime" "localtime64" "localtime_r"
|
||||
"localtime64_r" "mktime" "mktime64" "strftime" "strptime4" "time" "time64")
|
||||
(#has-ancestor? @function.builtin program_c_time_h))
|
||||
|
||||
((call_expression
|
||||
function: (identifier) @function.builtin)
|
||||
(#lua-match? @function.builtin "^__builtin_"))
|
||||
((identifier) @function.builtin
|
||||
(#set! priority 105)
|
||||
(#any-of? @function.builtin
|
||||
"btowc" "fgetwc6" "fgetws6" "fputwc6" "fputws6" "fwide6" "fwprintf6" "fwscanf6" "getwc6"
|
||||
"getwchar6" "mbrlen4" "mbrtowc4" "mbsinit4" "mbsrtowcs4" "putwc6" "putwchar6" "strfmon4"
|
||||
"swprintf" "swscanf" "ungetwc6" "vfwprintf6" "vswprintf" "vswscanf" "vwprintf6" "vwscanf"
|
||||
"wcrtomb4" "wcscat" "wcschr" "wcscmp" "wcscoll4" "wcscpy" "wcscspn" "wcsftime" "wcslen"
|
||||
"wcsncat" "wcsncmp" "wcsncpy" "wcspbrk" "wcsptime" "wcsrchr" "wcsrtombs4" "wcsspn" "wcsstr"
|
||||
"wcstod" "wcstod32" "wcstod64" "wcstod128" "wcstof" "wcstok" "wcstol" "wcstold" "wcstoul"
|
||||
"wcsxfrm4" "wctob" "wctype4" "wcwidth" "wmemchr" "wmemcmp" "wmemcpy" "wmemmove" "wmemset"
|
||||
"wprintf6" "wscanf6")
|
||||
(#has-ancestor? @function.builtin program_c_wchar_h))
|
||||
|
||||
((call_expression
|
||||
function: (identifier) @function.builtin)
|
||||
(#has-ancestor? @function.builtin attribute_specifier))
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @function.call)
|
||||
|
||||
(call_expression
|
||||
function: (field_expression
|
||||
field: (field_identifier) @function.call))
|
||||
|
||||
(function_declarator
|
||||
declarator: (identifier) @function)
|
||||
|
||||
(function_declarator
|
||||
declarator: (parenthesized_declarator
|
||||
(pointer_declarator
|
||||
declarator: (field_identifier) @function)))
|
||||
|
||||
(comment) @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
||||
|
||||
; Parameters
|
||||
(parameter_declaration
|
||||
declarator: (identifier) @variable.parameter)
|
||||
|
||||
(parameter_declaration
|
||||
declarator: (array_declarator) @variable.parameter)
|
||||
|
||||
(parameter_declaration
|
||||
declarator: (pointer_declarator) @variable.parameter)
|
||||
|
||||
; K&R functions
|
||||
; To enable support for K&R functions,
|
||||
; add the following lines to your own query config and uncomment them.
|
||||
; They are commented out as they'll conflict with C++
|
||||
; Note that you'll need to have `; extends` at the top of your query file.
|
||||
;
|
||||
; (parameter_list (identifier) @variable.parameter)
|
||||
;
|
||||
; (function_definition
|
||||
; declarator: _
|
||||
; (declaration
|
||||
; declarator: (identifier) @variable.parameter))
|
||||
;
|
||||
; (function_definition
|
||||
; declarator: _
|
||||
; (declaration
|
||||
; declarator: (array_declarator) @variable.parameter))
|
||||
;
|
||||
; (function_definition
|
||||
; declarator: _
|
||||
; (declaration
|
||||
; declarator: (pointer_declarator) @variable.parameter))
|
||||
((identifier) @function.builtin
|
||||
(#set! priority 105)
|
||||
(#any-of? @function.builtin
|
||||
"iswalnum4" "iswalpha4" "iswblank4" "iswcntrl4" "iswctype4" "iswdigit4" "iswgraph4" "iswlower4"
|
||||
"iswprint4" "iswpunct4" "iswspace4" "iswupper4" "iswxdigit4" "isxdigit4" "towctrans" "towlower4"
|
||||
"towupper4" "wctrans")
|
||||
(#has-ancestor? @function.builtin program_c_wctype_h))
|
||||
|
|
|
|||
|
|
@ -1,99 +0,0 @@
|
|||
[
|
||||
(compound_statement)
|
||||
(field_declaration_list)
|
||||
(case_statement)
|
||||
(enumerator_list)
|
||||
(compound_literal_expression)
|
||||
(initializer_list)
|
||||
(init_declarator)
|
||||
] @indent.begin
|
||||
|
||||
; With current indent logic, if we capture expression_statement with @indent.begin
|
||||
; It will be affected by _parent_ node with error subnodes deep down the tree
|
||||
; So narrow indent capture to check for error inside expression statement only,
|
||||
(expression_statement
|
||||
(_) @indent.begin
|
||||
";" @indent.end)
|
||||
|
||||
(ERROR
|
||||
"for"
|
||||
"(" @indent.begin
|
||||
";"
|
||||
";"
|
||||
")" @indent.end)
|
||||
|
||||
((for_statement
|
||||
body: (_) @_body) @indent.begin
|
||||
(#not-kind-eq? @_body "compound_statement"))
|
||||
|
||||
(while_statement
|
||||
condition: (_) @indent.begin)
|
||||
|
||||
((while_statement
|
||||
body: (_) @_body) @indent.begin
|
||||
(#not-kind-eq? @_body "compound_statement"))
|
||||
|
||||
((if_statement)
|
||||
.
|
||||
(ERROR
|
||||
"else" @indent.begin))
|
||||
|
||||
(if_statement
|
||||
condition: (_) @indent.begin)
|
||||
|
||||
; Supports if without braces (but not both if-else without braces)
|
||||
(if_statement
|
||||
consequence: (_
|
||||
";" @indent.end) @_consequence
|
||||
(#not-kind-eq? @_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))
|
||||
|
||||
(compound_statement
|
||||
"}" @indent.end)
|
||||
|
||||
[
|
||||
")"
|
||||
"}"
|
||||
(statement_identifier)
|
||||
] @indent.branch
|
||||
|
||||
[
|
||||
"#define"
|
||||
"#ifdef"
|
||||
"#ifndef"
|
||||
"#elif"
|
||||
"#if"
|
||||
"#else"
|
||||
"#endif"
|
||||
] @indent.zero
|
||||
|
||||
[
|
||||
(preproc_arg)
|
||||
(string_literal)
|
||||
] @indent.ignore
|
||||
|
||||
((ERROR
|
||||
(parameter_declaration)) @indent.align
|
||||
(#set! indent.open_delimiter "(")
|
||||
(#set! indent.close_delimiter ")"))
|
||||
|
||||
([
|
||||
(argument_list)
|
||||
(parameter_list)
|
||||
] @indent.align
|
||||
(#set! indent.open_delimiter "(")
|
||||
(#set! indent.close_delimiter ")"))
|
||||
|
||||
(comment) @indent.auto
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
((preproc_arg) @injection.content
|
||||
(#set! injection.self))
|
||||
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
((comment) @injection.content
|
||||
(#match? @injection.content "/\\*!([a-zA-Z]+:)?re2c")
|
||||
(#set! injection.language "re2c"))
|
||||
|
||||
((comment) @injection.content
|
||||
(#lua-match? @injection.content "/[*/][!*/]<?[^a-zA-Z]")
|
||||
(#set! injection.language "doxygen"))
|
||||
|
||||
((call_expression
|
||||
function: (identifier) @_function
|
||||
arguments: (argument_list
|
||||
.
|
||||
[
|
||||
(string_literal
|
||||
(string_content) @injection.content)
|
||||
(concatenated_string
|
||||
(string_literal
|
||||
(string_content) @injection.content))
|
||||
]))
|
||||
; format-ignore
|
||||
(#any-of? @_function
|
||||
"printf" "printf_s"
|
||||
"vprintf" "vprintf_s"
|
||||
"scanf" "scanf_s"
|
||||
"vscanf" "vscanf_s"
|
||||
"wprintf" "wprintf_s"
|
||||
"vwprintf" "vwprintf_s"
|
||||
"wscanf" "wscanf_s"
|
||||
"vwscanf" "vwscanf_s"
|
||||
"cscanf" "_cscanf"
|
||||
"printw"
|
||||
"scanw")
|
||||
(#set! injection.language "printf"))
|
||||
|
||||
((call_expression
|
||||
function: (identifier) @_function
|
||||
arguments: (argument_list
|
||||
(_)
|
||||
.
|
||||
[
|
||||
(string_literal
|
||||
(string_content) @injection.content)
|
||||
(concatenated_string
|
||||
(string_literal
|
||||
(string_content) @injection.content))
|
||||
]))
|
||||
; format-ignore
|
||||
(#any-of? @_function
|
||||
"fprintf" "fprintf_s"
|
||||
"sprintf"
|
||||
"dprintf"
|
||||
"fscanf" "fscanf_s"
|
||||
"sscanf" "sscanf_s"
|
||||
"vsscanf" "vsscanf_s"
|
||||
"vfprintf" "vfprintf_s"
|
||||
"vsprintf"
|
||||
"vdprintf"
|
||||
"fwprintf" "fwprintf_s"
|
||||
"vfwprintf" "vfwprintf_s"
|
||||
"fwscanf" "fwscanf_s"
|
||||
"swscanf" "swscanf_s"
|
||||
"vswscanf" "vswscanf_s"
|
||||
"vfscanf" "vfscanf_s"
|
||||
"vfwscanf" "vfwscanf_s"
|
||||
"wprintw"
|
||||
"vw_printw" "vwprintw"
|
||||
"wscanw"
|
||||
"vw_scanw" "vwscanw")
|
||||
(#set! injection.language "printf"))
|
||||
|
||||
((call_expression
|
||||
function: (identifier) @_function
|
||||
arguments: (argument_list
|
||||
(_)
|
||||
.
|
||||
(_)
|
||||
.
|
||||
[
|
||||
(string_literal
|
||||
(string_content) @injection.content)
|
||||
(concatenated_string
|
||||
(string_literal
|
||||
(string_content) @injection.content))
|
||||
]))
|
||||
; format-ignore
|
||||
(#any-of? @_function
|
||||
"sprintf_s"
|
||||
"snprintf" "snprintf_s"
|
||||
"vsprintf_s"
|
||||
"vsnprintf" "vsnprintf_s"
|
||||
"swprintf" "swprintf_s"
|
||||
"snwprintf_s"
|
||||
"vswprintf" "vswprintf_s"
|
||||
"vsnwprintf_s"
|
||||
"mvprintw"
|
||||
"mvscanw")
|
||||
(#set! injection.language "printf"))
|
||||
|
||||
((call_expression
|
||||
function: (identifier) @_function
|
||||
arguments: (argument_list
|
||||
(_)
|
||||
.
|
||||
(_)
|
||||
.
|
||||
(_)
|
||||
.
|
||||
[
|
||||
(string_literal
|
||||
(string_content) @injection.content)
|
||||
(concatenated_string
|
||||
(string_literal
|
||||
(string_content) @injection.content))
|
||||
]))
|
||||
(#any-of? @_function "mvwprintw" "mvwscanw")
|
||||
(#set! injection.language "printf"))
|
||||
|
||||
; 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"))
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
; Functions definitions
|
||||
(function_declarator
|
||||
declarator: (identifier) @local.definition.function)
|
||||
|
||||
(preproc_function_def
|
||||
name: (identifier) @local.definition.macro) @local.scope
|
||||
|
||||
(preproc_def
|
||||
name: (identifier) @local.definition.macro)
|
||||
|
||||
(pointer_declarator
|
||||
declarator: (identifier) @local.definition.var)
|
||||
|
||||
(parameter_declaration
|
||||
declarator: (identifier) @local.definition.parameter)
|
||||
|
||||
(init_declarator
|
||||
declarator: (identifier) @local.definition.var)
|
||||
|
||||
(array_declarator
|
||||
declarator: (identifier) @local.definition.var)
|
||||
|
||||
(declaration
|
||||
declarator: (identifier) @local.definition.var)
|
||||
|
||||
(enum_specifier
|
||||
name: (_) @local.definition.type
|
||||
(enumerator_list
|
||||
(enumerator
|
||||
name: (identifier) @local.definition.var)))
|
||||
|
||||
; Type / Struct / Enum
|
||||
(field_declaration
|
||||
declarator: (field_identifier) @local.definition.field)
|
||||
|
||||
(type_definition
|
||||
declarator: (type_identifier) @local.definition.type)
|
||||
|
||||
(struct_specifier
|
||||
name: (type_identifier) @local.definition.type)
|
||||
|
||||
; goto
|
||||
(labeled_statement
|
||||
(statement_identifier) @local.definition)
|
||||
|
||||
; References
|
||||
(identifier) @local.reference
|
||||
|
||||
((field_identifier) @local.reference
|
||||
(#set! reference.kind "field"))
|
||||
|
||||
((type_identifier) @local.reference
|
||||
(#set! reference.kind "type"))
|
||||
|
||||
(goto_statement
|
||||
(statement_identifier) @local.reference)
|
||||
|
||||
; Scope
|
||||
[
|
||||
(for_statement)
|
||||
(if_statement)
|
||||
(while_statement)
|
||||
(translation_unit)
|
||||
(function_definition)
|
||||
(compound_statement) ; a block in curly braces
|
||||
(struct_specifier)
|
||||
] @local.scope
|
||||
Loading…
Add table
Add a link
Reference in a new issue