You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
155 lines
5.6 KiB
155 lines
5.6 KiB
*asyncomplete.vim.txt* Async autocompletion for Vim 8 and Neovim.
|
|
*asyncomplete*
|
|
|
|
|
|
===============================================================================
|
|
CONTENTS *asyncomplete-contents*
|
|
|
|
1. Introduction |asyncomplete-introduction|
|
|
2. Options |asyncomplete-options|
|
|
3. Functions |asyncomplete-functions|
|
|
4. Global vim configuration |asyncomplete-global-config|
|
|
5. Known Issues |asyncomplete-known-issues|
|
|
|
|
===============================================================================
|
|
1. Introduction *asyncomplete-introduction*
|
|
|
|
Async autocompletion for Vim 8 and Neovim with |timers|.
|
|
|
|
This is inspired by https://github.com/roxma/nvim-complete-manager but written
|
|
in pure Vim Script.
|
|
|
|
===============================================================================
|
|
2. Options *asyncomplete-options*
|
|
|
|
|
|
g:asyncomplete_auto_popup *g:asyncomplete_auto_popup*
|
|
|
|
Type: |Number|
|
|
Default: `1`
|
|
|
|
Automatically show the autocomplete popup menu as you start typing.
|
|
|
|
g:asyncomplete_log_file *g:asyncomplete_log_file*
|
|
|
|
Type: |String|
|
|
Default: null
|
|
|
|
Path to log file.
|
|
|
|
g:asyncomplete_popup_delay *g:asyncomplete_popup_delay*
|
|
|
|
Type: |Number|
|
|
Default: 30
|
|
|
|
Milliseconds to wait before opening the popup menu
|
|
|
|
g:asyncomplete_auto_completeopt *g:asyncomplete_auto_completeopt*
|
|
|
|
Type: |Number|
|
|
Default: 1
|
|
|
|
Set default `completeopt` options. These are `menuone,noinsert,noselect`.
|
|
This effectively overwrites what ever the user has in their config file.
|
|
|
|
Set to 0 to disable.
|
|
|
|
g:asyncomplete_preprocessor *g:asyncomplete_preprocessor*
|
|
|
|
Type: |Array| for zero or one |Function|
|
|
Default: []
|
|
|
|
Set a function to allow custom filtering or sorting.
|
|
Below example implements removing duplicates.
|
|
|
|
function! s:my_asyncomplete_preprocessor(options, matches) abort
|
|
let l:visited = {}
|
|
let l:items = []
|
|
for [l:source_name, l:matches] in items(a:matches)
|
|
for l:item in l:matches['items']
|
|
if stridx(l:item['word'], a:options['base']) == 0
|
|
if !has_key(l:visited, l:item['word'])
|
|
call add(l:items, l:item)
|
|
let l:visited[l:item['word']] = 1
|
|
endif
|
|
endif
|
|
endfor
|
|
endfor
|
|
|
|
call asyncomplete#preprocess_complete(a:options, l:items)
|
|
endfunction
|
|
|
|
let g:asyncomplete_preprocessor = [function('s:my_asyncomplete_preprocessor')]
|
|
|
|
Note:
|
|
asyncomplete#preprocess_complete() must be called synchronously.
|
|
Plans to support async preprocessing will be supported in the future.
|
|
|
|
context and matches in arguments in preprecessor function should be treated
|
|
as immutable.
|
|
===============================================================================
|
|
3. Functions *asyncomplete-functions*
|
|
|
|
asyncomplete#close_popup() *asyncomplete#close_popup()*
|
|
|
|
Insert selected candidate and close popup menu.
|
|
Following example prevents popup menu from re-opening after insertion.
|
|
>
|
|
inoremap <expr> <C-y> pumvisible() ? asyncomplete#close_popup() : "\<C-y>"
|
|
<
|
|
asyncomplete#cancel_popup() *asyncomplete#cancel_popup()*
|
|
|
|
Cancel completion and close popup menu.
|
|
Following example prevents popup menu from re-opening after cancellation.
|
|
>
|
|
inoremap <expr> <C-e> pumvisible() ? asyncomplete#cancel_popup() : "\<C-e>"
|
|
<
|
|
asyncomplete#get_source_info({source-name}) *asyncomplete#get_source_info()*
|
|
|
|
Get the source configuration info as dict.
|
|
Below example implements a priority sort function.
|
|
>
|
|
function! s:sort_by_priority_preprocessor(options, matches) abort
|
|
let l:items = []
|
|
for [l:source_name, l:matches] in items(a:matches)
|
|
for l:item in l:matches['items']
|
|
if stridx(l:item['word'], a:options['base']) == 0
|
|
let l:item['priority'] =
|
|
\ get(asyncomplete#get_source_info(l:source_name),'priority',0)
|
|
call add(l:items, l:item)
|
|
endif
|
|
endfor
|
|
endfor
|
|
|
|
let l:items = sort(l:items, {a, b -> b['priority'] - a['priority']})
|
|
|
|
call asyncomplete#preprocess_complete(a:options, l:items)
|
|
endfunction
|
|
|
|
let g:asyncomplete_preprocessor = [function('s:sort_by_priority_preprocessor')]
|
|
<
|
|
asyncomplete#get_source_names() *asyncomplete#get_source_names()*
|
|
|
|
Get the registered source names list.
|
|
|
|
===============================================================================
|
|
4. Global vim configuration *asyncomplete-global-config*
|
|
|
|
If you notice messages like 'Pattern not found' or 'Match 1 of <N>' printed in
|
|
red colour in vim command line and in `:messages` history and you are annoyed
|
|
with them, try setting `shortmess` vim option in your `.vimrc` like so:
|
|
>
|
|
set shortmess+=c
|
|
<
|
|
See `:help shortmess` for details and description.
|
|
|
|
===============================================================================
|
|
5. Known Issues *asyncomplete-known-issues*
|
|
|
|
Builtin complete such as omni func, file func flickers and closes.
|
|
You need vim with patch v8.1.1068.
|
|
https://github.com/vim/vim/commit/fd133323d4e1cc9c0e61c0ce357df4d36ea148e3
|
|
|
|
===============================================================================
|
|
|
|
vim:tw=78:ts=4:sts=4:sw=4:ft=help:norl:
|
|
|