bgneal@0
|
1 " =============================================================================
|
bgneal@0
|
2 " File: autoload/ctrlp/quickfix.vim
|
bgneal@0
|
3 " Description: Quickfix extension
|
bgneal@0
|
4 " Author: Kien Nguyen <github.com/kien>
|
bgneal@0
|
5 " =============================================================================
|
bgneal@0
|
6
|
bgneal@0
|
7 " Init {{{1
|
bgneal@0
|
8 if exists('g:loaded_ctrlp_quickfix') && g:loaded_ctrlp_quickfix
|
bgneal@0
|
9 fini
|
bgneal@0
|
10 en
|
bgneal@0
|
11 let g:loaded_ctrlp_quickfix = 1
|
bgneal@0
|
12
|
bgneal@0
|
13 let s:var_qf = ['ctrlp#quickfix#init()', 'ctrlp#quickfix#accept', 'quickfix',
|
bgneal@0
|
14 \ 'qfx', [1]]
|
bgneal@0
|
15
|
bgneal@0
|
16 let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
|
bgneal@0
|
17 \ ? add(g:ctrlp_ext_vars, s:var_qf) : [s:var_qf]
|
bgneal@0
|
18
|
bgneal@0
|
19 let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
bgneal@0
|
20
|
bgneal@0
|
21 fu! s:lineout(dict)
|
bgneal@0
|
22 retu printf('%s|%d:%d| %s', bufname(a:dict['bufnr']), a:dict['lnum'],
|
bgneal@0
|
23 \ a:dict['col'], matchstr(a:dict['text'], '\s*\zs.*\S'))
|
bgneal@0
|
24 endf
|
bgneal@0
|
25 " Public {{{1
|
bgneal@0
|
26 fu! ctrlp#quickfix#init()
|
bgneal@0
|
27 let g:ctrlp_nolimit = 1
|
bgneal@0
|
28 sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|'
|
bgneal@0
|
29 hi def link CtrlPqfLineCol Search
|
bgneal@0
|
30 retu map(getqflist(), 's:lineout(v:val)')
|
bgneal@0
|
31 endf
|
bgneal@0
|
32
|
bgneal@0
|
33 fu! ctrlp#quickfix#accept(mode, str)
|
bgneal@0
|
34 let items = matchlist(a:str, '^\([^|]\+\ze\)|\(\d\+\):\(\d\+\)|')
|
bgneal@0
|
35 let [md, filpath] = [a:mode, fnamemodify(items[1], ':p')]
|
bgneal@0
|
36 if empty(filpath) | retu | en
|
bgneal@0
|
37 cal ctrlp#exit()
|
bgneal@0
|
38 let cmd = md == 't' ? 'tabe' : md == 'h' ? 'new' : md == 'v' ? 'vne'
|
bgneal@0
|
39 \ : ctrlp#normcmd('e')
|
bgneal@0
|
40 let cmd = cmd == 'e' && &modified ? 'hid e' : cmd
|
bgneal@0
|
41 try
|
bgneal@0
|
42 exe cmd.' '.ctrlp#fnesc(filpath)
|
bgneal@0
|
43 cat
|
bgneal@0
|
44 cal ctrlp#msg("Invalid command or argument.")
|
bgneal@0
|
45 fina
|
bgneal@3
|
46 cal cursor(items[2], items[3]) | sil! norm! zvzz
|
bgneal@0
|
47 endt
|
bgneal@0
|
48 endf
|
bgneal@0
|
49
|
bgneal@0
|
50 fu! ctrlp#quickfix#id()
|
bgneal@0
|
51 retu s:id
|
bgneal@0
|
52 endf
|
bgneal@0
|
53 "}}}
|
bgneal@0
|
54
|
bgneal@0
|
55 " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|