Skip to content

Commit 1c3c4c6

Browse files
authored
Make sure that we don't pipe stdin when starting a job (#250)
Starting with version 13, ripgrep always stats stdin and if it's not a TTY it uses it to read data. Unfortunately, Neovim always attaches a pipe to stdin by default and that leads to ripgrep reading nothing and it essentially breaks vim-grepper when targeting a recent version of ripgrep. (see neovim/neovim#14812 for more info) This was fixed in nvim by adding an option to jobstart to not pipe stdin (see neovim/neovim#14812). So we use this here which I verified fixes search through rg. Note that I'm not 100% sure how to gate this. It was technically added as a commit to neovim after 0.5 shipped so I imagine it will technically be released in 0.5.1. But it should also be harmless to only gate this to `nvim` since the options are a dictionary and old versions of neovim will just ignore that `stdin` key.
1 parent b80004c commit 1c3c4c6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

plugin/grepper.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,15 @@ function! s:run(flags)
936936
\ 'on_stderr': function('s:on_stdout_nvim'),
937937
\ 'on_exit': function('s:on_exit'),
938938
\ }
939+
if has('nvim-0.5.1')
940+
" Starting with version 13, ripgrep always stats stdin and if it's not a
941+
" TTY it uses it to read data. Unfortunately, Neovim always attaches a
942+
" pipe to stdin by default and that leads to ripgrep reading nothing...
943+
" (see https://github.com/mhinz/vim-grepper/issues/244 for more info)
944+
" This was fixed in nvim by adding an option to jobstart to not pipe stdin
945+
" (see https://github.com/neovim/neovim/pull/14812).
946+
let opts.stdin = 'null'
947+
endif
939948
if !a:flags.stop
940949
let opts.stdout_buffered = 1
941950
let opts.stderr_buffered = 1

0 commit comments

Comments
 (0)