vim-patch:9.1.1576: cannot easily trigger wildcard expansion (#35022)

Problem:  cannot easily trigger wildcard expansion
Solution: Introduce wildtrigger() function
          (Girish Palya)

This PR introduces a new `wildtrigger()` function.

See `:h wildtrigger()`

`wildtrigger()` behaves like pressing the `wildchar,` but provides a
more refined and controlled completion experience:

- Suppresses beeps when no matches are found.
- Avoids displaying irrelevant completions (like full command lists)
  when the prefix is insufficient or doesn't match.
- Skips completion if the typeahead buffer has pending input or if a
  wildmenu is already active.
- Does not print "..." before completion.

This is an improvement on the `feedkeys()` based autocompletion script
given in vim/vim#16759.

closes: vim/vim#17806

b486ed8266

While at it, also make Ctrl-Z trigger search completion.

Co-authored-by: Girish Palya <girishji@gmail.com>
This commit is contained in:
zeertzjq
2025-07-23 06:12:50 +08:00
committed by GitHub
parent 8b5d8dfc73
commit 9377db2545
15 changed files with 243 additions and 65 deletions

View File

@@ -215,10 +215,15 @@ enum key_extra {
// KE_FOCUSGAINED = 98, // focus gained
// KE_FOCUSLOST = 99, // focus lost
KE_MOUSEMOVE = 100, // mouse moved with no button down
// KE_CANCEL = 101, // return from vgetc()
// KE_MOUSEMOVE_XY = 101,
// KE_CANCEL = 102, // return from vgetc()
KE_EVENT = 102, // event
KE_LUA = 103, // Lua special key
KE_COMMAND = 104, // <Cmd> special key
// KE_S_BS = 105,
// KE_SID = 106,
// KE_ESC = 107,
KE_WILD = 108, // triggers wildmode completion
};
// the three byte codes are replaced with the following int when using vgetc()
@@ -451,6 +456,8 @@ enum key_extra {
#define K_COMMAND TERMCAP2KEY(KS_EXTRA, KE_COMMAND)
#define K_LUA TERMCAP2KEY(KS_EXTRA, KE_LUA)
#define K_WILD TERMCAP2KEY(KS_EXTRA, KE_WILD)
// Bits for modifier mask
// 0x01 cannot be used, because the modifier must be 0x02 or higher
#define MOD_MASK_SHIFT 0x02