]> git.madduck.net Git - etc/vim.git/blob - doc/asyncomplete.txt

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/asyncomplete/' content from commit 016590d2
[etc/vim.git] / doc / asyncomplete.txt
1 *asyncomplete.vim.txt*  Async autocompletion for Vim 8 and Neovim.
2 *asyncomplete*
3
4
5 ===============================================================================
6 CONTENTS                                                *asyncomplete-contents*
7
8     1. Introduction              |asyncomplete-introduction|
9     2. Options                   |asyncomplete-options|
10     3. Functions                 |asyncomplete-functions|
11     4. Global vim configuration  |asyncomplete-global-config|
12     5. Known Issues              |asyncomplete-known-issues|
13
14 ===============================================================================
15 1. Introduction                                     *asyncomplete-introduction*
16
17 Async autocompletion for Vim 8 and Neovim with |timers|.
18
19 This is inspired by https://github.com/roxma/nvim-complete-manager but written
20 in pure Vim Script.
21
22 ===============================================================================
23 2. Options                                               *asyncomplete-options*
24
25
26 g:asyncomplete_enable_for_all                   *g:asyncomplete_enable_for_all*
27
28     Type |Number|
29     Default: 1
30
31     Enable asyncomplete for all buffers. Can be overriden with
32     `b:asyncomplete_enable` on a per-buffer basis.  Setting this to 0 prevents
33     asyncomplete from loading upon entering a buffer.
34
35 b:asyncomplete_enable                                   *b:asyncomplete_enable*
36
37     Type |Number|
38     Default: 1
39
40     Setting this variable to 0 disables asyncomplete for the current buffer
41     and overrides `g:asyncomplete_enable_for_all` .
42
43 g:asyncomplete_auto_popup                           *g:asyncomplete_auto_popup*
44
45     Type: |Number|
46     Default: `1`
47
48     Automatically show the autocomplete popup menu as you start typing.
49
50 g:asyncomplete_log_file                               *g:asyncomplete_log_file*
51
52     Type: |String|
53     Default: null
54
55     Path to log file.
56
57 g:asyncomplete_popup_delay                         *g:asyncomplete_popup_delay*
58
59     Type: |Number|
60     Default: 30
61
62     Milliseconds to wait before opening the popup menu
63
64 g:asyncomplete_auto_completeopt               *g:asyncomplete_auto_completeopt*
65
66     Type: |Number|
67     Default: 1
68
69     Set default `completeopt` options. These are `menuone,noinsert,noselect`.
70     This effectively overwrites what ever the user has in their config file.
71
72     Set to 0 to disable.
73
74 g:asyncomplete_preprocessor                        *g:asyncomplete_preprocessor*
75
76     Type: |Array| for zero or one |Function|
77     Default: []
78
79     Set a function to allow custom filtering or sorting.
80     Below example implements removing duplicates.
81
82       function! s:my_asyncomplete_preprocessor(options, matches) abort
83         let l:visited = {}
84         let l:items = []
85         for [l:source_name, l:matches] in items(a:matches)
86           for l:item in l:matches['items']
87             if stridx(l:item['word'], a:options['base']) == 0
88               if !has_key(l:visited, l:item['word'])
89                 call add(l:items, l:item)
90                 let l:visited[l:item['word']] = 1
91               endif
92             endif
93           endfor
94         endfor
95
96         call asyncomplete#preprocess_complete(a:options, l:items)
97       endfunction
98
99       let g:asyncomplete_preprocessor = [function('s:my_asyncomplete_preprocessor')]
100
101     Note:
102     asyncomplete#preprocess_complete() must be called synchronously.
103     Plans to support async preprocessing will be supported in the future.
104
105     context and matches in arguments in preprecessor function should be treated
106     as immutable.
107
108 g:asyncomplete_min_chars                             *g:asyncomplete_min_chars*
109
110     Type: |Number|
111     Default: 0
112
113     Minimum consecutive characters to trigger auto-popup. Overridden by buffer
114     variable if set (`b:asyncomplete_min_chars`)
115
116 g:asyncomplete_matchfuzzy                           *g:asyncomplete_matchfuzzy*
117
118     Type: |Number|
119     Default: `exists('*matchfuzzypos')`
120
121     Use |matchfuzzypos| to support fuzzy matching of 'word' when completing
122     items. Requires vim with `matchfuzzypos()` function to exists.
123
124     Set to `0` to disable fuzzy matching.
125
126 ===============================================================================
127 3. Functions                                            *asyncomplete-functions*
128
129 asyncomplete#close_popup()                         *asyncomplete#close_popup()*
130
131     Insert selected candidate and close popup menu.
132     Following example prevents popup menu from re-opening after insertion.
133 >
134     inoremap <expr> <C-y> pumvisible() ? asyncomplete#close_popup() : "\<C-y>"
135 <
136 asyncomplete#cancel_popup()                       *asyncomplete#cancel_popup()*
137
138     Cancel completion and close popup menu.
139     Following example prevents popup menu from re-opening after cancellation.
140 >
141     inoremap <expr> <C-e> pumvisible() ? asyncomplete#cancel_popup() : "\<C-e>"
142 <
143 asyncomplete#get_source_info({source-name})    *asyncomplete#get_source_info()*
144
145     Get the source configuration info as dict.
146     Below example implements a priority sort function.
147 >
148     function! s:sort_by_priority_preprocessor(options, matches) abort
149       let l:items = []
150       for [l:source_name, l:matches] in items(a:matches)
151         for l:item in l:matches['items']
152           if stridx(l:item['word'], a:options['base']) == 0
153             let l:item['priority'] =
154                 \ get(asyncomplete#get_source_info(l:source_name),'priority',0)
155             call add(l:items, l:item)
156           endif
157         endfor
158       endfor
159
160       let l:items = sort(l:items, {a, b -> b['priority'] - a['priority']})
161
162       call asyncomplete#preprocess_complete(a:options, l:items)
163     endfunction
164
165     let g:asyncomplete_preprocessor = [function('s:sort_by_priority_preprocessor')]
166 <
167 asyncomplete#get_source_names()               *asyncomplete#get_source_names()*
168
169     Get the registered source names list.
170
171 ===============================================================================
172 4. Global vim configuration                          *asyncomplete-global-config*
173
174 If you notice messages like 'Pattern not found' or 'Match 1 of <N>' printed in
175 red colour in vim command line and in `:messages` history and you are annoyed
176 with them, try setting `shortmess` vim option in your `.vimrc` like so:
177 >
178     set shortmess+=c
179 <
180 See `:help shortmess` for details and description.
181
182 ===============================================================================
183 5. Known Issues                                       *asyncomplete-known-issues*
184
185 Builtin complete such as omni func, file func flickers and closes.
186     You need vim with patch v8.1.1068.
187     https://github.com/vim/vim/commit/fd133323d4e1cc9c0e61c0ce357df4d36ea148e3
188
189 ===============================================================================
190
191   vim:tw=78:ts=4:sts=4:sw=4:ft=help:norl: