diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-06-30 21:00:36 +0200 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-06-30 21:22:27 +0200 |
| commit | 0f8f1bed5c96d2aa1a195cf032dcf440f530119c (patch) | |
| tree | 984e6d890f3ebe9f09e87b2b3aded84e0bcbda4a /plugin | |
| parent | 1f793d38bd4273f00a8b93ea20dfddccf53af47b (diff) | |
| download | nvim-config-0f8f1bed5c96d2aa1a195cf032dcf440f530119c.tar.gz nvim-config-0f8f1bed5c96d2aa1a195cf032dcf440f530119c.zip | |
feat(cmdline): skip auto-completion for :find and :grep args
Their argument is a search pattern, not a file to complete eagerly.
For the find family a `**` pattern recursively walks the tree and
hangs on each keystroke in large directories. `<Tab>` still completes
on demand, and the recursive `**4` path entry is dropped.
Diffstat (limited to 'plugin')
| -rw-r--r-- | plugin/50-autocompletion.lua | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/plugin/50-autocompletion.lua b/plugin/50-autocompletion.lua index 1960871..160c75d 100644 --- a/plugin/50-autocompletion.lua +++ b/plugin/50-autocompletion.lua @@ -47,13 +47,17 @@ local function c_accept_selection_or_dismiss() return "<C-y>" end --- Show the command-line completion menu automatically. --- Except for `:grep` commands (`:grep`, `:vimgrep`, their `add` and location-list variants). +-- Show the command-line completion menu automatically, except in the argument of grep-family +-- (`:grep`, `:vimgrep`, their `add` and location-list variants) and find-family (`:find`, `:sfind`, +-- `:tabfind`) commands. Their argument is a search pattern, not a file to complete eagerly: for the +-- find family a `**` pattern recursively walks the tree and hangs on each keystroke in large +-- directories. Complete these on demand with `<Tab>` instead. local function trigger_wildmenu() if vim.fn.getcmdtype() == ":" then -- A command word followed by a delimiter (space, `/`, …) means we are past it, into the args. local cmd = vim.fn.getcmdline():match("^%s*(%a+)%A") - if cmd and vim.fn.fullcommand(cmd):find("grep", 1, true) then + cmd = cmd and vim.fn.fullcommand(cmd) + if cmd and (cmd:find("grep", 1, true) or cmd:find("find", 1, true)) then if vim.fn.cmdcomplete_info().pum_visible == 1 then vim.api.nvim_feedkeys(vim.keycode("<C-e>"), "n", false) end @@ -85,10 +89,6 @@ vim.opt.wildoptions = { "exacttext", "pum", "tagfile", "fuzzy" } --[[ Completion modes triggered in order by `wildtrigger()` or `wildchar`: list matches without inserting (`noselect`), then list matches and insert the first full match (`full`). ]] vim.opt.wildmode = { "noselect", "full" } --- Search recursively under the current directory so `:find` matches files in any subdirectory. --- `:find` globs the tree synchronously with no timeout, so cap the depth (`**4`): the default `**` --- depth of 30 walks all of `$HOME` when run from there and hangs. -vim.opt.path:append("**4") ---------------------------------------------------------------------------------------------------- -- Autocommands ------------------------------------------------------------------------------------ |
