comparison vim/vimfiles/bundle/ctrlp.vim/autoload/ctrlp/line.vim @ 7:86e0ac713642

Re-added the latest ctrlp.vim plugin. The ctrlp.vim commit was e61e7d5b801ade5fcefeab3aca75c1f37d54bdf1.
author Brian Neal <bgneal@gmail.com>
date Sun, 29 Apr 2012 16:20:31 -0500
parents
children
comparison
equal deleted inserted replaced
6:ff60fbc930de 7:86e0ac713642
1 " =============================================================================
2 " File: autoload/ctrlp/line.vim
3 " Description: Line extension
4 " Author: Kien Nguyen <github.com/kien>
5 " =============================================================================
6
7 " Init {{{1
8 if exists('g:loaded_ctrlp_line') && g:loaded_ctrlp_line
9 fini
10 en
11 let g:loaded_ctrlp_line = 1
12
13 cal add(g:ctrlp_ext_vars, {
14 \ 'init': 'ctrlp#line#init()',
15 \ 'accept': 'ctrlp#line#accept',
16 \ 'lname': 'lines',
17 \ 'sname': 'lns',
18 \ 'type': 'tabe',
19 \ })
20
21 let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
22 " Utilities {{{1
23 fu! s:syntax()
24 if !ctrlp#nosy()
25 cal ctrlp#hicheck('CtrlPBufName', 'Directory')
26 cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
27 sy match CtrlPBufName '\t|\zs[^|]\+\ze|\d\+:\d\+|$'
28 sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName
29 en
30 endf
31 " Public {{{1
32 fu! ctrlp#line#init()
33 let [bufs, lines] = [ctrlp#buffers('id'), []]
34 for bufnr in bufs
35 let [lfb, bufn] = [getbufline(bufnr, 1, '$'), bufname(bufnr)]
36 let lfb = lfb == [] ? ctrlp#utils#readfile(fnamemodify(bufn, ':p')) : lfb
37 cal map(lfb, 'tr(v:val, '' '', '' '')')
38 let [linenr, len_lfb, buft] = [1, len(lfb), fnamemodify(bufn, ':t')]
39 wh linenr <= len_lfb
40 let lfb[linenr - 1] .= ' |'.buft.'|'.bufnr.':'.linenr.'|'
41 let linenr += 1
42 endw
43 cal extend(lines, filter(lfb, 'v:val !~ ''^\s*\t|[^|]\+|\d\+:\d\+|$'''))
44 endfo
45 cal s:syntax()
46 retu lines
47 endf
48
49 fu! ctrlp#line#accept(mode, str)
50 let info = matchlist(a:str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$')
51 if info == [] | retu | en
52 let [bufnr, linenr] = [str2nr(get(info, 1)), get(info, 2)]
53 if bufnr > 0
54 cal ctrlp#acceptfile(a:mode, fnamemodify(bufname(bufnr), ':p'), linenr)
55 en
56 endf
57
58 fu! ctrlp#line#id()
59 retu s:id
60 endf
61 "}}}
62
63 " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2