forked from liuchengxu/vim-clap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrep2.vim
More file actions
46 lines (37 loc) · 1.3 KB
/
grep2.vim
File metadata and controls
46 lines (37 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
" Author: liuchengxu <xuliuchengxlc@gmail.com>
" Description: Grep on the fly with cache and dynamic results.
let s:save_cpo = &cpoptions
set cpoptions&vim
let s:grep2 = {}
if !executable('rg')
call clap#helper#echo_error('grep2 provider can not work without the executable rg.')
finish
endif
function! s:grep2.on_typed()
if exists('g:__clap_forerunner_tempfile')
call clap#filter#async#dyn#grep_from_cache(g:__clap_forerunner_tempfile)
else
call clap#filter#async#dyn#start_grep()
endif
endfunction
function! s:grep2.init() abort
let g:__clap_match_type_enum = 'IgnoreFilePath'
call clap#provider#grep#inject_icon_appended(g:clap_enable_icon)
if clap#maple#is_available()
call clap#rooter#try_set_cwd()
call clap#job#regular#forerunner#start_command(clap#maple#command#ripgrep_forerunner())
endif
endfunction
function! s:grep2.exit() abort
unlet g:__clap_match_type_enum
endfunction
let s:grep2.sink = g:clap#provider#grep#.sink
let s:grep2['sink*'] = g:clap#provider#grep#['sink*']
let s:grep2.on_move = g:clap#provider#grep#.on_move
let s:grep2.on_move_async = function('clap#impl#on_move#async')
let s:grep2.enable_rooter = v:true
let s:grep2.support_open_action = v:true
let s:grep2.syntax = 'clap_grep'
let g:clap#provider#grep2# = s:grep2
let &cpoptions = s:save_cpo
unlet s:save_cpo