mirror of
https://github.com/vim/vim
synced 2025-03-15 22:37:52 +01:00
Problem: command-line auto-completion hard with wildmenu Solution: implement "noselect" wildoption value (Girish Palya) When `noselect` is present in `wildmode` and 'wildmenu' is enabled, the completion menu appears without pre-selecting the first item. This change makes it easier to implement command-line auto-completion, where the menu dynamically appears as characters are typed, and `<Tab>` can be used to manually select an item. This can be achieved by leveraging the `CmdlineChanged` event to insert `wildchar(m)`, triggering completion menu. Without this change, auto-completion using the 'wildmenu' mechanism is not feasible, as it automatically inserts the first match, preventing dynamic selection. The following Vimscript snippet demonstrates how to configure auto-completion using `noselect`: ```vim vim9script set wim=noselect:lastused,full wop=pum wcm=<C-@> wmnu autocmd CmdlineChanged : timer_start(0, function(CmdComplete, [getcmdline()])) def CmdComplete(cur_cmdline: string, timer: number) var [cmdline, curpos] = [getcmdline(), getcmdpos()] if cur_cmdline ==# cmdline # Avoid completing each character in keymaps and pasted text && !pumvisible() && curpos == cmdline->len() + 1 if cmdline[curpos - 2] =~ '[\w*/:]' # Reduce noise by completing only selected characters feedkeys("\<C-@>", "ti") set eventignore+=CmdlineChanged # Suppress redundant completion attempts timer_start(0, (_) => { getcmdline()->substitute('\%x00$', '', '')->setcmdline() # Remove <C-@> if no completion items exist set eventignore-=CmdlineChanged }) endif endif enddef ``` fixes: #16551 closes: #16759 Signed-off-by: Girish Palya <girishji@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org> |
||
---|---|---|
.. | ||
autoload | ||
bitmaps | ||
colors | ||
compiler | ||
doc | ||
ftplugin | ||
icons | ||
import/dist | ||
indent | ||
keymap | ||
lang | ||
macros | ||
pack/dist/opt | ||
plugin | ||
spell | ||
syntax | ||
tools | ||
tutor | ||
bugreport.vim | ||
defaults.vim | ||
delmenu.vim | ||
doc.info | ||
evim.vim | ||
filetype.vim | ||
ftoff.vim | ||
ftplugin.vim | ||
ftplugof.vim | ||
gvim.desktop | ||
gvimrc_example.vim | ||
hi16-action-make.png | ||
hi22-action-make.png | ||
icons.info | ||
indent.vim | ||
indoff.vim | ||
macmap.vim | ||
macros.info | ||
makemenu.vim | ||
menu.vim | ||
mswin.vim | ||
optwin.vim | ||
scripts.vim | ||
synmenu.vim | ||
termcap | ||
tools.info | ||
tutor.info | ||
vim.desktop | ||
vim16x16.gif | ||
vim16x16.png | ||
vim16x16.xpm | ||
vim32x32.gif | ||
vim32x32.png | ||
vim32x32.xpm | ||
vim48x48.gif | ||
vim48x48.png | ||
vim48x48.xpm | ||
vimlogo.cdr | ||
vimlogo.eps | ||
vimlogo.gif | ||
vimlogo.pdf | ||
vimlogo.svg | ||
vimlogo.xpm | ||
vimrc_example.vim |