clang_complete icon indicating copy to clipboard operation
clang_complete copied to clipboard

Fuzzy completion

Open tobiasgrosser opened this issue 10 years ago • 6 comments

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.

tobiasgrosser avatar Mar 06 '14 14:03 tobiasgrosser

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.

tobiasgrosser avatar Mar 06 '14 15:03 tobiasgrosser

There is also a feature called '' 'refresh': 'always'" see ':help complete-functions', which might be helpful here too.

tobiasgrosser avatar Mar 06 '14 15:03 tobiasgrosser

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.

xavierd avatar Mar 08 '14 03:03 xavierd

This could be a great addition, can make it optional if cost is a concern.

damnskippy avatar Feb 08 '18 17:02 damnskippy

I am currently not working on this, but please feel free to pick this up.

tobiasgrosser avatar Feb 08 '18 17:02 tobiasgrosser

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.

jep-dev avatar Feb 18 '18 22:02 jep-dev