parent
ac56d68249
commit
dd832abfff
@ -201,7 +201,7 @@ fu! s:Close()
|
|||||||
exe s:winres[0]
|
exe s:winres[0]
|
||||||
en
|
en
|
||||||
unl! s:focus s:hisidx s:hstgot s:marked s:statypes s:cline s:init s:savestr
|
unl! s:focus s:hisidx s:hstgot s:marked s:statypes s:cline s:init s:savestr
|
||||||
\ s:winh g:ctrlp_nolimit
|
\ g:ctrlp_nolimit
|
||||||
cal ctrlp#recordhist()
|
cal ctrlp#recordhist()
|
||||||
cal s:onexit()
|
cal s:onexit()
|
||||||
cal s:log(0)
|
cal s:log(0)
|
||||||
@ -227,8 +227,8 @@ fu! ctrlp#reset()
|
|||||||
cal ctrlp#utils#opts()
|
cal ctrlp#utils#opts()
|
||||||
cal ctrlp#mrufiles#opts()
|
cal ctrlp#mrufiles#opts()
|
||||||
endf
|
endf
|
||||||
" * Files() {{{1
|
" * Files {{{1
|
||||||
fu! s:Files()
|
fu! ctrlp#files()
|
||||||
let [cwd, cafile, g:ctrlp_allfiles] = [getcwd(), ctrlp#utils#cachefile(), []]
|
let [cwd, cafile, g:ctrlp_allfiles] = [getcwd(), ctrlp#utils#cachefile(), []]
|
||||||
if g:ctrlp_newcache || !filereadable(cafile) || !s:caching
|
if g:ctrlp_newcache || !filereadable(cafile) || !s:caching
|
||||||
let lscmd = s:lsCmd()
|
let lscmd = s:lsCmd()
|
||||||
@ -307,17 +307,11 @@ fu! s:lsCmd()
|
|||||||
retu cmd['types'][key][1]
|
retu cmd['types'][key][1]
|
||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
fu! s:Buffers() "{{{1
|
" Buffers {{{1
|
||||||
let allbufs = []
|
fu! ctrlp#buffers()
|
||||||
for each in range(1, bufnr('$'))
|
retu map(filter(range(1, bufnr('$')), 'empty(getbufvar(v:val, "&bt"))'
|
||||||
if each != s:bufnr && getbufvar(each, '&bl')
|
\ .' && getbufvar(v:val, "&bl") && strlen(bufname(v:val))'),
|
||||||
let bufname = bufname(each)
|
\ 'fnamemodify(bufname(v:val), ":.")')
|
||||||
if strlen(bufname) && getbufvar(each, '&ma')
|
|
||||||
cal add(allbufs, fnamemodify(bufname, ':.'))
|
|
||||||
en
|
|
||||||
en
|
|
||||||
endfo
|
|
||||||
retu allbufs
|
|
||||||
endf
|
endf
|
||||||
" * MatchedItems() {{{1
|
" * MatchedItems() {{{1
|
||||||
fu! s:MatchIt(items, pat, limit, mfunc, ipt)
|
fu! s:MatchIt(items, pat, limit, mfunc, ipt)
|
||||||
@ -585,7 +579,7 @@ fu! s:PrtClearCache()
|
|||||||
if s:itemtype == 2
|
if s:itemtype == 2
|
||||||
let g:ctrlp_lines = ctrlp#mrufiles#list(-1, 1)
|
let g:ctrlp_lines = ctrlp#mrufiles#list(-1, 1)
|
||||||
el
|
el
|
||||||
cal s:SetLines(s:itemtype)
|
cal ctrlp#setlines(s:itemtype)
|
||||||
en
|
en
|
||||||
let s:force = 1
|
let s:force = 1
|
||||||
cal s:BuildPrompt(1)
|
cal s:BuildPrompt(1)
|
||||||
@ -694,9 +688,9 @@ fu! s:ToggleType(dir)
|
|||||||
if s:byfname && !s:ispathitem() | let s:byfname = 0 | en
|
if s:byfname && !s:ispathitem() | let s:byfname = 0 | en
|
||||||
unl! g:ctrlp_nolimit
|
unl! g:ctrlp_nolimit
|
||||||
if has('syntax') && exists('g:syntax_on')
|
if has('syntax') && exists('g:syntax_on')
|
||||||
cal s:syntax()
|
cal ctrlp#syntax()
|
||||||
en
|
en
|
||||||
cal s:SetLines(s:itemtype)
|
cal ctrlp#setlines(s:itemtype)
|
||||||
cal s:PrtSwitcher()
|
cal s:PrtSwitcher()
|
||||||
endf
|
endf
|
||||||
|
|
||||||
@ -771,12 +765,12 @@ fu! s:SpecInputs(str)
|
|||||||
let [str, type] = [a:str, s:type()]
|
let [str, type] = [a:str, s:type()]
|
||||||
if str == '..' && type =~ '\v^(0|dir)$'
|
if str == '..' && type =~ '\v^(0|dir)$'
|
||||||
cal s:parentdir(getcwd())
|
cal s:parentdir(getcwd())
|
||||||
cal s:SetLines(s:itemtype)
|
cal ctrlp#setlines(s:itemtype)
|
||||||
cal s:PrtClear()
|
cal s:PrtClear()
|
||||||
retu 1
|
retu 1
|
||||||
elsei str =~ '^[\/]$' && type =~ '\v^(0|dir)$'
|
elsei str =~ '^[\/]$' && type =~ '\v^(0|dir)$'
|
||||||
cal s:SetWD(2, 0)
|
cal s:SetWD(2, 0)
|
||||||
cal s:SetLines(s:itemtype)
|
cal ctrlp#setlines(s:itemtype)
|
||||||
cal s:PrtClear()
|
cal s:PrtClear()
|
||||||
retu 1
|
retu 1
|
||||||
elsei str == '?'
|
elsei str == '?'
|
||||||
@ -1171,7 +1165,7 @@ fu! ctrlp#setlcdir()
|
|||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
" Highlighting {{{2
|
" Highlighting {{{2
|
||||||
fu! s:syntax()
|
fu! ctrlp#syntax()
|
||||||
for [ke, va] in items(s:hlgrps) | if !hlexists('CtrlP'.ke)
|
for [ke, va] in items(s:hlgrps) | if !hlexists('CtrlP'.ke)
|
||||||
exe 'hi link CtrlP'.ke va
|
exe 'hi link CtrlP'.ke va
|
||||||
en | endfo
|
en | endfo
|
||||||
@ -1263,37 +1257,21 @@ fu! s:buftab(bufnr, md)
|
|||||||
let buflist = tabpagebuflist(tabnr)
|
let buflist = tabpagebuflist(tabnr)
|
||||||
if index(buflist, a:bufnr) >= 0
|
if index(buflist, a:bufnr) >= 0
|
||||||
for winnr in range(1, tabpagewinnr(tabnr, '$'))
|
for winnr in range(1, tabpagewinnr(tabnr, '$'))
|
||||||
if buflist[winnr - 1] == a:bufnr
|
if buflist[winnr - 1] == a:bufnr | retu [tabnr, winnr] | en
|
||||||
retu [tabnr, winnr]
|
|
||||||
en
|
|
||||||
endfo
|
endfo
|
||||||
en
|
en
|
||||||
endfo
|
endfo
|
||||||
retu [0, 0]
|
retu [0, 0]
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:normbuf()
|
|
||||||
let winnrs = []
|
|
||||||
for each in range(1, winnr('$'))
|
|
||||||
let bufnr = winbufnr(each)
|
|
||||||
if getbufvar(bufnr, '&bl') && empty(getbufvar(bufnr, '&bt'))
|
|
||||||
\ && getbufvar(bufnr, '&ma')
|
|
||||||
cal add(winnrs, each)
|
|
||||||
en
|
|
||||||
endfo
|
|
||||||
retu winnrs
|
|
||||||
endf
|
|
||||||
|
|
||||||
fu! ctrlp#normcmd(cmd, ...)
|
fu! ctrlp#normcmd(cmd, ...)
|
||||||
if s:nosplit()
|
if s:nosplit() | retu a:cmd | en
|
||||||
retu a:cmd
|
let norwins = filter(range(1, winnr('$')),
|
||||||
en
|
\ 'empty(getbufvar(winbufnr(v:val), "&bt"))')
|
||||||
let norwins = s:normbuf()
|
|
||||||
for each in norwins
|
for each in norwins
|
||||||
let bufnr = winbufnr(each)
|
let bufnr = winbufnr(each)
|
||||||
if empty(bufname(bufnr)) && empty(getbufvar(bufnr, '&ft'))
|
if empty(bufname(bufnr)) && empty(getbufvar(bufnr, '&ft'))
|
||||||
let fstemp = each
|
let fstemp = each | brea
|
||||||
brea
|
|
||||||
en
|
en
|
||||||
endfo
|
endfo
|
||||||
let norwin = empty(norwins) ? 0 : norwins[0]
|
let norwin = empty(norwins) ? 0 : norwins[0]
|
||||||
@ -1307,7 +1285,7 @@ fu! ctrlp#normcmd(cmd, ...)
|
|||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:nosplit()
|
fu! s:nosplit()
|
||||||
retu !empty(s:nosplit) && match([bufname('%'), &l:ft], s:nosplit) >= 0
|
retu !empty(s:nosplit) && match([bufname('%'), &l:ft, &l:bt], s:nosplit) >= 0
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:setupblank()
|
fu! s:setupblank()
|
||||||
@ -1515,20 +1493,6 @@ fu! s:onexit()
|
|||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! ctrlp#allbufs()
|
|
||||||
let bufs = []
|
|
||||||
for each in range(1, bufnr('$'))
|
|
||||||
if getbufvar(each, '&bl')
|
|
||||||
let bufname = bufname(each)
|
|
||||||
if strlen(bufname) && bufname != 'ControlP'
|
|
||||||
cal add(bufs, fnamemodify(bufname, ':p'))
|
|
||||||
en
|
|
||||||
en
|
|
||||||
endfo
|
|
||||||
cal filter(bufs, 'filereadable(v:val)')
|
|
||||||
retu bufs
|
|
||||||
endf
|
|
||||||
|
|
||||||
fu! ctrlp#exit()
|
fu! ctrlp#exit()
|
||||||
cal s:PrtExit()
|
cal s:PrtExit()
|
||||||
endf
|
endf
|
||||||
@ -1536,17 +1500,13 @@ endf
|
|||||||
fu! ctrlp#prtclear()
|
fu! ctrlp#prtclear()
|
||||||
cal s:PrtClear()
|
cal s:PrtClear()
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! ctrlp#setlines(type)
|
|
||||||
cal s:SetLines(a:type)
|
|
||||||
endf
|
|
||||||
"}}}1
|
"}}}1
|
||||||
" * Initialization {{{1
|
" * Initialization {{{1
|
||||||
fu! s:SetLines(type)
|
fu! ctrlp#setlines(type)
|
||||||
let s:itemtype = a:type
|
let s:itemtype = a:type
|
||||||
let types = [
|
let types = [
|
||||||
\ 's:Files()',
|
\ 'ctrlp#files()',
|
||||||
\ 's:Buffers()',
|
\ 'ctrlp#buffers()',
|
||||||
\ 'ctrlp#mrufiles#list(-1)',
|
\ 'ctrlp#mrufiles#list(-1)',
|
||||||
\ ]
|
\ ]
|
||||||
if exists('g:ctrlp_ext_vars')
|
if exists('g:ctrlp_ext_vars')
|
||||||
@ -1562,9 +1522,9 @@ fu! ctrlp#init(type, ...)
|
|||||||
cal s:SetWD(a:0 ? a:1 : '')
|
cal s:SetWD(a:0 ? a:1 : '')
|
||||||
cal s:MapKeys()
|
cal s:MapKeys()
|
||||||
if has('syntax') && exists('g:syntax_on')
|
if has('syntax') && exists('g:syntax_on')
|
||||||
cal s:syntax()
|
cal ctrlp#syntax()
|
||||||
en
|
en
|
||||||
cal s:SetLines(a:type)
|
cal ctrlp#setlines(a:type)
|
||||||
cal s:BuildPrompt(1)
|
cal s:BuildPrompt(1)
|
||||||
endf
|
endf
|
||||||
if has('autocmd') "{{{1
|
if has('autocmd') "{{{1
|
||||||
|
@ -198,17 +198,20 @@ fu! s:parseline(line)
|
|||||||
endf
|
endf
|
||||||
" Public {{{1
|
" Public {{{1
|
||||||
fu! ctrlp#buffertag#init(fname)
|
fu! ctrlp#buffertag#init(fname)
|
||||||
let fname = exists('s:bufname') ? s:bufname : a:fname
|
let bufs = exists('s:btmode') && s:btmode
|
||||||
let bufs = exists('s:btmode') && s:btmode ? ctrlp#allbufs() : [fname]
|
\ ? filter(ctrlp#buffers(), 'filereadable(v:val)')
|
||||||
|
\ : [exists('s:bufname') ? s:bufname : a:fname]
|
||||||
let lines = []
|
let lines = []
|
||||||
for each in bufs
|
for each in bufs
|
||||||
let tftype = get(split(getbufvar(each, '&ft'), '\.'), 0, '')
|
let tftype = get(split(getbufvar(each, '&ft'), '\.'), 0, '')
|
||||||
cal extend(lines, s:process(each, tftype))
|
cal extend(lines, s:process(each, tftype))
|
||||||
endfo
|
endfo
|
||||||
|
if has('syntax') && exists('g:syntax_on')
|
||||||
if !hlexists('CtrlPTabExtra')
|
if !hlexists('CtrlPTabExtra')
|
||||||
hi link CtrlPTabExtra Comment
|
hi link CtrlPTabExtra Comment
|
||||||
en
|
en
|
||||||
sy match CtrlPTabExtra '\zs\t.*\ze$'
|
sy match CtrlPTabExtra '\zs\t.*\ze$'
|
||||||
|
en
|
||||||
retu lines
|
retu lines
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
@ -31,30 +31,31 @@ let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
|
|||||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||||
" Public {{{1
|
" Public {{{1
|
||||||
fu! ctrlp#line#init()
|
fu! ctrlp#line#init()
|
||||||
let [bufs, lines] = [ctrlp#allbufs(), []]
|
let [bufs, lines] = [filter(ctrlp#buffers(), 'filereadable(v:val)'), []]
|
||||||
for each in bufs
|
for each in bufs
|
||||||
let from_file = readfile(each)
|
let [fnamet, from_file] = [fnamemodify(each, ':t'), readfile(each)]
|
||||||
cal map(from_file, 'tr(v:val, '' '', '' '')')
|
cal map(from_file, 'tr(v:val, '' '', '' '')')
|
||||||
let [id, len_ff, bufnr] = [1, len(from_file), bufnr('^'.each.'$')]
|
let [id, len_ff, bufnr] = [1, len(from_file), bufnr('^'.each.'$')]
|
||||||
wh id <= len_ff
|
wh id <= len_ff
|
||||||
let from_file[id-1] .= ' #:'.bufnr.':'.id
|
let from_file[id-1] .= ' |'.fnamet.'|'.bufnr.':'.id.'|'
|
||||||
let id += 1
|
let id += 1
|
||||||
endw
|
endw
|
||||||
cal filter(from_file, 'v:val !~ ''^\s*\t#:\d\+:\d\+$''')
|
cal filter(from_file, 'v:val !~ ''^\s*\t|[^|]\+|\d\+:\d\+|$''')
|
||||||
cal extend(lines, from_file)
|
cal extend(lines, from_file)
|
||||||
endfo
|
endfo
|
||||||
|
if has('syntax') && exists('g:syntax_on')
|
||||||
if !hlexists('CtrlPTabExtra')
|
if !hlexists('CtrlPTabExtra')
|
||||||
hi link CtrlPTabExtra Comment
|
hi link CtrlPTabExtra Comment
|
||||||
en
|
en
|
||||||
sy match CtrlPTabExtra '\zs\t.*\ze$'
|
sy match CtrlPTabExtra '\zs\t.*\ze$'
|
||||||
|
en
|
||||||
retu lines
|
retu lines
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! ctrlp#line#accept(mode, str)
|
fu! ctrlp#line#accept(mode, str)
|
||||||
let info = get(split(a:str, '\t#:\ze\d\+:\d\+$'), 1, 0)
|
let info = matchlist(a:str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$')
|
||||||
let bufnr = str2nr(get(split(info, ':'), 0, 0))
|
let [bufnr, linenr] = [str2nr(get(info, 1)), get(info, 2)]
|
||||||
let linenr = get(split(info, ':'), 1, 0)
|
if bufnr > 0
|
||||||
if bufnr
|
|
||||||
cal ctrlp#acceptfile(a:mode, fnamemodify(bufname(bufnr), ':p'), linenr)
|
cal ctrlp#acceptfile(a:mode, fnamemodify(bufname(bufnr), ':p'), linenr)
|
||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
|
@ -30,10 +30,12 @@ endf
|
|||||||
" Public {{{1
|
" Public {{{1
|
||||||
fu! ctrlp#quickfix#init()
|
fu! ctrlp#quickfix#init()
|
||||||
let g:ctrlp_nolimit = 1
|
let g:ctrlp_nolimit = 1
|
||||||
|
if has('syntax') && exists('g:syntax_on')
|
||||||
if !hlexists('CtrlPqfLineCol')
|
if !hlexists('CtrlPqfLineCol')
|
||||||
hi link CtrlPqfLineCol Search
|
hi link CtrlPqfLineCol Search
|
||||||
en
|
en
|
||||||
sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|'
|
sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|'
|
||||||
|
en
|
||||||
retu map(getqflist(), 's:lineout(v:val)')
|
retu map(getqflist(), 's:lineout(v:val)')
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
@ -65,10 +65,12 @@ fu! ctrlp#tag#init(tagfiles)
|
|||||||
let alltags = s:filter(ctrlp#utils#readfile(each))
|
let alltags = s:filter(ctrlp#utils#readfile(each))
|
||||||
cal extend(g:ctrlp_alltags, alltags)
|
cal extend(g:ctrlp_alltags, alltags)
|
||||||
endfo
|
endfo
|
||||||
|
if has('syntax') && exists('g:syntax_on')
|
||||||
if !hlexists('CtrlPTabExtra')
|
if !hlexists('CtrlPTabExtra')
|
||||||
hi link CtrlPTabExtra Comment
|
hi link CtrlPTabExtra Comment
|
||||||
en
|
en
|
||||||
sy match CtrlPTabExtra '\zs\t.*\ze$'
|
sy match CtrlPTabExtra '\zs\t.*\ze$'
|
||||||
|
en
|
||||||
retu g:ctrlp_alltags
|
retu g:ctrlp_alltags
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
@ -92,8 +92,8 @@ When opening a file with <cr>, |CtrlP| avoids opening it in windows created by
|
|||||||
plugins, help and quickfix. Use this to setup some exceptions: >
|
plugins, help and quickfix. Use this to setup some exceptions: >
|
||||||
let g:ctrlp_reuse_window = 'netrw'
|
let g:ctrlp_reuse_window = 'netrw'
|
||||||
<
|
<
|
||||||
Acceptable values are partial names or filetypes of the special buffers. Use
|
Acceptable values are partial name, filetype or buftype of the special buffers.
|
||||||
|regexp| to specify the pattern.
|
Use |regexp| to specify the pattern.
|
||||||
Example: >
|
Example: >
|
||||||
let g:ctrlp_reuse_window = 'netrw\|help\|quickfix'
|
let g:ctrlp_reuse_window = 'netrw\|help\|quickfix'
|
||||||
<
|
<
|
||||||
|
Loading…
x
Reference in New Issue
Block a user