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