aboutsummaryrefslogtreecommitdiffstats
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 19:38:18 +0200
commitaf8aa05d3ab251cd21f152fe337a335f2a9b3570 (patch)
tree41ad4cd5224483ce165eb57f6b9b6b5695e4e5bc /plugin
parent84ec454a22a58e35e59b6ee07794006efa96c69e (diff)
downloadnvim-config-af8aa05d3ab251cd21f152fe337a335f2a9b3570.tar.gz
nvim-config-af8aa05d3ab251cd21f152fe337a335f2a9b3570.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 ------------------------------------------------------------------------------------