Closed jerrykal closed 5 years ago
I am making a lot of assumptions below so treat what I say as wild guess :) I don't think that header completion is possible with libclang completion as headers (especially those not included) are not part of the TU. On the other hand ECC requires valid clang configuration file so it also has all required include directories. Grepping file names from include dirs and then injecting them to the completion list shouldn't be to hard.
So either way it should be possible to provide this functionality. The other question is if we (and by we I mean @niosus :D ) want to introduce it?
Sky is the limit :)
@ooJerryLeeoo yes, it should be possible. It is not provided by libclang itself, so we will have to parse things on our own.
@simia I am definitely for it. The problem here is that we have to be really careful with implementation. We can have hundreds of folders and thousands of headers. We need a fast way to search for them using a given prefix.
Maybe we can start with a relatively dumb implementation and replace it with something smarter later.
@niosus I was thinking about getting all headers names at plugin startup and holding them in some tree like structure for a fast lookup.
Yeah, that seems like the obvious solution. We just need to make sure that this job is asynchronous. Should be simple with the thread pool in place. If the speed is not enough, we can use a trie (I think this is the first time in my life when it makes sense to use this data structure :laughing: )
Related: https://github.com/google/pygtrie
UPD: as a side note, we should probably consider just throwing all of them into sublime completions and let sublime filter them itself. Seems it's doing a pretty good job at that.
Just thought, that we need to be careful with storing all headers as people tend to delete and create new files.
Yeah, people tend to do such a nonsense for some reason :smiley_cat:
But depending on how long it takes we can probably preload all headers on file open in a separate thread.
One suggestion regarding the cached path: I would distinguish between system folders (which are mostly fixed and could be cached once at plugin load) and project folders (where user might add/remove stuff, so they should be watched/monitored in a separate thread).
Also, it would be nice if you could make use of ST's fuzzy string matching to find the header file to include, but I don't know if plugins can do that.
This is a valid point @jdumas
I believe it is possible. We just need to try to throw all headers into sublime's completion engine.
It would be awesome if you could you the same data structure to navigate to the header file using a mouse click. :) Sorry if this is out of scope for here.
@bigboze I believe it should be possible once we nail down the completion.
There's a package for autocompleting header file paths: https://packagecontrol.io/packages/Include%20Autocomplete
Thanks for a suggestion, but that package doesn't really work for me. We could probably adapt it to this plugin to some degree, considering that we already have all the include folders.
Here is another package. https://github.com/ljesparis/CHeaders
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Just comment here to prevent this from happening.
:(
@jdumas I believe this is going to land some day. But I can't find the time to finish up the crude PR I started... Stale was not intended here.
It's ok, I'll just keep commenting if the bot is acting up again ... no rush here :D
It's gonna react again in 60 days. I hope it won't need to :laughing:
Closed in #411
Is possible to add C/C++ header completion like Xcode?