comparison vimrc @ 236:639222e1ab7b

Add Ag plugin
author zegervdv <zegervdv@me.com>
date Sat, 07 Feb 2015 22:12:55 +0100
parents 4ebdb386a987
children b3bf31ff1c1c
comparison
equal deleted inserted replaced
235:d29157c632c0 236:639222e1ab7b
30 " Comments 30 " Comments
31 Plug 'tpope/vim-commentary' 31 Plug 'tpope/vim-commentary'
32 32
33 " Moving in files 33 " Moving in files
34 Plug 'wellle/targets.vim' 34 Plug 'wellle/targets.vim'
35 Plug 'rking/ag.vim'
35 36
36 " Command line 37 " Command line
37 Plug 'tpope/vim-eunuch', { 'on' : ['Remove', 'Unlink', 'Move', 'Rename', 'Mkdir', 'Chmod', 'Find', 'Locate', 'SudoEdit', 'SudoWrite']} 38 Plug 'tpope/vim-eunuch', { 'on' : ['Remove', 'Unlink', 'Move', 'Rename', 'Mkdir', 'Chmod', 'Find', 'Locate', 'SudoEdit', 'SudoWrite']}
38 39
39 " Syntax and checking 40 " Syntax and checking
439 \ '\v\\\a*(ref|cite)\a*([^]]*\])?\{([^}]*,)*[^}]*' 440 \ '\v\\\a*(ref|cite)\a*([^]]*\])?\{([^}]*,)*[^}]*'
440 " }}} 441 " }}}
441 " Swoop {{{ 442 " Swoop {{{
442 let g:swoopUseDefaultKeyMap = 0 443 let g:swoopUseDefaultKeyMap = 0
443 " }}} 444 " }}}
445 " Ag {{{
446 " Ack motions by Steve Losh, adapted for Ag
447 nnoremap <silent> \a :set opfunc=<SID>AckMotion<CR>g@
448 xnoremap <silent> \a :<C-U>call <SID>AckMotion(visualmode())<CR>
449
450 function! s:CopyMotionForType(type)
451 if a:type ==# 'v'
452 silent execute "normal! `<" . a:type . "`>y"
453 elseif a:type ==# 'char'
454 silent execute "normal! `[v`]y"
455 endif
456 endfunction
457
458 function! s:AckMotion(type) abort
459 let reg_save = @@
460
461 call s:CopyMotionForType(a:type)
462
463 execute "normal! :Ag --literal " . shellescape(@@) . "\<cr>"
464
465 let @@ = reg_save
466 endfunction
467 " }}}
444 468
445 " Load local vimrc 469 " Load local vimrc
446 if filereadable($HOME . "/.vimrc.local") 470 if filereadable($HOME . "/.vimrc.local")
447 source ~/.vimrc.local 471 source ~/.vimrc.local
448 endif 472 endif