summaryrefslogtreecommitdiffstats
path: root/plugin
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-06-30 11:47:23 +0200
committerThomas Vanbesien <tvanbesi@proton.me>2026-06-30 11:55:50 +0200
commit5a1b8b5fd5174a8d31ca9b9cb7b287dcfb004ec4 (patch)
tree4ad7a3647f625e8ba2bb89993332f17bdc405dd7 /plugin
parentd388fbd6cb0cdae548c1350c0b55725fcd04e53f (diff)
downloadnvim-config-5a1b8b5fd5174a8d31ca9b9cb7b287dcfb004ec4.tar.gz
nvim-config-5a1b8b5fd5174a8d31ca9b9cb7b287dcfb004ec4.zip
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
Diffstat (limited to 'plugin')
-rw-r--r--plugin/50-autocompletion.lua15
1 files changed, 15 insertions, 0 deletions
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("<C-e>"), "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 ------------------------------------------------------------------------------------