mhinz / vim-grepper

:space_invader: Helps you win at grep.
MIT License
1.22k stars 58 forks source link

-side is not working as expected & sometimes throws an error #180

Closed ahmedelgabri closed 6 years ago

ahmedelgabri commented 6 years ago

I'm getting this error whenever I use -side & search while on an empty buffer or a Startify buffer.

Error detected while processing function <SNR>134_on_exit[4]..<SNR>134_finish_up[49]..<SNR>134_side[1]..<SNR>134_side_create_window:
line   33:
E484: Can't open file <empty>
Press ENTER or type command to continue

But if I run the same command on a non-empty buffer it opens this instead. Which is the Quickfix & the side buffer but at the bottom of the window

screenshot 2018-10-13 at 20 25 22

This is my grepper settings

command! Todo :Grepper
      \ -side
      \ -noprompt
      \ -tool git
      \ -grepprg git grep -nIi '\@\?\(TODO\|FIXME\|NOTE)'

augroup MyGrepper
  autocmd!
  autocmd FileType GrepperSide
      \  silent execute 'keeppatterns v#'.b:grepper_side.'#>'
      \| silent normal! ggn
      \| setl wrap
augroup END

xmap gs <plug>(GrepperOperator)
vmap gs <Plug>(GrepperOperator)
nnoremap \ :silent! packadd vim-grepper<CR><BAR>:Grepper -side -tool rg -query --hidden<SPACE>
mhinz commented 6 years ago

Your \ mapping is wrong. -query is used for the actual search query, not for options. I'll alter the doc to make this point clearer.

Use something like this instead:

nnoremap \ :silent! packadd vim-grepper<cr><bar>:Grepper -side -noprompt -tool rg -grepprg rg -H --vimgrep --no-heading --hidden<space>

This fixes the mapping but is quite long. You might want to remove the -nompromt and use Grepper's prompt instead. (And maybe even let g:grepper.simple_prompt = 1 for an even shorter prompt.)


I think :packadd already sources plugin/grepper.vim, so an alternative would be changing the default grepprg for rg:

nnoremap \ :silent! packadd vim-grepper<cr><bar>let g:grepper.rg.grepprg .= ' --hidden'<bar>Grepper -side -tool rg --query<space>

HTH

mhinz commented 6 years ago

I fixed the doc. Thanks for bringing this up! ✨

ahmedelgabri commented 6 years ago

Thanks, I tried both but it seems the second one deosn't work

nnoremap \ :silent! packadd vim-grepper<cr><bar>let g:grepper.rg.grepprg .= ' --hidden'<bar>Grepper -side -tool rg --query<space>

All I get back is this in the command bar at the bottom

:silent! packadd vim-grepper
ahmedelgabri commented 6 years ago

I found the issue, you missed the : before the let :) works fine, thanks again.