From 1c3c4c616df2fa118289df17bfc3961fe0a2993b Mon Sep 17 00:00:00 2001 From: Damien DeVille Date: Fri, 20 Aug 2021 14:02:51 -0700 Subject: [PATCH] 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 https://github.com/neovim/neovim/pull/14812 for more info) This was fixed in nvim by adding an option to jobstart to not pipe stdin (see https://github.com/neovim/neovim/pull/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. --- plugin/grepper.vim | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugin/grepper.vim b/plugin/grepper.vim index 73e4e36..01dfa51 100644 --- a/plugin/grepper.vim +++ b/plugin/grepper.vim @@ -936,6 +936,15 @@ function! s:run(flags) \ 'on_stderr': function('s:on_stdout_nvim'), \ 'on_exit': function('s:on_exit'), \ } + if has('nvim-0.5.1') + " 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... + " (see https://github.com/mhinz/vim-grepper/issues/244 for more info) + " This was fixed in nvim by adding an option to jobstart to not pipe stdin + " (see https://github.com/neovim/neovim/pull/14812). + let opts.stdin = 'null' + endif if !a:flags.stop let opts.stdout_buffered = 1 let opts.stderr_buffered = 1