prabirshrestha / asyncomplete.vim

async completion in pure vim script for vim8 and neovim
MIT License
926 stars 60 forks source link

How could I use tmux-complete.vim with asyncomplete.vim #33

Closed kepbod closed 6 years ago

kepbod commented 7 years ago

What's the config I should use to make tmux-complete.vim working well with asyncomplete.vim? Thanks!

prabirshrestha commented 6 years ago

Since tmux-complete.vim supports omni-func you could try asyncomplete-omni.vim.

You could create a wrapper around tmuxcomplete#gather_candidates() but this will still block your vim since it uses sync system() call. Omni will also block your vim.

To get the benefit of pure async I would suggest to file an issue in tmux-complete.vim to provide an async api.. https://github.com/prabirshrestha/asyncomplete.vim/blob/master/README.md#using-existing-vim-plugin-sources. It could then use async.vim to normalize jobs between vim8 and neovim so the command runs asynchronously. Feel free to file the issue there and I would be glad to help out. Looking at their source code seems like it is quite easy to implement a pure async source for tmux-complete.vim.

function s:completor(opt, ctx)
  call tmuxcomplete#get_async_completions({candidates, startcol -> asyncomplete#complete(a:opt['name'], a:ctx, startcol, candidates) })
endfunction

call asyncomplete#register_source({
    \ 'name': 'tmuxcomplete',
    \ 'whitelist': [*],
    \ 'completor': function('s:completor'),
    \ })
kepbod commented 6 years ago

Thanks a lot. I filled an issue in tmux-complete.vim.

prabirshrestha commented 6 years ago

@kepbod Added more comments - https://github.com/wellle/tmux-complete.vim/issues/76#issuecomment-346516885. Closing this for now. Feel free to send an update when the source is complete or if you need any help from me.