Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Word under cursor will be searched if no argument is passed to `Rg`
| g:rg_derive_root | false | true if you want to find project root from cwd
| g:rg_root_types | ['.git'] | list of files/dir found in project root
| g:rg_window_location | botright | quickfix window location
| g:rg_use_local_list | 0 | use local list instead of quickfix for search

## misc

Expand Down
24 changes: 21 additions & 3 deletions plugin/vim-ripgrep.vim
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ if !exists('g:rg_window_location')
let g:rg_window_location = 'botright'
endif

if !exists('g:rg_use_local_list')
let g:rg_use_local_list = 0
endif

let s:rg_window_cmd = 'copen'
let s:rg_grep_cmd = 'grep! '
if g:rg_use_local_list != 0
let s:rg_window_cmd = 'lopen'
let s:rg_grep_cmd = 'lgrep! '
end

fun! s:get_match_len()
if g:rg_use_local_list != 0
return len(getloclist(0))
end
return len(getqflist())
endfun

fun! g:RgVisual() range
call s:RgGrepContext(function('s:RgSearch'), '"' . s:RgGetVisualSelection() . '"')
endfun
Expand Down Expand Up @@ -61,9 +79,9 @@ fun! s:RgSearch(txt)
if &smartcase == 1
let l:rgopts = l:rgopts . '-S '
endif
silent! exe 'grep! ' . l:rgopts . a:txt
if len(getqflist())
exe g:rg_window_location 'copen'
silent! exe s:rg_grep_cmd . l:rgopts . a:txt
if s:get_match_len()
exe g:rg_window_location s:rg_window_cmd
redraw!
if exists('g:rg_highlight')
call s:RgHighlight(a:txt)
Expand Down