Open slashmili opened 2 years ago
Same issue here on my mac. It works on Windows though.
just for the record I ended up using this for now:
noremap <c-g> :execute "Grepper -noprompt -query " . expand("<cword>")<CR>
Same issue here
Same here
noremap
:execute "Grepper -noprompt -query " . expand(" ")
Does anyone have a version of this I can drop in my init.lua
?
I thought this might work, but no:
vim.api.nvim_set_keymap('n', 'gs', ':Grepper -noprompt -query ' .. vim.fn.expand('<cword>') .. '<CR>', { noremap = true, silent = true })
EDIT:
This works:
vim.api.nvim_set_keymap('n', 'gs', ':execute ":Grepper -noprompt -query " .. shellescape(expand("<cword>"))<cr>', { noremap = true, silent = true })
I had a prod around in the plugin sources today. There's a call to shellescape
that is double escaping the word anchors.
As @slashmili noted, this means we end up running commands like:
git grep -nGI> '\\bnoremap\\b'
instead of:
git grep -nGI> '\bnoremap\b'
This diff seems to work, but I can't vouch for its correctness. I'm not good at lua or vimscript:
diff --git a/plugin/grepper.vim b/plugin/grepper.vim
index 3552d51..9cd10e0 100644
--- a/plugin/grepper.vim
+++ b/plugin/grepper.vim
@@ -401,7 +401,7 @@ function! s:escape_cword(flags, cword)
endif
let a:flags.query_orig = a:cword
let a:flags.query_escaped = 1
- return shellescape(escaped_cword)
+ return "'" . escaped_cword . "'"
endfunction
" s:compute_working_directory() {{{2
shellescape
is here for a reason, so that the search string is correctly forwarded to the grep program if a special character is in the query.
It is working fine on linux with bash afaik, question would be why the \
is doubled on Mac in this case. Do you by any chance run fish shell?
Do you by any chance run fish shell?
You gotta be kidding me! I'm using fish on OpenBSD and Linux!
@vext01 there was this change in vim and neovim related to fish and escaping https://github.com/vim/vim/pull/8810, https://github.com/neovim/neovim/pull/15550
May be related to that
I use the fish shell on my mac. Seems like you're on to something.
I've just tried with my shell set to ksh
and there is no issue there. Seems to be to do with fish...
NVIM version: v0.6.1 vim-grepper version: 2b93535752ffcb312f9fab73d90e80dc9f2e60fc OS: Mac 12.3.1 git: 2.33.0
I've been using this option for a while but I've noticed it's stopped working recently:
If run this command
Grepper -cword
, I get:When I press enter, it won't match with any record
If run it again and this time, remove one set of
\
like this:it finds all the matches.