mirror of
https://github.com/prabirshrestha/asyncomplete.vim.git
synced 2025-12-14 20:35:41 +01:00
192 lines
6.7 KiB
Plaintext
192 lines
6.7 KiB
Plaintext
*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_enable_for_all *g:asyncomplete_enable_for_all*
|
|
|
|
Type |Number|
|
|
Default: 1
|
|
|
|
Enable asyncomplete for all buffers. Can be overriden with
|
|
`b:asyncomplete_enable` on a per-buffer basis. Setting this to 0 prevents
|
|
asyncomplete from loading upon entering a buffer.
|
|
|
|
b:asyncomplete_enable *b:asyncomplete_enable*
|
|
|
|
Type |Number|
|
|
Default: 1
|
|
|
|
Setting this variable to 0 disables asyncomplete for the current buffer
|
|
and overrides `g:asyncomplete_enable_for_all` .
|
|
|
|
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.
|
|
|
|
g:asyncomplete_min_chars *g:asyncomplete_min_chars*
|
|
|
|
Type: |Number|
|
|
Default: 0
|
|
|
|
Minimum consecutive characters to trigger auto-popup. Overridden by buffer
|
|
variable if set (`b:asyncomplete_min_chars`)
|
|
|
|
g:asyncomplete_matchfuzzy *g:asyncomplete_matchfuzzy*
|
|
|
|
Type: |Number|
|
|
Default: `exists('*matchfuzzypos')`
|
|
|
|
Use |matchfuzzypos| to support fuzzy matching of 'word' when completing
|
|
items. Requires vim with `matchfuzzypos()` function to exists.
|
|
|
|
Set to `0` to disable fuzzy matching.
|
|
|
|
===============================================================================
|
|
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:
|