2011-11-28 07:52:28 -05:00
|
|
|
" =============================================================================
|
|
|
|
" File: autoload/ctrlp/quickfix.vim
|
|
|
|
" Description: Quickfix extension
|
|
|
|
" Author: Kien Nguyen <github.com/kien>
|
|
|
|
" =============================================================================
|
|
|
|
|
2011-12-02 22:54:18 -05:00
|
|
|
" Init {{{1
|
2011-11-28 07:52:28 -05:00
|
|
|
if exists('g:loaded_ctrlp_quickfix') && g:loaded_ctrlp_quickfix
|
|
|
|
fini
|
|
|
|
en
|
|
|
|
let g:loaded_ctrlp_quickfix = 1
|
|
|
|
|
2012-04-07 07:55:23 -04:00
|
|
|
cal add(g:ctrlp_ext_vars, {
|
2012-01-15 12:42:14 -05:00
|
|
|
\ 'init': 'ctrlp#quickfix#init()',
|
|
|
|
\ 'accept': 'ctrlp#quickfix#accept',
|
|
|
|
\ 'lname': 'quickfix',
|
|
|
|
\ 'sname': 'qfx',
|
|
|
|
\ 'type': 'line',
|
2012-03-30 14:58:51 -04:00
|
|
|
\ 'sort': 0,
|
2012-04-10 14:19:10 -04:00
|
|
|
\ 'nolim': 1,
|
2012-04-07 07:55:23 -04:00
|
|
|
\ })
|
2011-11-28 07:52:28 -05:00
|
|
|
|
|
|
|
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
|
|
|
|
|
|
|
fu! s:lineout(dict)
|
|
|
|
retu printf('%s|%d:%d| %s', bufname(a:dict['bufnr']), a:dict['lnum'],
|
|
|
|
\ a:dict['col'], matchstr(a:dict['text'], '\s*\zs.*\S'))
|
|
|
|
endf
|
2012-04-06 22:01:06 -04:00
|
|
|
" Utilities {{{1
|
|
|
|
fu! s:syntax()
|
|
|
|
if !ctrlp#nosy()
|
|
|
|
cal ctrlp#hicheck('CtrlPqfLineCol', 'Search')
|
|
|
|
sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|'
|
|
|
|
en
|
|
|
|
endf
|
2011-12-02 22:54:18 -05:00
|
|
|
" Public {{{1
|
2011-11-28 07:52:28 -05:00
|
|
|
fu! ctrlp#quickfix#init()
|
2012-04-06 22:01:06 -04:00
|
|
|
cal s:syntax()
|
2011-11-28 07:52:28 -05:00
|
|
|
retu map(getqflist(), 's:lineout(v:val)')
|
|
|
|
endf
|
|
|
|
|
|
|
|
fu! ctrlp#quickfix#accept(mode, str)
|
|
|
|
let items = matchlist(a:str, '^\([^|]\+\ze\)|\(\d\+\):\(\d\+\)|')
|
2012-04-14 02:44:05 -04:00
|
|
|
if items == [] | retu | en
|
2011-11-28 07:52:28 -05:00
|
|
|
let [md, filpath] = [a:mode, fnamemodify(items[1], ':p')]
|
|
|
|
if empty(filpath) | retu | en
|
|
|
|
cal ctrlp#exit()
|
|
|
|
let cmd = md == 't' ? 'tabe' : md == 'h' ? 'new' : md == 'v' ? 'vne'
|
|
|
|
\ : ctrlp#normcmd('e')
|
|
|
|
let cmd = cmd == 'e' && &modified ? 'hid e' : cmd
|
2012-02-12 06:50:15 -05:00
|
|
|
exe cmd ctrlp#fnesc(filpath)
|
|
|
|
cal cursor(items[2], items[3])
|
|
|
|
sil! norm! zvzz
|
2012-03-03 10:31:50 -05:00
|
|
|
cal ctrlp#setlcdir()
|
2011-11-28 07:52:28 -05:00
|
|
|
endf
|
|
|
|
|
|
|
|
fu! ctrlp#quickfix#id()
|
|
|
|
retu s:id
|
|
|
|
endf
|
|
|
|
"}}}
|
|
|
|
|
2011-12-02 22:54:18 -05:00
|
|
|
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|