Some enhancements

* Add g:ctrlp_mruf_relative, an option to list only MRU files in the current
  working directory. Close #81.
* Extend <c-y> to work with <c-z> to get a base dir to create the new file.
  First stab at feature #77.
* Remove the hard limit for partial matching. Resolve #76.
* Merge custom_statusline. Close #80. Refs Lokaltog/vim-powerline#25.
This commit is contained in:
Kien N 2012-01-16 00:42:14 +07:00
parent eae302f869
commit ed2acba947
11 changed files with 164 additions and 80 deletions

View File

@ -2,7 +2,7 @@
" File: autoload/ctrlp.vim " File: autoload/ctrlp.vim
" Description: Fuzzy file, buffer, mru and tag finder. " Description: Fuzzy file, buffer, mru and tag finder.
" Author: Kien Nguyen <github.com/kien> " Author: Kien Nguyen <github.com/kien>
" Version: 1.6.6 " Version: 1.6.7
" ============================================================================= " =============================================================================
" Static variables {{{1 " Static variables {{{1
@ -19,14 +19,15 @@ fu! s:opts()
\ 'g:ctrlp_extensions': ['s:extensions', []], \ 'g:ctrlp_extensions': ['s:extensions', []],
\ 'g:ctrlp_follow_symlinks': ['s:folsym', 0], \ 'g:ctrlp_follow_symlinks': ['s:folsym', 0],
\ 'g:ctrlp_highlight_match': ['s:mathi', [1, 'Identifier']], \ 'g:ctrlp_highlight_match': ['s:mathi', [1, 'Identifier']],
\ 'g:ctrlp_lazy_update': ['s:lazy', 0],
\ 'g:ctrlp_jump_to_buffer': ['s:jmptobuf', 2], \ 'g:ctrlp_jump_to_buffer': ['s:jmptobuf', 2],
\ 'g:ctrlp_lazy_update': ['s:lazy', 0],
\ 'g:ctrlp_match_window_bottom': ['s:mwbottom', 1], \ 'g:ctrlp_match_window_bottom': ['s:mwbottom', 1],
\ 'g:ctrlp_match_window_reversed': ['s:mwreverse', 1], \ 'g:ctrlp_match_window_reversed': ['s:mwreverse', 1],
\ 'g:ctrlp_max_depth': ['s:maxdepth', 40], \ 'g:ctrlp_max_depth': ['s:maxdepth', 40],
\ 'g:ctrlp_max_files': ['s:maxfiles', 20000], \ 'g:ctrlp_max_files': ['s:maxfiles', 20000],
\ 'g:ctrlp_max_height': ['s:mxheight', 10], \ 'g:ctrlp_max_height': ['s:mxheight', 10],
\ 'g:ctrlp_max_history': ['s:maxhst', hst], \ 'g:ctrlp_max_history': ['s:maxhst', hst],
\ 'g:ctrlp_mruf_relative': ['s:relate', 0],
\ 'g:ctrlp_open_multi': ['s:opmul', '1v'], \ 'g:ctrlp_open_multi': ['s:opmul', '1v'],
\ 'g:ctrlp_open_new_file': ['s:newfop', 'v'], \ 'g:ctrlp_open_new_file': ['s:newfop', 'v'],
\ 'g:ctrlp_prompt_mappings': ['s:urprtmaps', 0], \ 'g:ctrlp_prompt_mappings': ['s:urprtmaps', 0],
@ -164,11 +165,8 @@ fu! s:Close()
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
\ g:ctrlp_nolimit \ g:ctrlp_nolimit
if exists('g:ctrlp_ext_vars')
cal map(filter(copy(g:ctrlp_ext_vars),
\ 'exists("v:val[4]")'), 'eval(v:val[4])')
en
cal ctrlp#recordhist() cal ctrlp#recordhist()
cal s:onexit()
if exists('g:ctrlp_log') && g:ctrlp_log if exists('g:ctrlp_log') && g:ctrlp_log
sil! redi END sil! redi END
en en
@ -290,16 +288,20 @@ fu! s:MatchIt(items, pat, limit, mfunc)
endf endf
fu! s:MatchedItems(items, pats, limit) fu! s:MatchedItems(items, pats, limit)
let [items, pats, limit, ipt] = [a:items, a:pats, a:limit, s:ispathitem()] let [items, pats, limit] = [a:items, a:pats, a:limit]
" If items is longer than s:mltipats_lim, use only the last pattern " If items is longer than s:mltipats_lim, use only the last pattern
if len(items) >= s:mltipats_lim || ( exists('s:height') && s:height > 20 ) if len(items) >= s:mltipats_lim || ( exists('s:height') && s:height > 20 )
let pats = [pats[-1]] let pats = [pats[-1]]
en en
cal map(pats, 'substitute(v:val, "\\\~", "\\\\\\~", "g")') cal map(pats, 'substitute(v:val, "\\\~", "\\\\\\~", "g")')
if !s:regexp | cal map(pats, 'escape(v:val, ".")') | en if !s:regexp | cal map(pats, 'escape(v:val, ".")') | en
let mfunc = s:byfname && ipt ? 's:matchfname' let [type, ipt, mfunc] = [s:type(1), s:ispathitem(), 'match']
\ : s:itemtype > 2 && len(items) < 30000 && !ipt ? 's:matchtab' if s:byfname && ipt
\ : 'match' let mfunc = 's:matchfname'
elsei s:itemtype > 2
let types = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' }
if has_key(types, type) | let mfunc = types[type] | en
en
" Loop through the patterns " Loop through the patterns
for pat in pats for pat in pats
" If newitems is small, set it as items to search in " If newitems is small, set it as items to search in
@ -651,7 +653,7 @@ endf
fu! s:ToggleType(dir) fu! s:ToggleType(dir)
let ext = exists('g:ctrlp_ext_vars') ? len(g:ctrlp_ext_vars) : 0 let ext = exists('g:ctrlp_ext_vars') ? len(g:ctrlp_ext_vars) : 0
let s:itemtype = s:walker(g:ctrlp_builtins + ext, s:itemtype, a:dir) let s:itemtype = s:walker(g:ctrlp_builtins + ext, s:itemtype, a:dir)
let s:extid = s:itemtype - ( g:ctrlp_builtins + 1 ) if s:byfname && !s:ispathitem() | let s:byfname = 0 | en
unl! g:ctrlp_nolimit unl! g:ctrlp_nolimit
cal s:SetLines(s:itemtype) cal s:SetLines(s:itemtype)
cal s:PrtSwitcher() cal s:PrtSwitcher()
@ -692,7 +694,7 @@ endf
fu! ctrlp#acceptfile(mode, matchstr, ...) fu! ctrlp#acceptfile(mode, matchstr, ...)
let [md, matchstr] = [a:mode, a:matchstr] let [md, matchstr] = [a:mode, a:matchstr]
" Get the full path " Get the full path
let filpath = s:itemtype ? matchstr : getcwd().s:lash.matchstr let filpath = s:nocwd() ? getcwd().s:lash.matchstr : matchstr
cal s:PrtExit() cal s:PrtExit()
let bufnum = bufnr(filpath) let bufnum = bufnr(filpath)
if s:jmptobuf && bufnum > 0 && md =~ 'e\|t' if s:jmptobuf && bufnum > 0 && md =~ 'e\|t'
@ -752,7 +754,7 @@ fu! s:AcceptSelection(mode)
if empty(matchstr) | retu | en if empty(matchstr) | retu | en
" Do something with it " Do something with it
let actfunc = s:itemtype < 3 ? 'ctrlp#acceptfile' let actfunc = s:itemtype < 3 ? 'ctrlp#acceptfile'
\ : g:ctrlp_ext_vars[s:itemtype - ( g:ctrlp_builtins + 1 )][1] \ : g:ctrlp_ext_vars[s:itemtype - ( g:ctrlp_builtins + 1 )]['accept']
cal call(actfunc, [a:mode, matchstr]) cal call(actfunc, [a:mode, matchstr])
endf endf
fu! s:CreateNewFile(...) "{{{1 fu! s:CreateNewFile(...) "{{{1
@ -766,22 +768,28 @@ fu! s:CreateNewFile(...) "{{{1
let str = s:sanstail(str) let str = s:sanstail(str)
let arr = split(str, '[\/]') let arr = split(str, '[\/]')
let fname = remove(arr, -1) let fname = remove(arr, -1)
if exists('s:marked') && len(s:marked)
" Use the first marked file's path
let val = values(s:marked)[0]
let mrk = ctrlp#rmbasedir([val])[0]
if val != mrk
let arr = extend(split(mrk, '[\/]')[:-2], arr)
let str = ctrlp#rmbasedir([fnamemodify(val, ':p:h').s:lash.str])[0]
en
en
if len(arr) | if isdirectory(s:createparentdirs(arr)) if len(arr) | if isdirectory(s:createparentdirs(arr))
let optyp = str let optyp = str | en | el | let optyp = fname
en | el
let optyp = fname
en
if exists('optyp')
let filpath = getcwd().s:lash.optyp
cal s:insertcache(str)
cal s:PrtExit()
let cmd = md == 'r' ? ctrlp#normcmd('e') :
\ s:newfop =~ '1\|t' || ( a:0 && a:1 == 't' ) || md == 't' ? 'tabe' :
\ s:newfop =~ '2\|h' || ( a:0 && a:1 == 'h' ) || md == 'h' ? 'new' :
\ s:newfop =~ '3\|v' || ( a:0 && a:1 == 'v' ) || md == 'v' ? 'vne' :
\ ctrlp#normcmd('e')
cal s:openfile(cmd, filpath)
en en
if !exists('optyp') | retu | en
let filpath = getcwd().s:lash.optyp
cal s:insertcache(str)
cal s:PrtExit()
let cmd = md == 'r' ? ctrlp#normcmd('e') :
\ s:newfop =~ '1\|t' || ( a:0 && a:1 == 't' ) || md == 't' ? 'tabe' :
\ s:newfop =~ '2\|h' || ( a:0 && a:1 == 'h' ) || md == 'h' ? 'new' :
\ s:newfop =~ '3\|v' || ( a:0 && a:1 == 'v' ) || md == 'v' ? 'vne' :
\ ctrlp#normcmd('e')
cal s:openfile(cmd, filpath)
endf endf
" * OpenMulti() {{{1 " * OpenMulti() {{{1
fu! s:MarkToOpen() fu! s:MarkToOpen()
@ -791,7 +799,7 @@ fu! s:MarkToOpen()
en en
let matchstr = matchstr(getline('.'), '^> \zs.\+\ze\t*$') let matchstr = matchstr(getline('.'), '^> \zs.\+\ze\t*$')
if empty(matchstr) | retu | en if empty(matchstr) | retu | en
let filpath = s:itemtype ? matchstr : getcwd().s:lash.matchstr let filpath = s:nocwd() ? getcwd().s:lash.matchstr : matchstr
if exists('s:marked') && s:dictindex(s:marked, filpath) > 0 if exists('s:marked') && s:dictindex(s:marked, filpath) > 0
" Unmark and remove the file from s:marked " Unmark and remove the file from s:marked
let key = s:dictindex(s:marked, filpath) let key = s:dictindex(s:marked, filpath)
@ -913,7 +921,8 @@ fu! ctrlp#statusline()
\ ['mru files', 'mru'], \ ['mru files', 'mru'],
\ ] \ ]
if exists('g:ctrlp_ext_vars') if exists('g:ctrlp_ext_vars')
cal map(copy(g:ctrlp_ext_vars), 'add(s:statypes, [ v:val[2], v:val[3] ])') cal map(copy(g:ctrlp_ext_vars),
\ 'add(s:statypes, [ v:val["lname"], v:val["sname"] ])')
en en
en en
let tps = s:statypes let tps = s:statypes
@ -927,7 +936,7 @@ fu! ctrlp#statusline()
\ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <+>' : '' \ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <+>' : ''
if has_key(s:status, 'main') if has_key(s:status, 'main')
let args = [focus, byfname, s:regexp, prv, item, nxt, marked] let args = [focus, byfname, s:regexp, prv, item, nxt, marked]
let &l:stl = call(s:status.main, args) let &l:stl = call(s:status['main'], args)
el el
let item = '%#Character# '.item.' %*' let item = '%#Character# '.item.' %*'
let focus = '%#LineNr# '.focus.' %*' let focus = '%#LineNr# '.focus.' %*'
@ -944,17 +953,17 @@ fu! s:dismrk()
\ '%<'.join(values(map(copy(s:marked), 'split(v:val, "[\\/]")[-1]')), ', ') \ '%<'.join(values(map(copy(s:marked), 'split(v:val, "[\\/]")[-1]')), ', ')
endf endf
fu! ctrlp#progress(len) fu! ctrlp#progress(enum)
if has('macunix') || has('mac') | sl 1m | en if has('macunix') || has('mac') | sl 1m | en
let &l:stl = has_key(s:status, 'prog') ? call(s:status.prog, [a:len]) let &l:stl = has_key(s:status, 'prog') ? call(s:status['prog'], [a:enum])
\ : '%#Function# '.a:len.' %* %=%<%#LineNr# '.getcwd().' %*' \ : '%#Function# '.a:enum.' %* %=%<%#LineNr# '.getcwd().' %*'
redr redr
endf endf
" Paths {{{2 " Paths {{{2
fu! s:ispathitem() fu! s:ispathitem()
let ext = s:itemtype - ( g:ctrlp_builtins + 1 ) let ext = s:itemtype - ( g:ctrlp_builtins + 1 )
retu s:itemtype < 3 retu s:itemtype < 3
\ || ( s:itemtype > 2 && g:ctrlp_ext_vars[ext][3] =~ 'dir\|rts' ) \ || ( s:itemtype > 2 && g:ctrlp_ext_vars[ext]['type'] == 'path' )
endf endf
fu! ctrlp#dirnfile(entries) fu! ctrlp#dirnfile(entries)
@ -996,7 +1005,7 @@ endf
fu! ctrlp#rmbasedir(items) fu! ctrlp#rmbasedir(items)
let cwd = getcwd() let cwd = getcwd()
if !stridx(a:items[0], cwd) if a:items != [] && !stridx(a:items[0], cwd)
let idx = strlen(cwd) + 1 let idx = strlen(cwd) + 1
retu map(a:items, 'strpart(v:val, idx)') retu map(a:items, 'strpart(v:val, idx)')
en en
@ -1066,7 +1075,7 @@ endf
fu! s:highlight(pat, grp) fu! s:highlight(pat, grp)
cal clearmatches() cal clearmatches()
if !empty(a:pat) && s:itemtype < 3 if !empty(a:pat) && s:ispathitem()
let pat = substitute(a:pat, '\~', '\\~', 'g') let pat = substitute(a:pat, '\~', '\\~', 'g')
if !s:regexp | let pat = escape(pat, '.') | en if !s:regexp | let pat = escape(pat, '.') | en
" Match only filename " Match only filename
@ -1319,6 +1328,10 @@ fu! ctrlp#j2l(nr)
sil! norm! zvzz sil! norm! zvzz
endf endf
fu! s:nocwd()
retu !s:itemtype || ( s:itemtype == 2 && s:relate )
endf
fu! s:regexfilter(str) fu! s:regexfilter(str)
let str = a:str let str = a:str
for key in keys(s:fpats) | if match(str, key) >= 0 for key in keys(s:fpats) | if match(str, key) >= 0
@ -1335,10 +1348,14 @@ fu! s:matchfname(item, pat)
retu match(split(a:item, s:lash)[-1], a:pat) retu match(split(a:item, s:lash)[-1], a:pat)
endf endf
fu! s:matchtab(item, pat) fu! s:matchtabs(item, pat)
retu match(split(a:item, '\t\+')[0], a:pat) retu match(split(a:item, '\t\+')[0], a:pat)
endf endf
fu! s:matchtabe(item, pat)
retu match(split(a:item, '\t\+[^\t]\+$')[0], a:pat)
endf
fu! s:maxf(len) fu! s:maxf(len)
retu s:maxfiles && a:len > s:maxfiles ? 1 : 0 retu s:maxfiles && a:len > s:maxfiles ? 1 : 0
endf endf
@ -1360,15 +1377,22 @@ fu! s:insertcache(str)
cal s:writecache(0, ctrlp#utils#cachefile()) cal s:writecache(0, ctrlp#utils#cachefile())
endf endf
" Extensions {{{2 " Extensions {{{2
fu! s:type() fu! s:type(...)
retu s:itemtype > 2 ? let ext = s:itemtype - ( g:ctrlp_builtins + 1 )
\ g:ctrlp_ext_vars[s:itemtype - ( g:ctrlp_builtins + 1 )][3] : s:itemtype retu s:itemtype > 2 ? g:ctrlp_ext_vars[ext][a:0 ? 'type' : 'sname'] : s:itemtype
endf endf
fu! s:tagfiles() fu! s:tagfiles()
retu filter(map(tagfiles(), 'fnamemodify(v:val, ":p")'), 'filereadable(v:val)') retu filter(map(tagfiles(), 'fnamemodify(v:val, ":p")'), 'filereadable(v:val)')
endf endf
fu! s:onexit()
if exists('g:ctrlp_ext_vars')
cal map(filter(copy(g:ctrlp_ext_vars),
\ 'has_key(v:val, "exit")'), 'eval(v:val["exit"])')
en
endf
fu! ctrlp#allbufs() fu! ctrlp#allbufs()
let bufs = [] let bufs = []
for each in range(1, bufnr('$')) for each in range(1, bufnr('$'))
@ -1404,7 +1428,7 @@ fu! s:SetLines(type)
\ 'ctrlp#mrufiles#list(-1)', \ 'ctrlp#mrufiles#list(-1)',
\ ] \ ]
if exists('g:ctrlp_ext_vars') if exists('g:ctrlp_ext_vars')
cal map(copy(g:ctrlp_ext_vars), 'add(types, v:val[0])') cal map(copy(g:ctrlp_ext_vars), 'add(types, v:val["init"])')
en en
let g:ctrlp_lines = eval(types[a:type]) let g:ctrlp_lines = eval(types[a:type])
endf endf

View File

@ -13,8 +13,14 @@ if exists('g:loaded_ctrlp_buftag') && g:loaded_ctrlp_buftag
en en
let g:loaded_ctrlp_buftag = 1 let g:loaded_ctrlp_buftag = 1
let s:buftag_var = ['ctrlp#buffertag#init(s:crfile)', 'ctrlp#buffertag#accept', let s:buftag_var = {
\ 'buffer tags', 'bft', 'ctrlp#buffertag#exit()'] \ 'init': 'ctrlp#buffertag#init(s:crfile)',
\ 'accept': 'ctrlp#buffertag#accept',
\ 'lname': 'buffer tags',
\ 'sname': 'bft',
\ 'exit': 'ctrlp#buffertag#exit()',
\ 'type': 'tabs',
\ }
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars) let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
\ ? add(g:ctrlp_ext_vars, s:buftag_var) : [s:buftag_var] \ ? add(g:ctrlp_ext_vars, s:buftag_var) : [s:buftag_var]

View File

@ -17,8 +17,13 @@ let s:ars = [
\ 's:glob', \ 's:glob',
\ ] \ ]
let s:dir_var = ['ctrlp#dir#init('.join(s:ars, ', ').')', 'ctrlp#dir#accept', let s:dir_var = {
\ 'dirs', 'dir'] \ 'init': 'ctrlp#dir#init('.join(s:ars, ', ').')',
\ 'accept': 'ctrlp#dir#accept',
\ 'lname': 'dirs',
\ 'sname': 'dir',
\ 'type': 'path',
\ }
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars) let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
\ ? add(g:ctrlp_ext_vars, s:dir_var) : [s:dir_var] \ ? add(g:ctrlp_ext_vars, s:dir_var) : [s:dir_var]
@ -45,8 +50,8 @@ fu! ctrlp#dir#init(...)
for each in range(len(s:ars)) for each in range(len(s:ars))
exe 'let' s:ars[each] '=' string(eval('a:'.(each + 1))) exe 'let' s:ars[each] '=' string(eval('a:'.(each + 1)))
endfo endfo
let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().s:dir_var[3] let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().s:dir_var['sname']
let cafile = cadir.ctrlp#utils#lash().ctrlp#utils#cachefile(s:dir_var[3]) let cafile = cadir.ctrlp#utils#lash().ctrlp#utils#cachefile(s:dir_var['sname'])
if g:ctrlp_newdir || !filereadable(cafile) if g:ctrlp_newdir || !filereadable(cafile)
let g:ctrlp_alldirs = [] let g:ctrlp_alldirs = []
cal s:globdirs(s:cwd, 0) cal s:globdirs(s:cwd, 0)

View File

@ -17,7 +17,13 @@ if exists('g:loaded_ctrlp_line') && g:loaded_ctrlp_line
en en
let g:loaded_ctrlp_line = 1 let g:loaded_ctrlp_line = 1
let s:line_var = ['ctrlp#line#init()', 'ctrlp#line#accept', 'lines', 'lns'] let s:line_var = {
\ 'init': 'ctrlp#line#init()',
\ 'accept': 'ctrlp#line#accept',
\ 'lname': 'lines',
\ 'sname': 'lns',
\ 'type': 'tabe',
\ }
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars) let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
\ ? add(g:ctrlp_ext_vars, s:line_var) : [s:line_var] \ ? add(g:ctrlp_ext_vars, s:line_var) : [s:line_var]

View File

@ -11,6 +11,7 @@ fu! ctrlp#mrufiles#opts()
\ 'g:ctrlp_mruf_include': ['s:include', ''], \ 'g:ctrlp_mruf_include': ['s:include', ''],
\ 'g:ctrlp_mruf_exclude': ['s:exclude', ''], \ 'g:ctrlp_mruf_exclude': ['s:exclude', ''],
\ 'g:ctrlp_mruf_case_sensitive': ['s:csen', 1], \ 'g:ctrlp_mruf_case_sensitive': ['s:csen', 1],
\ 'g:ctrlp_mruf_relative': ['s:relate', 0],
\ } \ }
for [ke, va] in items(opts) for [ke, va] in items(opts)
exe 'let' va[0] '=' string(exists(ke) ? eval(ke) : va[1]) exe 'let' va[0] '=' string(exists(ke) ? eval(ke) : va[1])
@ -47,8 +48,14 @@ fu! ctrlp#mrufiles#list(bufnr, ...) "{{{1
en en
" Return the list with the active buffer removed " Return the list with the active buffer removed
if bufnr == -1 if bufnr == -1
let crfile = fnamemodify(bufname(winbufnr(winnr('#'))), ':p') let crf = fnamemodify(bufname(winbufnr(winnr('#'))), ':p')
retu empty(crfile) ? mrufs : filter(mrufs, 'v:val !='.s:csen.' crfile') let mrufs = empty(crf) ? mrufs : filter(mrufs, 'v:val !='.s:csen.' crf')
if s:relate
let cwd = getcwd()
cal filter(mrufs, '!stridx(v:val, cwd)')
cal ctrlp#rmbasedir(mrufs)
en
retu mrufs
en en
" Remove old entry " Remove old entry
cal filter(mrufs, 'v:val !='.s:csen.' filename') cal filter(mrufs, 'v:val !='.s:csen.' filename')

View File

@ -10,8 +10,13 @@ if exists('g:loaded_ctrlp_quickfix') && g:loaded_ctrlp_quickfix
en en
let g:loaded_ctrlp_quickfix = 1 let g:loaded_ctrlp_quickfix = 1
let s:var_qf = ['ctrlp#quickfix#init()', 'ctrlp#quickfix#accept', 'quickfix', let s:var_qf = {
\ 'qfx'] \ 'init': 'ctrlp#quickfix#init()',
\ 'accept': 'ctrlp#quickfix#accept',
\ 'lname': 'quickfix',
\ 'sname': 'qfx',
\ 'type': 'line',
\ }
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars) let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
\ ? add(g:ctrlp_ext_vars, s:var_qf) : [s:var_qf] \ ? add(g:ctrlp_ext_vars, s:var_qf) : [s:var_qf]

View File

@ -1,24 +1,22 @@
" ============================================================================= " =============================================================================
" File: autoload/ctrlp/rtscript.vim " File: autoload/ctrlp/rtscript.vim
" Description: Runtime scripts extension - Find vimscripts in runtimepath " Description: Runtime scripts extension
" Author: Kien Nguyen <github.com/kien> " Author: Kien Nguyen <github.com/kien>
" ============================================================================= " =============================================================================
" User Configuration {{{1
" Enable:
" let g:ctrlp_extensions += ['rtscript']
" Create A Command:
" com! CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id())
"}}}
" Init {{{1 " Init {{{1
if exists('g:loaded_ctrlp_rtscript') && g:loaded_ctrlp_rtscript if exists('g:loaded_ctrlp_rtscript') && g:loaded_ctrlp_rtscript
fini fini
en en
let [g:loaded_ctrlp_rtscript, g:ctrlp_newrts] = [1, 0] let [g:loaded_ctrlp_rtscript, g:ctrlp_newrts] = [1, 0]
let s:rtscript_var = ['ctrlp#rtscript#init()', 'ctrlp#rtscript#accept', let s:rtscript_var = {
\ 'runtime scripts', 'rts'] \ 'init': 'ctrlp#rtscript#init()',
\ 'accept': 'ctrlp#rtscript#accept',
\ 'lname': 'runtime scripts',
\ 'sname': 'rts',
\ 'type': 'path',
\ }
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars) let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
\ ? add(g:ctrlp_ext_vars, s:rtscript_var) : [s:rtscript_var] \ ? add(g:ctrlp_ext_vars, s:rtscript_var) : [s:rtscript_var]
@ -27,6 +25,7 @@ let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
" Public {{{1 " Public {{{1
fu! ctrlp#rtscript#init() fu! ctrlp#rtscript#init()
if g:ctrlp_newrts || !exists('g:ctrlp_rtscache') if g:ctrlp_newrts || !exists('g:ctrlp_rtscache')
sil! cal ctrlp#progress('Indexing...')
let entries = split(globpath(&rtp, '**/*.\(vim\|txt\)'), "\n") let entries = split(globpath(&rtp, '**/*.\(vim\|txt\)'), "\n")
let [g:ctrlp_rtscache, g:ctrlp_newrts] = [ctrlp#dirnfile(entries)[1], 0] let [g:ctrlp_rtscache, g:ctrlp_newrts] = [ctrlp#dirnfile(entries)[1], 0]
en en

View File

@ -10,8 +10,13 @@ if exists('g:loaded_ctrlp_tag') && g:loaded_ctrlp_tag
en en
let g:loaded_ctrlp_tag = 1 let g:loaded_ctrlp_tag = 1
let s:tag_var = ['ctrlp#tag#init(s:tagfiles)', 'ctrlp#tag#accept', let s:tag_var = {
\ 'tags', 'tag'] \ 'init': 'ctrlp#tag#init(s:tagfiles)',
\ 'accept': 'ctrlp#tag#accept',
\ 'lname': 'tags',
\ 'sname': 'tag',
\ 'type': 'tabs',
\ }
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars) let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
\ ? add(g:ctrlp_ext_vars, s:tag_var) : [s:tag_var] \ ? add(g:ctrlp_ext_vars, s:tag_var) : [s:tag_var]

View File

@ -18,8 +18,13 @@ if ( exists('g:loaded_ctrlp_undo') && g:loaded_ctrlp_undo )
en en
let g:loaded_ctrlp_undo = 1 let g:loaded_ctrlp_undo = 1
let s:undo_var = ['ctrlp#undo#init(s:undotree)', 'ctrlp#undo#accept', let s:undo_var = {
\ 'undo', 'udo'] \ 'init': 'ctrlp#undo#init(s:undotree)',
\ 'accept': 'ctrlp#undo#accept',
\ 'lname': 'undo',
\ 'sname': 'udo',
\ 'type': 'line',
\ }
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars) let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
\ ? add(g:ctrlp_ext_vars, s:undo_var) : [s:undo_var] \ ? add(g:ctrlp_ext_vars, s:undo_var) : [s:undo_var]

View File

@ -1,4 +1,4 @@
*ctrlp.txt* Fuzzy file, buffer, mru and tag finder. v1.6.6 *ctrlp.txt* Fuzzy file, buffer, mru and tag finder. v1.6.7
*CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'* *CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'*
=============================================================================== ===============================================================================
# # # #
@ -195,6 +195,11 @@ Example: >
let g:ctrlp_mruf_include = '\.py$\|\.rb$' let g:ctrlp_mruf_include = '\.py$\|\.rb$'
< <
*'g:ctrlp_mruf_relative'*
Set this to 1 to show only MRU files in the current working directory: >
let g:ctrlp_mruf_relative = 0
<
*'g:ctrlp_mruf_case_sensitive'* *'g:ctrlp_mruf_case_sensitive'*
Match this with your file system case-sensitivity setting to avoid duplicate Match this with your file system case-sensitivity setting to avoid duplicate
MRU entries: > MRU entries: >
@ -227,7 +232,7 @@ Examples: >
let g:ctrlp_custom_ignore = { let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.hg$\|\.svn$', \ 'dir': '\.git$\|\.hg$\|\.svn$',
\ 'file': '\.exe$\|\.so$\|\.dll$', \ 'file': '\.exe$\|\.so$\|\.dll$',
\ 'link': 'bad_symbolic_link', \ 'link': 'some$\|bad$\|symbolic$\|links$',
\ } \ }
> >
@ -355,13 +360,13 @@ works in |regexp| mode. To split the pattern, separate words with space: >
< <
*'g:ctrlp_status_func'* *'g:ctrlp_status_func'*
Use this to set custom statuslines for the |CtrlP| window: > Use this to customize the statuslines for the |CtrlP| window: >
let g:ctrlp_status_func = {} let g:ctrlp_status_func = {}
< <
Example: > Example: >
let g:ctrlp_status_func = { let g:ctrlp_status_func = {
\ 'main': 'function_name_1', \ 'main': 'Function_Name_1',
\ 'prog': 'function_name_2', \ 'prog': 'Function_Name_2',
\ } \ }
< <
See https://gist.github.com/1610859 for a working example. See https://gist.github.com/1610859 for a working example.
@ -396,7 +401,7 @@ See https://gist.github.com/1610859 for a working example.
*:ResetCtrlP* *:ResetCtrlP*
:ResetCtrlP :ResetCtrlP
Reset all options, take in new values of the option variables in section 2. Reset all options and take in new values of the option variables.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
The following commands ignore the current value of |g:ctrlp_working_path_mode|: The following commands ignore the current value of |g:ctrlp_working_path_mode|:
@ -423,7 +428,7 @@ Once inside the prompt:~
Toggle between the string mode (section 5.a & b) and full |regexp| mode. Toggle between the string mode (section 5.a & b) and full |regexp| mode.
(note: in full |regexp| mode, the prompts base is 'r>>' instead of '>>>') (note: in full |regexp| mode, the prompts base is 'r>>' instead of '>>>')
See also |input-formats| and |g:ctrlp_regexp_search|. See also |input-formats| (guide) and |g:ctrlp_regexp_search| (option).
<c-d> <c-d>
Toggle between full path search and filename only search. Toggle between full path search and filename only search.
@ -500,7 +505,8 @@ Once inside the prompt:~
Previous string in the prompts history Previous string in the prompts history
<c-z> <c-z>
Mark/unmark a file to be opened with <c-o>. - Mark/unmark a file to be opened with <c-o>.
- Mark/unmark a file to create a new file in the same directory with <c-y>.
<c-o> <c-o>
Open files marked by <c-z>. Open files marked by <c-z>.
@ -546,7 +552,7 @@ c) End the string with a colon ':' followed by a Vim command to execute that
with a backslash: '\:'. When opening multiple files, the command will be with a backslash: '\:'. When opening multiple files, the command will be
executed on each opening file. executed on each opening file.
e.g. 'abc:45' will open the selected file and jump to line 45. e.g. 'abc:45' will open the selected file and jump to line 45.
'abc:/my\:function' will open the selected file and jump to the first 'abc:/my\:string' will open the selected file and jump to the first
instance of 'my:function'. instance of 'my:function'.
'abc:+setf\ myfiletype|50' will open the selected file and set its 'abc:+setf\ myfiletype|50' will open the selected file and set its
filetype to 'myfiletype', then jump to line 50. filetype to 'myfiletype', then jump to line 50.
@ -563,9 +569,14 @@ e) Similarly, submit '/' or '\' to find and go to the projects root. If the
project is large, using a VCS listing command to look for files might help project is large, using a VCS listing command to look for files might help
speeding up the intial scan (see |g:ctrlp_user_command| for more details). speeding up the intial scan (see |g:ctrlp_user_command| for more details).
f) Type the name of a non-existent file and press <c-y> to create it. f) Type the name of a non-existent file and press <c-y> to create it. Mark a
e.g. 'parentdir/file.txt' will create a directory named 'parentdir' as well file with <c-z> to create the new file in the same directory as the marked
as 'file.txt'. file.
e.g. 'parentdir/newfile.txt' will create a directory named 'parentdir' as
well as 'newfile.txt'.
If 'some/old/dirs/oldfile.txt' is marked with <c-z>, then 'parentdir'
and 'newfile.txt' will be created in 'some/old/dirs'. The final path
will then be 'some/old/dirs/parentdir/newfile.txt'.
Use '\' in place of '/' on Windows (if |'ssl'| is not set). Use '\' in place of '/' on Windows (if |'ssl'| is not set).
g) Submit ? to open this help file. g) Submit ? to open this help file.
@ -575,7 +586,7 @@ g) Submit ? to open this help file.
Extensions are optional. To enable an extension, add its name to the variable Extensions are optional. To enable an extension, add its name to the variable
g:ctrlp_extensions: > g:ctrlp_extensions: >
let g:ctrlp_extensions = ['tag', 'buffertag', 'quickfix', 'dir'] let g:ctrlp_extensions = ['tag', 'buffertag', 'quickfix', 'dir', 'rtscript']
< <
The order of the items will be the order they appear on the statusline and when The order of the items will be the order they appear on the statusline and when
using <c-f>, <c-b>. using <c-f>, <c-b>.
@ -617,6 +628,12 @@ Available extensions:~
+ <c-x> change the global working directory to |CtrlP|s current local + <c-x> change the global working directory to |CtrlP|s current local
working directory (exit). working directory (exit).
*:CtrlPRTS*
* Runtime script mode:~
- Name: 'rts'
- Command: ':CtrlPRTS'
- Search for vimscripts in runtimepath.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Buffer Tag mode options:~ Buffer Tag mode options:~
@ -719,10 +736,11 @@ Special thanks:~
=============================================================================== ===============================================================================
CHANGELOG *ctrlp-changelog* CHANGELOG *ctrlp-changelog*
Before 2012/01/14~ Before 2012/01/15~
+ New options: |g:ctrlp_arg_map| for <c-y>, <c-o> to accept an argument. + New options: |g:ctrlp_arg_map| for <c-y>, <c-o> to accept an argument.
|g:ctrlp_status_func| custom statusline. |g:ctrlp_status_func| custom statusline.
|g:ctrlp_mruf_relative| show only MRU files inside cwd.
+ Extend |g:ctrlp_open_multi| with new optional values: tr, hr, vr. + Extend |g:ctrlp_open_multi| with new optional values: tr, hr, vr.
+ Extend |g:ctrlp_custom_ignore| to specifically filter dir, file and link. + Extend |g:ctrlp_custom_ignore| to specifically filter dir, file and link.

View File

@ -55,4 +55,8 @@ if index(s:ext, 'buffertag') >= 0
com! CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1)) com! CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1))
en en
if index(s:ext, 'rts') >= 0
com! CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id())
en
unl s:ext unl s:ext