annotate vim/vimfiles/bundle/ctrlp.vim/autoload/ctrlp/line.vim @ 11:d428a965f322

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