.vim/autoload/vimrc.vim

changeset 953
e033f9ce0d8c
parent 943
e0ff02862951
equal deleted inserted replaced
952:0d98622cf4d6 953:e033f9ce0d8c
33 execute "source " . sessionfile 33 execute "source " . sessionfile
34 endif 34 endif
35 endif 35 endif
36 endfunc 36 endfunc
37 37
38 func! vimrc#Ag(args) abort 38 func! vimrc#Grep(...) abort
39 let orig_t_ti = &t_ti 39 let pattern = get(a:000, 0, expand('<cword>'))
40 let orig_t_te = &t_te 40 let cmd = join([&grepprg, shellescape(pattern)] + a:000[1:], ' ')
41 let orig_shellpipe = &shellpipe
42 41
43 set t_ti= t_te= 42 cgetexpr system(cmd)
44 let &shellpipe = substitute(&shellpipe, '| tee', ' >', '') 43 call setqflist([], 'a', {"title": cmd})
45 44 let @/ = '\v' . pattern
46 let grepargs = a:args == '' ? expand('<cword>') : a:args . join(a:000, ' ') 45 copen
47 46 cfirst
48 try
49 silent! execute "grep " . escape(grepargs, '|')
50 copen
51
52 let @/ = matchstr(a:args, "\\v(-)\@<!(\<)\@<=\\w+|['\"]\\zs.{-}\\ze['\"]")
53 call feedkeys(":let &hlsearch=1 \| echo \<CR>", 'n')
54 finally
55 let &t_ti = orig_t_ti
56 let &t_te = orig_t_te
57 let &shellpipe = orig_shellpipe
58 endtry
59 endfunc 47 endfunc
60 48
61 func! vimrc#Gcd() abort 49 func! vimrc#Gcd() abort
62 let root = system('git rev-parse --show-toplevel 2>/dev/null')[:-2] 50 let root = system('git rev-parse --show-toplevel 2>/dev/null')[:-2]
63 if ! v:shell_error 51 if ! v:shell_error

mercurial