0

I recently switched to neovim, but ever since my AG usage have acted weird lately. Here is my current .vimrc file.

Here is my neovim init file ~/.config/nvim/init.vim:

set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath=&runtimepath
source ~/.vimrc
let g:python3_host_prog='/Users/abdullah/.pyenv/shims/python3'
let g:python_host_prog='/Users/abdullah/.pyenv/shims/python'

Here are the problems I'm facing:

When I search the current keyword, I get a preview of the results, before actually seeing the results

So suppose I place the cursor ontop of attachClusteredOrders here

public static function attachClusteredOrders($orders, float $distanceThreshold, int $backtrackDays)

actual behaviour

I get this preview of search results with the prompt to enter a command to continue: enter image description here

Once I enter Enter, I see this

enter image description here

expected behaviour

I should see the search results directly without having to enter Enter

Note: here is the relevant part from my vimrc on this:

" The Silver Searcher
if executable('ag')
  " Use ag over grep
  let &grepprg = "ag --nogroup --nocolor --ignore wiki --ignore tags --ignore dist --ignore tests --ignore seeds --ignore migrations -w"

  " Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
  let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'

  " ag is fast enough that CtrlP doesn't need to cache
  let g:ctrlp_use_caching = 0
endif

" bind K to grep word under cursor
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>

" command -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
" above replaced with
" https://vi.stackexchange.com/a/14939/14510
function! Ag(args) abort
  execute "silent! grep!" shellescape(a:args)
  cwindow
  redraw!
endfunction

When I run my keyboard shortcut to launch AG, nothing happens

actual behaviour

I run my keyboard shortcut to start the AG prompt \ and then I see this

enter image description here

but when I type enter nothing happens. But if I manually type :Ag <query> and press enter it works just fine!

expected behaviour

The keyboard shortcut should work from the first time

Note: relevant part of my vimrc:

" bind \ (backward slash) to grep shortcut
nnoremap \ :Ag<SPACE>
0

this fix worked for me so far but I'm not too happy about it b/c it still shows the intermediary output for a second then it shows the results, I'd rather it jumped straight to the results instead.

" bind K to grep word under cursor
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR><ENTER>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.