From af8aa05d3ab251cd21f152fe337a335f2a9b3570 Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Tue, 30 Jun 2026 11:47:23 +0200 Subject: feat(cmdline): recursive :find, ripgrep :grep, quiet grep menu - path+=** so :find searches subdirectories recursively - grepprg/grepformat drive :grep through ripgrep (--vimgrep --smart-case), with a comment on the -./-uu/-uuu opt-in flags - the auto-completion menu skips grep-family commands while their search-pattern argument is being typed, and dismisses any menu left over from completing the command name --- plugin/50-autocompletion.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'plugin') diff --git a/plugin/50-autocompletion.lua b/plugin/50-autocompletion.lua index a8b7f4b..1960871 100644 --- a/plugin/50-autocompletion.lua +++ b/plugin/50-autocompletion.lua @@ -48,7 +48,18 @@ local function c_accept_selection_or_dismiss() end -- Show the command-line completion menu automatically. +-- Except for `:grep` commands (`:grep`, `:vimgrep`, their `add` and location-list variants). 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 + if vim.fn.cmdcomplete_info().pum_visible == 1 then + vim.api.nvim_feedkeys(vim.keycode(""), "n", false) + end + return + end + end vim.fn.wildtrigger() end @@ -74,6 +85,10 @@ 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 ------------------------------------------------------------------------------------ -- cgit v1.3.1