mirror of
https://github.com/jremmen/vim-ripgrep.git
synced 2025-12-26 19:45:29 +08:00
Sub: Add doc info & mappings to open file in search results
Body: Fix: No ==== End ====
This commit is contained in:
parent
ec87af6b69
commit
01c11860b9
2 changed files with 34 additions and 10 deletions
16
doc/vim-ripgrep.txt
Normal file
16
doc/vim-ripgrep.txt
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
*vim-ripgrep.txt* Plugin that integrates rg with Vim
|
||||
==============================================================================
|
||||
INTRODUCTION *rg*
|
||||
|
||||
This plugin is a front for ripgrep: rg. Rg can be used as a replacement for ack
|
||||
or ag. This plugin will allow you to run rg from vim, and shows the results in
|
||||
a split window.
|
||||
|
||||
:Rg[!] [options] {pattern} [{directory}] *:Rg*
|
||||
|
||||
Search recursively in {directory} (which defaults to the current
|
||||
directory) for the {pattern}. Behaves just like the |:grep| command, but
|
||||
will open the |Quickfix| window for you. If [!] is not given the first
|
||||
error is jumped to.
|
||||
|
||||
vim:tw=78:fo=tcq2:ft=help:norl:
|
||||
|
|
@ -33,16 +33,16 @@ fun! s:Rg(txt)
|
|||
endfun
|
||||
|
||||
fun! s:RgGetVisualSelection()
|
||||
" Why is this not a built-in Vim script function?!
|
||||
let [line_start, column_start] = getpos("'<")[1:2]
|
||||
let [line_end, column_end] = getpos("'>")[1:2]
|
||||
let lines = getline(line_start, line_end)
|
||||
if len(lines) == 0
|
||||
return ''
|
||||
endif
|
||||
let lines[-1] = lines[-1][: column_end - (&selection == 'inclusive' ? 1 : 2)]
|
||||
let lines[0] = lines[0][column_start - 1:]
|
||||
return join(lines, "\n")
|
||||
" Why is this not a built-in Vim script function?!
|
||||
let [line_start, column_start] = getpos("'<")[1:2]
|
||||
let [line_end, column_end] = getpos("'>")[1:2]
|
||||
let lines = getline(line_start, line_end)
|
||||
if len(lines) == 0
|
||||
return ''
|
||||
endif
|
||||
let lines[-1] = lines[-1][: column_end - (&selection == 'inclusive' ? 1 : 2)]
|
||||
let lines[0] = lines[0][column_start - 1:]
|
||||
return join(lines, "\n")
|
||||
endfun
|
||||
|
||||
fun! s:RgSearchTerm(txt)
|
||||
|
|
@ -61,10 +61,18 @@ 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'
|
||||
redraw!
|
||||
" Map commands in quickfix window to open files in search results
|
||||
nnoremap <silent> <buffer> h <C-W><CR><C-w>K
|
||||
nnoremap <silent> <buffer> H <C-W><CR><C-w>K<C-w>b
|
||||
nnoremap <silent> <buffer> o <CR>
|
||||
nnoremap <silent> <buffer> t <C-w><CR><C-w>T
|
||||
nnoremap <silent> <buffer> T <C-w><CR><C-w>TgT<C-W><C-W>
|
||||
nnoremap <silent> <buffer> v <C-w><CR><C-w>H<C-W>b<C-W>J<C-W>t
|
||||
if exists('g:rg_highlight')
|
||||
call s:RgHighlight(a:txt)
|
||||
endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue