bgneal@0: " ============================================================================= bgneal@0: " File: autoload/ctrlp/line.vim bgneal@0: " Description: Line extension - find a line in any buffer. bgneal@0: " Author: Kien Nguyen bgneal@0: " ============================================================================= bgneal@0: bgneal@0: " Init {{{1 bgneal@0: if exists('g:loaded_ctrlp_line') && g:loaded_ctrlp_line bgneal@0: fini bgneal@0: en bgneal@0: let g:loaded_ctrlp_line = 1 bgneal@0: bgneal@0: let s:line_var = ['ctrlp#line#init()', 'ctrlp#line#accept', 'lines', 'line'] bgneal@0: bgneal@0: let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars) bgneal@0: \ ? add(g:ctrlp_ext_vars, s:line_var) : [s:line_var] bgneal@0: bgneal@0: let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) bgneal@0: " Public {{{1 bgneal@0: fu! ctrlp#line#init() bgneal@0: let [bufs, lines] = [[], []] bgneal@0: for each in range(1, bufnr('$')) bgneal@0: if getbufvar(each, '&bl') bgneal@0: let bufname = bufname(each) bgneal@0: if strlen(bufname) && bufname != 'ControlP' bgneal@0: cal add(bufs, fnamemodify(bufname, ':p')) bgneal@0: en bgneal@0: en bgneal@0: endfo bgneal@0: cal filter(bufs, 'filereadable(v:val)') bgneal@0: for each in bufs bgneal@0: let from_file = readfile(each) bgneal@0: cal map(from_file, 'tr(v:val, '' '', '' '')') bgneal@0: let [id, len_ff, bufnr] = [1, len(from_file), bufnr(each)] bgneal@0: wh id <= len_ff bgneal@0: let from_file[id-1] .= ' #:'.bufnr.':'.id bgneal@0: let id += 1 bgneal@0: endw bgneal@0: cal filter(from_file, 'v:val !~ ''^\s*\t#:\d\+:\d\+$''') bgneal@0: cal extend(lines, from_file) bgneal@0: endfo bgneal@0: sy match CtrlPTabExtra '\zs\t.*\ze$' bgneal@0: hi link CtrlPTabExtra Comment bgneal@0: retu lines bgneal@0: endf bgneal@0: bgneal@0: fu! ctrlp#line#accept(mode, str) bgneal@0: let info = get(split(a:str, '\t#:\ze\d\+:\d\+$'), 1, 0) bgneal@0: let bufnr = str2nr(get(split(info, ':'), 0, 0)) bgneal@0: let linenr = get(split(info, ':'), 1, 0) bgneal@0: if bufnr bgneal@0: cal ctrlp#acceptfile(a:mode, fnamemodify(bufname(bufnr), ':p'), linenr) bgneal@0: en bgneal@0: endf bgneal@0: bgneal@0: fu! ctrlp#line#id() bgneal@0: retu s:id bgneal@0: endf bgneal@0: "}}} bgneal@0: bgneal@0: " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2