comparison vim/vimfiles/autoload/ctrlp/quickfix.vim @ 0:48859d9c82c5

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