bgneal@7: " ============================================================================= bgneal@7: " File: autoload/ctrlp/line.vim bgneal@7: " Description: Line extension bgneal@7: " Author: Kien Nguyen bgneal@7: " ============================================================================= bgneal@7: bgneal@7: " Init {{{1 bgneal@7: if exists('g:loaded_ctrlp_line') && g:loaded_ctrlp_line bgneal@7: fini bgneal@7: en bgneal@7: let g:loaded_ctrlp_line = 1 bgneal@7: bgneal@7: cal add(g:ctrlp_ext_vars, { bgneal@7: \ 'init': 'ctrlp#line#init()', bgneal@7: \ 'accept': 'ctrlp#line#accept', bgneal@7: \ 'lname': 'lines', bgneal@7: \ 'sname': 'lns', bgneal@7: \ 'type': 'tabe', bgneal@7: \ }) bgneal@7: bgneal@7: let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) bgneal@7: " Utilities {{{1 bgneal@7: fu! s:syntax() bgneal@7: if !ctrlp#nosy() bgneal@7: cal ctrlp#hicheck('CtrlPBufName', 'Directory') bgneal@7: cal ctrlp#hicheck('CtrlPTabExtra', 'Comment') bgneal@7: sy match CtrlPBufName '\t|\zs[^|]\+\ze|\d\+:\d\+|$' bgneal@7: sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName bgneal@7: en bgneal@7: endf bgneal@7: " Public {{{1 bgneal@7: fu! ctrlp#line#init() bgneal@7: let [bufs, lines] = [ctrlp#buffers('id'), []] bgneal@7: for bufnr in bufs bgneal@7: let [lfb, bufn] = [getbufline(bufnr, 1, '$'), bufname(bufnr)] bgneal@7: let lfb = lfb == [] ? ctrlp#utils#readfile(fnamemodify(bufn, ':p')) : lfb bgneal@7: cal map(lfb, 'tr(v:val, '' '', '' '')') bgneal@7: let [linenr, len_lfb, buft] = [1, len(lfb), fnamemodify(bufn, ':t')] bgneal@7: wh linenr <= len_lfb bgneal@7: let lfb[linenr - 1] .= ' |'.buft.'|'.bufnr.':'.linenr.'|' bgneal@7: let linenr += 1 bgneal@7: endw bgneal@7: cal extend(lines, filter(lfb, 'v:val !~ ''^\s*\t|[^|]\+|\d\+:\d\+|$''')) bgneal@7: endfo bgneal@7: cal s:syntax() bgneal@7: retu lines bgneal@7: endf bgneal@7: bgneal@7: fu! ctrlp#line#accept(mode, str) bgneal@7: let info = matchlist(a:str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$') bgneal@7: if info == [] | retu | en bgneal@7: let [bufnr, linenr] = [str2nr(get(info, 1)), get(info, 2)] bgneal@7: if bufnr > 0 bgneal@7: cal ctrlp#acceptfile(a:mode, fnamemodify(bufname(bufnr), ':p'), linenr) bgneal@7: en bgneal@7: endf bgneal@7: bgneal@7: fu! ctrlp#line#id() bgneal@7: retu s:id bgneal@7: endf bgneal@7: "}}} bgneal@7: bgneal@7: " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2