C query issue: Function after global variable is not detected
Language: C AerialInfo:
Aerial Info
-----------
Filetype: c
Configured backends:
treesitter (supported) (attached)
lsp (supported)
markdown (not supported) [Filetype is not markdown]
asciidoc (not supported) [Filetype is not asciidoc]
man (not supported) [Filetype is not man]
Show symbols: Class, Constructor, Enum, Function, Interface, Module, Method, Struct
The minimal amount of code that demonstrates the missing symbol:
01 int var = 5;
02
03 int foo() { // undetected
04 return 0;
05 }
06
07 int bar() {
08 return 0;
09 }
Expected symbol: Function named foo at lines 3-5
Explanation
A function following a global variable declaration doesn't appear to be detected. It appears that lines from 1-5 are detected as being part of a function named var, but var is actually just a variable on line 1 (also happens with arrays). Here is the output from get_location(true) at line 4:
{
{
col = 4,
icon = " ",
kind = "Function",
lnum = 1,
name = "var"
}
}
The C++ query file doesn't seem to have this issue when identical code is used (putting it in a .cpp file instead of a .c file). Perhaps a solution is just to use the same query file for both languages (or a stripped down version of the C++ query file)? Actually it looks you can't simply do that. I guess the parsers are different. Unfortunately I don't know enough about treesitter queries to fix this myself.
Thanks in advance