diff options
author | Luna Saphie Mittelbach <lunarlambda@gmail.com> | 2024-04-28 18:00:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-28 09:00:48 -0700 |
commit | 513fc461957f370f9e89b3cfd56cb03a816d6941 (patch) | |
tree | 03098d5684503e0a5a145a63a69d2c0956aca7e5 /runtime/lua/vim | |
parent | 83635e4e3db9a99c128e84e79deb590da354215d (diff) | |
download | rneovim-513fc461957f370f9e89b3cfd56cb03a816d6941.tar.gz rneovim-513fc461957f370f9e89b3cfd56cb03a816d6941.tar.bz2 rneovim-513fc461957f370f9e89b3cfd56cb03a816d6941.zip |
feat(defaults): improve :grep defaults #28545
Based on feedback from #28324, pass -H and -I to regular grep
(available on all platforms officially supported by Neovim), and
only pass -uu to ripgrep. This makes :grep ignore binary files by
default in both cases.
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r-- | runtime/lua/vim/_defaults.lua | 5 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/options.lua | 14 |
2 files changed, 6 insertions, 13 deletions
diff --git a/runtime/lua/vim/_defaults.lua b/runtime/lua/vim/_defaults.lua index e9575c0e1e..7166f7a23c 100644 --- a/runtime/lua/vim/_defaults.lua +++ b/runtime/lua/vim/_defaults.lua @@ -560,9 +560,8 @@ end do --- Default 'grepprg' to ripgrep if available. if vim.fn.executable('rg') == 1 then - -- Match :grep default, otherwise rg searches cwd by default - -- Use -uuu to make ripgrep not do its default filtering - vim.o.grepprg = 'rg --vimgrep -uuu $* ' .. (vim.fn.has('unix') == 1 and '/dev/null' or 'nul') + -- Use -uu to make ripgrep not check ignore files/skip dot-files + vim.o.grepprg = 'rg --vimgrep -uu ' vim.o.grepformat = '%f:%l:%c:%m' end end diff --git a/runtime/lua/vim/_meta/options.lua b/runtime/lua/vim/_meta/options.lua index e10eb305b1..9aa20f59bc 100644 --- a/runtime/lua/vim/_meta/options.lua +++ b/runtime/lua/vim/_meta/options.lua @@ -2638,12 +2638,6 @@ vim.go.gfm = vim.go.grepformat --- line. The placeholder "$*" is allowed to specify where the arguments --- will be included. Environment variables are expanded `:set_env`. See --- `option-backslash` about including spaces and backslashes. ---- When your "grep" accepts the "-H" argument, use this to make ":grep" ---- also work well with a single file: ---- ---- ```vim ---- set grepprg=grep\ -nH ---- ``` --- Special value: When 'grepprg' is set to "internal" the `:grep` command --- works like `:vimgrep`, `:lgrep` like `:lvimgrep`, `:grepadd` like --- `:vimgrepadd` and `:lgrepadd` like `:lvimgrepadd`. @@ -2652,18 +2646,18 @@ vim.go.gfm = vim.go.grepformat --- This option cannot be set from a `modeline` or in the `sandbox`, for --- security reasons. --- This option defaults to: ---- - `rg --vimgrep -uuu $* ...` if ripgrep is available (`:checkhealth`), ---- - `grep -n $* /dev/null` on Unix, +--- - `rg --vimgrep -uu ` if ripgrep is available (`:checkhealth`), +--- - `grep -HIn $* /dev/null` on Unix, --- - `findstr /n $* nul` on Windows. --- Ripgrep can perform additional filtering such as using .gitignore rules ---- and skipping hidden or binary files. This is disabled by default (see the -u option) +--- and skipping hidden files. This is disabled by default (see the -u option) --- to more closely match the behaviour of standard grep. --- You can make ripgrep match Vim's case handling using the --- -i/--ignore-case and -S/--smart-case options. --- An `OptionSet` autocmd can be used to set it up to match automatically. --- --- @type string -vim.o.grepprg = "grep -n $* /dev/null" +vim.o.grepprg = "grep -HIn $* /dev/null" vim.o.gp = vim.o.grepprg vim.bo.grepprg = vim.o.grepprg vim.bo.gp = vim.bo.grepprg |