3

I am using the autocomplete and I feel quite comfortable with it because it's minimalistic and simple. But there is just a thing I dislike: sometimes it interferes with the mouse scrolling auto-changing some word... Well, sometimes it also interferes when I jump from word to word in insert-mode, obligating me to undo the pop-up with direction keys...

Perhaps in this last weeks I am playing too much with vim, but my intention is to investigate the small plugin code to adjust it as my needs (if possible), enabling / disabling it depending if I am writing or not.

The pseudocode I thought is:

  1. Start typing or entering insert-mode, execute acp#enable()
  2. Stop typing or exit from insert-mode, execute acp#disable()

So is there any possible vim option that could enable it only when I am typing and disable after a short timeout when I stop/pause typing text ?

Is this too good to be true?

EDIT:

I just saw these interesting features:

TextChangedI            
                After a change was made to the text in the
                current buffer in Insert mode.
                Not triggered when the popup menu is visible.
                Otherwise the same as TextChanged.

InsertCharPre           
                When a character is typed in Insert mode,
                before inserting the char.
                The |v:char| variable indicates the char typed
                and can be changed during the event to insert
                a different character.  When |v:char| is set
                to more than one character this text is
                inserted literally.
                It is not allowed to change the text |textlock|.
                The event is not triggered when 'paste' is
                set.

And help timeout.

  • 1
    I don't use this plugin and I'm really not sure what you want to do is a good idea (that look like a hacky trick which might cause more problems than it solves, but once again I don't use this plugin so I might be wrong). However you might also be interested in :h CursorHoldI. – statox Dec 20 '17 at 14:44
  • Good to know this event. I actually set up an autocmd for InsertCharPre which calls acp#enable(), and other three autocmds for the events InsertLeave, CursorHold, CursorHoldI, and each one calls acp#disable(). Seems to be helpful ! – simo-zz Dec 20 '17 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.