parent
50e494d635
commit
287b9c12aa
@ -415,8 +415,19 @@ endf
|
|||||||
" - Buffers {{{1
|
" - Buffers {{{1
|
||||||
fu! ctrlp#buffers(...)
|
fu! ctrlp#buffers(...)
|
||||||
let ids = sort(filter(range(1, bufnr('$')), 'empty(getbufvar(v:val, "&bt"))'
|
let ids = sort(filter(range(1, bufnr('$')), 'empty(getbufvar(v:val, "&bt"))'
|
||||||
\ .' && getbufvar(v:val, "&bl") && strlen(bufname(v:val))'), 's:compmreb')
|
\ .' && getbufvar(v:val, "&bl")'), 's:compmreb')
|
||||||
retu a:0 && a:1 == 'id' ? ids : map(ids, 'fnamemodify(bufname(v:val), ":.")')
|
if a:0 && a:1 == 'id'
|
||||||
|
retu ids
|
||||||
|
el
|
||||||
|
let bufs = [[], []]
|
||||||
|
for id in ids
|
||||||
|
let bname = bufname(id)
|
||||||
|
let ebname = bname == ''
|
||||||
|
let fname = fnamemodify(ebname ? '['.id.'*No Name]' : bname, ':.')
|
||||||
|
cal add(bufs[ebname], fname)
|
||||||
|
endfo
|
||||||
|
retu bufs[0] + bufs[1]
|
||||||
|
en
|
||||||
endf
|
endf
|
||||||
" * MatchedItems() {{{1
|
" * MatchedItems() {{{1
|
||||||
fu! s:MatchIt(items, pat, limit, exc)
|
fu! s:MatchIt(items, pat, limit, exc)
|
||||||
@ -927,9 +938,20 @@ fu! s:SetWD(args)
|
|||||||
endf
|
endf
|
||||||
" * AcceptSelection() {{{1
|
" * AcceptSelection() {{{1
|
||||||
fu! ctrlp#acceptfile(mode, line, ...)
|
fu! ctrlp#acceptfile(mode, line, ...)
|
||||||
let [md, filpath] = [a:mode, fnamemodify(a:line, ':p')]
|
let [md, useb] = [a:mode, 0]
|
||||||
|
if !type(a:line)
|
||||||
|
let [filpath, bufnr, useb] = [a:line, a:line, 1]
|
||||||
|
el
|
||||||
|
let filpath = fnamemodify(a:line, ':p')
|
||||||
|
if s:nonamecond(a:line, filpath)
|
||||||
|
let bufnr = str2nr(matchstr(a:line, '[\/]\?\[\zs\d\+\ze\*No Name\]$'))
|
||||||
|
let [filpath, useb] = [bufnr, 1]
|
||||||
|
el
|
||||||
|
let bufnr = bufnr('^'.filpath.'$')
|
||||||
|
en
|
||||||
|
en
|
||||||
cal s:PrtExit()
|
cal s:PrtExit()
|
||||||
let [bufnr, tail] = [bufnr('^'.filpath.'$'), s:tail()]
|
let tail = s:tail()
|
||||||
let j2l = a:0 ? a:1 : matchstr(tail, '^ +\zs\d\+$')
|
let j2l = a:0 ? a:1 : matchstr(tail, '^ +\zs\d\+$')
|
||||||
if ( s:jmptobuf =~ md || ( s:jmptobuf && md =~ '[et]' ) ) && bufnr > 0
|
if ( s:jmptobuf =~ md || ( s:jmptobuf && md =~ '[et]' ) ) && bufnr > 0
|
||||||
\ && !( md == 'e' && bufnr == bufnr('%') )
|
\ && !( md == 'e' && bufnr == bufnr('%') )
|
||||||
@ -949,7 +971,7 @@ fu! ctrlp#acceptfile(mode, line, ...)
|
|||||||
if j2l | cal ctrlp#j2l(j2l) | en
|
if j2l | cal ctrlp#j2l(j2l) | en
|
||||||
el
|
el
|
||||||
" Determine the command to use
|
" Determine the command to use
|
||||||
let useb = bufnr > 0 && buflisted(bufnr) && empty(tail)
|
let useb = bufnr > 0 && buflisted(bufnr) && ( empty(tail) || useb )
|
||||||
let cmd =
|
let cmd =
|
||||||
\ md == 't' || s:splitwin == 1 ? ( useb ? 'tab sb' : 'tabe' ) :
|
\ md == 't' || s:splitwin == 1 ? ( useb ? 'tab sb' : 'tabe' ) :
|
||||||
\ md == 'h' || s:splitwin == 2 ? ( useb ? 'sb' : 'new' ) :
|
\ md == 'h' || s:splitwin == 2 ? ( useb ? 'sb' : 'new' ) :
|
||||||
@ -1247,6 +1269,12 @@ fu! s:shortest(lens)
|
|||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:mixedsort(...)
|
fu! s:mixedsort(...)
|
||||||
|
if s:itemtype == 1
|
||||||
|
let pat = '[\/]\?\[\d\+\*No Name\]$'
|
||||||
|
if a:1 =~# pat && a:2 =~# pat | retu 0
|
||||||
|
elsei a:1 =~# pat | retu 1
|
||||||
|
elsei a:2 =~# pat | retu -1 | en
|
||||||
|
en
|
||||||
let [cln, cml] = [ctrlp#complen(a:1, a:2), s:compmatlen(a:1, a:2)]
|
let [cln, cml] = [ctrlp#complen(a:1, a:2), s:compmatlen(a:1, a:2)]
|
||||||
if s:ispath
|
if s:ispath
|
||||||
let ms = []
|
let ms = []
|
||||||
@ -1330,11 +1358,14 @@ endf
|
|||||||
fu! s:formatline(str)
|
fu! s:formatline(str)
|
||||||
let str = a:str
|
let str = a:str
|
||||||
if s:itemtype == 1
|
if s:itemtype == 1
|
||||||
let bfnr = bufnr('^'.fnamemodify(str, ':p').'$')
|
let filpath = fnamemodify(str, ':p')
|
||||||
let idc = ( bfnr == bufnr('#') ? '#' : '' )
|
let bufnr = s:nonamecond(str, filpath)
|
||||||
\ . ( getbufvar(bfnr, '&ma') ? '' : '-' )
|
\ ? str2nr(matchstr(str, '[\/]\?\[\zs\d\+\ze\*No Name\]$'))
|
||||||
\ . ( getbufvar(bfnr, '&ro') ? '=' : '' )
|
\ : bufnr('^'.filpath.'$')
|
||||||
\ . ( getbufvar(bfnr, '&mod') ? '+' : '' )
|
let idc = ( bufnr == bufnr('#') ? '#' : '' )
|
||||||
|
\ . ( getbufvar(bufnr, '&ma') ? '' : '-' )
|
||||||
|
\ . ( getbufvar(bufnr, '&ro') ? '=' : '' )
|
||||||
|
\ . ( getbufvar(bufnr, '&mod') ? '+' : '' )
|
||||||
let str .= idc != '' ? ' '.idc : ''
|
let str .= idc != '' ? ' '.idc : ''
|
||||||
en
|
en
|
||||||
let cond = s:ispath && ( s:winw - 4 ) < s:strwidth(str)
|
let cond = s:ispath && ( s:winw - 4 ) < s:strwidth(str)
|
||||||
@ -1613,6 +1644,11 @@ fu! s:bufwins(bufnr)
|
|||||||
retu winns
|
retu winns
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
fu! s:nonamecond(str, filpath)
|
||||||
|
retu a:str =~ '[\/]\?\[\d\+\*No Name\]$' && !filereadable(a:filpath)
|
||||||
|
\ && bufnr('^'.a:filpath.'$') < 1
|
||||||
|
endf
|
||||||
|
|
||||||
fu! ctrlp#normcmd(cmd, ...)
|
fu! ctrlp#normcmd(cmd, ...)
|
||||||
if a:0 < 2 && s:nosplit() | retu a:cmd | en
|
if a:0 < 2 && s:nosplit() | retu a:cmd | en
|
||||||
let norwins = filter(range(1, winnr('$')),
|
let norwins = filter(range(1, winnr('$')),
|
||||||
@ -1878,11 +1914,13 @@ endf
|
|||||||
" Entering & Exiting {{{2
|
" Entering & Exiting {{{2
|
||||||
fu! s:getenv()
|
fu! s:getenv()
|
||||||
let [s:cwd, s:winres] = [getcwd(), [winrestcmd(), &lines, winnr('$')]]
|
let [s:cwd, s:winres] = [getcwd(), [winrestcmd(), &lines, winnr('$')]]
|
||||||
let [s:crfile, s:crfpath] = [expand('%:p', 1), expand('%:p:h', 1)]
|
|
||||||
let [s:crword, s:crnbword] = [expand('<cword>', 1), expand('<cWORD>', 1)]
|
let [s:crword, s:crnbword] = [expand('<cword>', 1), expand('<cWORD>', 1)]
|
||||||
let [s:crgfile, s:crline] = [expand('<cfile>', 1), getline('.')]
|
let [s:crgfile, s:crline] = [expand('<cfile>', 1), getline('.')]
|
||||||
let [s:winh, s:crcursor] = [min([s:mxheight, &lines]), getpos('.')]
|
let [s:winh, s:crcursor] = [min([s:mxheight, &lines]), getpos('.')]
|
||||||
let [s:crbufnr, s:crvisual] = [bufnr('%'), s:lastvisual()]
|
let [s:crbufnr, s:crvisual] = [bufnr('%'), s:lastvisual()]
|
||||||
|
let s:crfile = bufname('%') == ''
|
||||||
|
\ ? '['.s:crbufnr.'*No Name]' : expand('%:p', 1)
|
||||||
|
let s:crfpath = expand('%:p:h', 1)
|
||||||
let s:mrbs = ctrlp#mrufiles#bufs()
|
let s:mrbs = ctrlp#mrufiles#bufs()
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ fu! ctrlp#buffertag#accept(mode, str)
|
|||||||
\ '\v^[^\t]+\t+[^\t|]+\|(\d+)\:[^\t|]+\|(\d+)\|\s(.+)$')
|
\ '\v^[^\t]+\t+[^\t|]+\|(\d+)\:[^\t|]+\|(\d+)\|\s(.+)$')
|
||||||
let bufnr = str2nr(get(vals, 1))
|
let bufnr = str2nr(get(vals, 1))
|
||||||
if bufnr
|
if bufnr
|
||||||
cal ctrlp#acceptfile(a:mode, bufname(bufnr))
|
cal ctrlp#acceptfile(a:mode, bufnr)
|
||||||
exe 'norm!' str2nr(get(vals, 2, line('.'))).'G'
|
exe 'norm!' str2nr(get(vals, 2, line('.'))).'G'
|
||||||
cal s:chknearby('\V\C'.get(vals, 3, ''))
|
cal s:chknearby('\V\C'.get(vals, 3, ''))
|
||||||
sil! norm! zvzz
|
sil! norm! zvzz
|
||||||
|
@ -59,7 +59,8 @@ fu! ctrlp#changes#init(original_bufnr, bufnr)
|
|||||||
let [swb, &swb] = [&swb, '']
|
let [swb, &swb] = [&swb, '']
|
||||||
let lines = []
|
let lines = []
|
||||||
for each in bufs
|
for each in bufs
|
||||||
let fnamet = fnamemodify(bufname(each), ':t')
|
let bname = bufname(each)
|
||||||
|
let fnamet = fnamemodify(bname == '' ? '[No Name]' : bname, ':t')
|
||||||
cal extend(lines, s:process(s:changelist(each), each, fnamet))
|
cal extend(lines, s:process(s:changelist(each), each, fnamet))
|
||||||
endfo
|
endfo
|
||||||
sil! exe 'noa hid b' a:original_bufnr
|
sil! exe 'noa hid b' a:original_bufnr
|
||||||
@ -73,7 +74,7 @@ fu! ctrlp#changes#accept(mode, str)
|
|||||||
let info = matchlist(a:str, '\t|\(\d\+\):[^|]\+|\(\d\+\):\(\d\+\)|$')
|
let info = matchlist(a:str, '\t|\(\d\+\):[^|]\+|\(\d\+\):\(\d\+\)|$')
|
||||||
let bufnr = str2nr(get(info, 1))
|
let bufnr = str2nr(get(info, 1))
|
||||||
if bufnr
|
if bufnr
|
||||||
cal ctrlp#acceptfile(a:mode, bufname(bufnr))
|
cal ctrlp#acceptfile(a:mode, bufnr)
|
||||||
cal cursor(get(info, 2), get(info, 3))
|
cal cursor(get(info, 2), get(info, 3))
|
||||||
sil! norm! zvzz
|
sil! norm! zvzz
|
||||||
en
|
en
|
||||||
|
@ -33,9 +33,12 @@ fu! ctrlp#line#init()
|
|||||||
let [bufs, lines] = [ctrlp#buffers('id'), []]
|
let [bufs, lines] = [ctrlp#buffers('id'), []]
|
||||||
for bufnr in bufs
|
for bufnr in bufs
|
||||||
let [lfb, bufn] = [getbufline(bufnr, 1, '$'), bufname(bufnr)]
|
let [lfb, bufn] = [getbufline(bufnr, 1, '$'), bufname(bufnr)]
|
||||||
let lfb = lfb == [] ? ctrlp#utils#readfile(fnamemodify(bufn, ':p')) : lfb
|
if lfb == [] && bufn != ''
|
||||||
|
let lfb = ctrlp#utils#readfile(fnamemodify(bufn, ':p'))
|
||||||
|
en
|
||||||
cal map(lfb, 'tr(v:val, '' '', '' '')')
|
cal map(lfb, 'tr(v:val, '' '', '' '')')
|
||||||
let [linenr, len_lfb, buft] = [1, len(lfb), fnamemodify(bufn, ':t')]
|
let [linenr, len_lfb] = [1, len(lfb)]
|
||||||
|
let buft = bufn == '' ? '[No Name]' : fnamemodify(bufn, ':t')
|
||||||
wh linenr <= len_lfb
|
wh linenr <= len_lfb
|
||||||
let lfb[linenr - 1] .= ' |'.buft.'|'.bufnr.':'.linenr.'|'
|
let lfb[linenr - 1] .= ' |'.buft.'|'.bufnr.':'.linenr.'|'
|
||||||
let linenr += 1
|
let linenr += 1
|
||||||
@ -50,7 +53,7 @@ fu! ctrlp#line#accept(mode, str)
|
|||||||
let info = matchlist(a:str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$')
|
let info = matchlist(a:str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$')
|
||||||
let bufnr = str2nr(get(info, 1))
|
let bufnr = str2nr(get(info, 1))
|
||||||
if bufnr
|
if bufnr
|
||||||
cal ctrlp#acceptfile(a:mode, bufname(bufnr), get(info, 2))
|
cal ctrlp#acceptfile(a:mode, bufnr, get(info, 2))
|
||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
@ -41,7 +41,11 @@ fu! s:getnewmix(cwd, clim)
|
|||||||
if exists('+ssl') && &ssl
|
if exists('+ssl') && &ssl
|
||||||
cal map(mrufs, 'tr(v:val, "\\", "/")')
|
cal map(mrufs, 'tr(v:val, "\\", "/")')
|
||||||
en
|
en
|
||||||
let bufs = map(ctrlp#buffers('id'), 'fnamemodify(bufname(v:val), ":p")')
|
let allbufs = map(ctrlp#buffers(), 'fnamemodify(v:val, ":p")')
|
||||||
|
let [bufs, ubufs] = [[], []]
|
||||||
|
for each in allbufs
|
||||||
|
cal add(filereadable(each) ? bufs : ubufs, each)
|
||||||
|
endfo
|
||||||
let mrufs = bufs + filter(mrufs, 'index(bufs, v:val) < 0')
|
let mrufs = bufs + filter(mrufs, 'index(bufs, v:val) < 0')
|
||||||
if len(mrufs) > len(g:ctrlp_lines)
|
if len(mrufs) > len(g:ctrlp_lines)
|
||||||
cal filter(mrufs, 'stridx(v:val, a:cwd)')
|
cal filter(mrufs, 'stridx(v:val, a:cwd)')
|
||||||
@ -53,6 +57,7 @@ fu! s:getnewmix(cwd, clim)
|
|||||||
if id >= 0 | cal remove(g:ctrlp_lines, id) | en
|
if id >= 0 | cal remove(g:ctrlp_lines, id) | en
|
||||||
endfo
|
endfo
|
||||||
en
|
en
|
||||||
|
let mrufs += ubufs
|
||||||
cal map(mrufs, 'fnamemodify(v:val, ":.")')
|
cal map(mrufs, 'fnamemodify(v:val, ":.")')
|
||||||
let g:ctrlp_lines = len(mrufs) > len(g:ctrlp_lines)
|
let g:ctrlp_lines = len(mrufs) > len(g:ctrlp_lines)
|
||||||
\ ? g:ctrlp_lines + mrufs : mrufs + g:ctrlp_lines
|
\ ? g:ctrlp_lines + mrufs : mrufs + g:ctrlp_lines
|
||||||
|
Loading…
Reference in New Issue
Block a user