Open frithrah opened 2 years ago
That's what ST's auto-completion is designed to work like.
It only completes tokens from global index if they appear in the buffer at least once. So if a function foo()
declared in a header file is indexed, ST will auto-complete it only, if it finds a foo()
function call in the open document.
The reason why it works like that is performance. ST isn't able to filter indexed tokens semantically and would display all kinds of irrelevant stuff from any indexed file and syntax. Depending on the open project many many many items would be suggested which would slow down ST for nothing.
Thanks for replying but I don't think that's the case. If I add a folder to the actual .c files (not just the headers) then autocomplete will suggest functions from those files even if it's the first time I've used them*. This is correct and good and fast. It's just references from headers only that are missed (probably for a good reason but I don't know what).
Here's a small example to illustrate how it works without any LSP or code intelligence plugins installed.
See how the first time fun
is typed, nothing is completed in debug.c
, while fun1
is suggested once it exists. But fun2
is still not suggested (as it does not yet exist).
Once fun1
is found and suggested in completions ST also shows the 2 locatations of definition.
As headers (.h) and sources (.c) use the same syntax and therefore the same indexing rules they are treated equally by ST's indexer.
Hmmm. Well that's interesting. Here's what I'm seeing...
What are we doing differently here? :)
For the record, this is what I want and expect, it just doesn't do this when only the headers are added (as would be the case when using most shared libraries).
Here's an even clearer example. It demonstrates that autocomplete isn't picked up from a header file but is when the c body is added.
This example uses a minimal header and source file from the PCG project. Just grab: pcg_basic.h and pcg_basic.c.
It would be brilliant to get autocomplete when only the header is indexed so it works when using shared libraries.
Description of the bug
Autocomplete is not suggesting functions from indexed C headers.
Steps to reproduce
Expected behavior
Autocomplete suggests functions from included header files.
Actual behavior
Autocomplete does not suggest functions from included headers. If I type the function manually, goto Definition and references work so the indexes are good - all that's missing is the autocomplete.
Sublime Text build number
4122
Operating system & version
openSUSE Tumbleweed
(Linux) Desktop environment and/or window manager
Xfce
Additional information
No response
OpenGL context information
No response