-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathpum.txt
775 lines (577 loc) · 25.6 KB
/
pum.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
*pum.txt* Original popup completion menu framework library
Version: 2.0
Author: Shougo <Shougo.Matsu at gmail.com>
License: MIT license
CONTENTS *pum-contents*
Introduction |pum-introduction|
Install |pum-install|
Interface |pum-interface|
Variables |pum-variables|
Options |pum-options|
Functions |pum-functions|
Columns |pum-columns|
Key mappings |pum-key-mappings|
Autocmds |pum-autocmds|
Examples |pum-examples|
FAQ |pum-faq|
Compatibility |pum-compatibility|
==============================================================================
INTRODUCTION *pum-introduction*
*pum* is the framework library to implement original popup menu completion.
It works both insert mode and command line mode.
==============================================================================
INSTALL *pum-install*
NOTE: pum.vim requires Neovim (0.10.0+) or Vim 9.1.0448+ (latest is
recommended).
pum.vim detects if "noice.nvim" is installed.
https://github.com/folke/noice.nvim
==============================================================================
INTERFACE *pum-interface*
------------------------------------------------------------------------------
VARIABLES *pum-variables*
*g:pum#completed_event*
g:pum#completed_event
It is event name.
"confirm": |pum#map#confirm()|.
"confirm_word": |pum#map#confirm_word()|.
"complete_done": Others.
It is used in |PumCompleteDone| event.
*g:pum#completed_item*
g:pum#completed_item
It is inserted item like |v:completed_item|.
It is used in |PumCompleteDone| event.
------------------------------------------------------------------------------
OPTIONS *pum-options*
Options can be toggled through the use of |pum#set_option()|.
NOTE: The options must be set before call of |pum#open()|.
*pum-option-auto_confirm_time*
auto_confirm_time
If it is positive value, the inserted item is auto confirmed
after you don't input.
Default: 0
*pum-option-auto_select*
auto_select
Enable the auto selection of the first item.
Default: v:true if 'completeopt' contains "noinsert"
*pum-option-blend*
blend
Specify 'winblend' option value.
NOTE: neovim only feature.
Default: 'pumblend' value
*pum-option-border*
border
The completion window border.
See |nvim_open_win()| or |popup_create-arguments| for the
detail.
Following values are available:
"none": Disabled.
"single": A single line box.
"double": A double line box.
"rounded": neovim only.
"solid": neovim only.
"shadow": neovim only.
array: Specifify the eight chars building up the border.
NOTE: If you use "single" or "double" in Vim, 'ambiwidth' must
be "single" and 'encoding' must be "utf-8".
Default: "none"
*pum-option-commit_characters*
commit_characters
When the characters are input, execute |pum#map#confirm()|
automatically.
NOTE: It does work only insert mode.
NOTE: The input text must be head match.
Default: []
*pum-option-direction*
direction
The popup menu direction if possible.
NOTE: It does not work for command line mode.
"above": Above menu direction.
"below": Below menu dicrection.
"auto": Wider menu dicrection is used.
Default: "auto"
*pum-option-follow_cursor*
follow_cursor
The popup menu is displayed after the cursor position.
Default: v:false
*pum-option-highlight_columns*
highlight_columns
The columns highlights of candidates.
The key is column name.
The value is highlight name.
See |pum-columns|.
Default: {}
*pum-option-highlight_horizontal_menu*
highlight_horizontal_menu
The highlight of the horizontal menu.
|pum-option-horizontal_menu|
Default: ""
*pum-option-highlight_horizontal_separator*
highlight_horizontal_separator
The highlight of the horizontal menu separator.
|pum-option-horizontal_menu|
Default: "PmenuSbar"
*pum-option-highlight_inserted*
highlight_inserted
The highlight of the inserted text when
|pum#map#insert_relative()|.
Default: "ComplMatchIns"
*pum-option-highlight_lead*
highlight_lead
The highlight of the lead text when
|pum#map#insert_relative()|.
Default: "PmenuMatchLead"
*pum-option-highlight_matches*
highlight_matches
The input matches highlight of candidates.
Default: "PmenuMatch"
*pum-option-highlight_normal_menu*
highlight_normal_menu
The highlight of the normal menu.
Default: "Pmenu"
*pum-option-highlight_preview*
highlight_preview
The highlight of the preview window.
Default: "Pmenu"
*pum-option-highlight_scrollbar*
highlight_scrollbar
The scrollbar highlight.
NOTE: neovim only feature.
Default: "PmenuSbar"
*pum-option-highlight_selected*
highlight_selected
The selected highlight of candidates.
Default: "PmenuSel"
*pum-option-horizontal_menu*
horizontal_menu
Use horizontal menu instead of vertical popup menu.
NOTE: The feature does not support custom highlights and
columns.
Default: v:false
*pum-option-insert_preview*
insert_preview
Enable inserted text highlight when
|pum#map#insert_relative()|.
Default: v:false
*pum-option-item_orders*
item_orders
The column order of the item.
NOTE: "space" column means between items padding.
See |pum-columns|.
Default: ["abbr", "space", "kind", "space", "menu"]
*pum-option-max_columns*
max_columns
The column maximum width of the item.
See |pum-columns|.
Default: #{ kind: 10, menu: 20 }
*pum-option-max_horizontal_items*
max_horizontal_items
The max items of the horizontal menu.
|pum-option-horizontal_menu|
Default: 3
*pum-option-max_height*
max_height
The maximum height of the popup menu.
Default: 'pumheight' value
*pum-option-max_width*
max_width
The maximum width of the popup menu.
Default: 0
*pum-option-min_height*
min_height
The minimum height of the popup menu.
Default: 0
*pum-option-min_width*
min_width
The minimum width of the popup menu.
Default: 'pumwidth' value
*pum-option-offset_cmdcol*
offset_cmdcol
Popup col offset in the command line mode.
Default: 0
*pum-option-offset_cmdrow*
offset_cmdrow
Popup row offset in the command line mode.
Default: 0
*pum-option-offset_col*
offset_col
Popup column offset if |pum-option-horizontal_menu|.
Default: 0
*pum-option-offset_row*
offset_row
Popup row offset.
Default: 0
*pum-option-padding*
padding
Enable left/right padding like native completion menu.
Default: v:false
*pum-option-preview*
preview
Enable pum.vim builtin preview window.
It prints "info" attribute in current item or prints previewer
information from |ddc#get_previewer()|.
Default: v:false
*pum-option-preview-border*
preview_border
The preview window border. You can specify border
|nvim_open_win()| border option.
NOTE: neovim only feature. Vim's border feature is not
stable.
Default: "none"
*pum-option-preview_delay*
preview_delay
The delay time(ms) to display preview window.
Default: 500
*pum-option-preview_height*
preview_height
The maximum height of the preview window.
Default: 'previewheight' value
*pum-option-preview_width*
preview_width
The maximum width of the preview window.
Default: 'pumwidth' / 2 value
*pum-option-reversed*
reversed
Enable reversed mode. The items order is reversed.
NOTE: It increases screen flicker.
NOTE: |pum-option-direction| must be "above" or command line
mode for the feature.
Default: v:false
*pum-option-scrollbar_char*
scrollbar_char
Specify scrollbar character.
NOTE: The scrollbar feature is disabled if it is empty string.
NOTE: neovim only feature.
Default: "|"
*pum-option-use_setline*
use_setline
Use |setline()| instead of |feedkeys()| when insertion.
It is faster but |.| repeat does not work.
NOTE: It is for insert mode only.
Default: v:false
*pum-option-zindex*
zindex
Popup window z-index.
Default: 1000
------------------------------------------------------------------------------
FUNCTIONS *pum-functions*
*pum#close()*
pum#close()
Close current popup menu and preview window.
*pum#complete_info()*
pum#complete_info([{what}])
Returns |Dictionary| like |complete_info()|.
If {what} is supplied, then only the items listed in {what}
are returned.
*pum#current_item()*
pum#current_item()
Get current cursor item.
*pum#entered()*
pum#entered()
Returns |v:true| if you have selected or inserted popup menu.
NOTE: It does not work for auto selection feature.
*pum#get_direction()*
pum#get_direction()
Get popup menu current direction.
*pum#get_pos()*
pum#get_pos()
Returns like |pum_getpos()| result.
height window height
width window width
row screen position row (0 origin)
col screen position col (0 origin)
size total number of items
scrollbar |TRUE| if scrollbar is visible
*pum#get_preview_buf()*
pum#get_preview_buf()
Returns the preview buffer number.
NOTE: You must enable |pum-option-preview|.
*pum#open()*
pum#open({startcol}, {items})
Open popup menu like |complete()|.
{startcol} is the byte offset in the line where the completed
text start.
NOTE: {startcol} is 1 origin like |col()|.
{items} must be a |List|. See |complete-items| for the kind
of items. You can use following special key.
highlights: Custom highlights.
type "abbr" or "kind" or "menu"
name highlight name. It is used for
|prop_type_add()| in Vim.
NOTE: It must be unique of each
highlight group.
hl_group highlight group
(|highlight-groups|)
col highlight start column (1 origin)
width highlight end column width
NOTE: It is experimental feature.
NOTE: If 'completeopt' contains "noinsert", the first item is
selected automatically, but it increases screen flicker.
*pum#open_preview()*
pum#open_preview()
Open preview window for current item.
It works even |pum-option-preview| is false.
*pum#preview_visible()*
pum#preview_visible()
Returns |v:true| if the preview window is visible in pum.vim.
*pum#set_buffer_option()*
pum#set_buffer_option({option-name}, {value})
pum#set_buffer_option({dict})
Set {option-name} option to {value} for current buffer.
If {dict} is available, the key is {option-name} and the value
is {value}. See |pum-options| for available {option-name}.
*pum#set_local_option()*
pum#set_local_option({mode}, {option-name}, {value})
pum#set_local_option({mode}, {dict})
Set {option-name} option to {value} for {mode}.
You can specify {mode} from |mode()| or |getcmdtype()|.
If {dict} is available, the key is {option-name} and the value
is {value}. See |pum-options| for available {option-name}.
*pum#set_option()*
pum#set_option({option-name}, {value})
pum#set_option({dict})
Set {option-name} option to {value}.
If {dict} is available, the key is {option-name} and the value
is {value}. See |pum-options| for available {option-name}.
*pum#skip_complete()*
pum#skip_complete()
If it is |v:true|, auto completion plugin must be skipped auto
completion.
*pum#update_current_item()*
pum#update_current_item({dict})
Update current cursor item by {dict}.
It executes |PumCompleteChanged| autocmd.
NOTE: It does not redraw current popup menu.
*pum#visible()*
pum#visible()
Returns |v:true| if the popup menu is visible like
|pumvisible()|.
------------------------------------------------------------------------------
COLUMNS *pum-columns*
"abbr", "kind" and "menu" columns are from the item attribute. Other columns
are from the item's "columns" attribute.
------------------------------------------------------------------------------
KEY MAPPINGS *pum-key-mappings*
*pum#map#cancel()*
pum#map#cancel()
Cancel the select and close the popup.
NOTE: It must not be called in |:map-<expr>|.
*pum#map#confirm()*
pum#map#confirm()
Insert the selected item and close the popup.
NOTE: It must not be called in |:map-<expr>|.
*pum#map#confirm_mouse()*
pum#map#confirm_mouse()
Insert the mouse selected item and close the popup.
NOTE: It must not be called in |:map-<expr>|.
NOTE: 'mouse' option must be set.
>vim
inoremap <LeftMouse> <Cmd>call pum#map#confirm_mouse()<CR>
<
*pum#map#confirm_suffix()*
pum#map#confirm_suffix()
Insert the select suffix matched word and close the popup.
It is useful if you want to edit suffix.
NOTE: It must not be called in |:map-<expr>|.
NOTE: It does not work in |:terminal|.
*pum#map#confirm_word()*
pum#map#confirm_word()
Insert the select word and close the popup.
The word means non spaces charaters.
It is useful if you want to complete word by word.
NOTE: It must not be called in |:map-<expr>|.
*pum#map#insert_relative()*
pum#map#insert_relative({delta}[, {overflow}])
Move forward or backward {delta} number and insert the
candidate.
{overflow} is loop behavior when the cursor is overflowed.
"empty": Insert empty text. It is same with native
completion behavior.
"ignore": Ignore the cursor move.
"loop": Move to the opposite item. It is same with
VSCode behavior.
Default: "empty"
NOTE: It must not be called in |:map-<expr>|.
NOTE: It does not work in |:terminal|.
*pum#map#insert_relative_page()*
pum#map#insert_relative_page({delta}[, {overflow}])
Move forward or backward "{delta} * page height" number and
insert the candidate.
{overflow} is same with |pum#map#insert_relative()|.
NOTE: It must not be called in |:map-<expr>|.
NOTE: It does not work in |:terminal|.
*pum#map#longest_relative()*
pum#map#longest_relative({delta}[, {overflow}])
Insert the longest word.
If the longest word is not found, it is same with
|pum#map#insert_relative()|.
The behavior is like "list:longest,full" in 'wildmode'.
NOTE: It must not be called in |:map-<expr>|.
*pum#map#scroll_preview()*
pum#map#scroll_preview({delta})
Scroll forward or backward {delta} number in the
|pum-option-preview| window.
NOTE: It must not be called in |:map-<expr>|.
*pum#map#select_relative()*
pum#map#select_relative({delta}[, {overflow}[, {auto_confirm}]])
Move forward or backward {delta} number and select the
candidate.
{overflow} is same with |pum#map#insert_relative()|.
{auto_confirm} is enable auto confirm feature when user input
text.
NOTE: It must not be called in |:map-<expr>|.
*pum#map#select_relative_page()*
pum#map#select_relative_page({delta}[, {overflow}[, {auto_confirm}]])
Move forward or backward "{delta} * page height" number and
select the candidate.
{overflow} is same with |pum#map#insert_relative()|.
{auto_confirm} is same with |pum#map#select_relative()|.
NOTE: It must not be called in |:map-<expr>|.
*pum#map#toggle_preview()*
pum#map#toggle_preview()
Toggle pum.vim builtin preview window(|pum-option-preview|).
------------------------------------------------------------------------------
AUTOCMDS *pum-autocmds*
*PumClose*
PumClose
It is called before completion menu is closed.
*PumCompleteChanged*
PumCompleteChanged
After each time completion menu changed like
|CompleteChanged|. |complete_info()| gives the information.
*PumCompleteDone*
PumCompleteDone
It is called after completion is done like |CompleteDone|.
|g:pum#completed_item| gives the completed item.
|g:pum#completed_event| gives the event name.
NOTE: You must not use |v:completed_item| in the event.
Please use |g:pum#completed_item| instead.
*PumCompleteDonePre*
PumCompleteDonePre
It is called before |PumCompleteDone| like |CompleteDonePre|.
|g:pum#completed_item| gives the completed item.
NOTE: You must not use |v:completed_item| in the event.
Please use |g:pum#completed_item| instead.
*PumPreview*
PumPreview
It is called after the preview window is created.
You can get preview buffer number by |pum#get_preview_buf()|.
NOTE: You must enable |pum-option-preview|.
==============================================================================
EXAMPLES *pum-examples*
>vim
inoremap <C-n> <Cmd>call pum#map#insert_relative(+1)<CR>
inoremap <C-p> <Cmd>call pum#map#insert_relative(-1)<CR>
inoremap <C-y> <Cmd>call pum#map#confirm()<CR>
inoremap <C-e> <Cmd>call pum#map#cancel()<CR>
inoremap <PageDown> <Cmd>call pum#map#insert_relative_page(+1)<CR>
inoremap <PageUp> <Cmd>call pum#map#insert_relative_page(-1)<CR>
<
==============================================================================
FREQUENTLY ASKED QUESTIONS (FAQ) *pum-faq*
FAQ 1: |pum-faq-1|
How to donate money to you?
FAQ 2: |pum-faq-2|
The popup menu does not close immediately in Vim.
FAQ 3: |pum-faq-3|
The popup menu does not work in |command-line-window|.
FAQ 4: |pum-faq-4|
Auto import or auto snippet expansion does not work in pum.vim.
FAQ 5: |pum-faq-5|
I want to use j/k keys to navigate popup menu when only entered popup
menu.
FAQ 6: |pum-faq-6|
The popup window does not close when enter |command-line-window|.
FAQ 7: |pum-faq-7|
I want to move to the first/last item by Home/End keys.
FAQ 8: |pum-faq-8|
'incsearch' text is flickered when |pum-option-reversed| is set in
neovim.
FAQ 9: |pum-faq-9|
I want to enter the documentation window.
------------------------------------------------------------------------------
*pum-faq-1*
Q: How to donate money to you?
A: I have started github sponsorship to spend more time for Vim/neovim
plugins. You can donate money to help me!
https://github.com/sponsors/Shougo
*pum-faq-2*
Q: The popup menu does not close immediately in Vim.
A: It is the known issue of Vim. |popup_close()| does not work immediately.
*pum-faq-3*
Q: The popup menu does not work in |command-line-window|.
A: It is the limitation of |command-line-window|.
NOTE: The problem is fixed in neovim 0.10+. But |command-line-window| is
special buffer. If you use "ddc.vim", you need to enable special buffer
completion.
*pum-faq-4*
Q: Auto import or auto snippet expansion does not work in pum.vim.
A: pum.vim does not support |CompleteDone| autocmd. You need to emulate the
event like this.
NOTE: It is for ale plugin. >vim
autocmd User PumCompleteDone
\ call ale#completion#HandleUserData(g:pum#completed_item)
<
NOTE: If you use "ddc-source-lsp" source, you don't need to add the event
manually. Because, it register the event automatically.
*pum-faq-5*
Q: I want to use j/k keys to navigate popup menu when only entered popup menu.
A: >vim
inoremap <expr> j pum#entered() ?
\ '<Cmd> call pum#map#insert_relative(+1)<CR>' : 'j'
inoremap <expr> k pum#entered() ?
\ '<Cmd> call pum#map#insert_relative(-1)<CR>' : 'k'
<
*pum-faq-6*
Q: The popup window does not close when enter |command-line-window|.
A: In |command-line-window|, the popup window cannot be closed. It is
Vim/neovim's feature. The window is closed after you have leaved
|command-line-window|. You can use the mapping like this.
>vim
cnoremap <C-f> <Cmd>call pum#close()<CR><C-f>
<
NOTE: The problem is fixed in neovim 0.10+.
*pum-faq-7*
Q: I want to move to the first/last item by Home/End keys.
A: >vim
inoremap <Home>
\ <Cmd>call pum#map#insert_relative(-9999, 'ignore')<CR>
inoremap <End>
\ <Cmd>call pum#map#insert_relative(+9999, 'ignore')<CR>
<
*pum-faq-8*
Q: 'incsearch' text is cleared when |pum-option-reversed| is set or move
cursor in neovim.
A: It is feature. Because 'incsearch' is broken when |:redraw| in floating
window. I have gave up to fix it in plugin side.
https://github.com/neovim/neovim/issues/17810
*pum-faq-9*
Q: I want to enter the documentation window.
A: You can use |pum#get_preview_buf()| for it.
>vim
execute pum#get_preview_buf() .. 'buffer'
<
==============================================================================
COMPATIBILITY *pum-compatibility*
2023.12.06
* "use_complete" is default behavior.
2023.07.19
* "item_orders" must include "space" item.
2023.07.08
* Vim 9.0.1276+ or neovim 0.8+ is required to support the latest MacVim.
2023.07.07
* Vim 9.0.1499+ or neovim 0.8+ is required.
2023.07.06
* Vim 9.0+ or neovim 0.8+ is required.
2023.06.23
* Item highlight is 1 origin instead of 0 origin.
2023.05.22
* Rename "offset_row" option to "offset_cmdrow".
2022.11.18
* neovim 0.8 is required.
2022.09.10
* Rename "offset" option to "offset_row".
2022.09.08
* Remove "highlight_abbr", "highlight_kind" and "highlight_menu" options.
Please use "highlight_columns" instead.
==============================================================================
vim:tw=78:ts=8:ft=help:norl:noet:fen:noet: