bgneal@0: " ============================================================================= bgneal@0: " File: autoload/ctrlp/quickfix.vim bgneal@0: " Description: Quickfix extension bgneal@0: " Author: Kien Nguyen bgneal@0: " ============================================================================= bgneal@0: bgneal@0: " Init {{{1 bgneal@0: if exists('g:loaded_ctrlp_quickfix') && g:loaded_ctrlp_quickfix bgneal@0: fini bgneal@0: en bgneal@0: let g:loaded_ctrlp_quickfix = 1 bgneal@0: bgneal@0: let s:var_qf = ['ctrlp#quickfix#init()', 'ctrlp#quickfix#accept', 'quickfix', bgneal@0: \ 'qfx', [1]] bgneal@0: bgneal@0: let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars) bgneal@0: \ ? add(g:ctrlp_ext_vars, s:var_qf) : [s:var_qf] bgneal@0: bgneal@0: let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) bgneal@0: bgneal@0: fu! s:lineout(dict) bgneal@0: retu printf('%s|%d:%d| %s', bufname(a:dict['bufnr']), a:dict['lnum'], bgneal@0: \ a:dict['col'], matchstr(a:dict['text'], '\s*\zs.*\S')) bgneal@0: endf bgneal@0: " Public {{{1 bgneal@0: fu! ctrlp#quickfix#init() bgneal@0: let g:ctrlp_nolimit = 1 bgneal@0: sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|' bgneal@0: hi def link CtrlPqfLineCol Search bgneal@0: retu map(getqflist(), 's:lineout(v:val)') bgneal@0: endf bgneal@0: bgneal@0: fu! ctrlp#quickfix#accept(mode, str) bgneal@0: let items = matchlist(a:str, '^\([^|]\+\ze\)|\(\d\+\):\(\d\+\)|') bgneal@0: let [md, filpath] = [a:mode, fnamemodify(items[1], ':p')] bgneal@0: if empty(filpath) | retu | en bgneal@0: cal ctrlp#exit() bgneal@0: let cmd = md == 't' ? 'tabe' : md == 'h' ? 'new' : md == 'v' ? 'vne' bgneal@0: \ : ctrlp#normcmd('e') bgneal@0: let cmd = cmd == 'e' && &modified ? 'hid e' : cmd bgneal@0: try bgneal@0: exe cmd.' '.ctrlp#fnesc(filpath) bgneal@0: cat bgneal@0: cal ctrlp#msg("Invalid command or argument.") bgneal@0: fina bgneal@0: cal cursor(items[2], items[3]) | sil! norm! zOzz bgneal@0: endt bgneal@0: endf bgneal@0: bgneal@0: fu! ctrlp#quickfix#id() bgneal@0: retu s:id bgneal@0: endf bgneal@0: "}}} bgneal@0: bgneal@0: " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2