Async completion in vim

David · April 25, 2020

I recently starting using asyncomplete.vim for vim completion with LSP servers. I initially tested it out just to see if it would be more responsive than manually invoking vim-lsp’s completion (which sometimes takes a moment regardless of async because I don’t proceed until it’s done) and found that it seemed improve responsiveness – presumably because the completions appear once their available instead of when I request them.

I get a lot more completions than I used to (it completes keywords and short things I wouldn’t bother) and I’ve had to reconfigure some mappings to handle frequently exiting from completion. It also doesn’t do fuzzy completion (it’s prefix only), but invoking vim-lsp’s omnicompletion performs fuzzy completion so that option is always available.

Asyncomplete uses vim jobs to do completion without blocking your input and it’s vimscript, so no dependencies and no compiling. It’s by the same author as vim-lsp, so you can expect pretty solid integration between the two, but they’re also logically separate with the asyncomplete-lsp plugin implementing an asyncomplete provider for lsp’s completions so it’s shouldn’t be too hard to switch away from vim-lsp.

When completions have multiple parts – like arguments in a function – asyncomplete inserts some placeholders. But if you use Ultisnips, you can install vim-lsp-ultisnips.vim to make jumping between arguments smoother. I think there are alternatives for other snippet engines too.

Then installing the server is usually easy:


You can check if it’s working:


In short, for vim-plug:

Plug 'mattn/vim-lsp-settings'
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'prabirshrestha/asyncomplete-tags.vim'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'thomasfaingnaert/vim-lsp-ultisnips'

Twitter, Facebook