comparison vim/vimfiles/autoload/ctrlp/line.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/line.vim
3 " Description: Line extension - find a line in any buffer.
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 let s:line_var = ['ctrlp#line#init()', 'ctrlp#line#accept', 'lines', 'line']
14
15 let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
16 \ ? add(g:ctrlp_ext_vars, s:line_var) : [s:line_var]
17
18 let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
19 " Public {{{1
20 fu! ctrlp#line#init()
21 let [bufs, lines] = [[], []]
22 for each in range(1, bufnr('$'))
23 if getbufvar(each, '&bl')
24 let bufname = bufname(each)
25 if strlen(bufname) && bufname != 'ControlP'
26 cal add(bufs, fnamemodify(bufname, ':p'))
27 en
28 en
29 endfo
30 cal filter(bufs, 'filereadable(v:val)')
31 for each in bufs
32 let from_file = readfile(each)
33 cal map(from_file, 'tr(v:val, '' '', '' '')')
34 let [id, len_ff, bufnr] = [1, len(from_file), bufnr(each)]
35 wh id <= len_ff
36 let from_file[id-1] .= ' #:'.bufnr.':'.id
37 let id += 1
38 endw
39 cal filter(from_file, 'v:val !~ ''^\s*\t#:\d\+:\d\+$''')
40 cal extend(lines, from_file)
41 endfo
42 sy match CtrlPTabExtra '\zs\t.*\ze$'
43 hi link CtrlPTabExtra Comment
44 retu lines
45 endf
46
47 fu! ctrlp#line#accept(mode, str)
48 let info = get(split(a:str, '\t#:\ze\d\+:\d\+$'), 1, 0)
49 let bufnr = str2nr(get(split(info, ':'), 0, 0))
50 let linenr = get(split(info, ':'), 1, 0)
51 if bufnr
52 cal ctrlp#acceptfile(a:mode, fnamemodify(bufname(bufnr), ':p'), linenr)
53 en
54 endf
55
56 fu! ctrlp#line#id()
57 retu s:id
58 endf
59 "}}}
60
61 " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2