xavierd / clang_complete

Vim plugin that use clang for completing C/C++ code.
http://www.vim.org/scripts/script.php?script_id=3302
1.96k stars 308 forks source link

Request: list all identifiers in the current file #535

Closed damnskippy closed 7 years ago

damnskippy commented 7 years ago

Would it be possible to add an API to return a list of all identifiers found in the current file (and those included), known to clang_complete?

This list can be then be fed into a fuzzy searcher (like fzf to look up an identifier at will. For instance, there's a working example using ctags in fzf.vim -- basically it gets a list of tags from ctags and then feeds it into fzf parser. And this really makes for a powerful way of searching for a tag in a given file (IMHO).

If I'm not mistaken, I assume clang_complete builds a cache of information about the current file so it won't have to do it over again, that is then used for code completion.

I totally understand if you feel this request is outside the scope of this plugin. Any clang related pointers on how to do this would be greatly appreciated. Thanks.

damnskippy commented 7 years ago

Oh, wait - I guess this must already be possible by calling the omnifunc directly with args like this: ClangComplete(0,'')?

xaizek commented 7 years ago

Oh, wait - I guess this must already be possible by calling the omnifunc directly with args like this: ClangComplete(0,'')?

No, that invokes completion, which accounts for context and also includes things from included files.

See 31280bde3cb86ab77064dbf31d023637f4790b61 for an example, g:ClangListSymbols() returns some symbols (this includes parameters of functions). Locations are there, but names probably need to be made fully qualified and more stuff might need to be filtered out, this is in listSymbols() in python.

The plugin contains diagnostics and goto-definition functionality already, so listing symbols won't make much difference. I can merge a pull request with it, but since I'm not actually using the plugin anymore, I'm reluctant to implement new functionality myself.

damnskippy commented 7 years ago

No worries, I fully understand - thanks also for the the pointers/patch.