mirror of
https://github.com/jremmen/vim-ripgrep.git
synced 2026-01-09 03:58:09 +08:00
support local list
This commit is contained in:
parent
ec87af6b69
commit
318b058c00
1 changed files with 21 additions and 3 deletions
|
|
@ -24,6 +24,24 @@ if !exists('g:rg_window_location')
|
||||||
let g:rg_window_location = 'botright'
|
let g:rg_window_location = 'botright'
|
||||||
endif
|
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
|
fun! g:RgVisual() range
|
||||||
call s:RgGrepContext(function('s:RgSearch'), '"' . s:RgGetVisualSelection() . '"')
|
call s:RgGrepContext(function('s:RgSearch'), '"' . s:RgGetVisualSelection() . '"')
|
||||||
endfun
|
endfun
|
||||||
|
|
@ -61,9 +79,9 @@ fun! s:RgSearch(txt)
|
||||||
if &smartcase == 1
|
if &smartcase == 1
|
||||||
let l:rgopts = l:rgopts . '-S '
|
let l:rgopts = l:rgopts . '-S '
|
||||||
endif
|
endif
|
||||||
silent! exe 'grep! ' . l:rgopts . a:txt
|
silent! exe s:rg_grep_cmd . l:rgopts . a:txt
|
||||||
if len(getqflist())
|
if s:get_match_len()
|
||||||
exe g:rg_window_location 'copen'
|
exe g:rg_window_location s:rg_window_cmd
|
||||||
redraw!
|
redraw!
|
||||||
if exists('g:rg_highlight')
|
if exists('g:rg_highlight')
|
||||||
call s:RgHighlight(a:txt)
|
call s:RgHighlight(a:txt)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue