lifepillar / vim-mucomplete

Chained completion that works the way you want!
MIT License
913 stars 18 forks source link

How to configure with MultiWordComplete? #80

Closed reckoner closed 6 years ago

reckoner commented 6 years ago

I am trying to get this working with MultiWordComplete by doing the following in my vimrc:

let g:mucomplete#user_mappings = {
      \ 'mwc'  : "\<c-x>w"
      \ }
let g:mucomplete#chains = {}
let g:mucomplete#chains.default = ["mwc","omni","user","keyp","keyn","dict"]
let g:mucomplete#enable_auto_at_startup = 1

but this doesn't work. Note that completefunc is set by MultiWordComplete as the following:

completefunc=MultiWordComplete#MultiWordComplete

Any help appreciated.

lifepillar commented 6 years ago

Does it work when you turn auto-completion off and use Tab instead? Does let g:MultiWordComplete_FindStartMark='' help? You might also want to define g:mucomplete#can_complete to avoid triggering completion after just one character, e.g.:

  let g:mucomplete#can_complete = { 'default': {} }
  " Trigger after two keyword characters
  let g:mucomplete#can_complete.default.mwc = { t -> g:mucomplete_with_key || t =~# '\m\k\k$' }

But please, first of all make sure that MWC does what you expect when you invoke it directly. For example, after playing a bit with it I have found that when I type this in an empty buffer:

ops per sec
ops<c-x>w<c-e><c-x>w

the first <c-x>w triggers completion correctly, but the second <c-x>w does not trigger anything. This behaviour does not seem correct to me, and it is surely disappointing for µcomplete :/

lifepillar commented 6 years ago

Also, try the following, which simulates what µcomplete does when auto-completing (assuming that completion is triggered after two characters). Make sure auto-completion is off, and type this in a new session:

ops per sec
op<c-x>w s pe<c-w>x

After typing op<c-x>w, MWC offers to complete with ops per. If you continue typing, after pressing Space the menu is correctly dismissed because nothing matches. If you go on and type pe<c-w>x, MWC deletes pe. This shouldn't happen. If you type the same with auto-completion on, the effect is that you see the text disappearing while your are typing. This is a problem with MWC, not µcomplete.

Given how it works, I am not sure that it makes sense to use MWC with autocompletion on. It is probably better to enable it only on manual completion (see :help mucomplete-tips for an example of how to do that).

reckoner commented 6 years ago

Thanks for checking into it. I'll set it up for manual completion.