clang_complete
clang_complete copied to clipboard
Fuzzy completion
It would be really nice to optionally have fuzzy completion for clang_complete.
This means, for this completion
HairObject.Bl ^ completion triggered here
The following options shown should be:
HairObject.isBlue() .isBlond() .Bleach()
Currently, only the very last one is shown.
Implementing this is not very difficult. The idea is to automatically retrigger the completion function on every keystroke (autocmd CursorMoved) e.g. by calling C-X C-U.
The following patch gives us then a first kind of fuzzy matching:
@@ -495,7 +495,7 @@ def getCurrentCompletions(base): timer.registerEvent("Count # Results (%s)" % str(len(results)))
if base != "":
- results = filter(lambda x: getAbbr(x.string).startswith(base), results)
- results = filter(lambda x: getAbbr(x.string).count(base), results)
This can then possibly be extended by ignoring the case or matching all uppercase letters such as 'wac' -> 'HairObject.WashAndCut()" or doing some basic edit-distance computations.
This commit drafts this feature. https://github.com/tobig/clang_complete/commit/3fe5c08f950caae0c9d49985823f97c84a005254
It is still a huge hack and currently also still very costly as we call clang at each character stroke. We can probably make this a lot faster.
There is also a feature called '' 'refresh': 'always'" see ':help complete-functions', which might be helpful here too.
It could be interesting yes, I'm just worried about the cost :). We can probably have some caching mechanism to prevent calling into vim every time.
This could be a great addition, can make it optional if cost is a concern.
I am currently not working on this, but please feel free to pick this up.
I'm very interested in this feature - is anyone actively working on it? I wouldn't be the right person to start it, but I'd be happy to contribute, test, profile, etc. if it's public. Edit - just saw the draft, I'll take a look.