1
0
mirror of https://github.com/gryf/.vim.git synced 2025-12-18 20:10:27 +01:00

Plugins update

This commit is contained in:
2012-03-12 17:00:46 +01:00
parent c2500d764e
commit 7cbe6dca6d
37 changed files with 977 additions and 589 deletions

View File

@@ -2,7 +2,7 @@
" File: autoload/ctrlp.vim
" Description: Fuzzy file, buffer, mru and tag finder.
" Author: Kien Nguyen <github.com/kien>
" Version: 1.7.1
" Version: 1.7.2
" =============================================================================
" Static variables {{{1
@@ -42,6 +42,15 @@ fu! s:opts()
for [ke, va] in items(opts)
exe 'let' va[0] '=' string(exists(ke) ? eval(ke) : va[1])
endfo
let new_opts = {
\ 'g:ctrlp_open_multiple_files': 's:opmul',
\ 'g:ctrlp_regexp': 's:regexp',
\ 'g:ctrlp_reuse_window': 's:nosplit',
\ 'g:ctrlp_switch_buffer': 's:jmptobuf',
\ }
for [key, val] in items(new_opts)
exe 'let' val '=' string(eval(exists(key) ? key : val))
endfo
if !exists('g:ctrlp_newcache') | let g:ctrlp_newcache = 0 | en
let s:maxdepth = min([s:maxdepth, 100])
let s:mxheight = max([s:mxheight, 1])
@@ -49,9 +58,9 @@ fu! s:opts()
let s:igntype = empty(s:usrign) ? -1 : type(s:usrign)
" Extensions
let g:ctrlp_builtins = 2
if !empty(s:extensions) | for each in s:extensions
for each in s:extensions
exe 'ru autoload/ctrlp/'.each.'.vim'
endfo | en
endfo
" Keymaps
let [s:lcmap, s:prtmaps] = ['nn <buffer> <silent>', {
\ 'PrtBS()': ['<bs>', '<c-]>'],
@@ -60,10 +69,10 @@ fu! s:opts()
\ 'PrtClear()': ['<c-u>'],
\ 'PrtSelectMove("j")': ['<c-j>', '<down>'],
\ 'PrtSelectMove("k")': ['<c-k>', '<up>'],
\ 'PrtSelectMove("t")': ['<home>'],
\ 'PrtSelectMove("b")': ['<end>'],
\ 'PrtSelectMove("u")': ['<PageUp>'],
\ 'PrtSelectMove("d")': ['<PageDown>'],
\ 'PrtSelectMove("t")': ['<Home>', '<kHome>'],
\ 'PrtSelectMove("b")': ['<End>', '<kEnd>'],
\ 'PrtSelectMove("u")': ['<PageUp>', '<kPageUp>'],
\ 'PrtSelectMove("d")': ['<PageDown>', '<kPageDown>'],
\ 'PrtHistory(-1)': ['<c-n>'],
\ 'PrtHistory(1)': ['<c-p>'],
\ 'AcceptSelection("e")': ['<cr>', '<2-LeftMouse>'],
@@ -97,26 +106,11 @@ fu! s:opts()
if type(s:urprtmaps) == 4
cal extend(s:prtmaps, s:urprtmaps)
en
let s:prtunmaps = [
\ 'PrtBS()',
\ 'PrtDelete()',
\ 'PrtDeleteWord()',
\ 'PrtClear()',
\ 'PrtCurStart()',
\ 'PrtCurEnd()',
\ 'PrtCurLeft()',
\ 'PrtCurRight()',
\ 'PrtHistory(-1)',
\ 'PrtHistory(1)',
\ 'PrtInsert("w")',
\ 'PrtInsert("s")',
\ 'PrtInsert("v")',
\ 'PrtInsert("+")',
\ ]
" Global options
let s:glbs = { 'magic': 1, 'to': 1, 'tm': 0, 'sb': 1, 'hls': 0, 'im': 0,
\ 'report': 9999, 'sc': 0, 'ss': 0, 'siso': 0, 'mfd': 200, 'mouse': 'n',
\ 'gcr': 'a:blinkon0', 'ic': 1, 'scs': 1, 'lmap': '' }
\ 'gcr': 'a:blinkon0', 'ic': 1, 'scs': 1, 'lmap': '', 'mousef': 0,
\ 'imd': 1 }
if s:lazy
cal extend(s:glbs, { 'ut': ( s:lazy > 1 ? s:lazy : 250 ) })
en
@@ -136,6 +130,33 @@ let s:fpats = {
\ '^\S\\?$': '\\?',
\ }
" Mappings
let s:prtunmaps = [
\ 'PrtBS()',
\ 'PrtDelete()',
\ 'PrtDeleteWord()',
\ 'PrtClear()',
\ 'PrtCurStart()',
\ 'PrtCurEnd()',
\ 'PrtCurLeft()',
\ 'PrtCurRight()',
\ 'PrtHistory(-1)',
\ 'PrtHistory(1)',
\ 'PrtInsert("w")',
\ 'PrtInsert("s")',
\ 'PrtInsert("v")',
\ 'PrtInsert("+")',
\ ]
" Keypad
let s:kprange = {
\ 'Plus': '+',
\ 'Minus': '-',
\ 'Divide': '/',
\ 'Multiply': '*',
\ 'Point': '.',
\ }
" Highlight groups
let s:hlgrps = {
\ 'NoEntries': 'Error',
@@ -149,21 +170,18 @@ let s:hlgrps = {
\ }
" * Open & Close {{{1
fu! s:Open()
if exists('g:ctrlp_log') && g:ctrlp_log
let cadir = ctrlp#utils#cachedir()
sil! exe 'redi! >' cadir.s:lash(cadir).'ctrlp.log'
en
cal s:log(1)
cal s:getenv()
sil! exe 'noa keepa' ( s:mwbottom ? 'bo' : 'to' ) '1new ControlP'
let [s:bufnr, s:prompt] = [bufnr('%'), ['', '', '']]
let [s:bufnr, s:prompt, s:winw] = [bufnr('%'), ['', '', ''], winwidth(0)]
abc <buffer>
if !exists('s:hstry')
let hst = filereadable(s:gethistloc()[1]) ? s:gethistdata() : ['']
let s:hstry = empty(hst) || !s:maxhst ? [''] : hst
en
for [ke, va] in items(s:glbs)
for [ke, va] in items(s:glbs) | if exists('+'.ke)
sil! exe 'let s:glb_'.ke.' = &'.ke.' | let &'.ke.' = '.string(va)
endfo
en | endfo
if s:opmul != '0' && has('signs')
sign define ctrlpmark text=+> texthl=Search
en
@@ -174,21 +192,19 @@ fu! s:Close()
try | noa bun!
cat | noa clo! | endt
cal s:unmarksigns()
for key in keys(s:glbs)
for key in keys(s:glbs) | if exists('+'.key)
sil! exe 'let &'.key.' = s:glb_'.key
endfo
en | endfo
if exists('s:glb_acd') | let &acd = s:glb_acd | en
let [g:ctrlp_lines, g:ctrlp_allfiles] = [[], []]
if s:winres[1] >= &lines && s:winres[2] == winnr('$')
exe s:winres[0]
en
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 s:onexit()
if exists('g:ctrlp_log') && g:ctrlp_log
sil! redi END
en
cal s:log(0)
ec
endf
" * Clear caches {{{1
@@ -210,10 +226,9 @@ fu! ctrlp#reset()
cal s:opts()
cal ctrlp#utils#opts()
cal ctrlp#mrufiles#opts()
unl! s:cline
endf
" * Files() {{{1
fu! s:Files()
" * Files {{{1
fu! ctrlp#files()
let [cwd, cafile, g:ctrlp_allfiles] = [getcwd(), ctrlp#utils#cachefile(), []]
if g:ctrlp_newcache || !filereadable(cafile) || !s:caching
let lscmd = s:lsCmd()
@@ -292,23 +307,17 @@ fu! s:lsCmd()
retu cmd['types'][key][1]
en
endf
fu! s:Buffers() "{{{1
let allbufs = []
for each in range(1, bufnr('$'))
if getbufvar(each, '&bl') && each != s:crbufnr
let bufname = bufname(each)
if strlen(bufname) && getbufvar(each, '&ma') && bufname != 'ControlP'
cal add(allbufs, fnamemodify(bufname, ':.'))
en
en
endfo
retu allbufs
" Buffers {{{1
fu! ctrlp#buffers()
retu map(filter(range(1, bufnr('$')), 'empty(getbufvar(v:val, "&bt"))'
\ .' && getbufvar(v:val, "&bl") && strlen(bufname(v:val))'),
\ 'fnamemodify(bufname(v:val), ":.")')
endf
" * MatchedItems() {{{1
fu! s:MatchIt(items, pat, limit, mfunc)
let newitems = []
fu! s:MatchIt(items, pat, limit, mfunc, ipt)
let [newitems, crfile] = [[], exists('s:crfilerel') ? s:crfilerel : '']
for item in a:items
try | if call(a:mfunc, [item, a:pat]) >= 0
try | if !( a:ipt && item == crfile ) && call(a:mfunc, [item, a:pat]) >= 0
cal add(newitems, item)
en | cat | brea | endt
if a:limit > 0 && len(newitems) >= a:limit | brea | en
@@ -316,16 +325,15 @@ fu! s:MatchIt(items, pat, limit, mfunc)
retu newitems
endf
fu! s:MatchedItems(items, pat, limit)
let [items, pat, limit] = [a:items, a:pat, a:limit]
let [type, ipt, mfunc] = [s:type(1), s:ispathitem(), 'match']
if s:byfname && ipt
fu! s:MatchedItems(items, pat, limit, ipt)
let [type, mfunc] = [s:type(1), 'match']
if s:byfname && a:ipt
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
let newitems = s:MatchIt(items, pat, limit, mfunc)
let newitems = s:MatchIt(a:items, a:pat, a:limit, mfunc, a:ipt)
let s:matches = len(newitems)
retu newitems
endf
@@ -358,31 +366,31 @@ fu! s:SplitPattern(str) "{{{1
retu escape(pat, '~')
endf
" * BuildPrompt() {{{1
fu! s:Render(lines, pat)
let lines = a:lines
fu! s:Render(lines, pat, ipt)
let [&ma, lines, s:height] = [1, a:lines, min([len(a:lines), s:winh])]
" Setup the match window
let s:height = min([len(lines), s:winh])
sil! exe '%d _ | res' s:height
" Print the new items
if empty(lines)
setl nocul
let s:matched = []
cal setline(1, ' == NO ENTRIES ==')
setl noma nocul
cal s:unmarksigns()
if s:dohighlight() | cal clearmatches() | en
retu
en
setl cul
" Sort if not MRU
if ( s:itemtype != 2 && !exists('g:ctrlp_nolimit') )
\ || !empty(join(s:prompt, ''))
\ || s:prompt != ['', '', '']
let s:compat = a:pat
cal sort(lines, 's:mixedsort')
unl s:compat
en
if s:mwreverse | cal reverse(lines) | en
let s:matched = copy(lines)
cal map(lines, '"> ".v:val')
cal map(lines, 's:formatline(v:val, a:ipt)')
cal setline(1, lines)
setl noma cul
exe 'keepj norm!' ( s:mwreverse ? 'G' : 'gg' ).'1|'
cal s:unmarksigns()
cal s:remarksigns()
@@ -391,7 +399,7 @@ fu! s:Render(lines, pat)
en
" Highlighting
if s:dohighlight()
cal s:highlight(a:pat, s:mathi[1] == '' ? 'Identifier' : s:mathi[1])
cal s:highlight(a:pat, s:mathi[1], a:ipt)
en
endf
@@ -401,13 +409,11 @@ fu! s:Update(str)
" Get the new string sans tail
let str = s:sanstail(a:str)
" Stop if the string's unchanged
if str == oldstr && !empty(str) && !exists('s:force')
retu
en
let pat = s:SplitPattern(str)
if str == oldstr && !empty(str) && !exists('s:force') | retu | en
let [pat, ipt] = [s:SplitPattern(str), s:ispathitem()]
let lines = exists('g:ctrlp_nolimit') && empty(str) ? copy(g:ctrlp_lines)
\ : s:MatchedItems(g:ctrlp_lines, pat, s:winh)
cal s:Render(lines, pat)
\ : s:MatchedItems(g:ctrlp_lines, pat, s:winh, ipt)
cal s:Render(lines, pat, ipt)
endf
fu! s:ForceUpdate()
@@ -459,8 +465,7 @@ endf
fu! s:PrtBS()
unl! s:hstgot
let [prt, s:matches] = [s:prompt, 1]
let prt[0] = substitute(prt[0], '.$', '', '')
let [s:prompt[0], s:matches] = [substitute(s:prompt[0], '.$', '', ''), 1]
cal s:BuildPrompt(1)
endf
@@ -485,7 +490,6 @@ endf
fu! s:PrtInsert(type)
unl! s:hstgot
" Insert current word, search register, last visual and clipboard
let s:prompt[0] .= a:type == 'w' ? s:crword
\ : a:type == 's' ? getreg('/')
\ : a:type == 'v' ? s:crvisual
@@ -507,20 +511,18 @@ fu! s:PrtExpandDir()
endf
" Movement {{{2
fu! s:PrtCurLeft()
if !empty(s:prompt[0])
let prt = s:prompt
let prt[2] = prt[1] . prt[2]
let prt[1] = matchstr(prt[0], '.$')
let prt[0] = substitute(prt[0], '.$', '', '')
let prt = s:prompt
if !empty(prt[0])
let s:prompt = [substitute(prt[0], '.$', '', ''), matchstr(prt[0], '.$'),
\ prt[1] . prt[2]]
en
cal s:BuildPrompt(0)
endf
fu! s:PrtCurRight()
let prt = s:prompt
let prt[0] .= prt[1]
let prt[1] = matchstr(prt[2], '^.')
let prt[2] = substitute(prt[2], '^.', '', '')
let s:prompt = [prt[0] . prt[1], matchstr(prt[2], '^.'),
\ substitute(prt[2], '^.', '', '')]
cal s:BuildPrompt(0)
endf
@@ -577,7 +579,7 @@ fu! s:PrtClearCache()
if s:itemtype == 2
let g:ctrlp_lines = ctrlp#mrufiles#list(-1, 1)
el
cal s:SetLines(s:itemtype)
cal ctrlp#setlines(s:itemtype)
en
let s:force = 1
cal s:BuildPrompt(1)
@@ -585,12 +587,16 @@ fu! s:PrtClearCache()
endf
fu! s:PrtDeleteMRU()
if s:itemtype == 2
let s:force = 1
let g:ctrlp_lines = ctrlp#mrufiles#list(-1, 2)
cal s:BuildPrompt(1)
unl s:force
if s:itemtype != 2 | retu | en
let [s:force, ags] = [1, [-1, 2]]
if exists('s:marked')
let ags = [-1, 2, values(s:marked)]
cal s:unmarksigns()
unl s:marked
en
let g:ctrlp_lines = call('ctrlp#mrufiles#list', ags)
cal s:BuildPrompt(1)
unl s:force
endf
fu! s:PrtExit()
@@ -616,11 +622,18 @@ endf
fu! s:MapKeys(...)
" Normal keys
let pfunc = a:0 && !a:1 ? 'PrtSelectJump' : 'PrtAdd'
let dojmp = s:byfname && pfunc == 'PrtSelectJump' ? ', 1' : ''
let dojmp = s:byfname && a:0 && !a:1 ? ', 1' : ''
let pcmd = "nn \<buffer> \<silent> \<k%s> :\<c-u>cal \<SID>%s(\"%s\"%s)\<cr>"
let cmd = substitute(pcmd, 'k%s', 'char-%d', '')
for each in range(32, 126)
let cmd = "nn \<buffer> \<silent> \<char-%d> :\<c-u>cal \<SID>%s(\"%s\"%s)\<cr>"
exe printf(cmd, each, pfunc, escape(nr2char(each), '"|\'), dojmp)
endfo
for each in range(0, 9)
exe printf(pcmd, each, pfunc, each, dojmp)
endfo
for [ke, va] in items(s:kprange)
exe printf(pcmd, ke, pfunc, va, dojmp)
endfo
" Special keys
if a:0 < 2
cal call('s:MapSpecs', a:0 && !a:1 ? [1] : [])
@@ -675,9 +688,9 @@ fu! s:ToggleType(dir)
if s:byfname && !s:ispathitem() | let s:byfname = 0 | en
unl! g:ctrlp_nolimit
if has('syntax') && exists('g:syntax_on')
cal s:syntax()
cal ctrlp#syntax()
en
cal s:SetLines(s:itemtype)
cal ctrlp#setlines(s:itemtype)
cal s:PrtSwitcher()
endf
@@ -687,7 +700,7 @@ fu! s:PrtSwitcher()
unl s:force
endf
fu! s:SetWD(...) "{{{1
let pathmode = s:pathmode
let [pathmode, s:crfilerel] = [s:wpmode, fnamemodify(s:crfile, ':.')]
if a:0 && strlen(a:1) | if type(a:1)
cal ctrlp#setdir(a:1) | retu
el
@@ -699,7 +712,7 @@ fu! s:SetWD(...) "{{{1
cal ctrlp#setdir(s:crfpath)
en
if pathmode == 1 | retu | en
let markers = ['root.dir','.git/','.hg/','_darcs/','.bzr/']
let markers = ['root.dir', '.git/', '.hg/', '.svn/', '.bzr/', '_darcs/']
if type(s:rmarkers) == 3 && !empty(s:rmarkers)
cal extend(markers, s:rmarkers, 0)
en
@@ -710,8 +723,8 @@ fu! s:SetWD(...) "{{{1
unl! s:foundroot
endf
" * AcceptSelection() {{{1
fu! ctrlp#acceptfile(mode, matchstr, ...)
let [md, filpath] = [a:mode, fnamemodify(a:matchstr, ':p')]
fu! ctrlp#acceptfile(mode, line, ...)
let [md, filpath] = [a:mode, fnamemodify(a:line, ':p')]
cal s:PrtExit()
let [bufnr, tail] = [bufnr('^'.filpath.'$'), s:tail()]
let j2l = a:0 ? a:1 : str2nr(matchstr(tail, '^ +\D*\zs\d\+\ze\D*'))
@@ -752,12 +765,12 @@ fu! s:SpecInputs(str)
let [str, type] = [a:str, s:type()]
if str == '..' && type =~ '\v^(0|dir)$'
cal s:parentdir(getcwd())
cal s:SetLines(s:itemtype)
cal ctrlp#setlines(s:itemtype)
cal s:PrtClear()
retu 1
elsei str =~ '^[\/]$' && type =~ '\v^(0|dir)$'
cal s:SetWD(2, 0)
cal s:SetLines(s:itemtype)
cal ctrlp#setlines(s:itemtype)
cal s:PrtClear()
retu 1
elsei str == '?'
@@ -773,17 +786,16 @@ fu! s:AcceptSelection(mode)
let str = join(s:prompt, '')
if a:mode == 'e' | if s:SpecInputs(str) | retu | en | en
" Get the selected line
let line = getline('.')
if a:mode != 'e' && s:itemtype < 3 && line == ' == NO ENTRIES =='
let line = !empty(s:matched) ? s:matched[line('.') - 1] : ''
if a:mode != 'e' && s:itemtype < 3 && line == ''
\ && str !~ '\v^(\.\.|/|\\|\?)$'
cal s:CreateNewFile(a:mode) | retu
en
let matchstr = matchstr(line, '^> \zs.\+\ze\t*$')
if empty(matchstr) | retu | en
if empty(line) | retu | en
" Do something with it
let actfunc = s:itemtype < 3 ? 'ctrlp#acceptfile'
\ : g:ctrlp_ext_vars[s:itemtype - ( g:ctrlp_builtins + 1 )]['accept']
cal call(actfunc, [a:mode, matchstr])
cal call(actfunc, [a:mode, line])
endf
fu! s:CreateNewFile(...) "{{{1
let [md, str] = ['', join(s:prompt, '')]
@@ -807,7 +819,7 @@ fu! s:CreateNewFile(...) "{{{1
en
if !exists('optyp') | retu | en
let [filpath, tail] = [fnamemodify(optyp, ':p'), s:tail()]
cal s:insertcache(str)
if !stridx(filpath, getcwd()) | cal s:insertcache(str) | en
cal s:PrtExit()
let cmd = md == 'r' ? ctrlp#normcmd('e') :
\ s:newfop =~ '1\|t' || ( a:0 && a:1 == 't' ) || md == 't' ? 'tabe' :
@@ -822,9 +834,9 @@ fu! s:MarkToOpen()
\ || ( s:itemtype > g:ctrlp_builtins && s:type() !~ 'rts' )
retu
en
let matchstr = matchstr(getline('.'), '^> \zs.\+\ze\t*$')
if empty(matchstr) | retu | en
let filpath = fnamemodify(matchstr, ':p')
let line = !empty(s:matched) ? s:matched[line('.') - 1] : ''
if empty(line) | retu | en
let filpath = fnamemodify(line, ':p')
if exists('s:marked') && s:dictindex(s:marked, filpath) > 0
" Unmark and remove the file from s:marked
let key = s:dictindex(s:marked, filpath)
@@ -861,8 +873,8 @@ fu! s:OpenMulti()
cal s:sanstail(join(s:prompt, ''))
cal s:PrtExit()
" Move the cursor to a reusable window
let tail = s:tail()
let emptytail = empty(tail)
let [tail, fnesc] = [s:tail(), exists('*fnameescape') && v:version > 701]
let [emptytail, nwpt] = [empty(tail), exists('g:ctrlp_open_multiple_files')]
let useb = bufnr('^'.mkd[0].'$') > 0 && emptytail
let fst = call('ctrlp#normcmd', useb ? ['b', 'bo vert sb'] : ['e'])
" Check if it's a replaceable buffer
@@ -875,12 +887,19 @@ fu! s:OpenMulti()
for va in mkd
let bufnr = bufnr('^'.va.'$')
let useb = bufnr > 0 && emptytail
let snd = md != '' && has_key(cmds, md)
\ ? ( useb ? cmds[md][0] : cmds[md][1] ) : ( useb ? 'vert sb' : 'vne' )
let fid = useb ? bufnr : va
cal s:openfile(ic == 1 && ( ucr == 'r' || repabl ) ? fst : snd, fid, tail)
if ( nr != '' && nr > 1 && nr < ic ) || ( nr == '' && ic > 1 )
sil! hid clo! | el | let ic += 1
let snd = md != '' && has_key(cmds, md) ?
\ ( useb ? cmds[md][0] : cmds[md][1] ) : ( useb ? 'vert sb' : 'vne' )
let cmd = ic == 1 && ( ucr == 'r' || repabl ) ? fst : snd
let conds = [( nr != '' && nr > 1 && nr < ic ) || ( nr == '' && ic > 1 ),
\ nr != '' && nr < ic]
if conds[nwpt]
if bufnr <= 0 | if fnesc
cal s:openfile('bad', fnamemodify(va, ':.'), '')
el
cal s:openfile(cmd, va, tail) | sil! hid clo!
en | en
el
cal s:openfile(cmd, useb ? bufnr : va, tail) | let ic += 1
en
endfo
let &swb = swb
@@ -919,6 +938,13 @@ fu! s:comparent(s1, s2)
retu 0
endf
fu! s:compfnlen(s1, s2)
" By filename length
let len1 = strlen(split(a:s1, s:lash)[-1])
let len2 = strlen(split(a:s2, s:lash)[-1])
retu len1 == len2 ? 0 : len1 > len2 ? 1 : -1
endf
fu! s:matchlens(str, pat, ...)
if empty(a:pat) || index(['^', '$'], a:pat) >= 0 | retu {} | en
let st = a:0 ? a:1 : 0
@@ -940,11 +966,12 @@ endf
fu! s:mixedsort(s1, s2)
let [cml, cln] = [s:compmatlen(a:s1, a:s2), ctrlp#complen(a:s1, a:s2)]
if s:itemtype < 3 && s:height < 51
let par = s:comparent(a:s1, a:s2)
let [par, cfn] = [s:comparent(a:s1, a:s2), s:compfnlen(a:s1, a:s2)]
if s:height < 21
retu 6 * cml + 3 * par + 2 * s:comptime(a:s1, a:s2) + cln
let ctm = s:comptime(a:s1, a:s2)
retu 12 * cml + 6 * par + 3 * cfn + 2 * ctm + cln
en
retu 3 * cml + 2 * par + cln
retu 6 * cml + 3 * par + 2 * cfn + cln
en
retu 2 * cml + cln
endf
@@ -973,7 +1000,7 @@ fu! ctrlp#statusline()
let focus = s:Focus() ? 'prt' : 'win'
let byfname = s:byfname ? 'file' : 'path'
let marked = s:opmul != '0' ?
\ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <+>' : ''
\ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <->' : ''
if has_key(s:status, 'main')
let args = [focus, byfname, s:regexp, prv, item, nxt, marked]
let &l:stl = call(s:status['main'], args)
@@ -989,7 +1016,7 @@ fu! ctrlp#statusline()
endf
fu! s:dismrk()
retu has('signs') ? '+'.len(s:marked) :
retu has('signs') ? len(s:marked) :
\ '%<'.join(values(map(copy(s:marked), 'split(v:val, "[\\/]")[-1]')), ', ')
endf
@@ -997,9 +1024,14 @@ fu! ctrlp#progress(enum)
if has('macunix') || has('mac') | sl 1m | en
let &l:stl = has_key(s:status, 'prog') ? call(s:status['prog'], [a:enum])
\ : '%#CtrlPStats# '.a:enum.' %* %=%<%#CtrlPMode2# '.getcwd().' %*'
redr
redraws
endf
" Paths {{{2
fu! s:formatline(str, ipt)
let cond = a:ipt && ( s:winw - 4 ) < s:strwidth(a:str)
retu '> '.( cond ? pathshorten(a:str) : a:str )
endf
fu! s:dircompl(be, sd)
if a:sd == '' | retu [] | en
let [be, sd] = a:be == '' ? [getcwd(), a:sd] : [a:be, a:be.s:lash(a:be).a:sd]
@@ -1124,9 +1156,16 @@ endf
fu! ctrlp#setdir(path, ...)
let cmd = a:0 ? a:1 : 'lc!'
sil! exe cmd ctrlp#fnesc(a:path)
let s:crfilerel = fnamemodify(s:crfile, ':.')
endf
fu! ctrlp#setlcdir()
if exists('*haslocaldir')
cal ctrlp#setdir(getcwd(), haslocaldir() ? 'lc!' : 'cd!')
en
endf
" Highlighting {{{2
fu! s:syntax()
fu! ctrlp#syntax()
for [ke, va] in items(s:hlgrps) | if !hlexists('CtrlP'.ke)
exe 'hi link CtrlP'.ke va
en | endfo
@@ -1140,9 +1179,9 @@ fu! s:syntax()
en
endf
fu! s:highlight(pat, grp)
fu! s:highlight(pat, grp, ipt)
cal clearmatches()
if !empty(a:pat) && s:ispathitem()
if !empty(a:pat) && a:ipt
let pat = s:regexp ? substitute(a:pat, '\\\@<!\^', '^> \\zs', 'g') : a:pat
if s:byfname
" Match only filename
@@ -1157,7 +1196,7 @@ fu! s:highlight(pat, grp)
endf
fu! s:dohighlight()
retu len(s:mathi) > 1 && s:mathi[0] && exists('*clearmatches')
retu s:mathi[0] && exists('*clearmatches')
endf
" Prompt history {{{2
fu! s:gethistloc()
@@ -1218,37 +1257,21 @@ fu! s:buftab(bufnr, md)
let buflist = tabpagebuflist(tabnr)
if index(buflist, a:bufnr) >= 0
for winnr in range(1, tabpagewinnr(tabnr, '$'))
if buflist[winnr - 1] == a:bufnr
retu [tabnr, winnr]
en
if buflist[winnr - 1] == a:bufnr | retu [tabnr, winnr] | en
endfo
en
endfo
retu [0, 0]
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, ...)
if s:nosplit()
retu a:cmd
en
let norwins = s:normbuf()
if s:nosplit() | retu a:cmd | en
let norwins = filter(range(1, winnr('$')),
\ 'empty(getbufvar(winbufnr(v:val), "&bt"))')
for each in norwins
let bufnr = winbufnr(each)
if empty(bufname(bufnr)) && empty(getbufvar(bufnr, '&ft'))
let fstemp = each
brea
let fstemp = each | brea
en
endfo
let norwin = empty(norwins) ? 0 : norwins[0]
@@ -1262,7 +1285,7 @@ fu! ctrlp#normcmd(cmd, ...)
endf
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
fu! s:setupblank()
@@ -1274,8 +1297,7 @@ fu! s:setupblank()
endf
fu! s:leavepre()
if s:clrex && ( !has('clientserver') ||
\ ( has('clientserver') && len(split(serverlist(), "\n")) == 1 ) )
if s:clrex && !( has('clientserver') && len(split(serverlist(), "\n")) > 1 )
cal ctrlp#clra()
en
endf
@@ -1320,18 +1342,37 @@ fu! s:argmaps(md, ...)
retu a:md
endf
" Misc {{{2
fu! s:log(m)
if exists('g:ctrlp_log') && g:ctrlp_log | if a:m
let cadir = ctrlp#utils#cachedir()
sil! exe 'redi! >' cadir.s:lash(cadir).'ctrlp.log'
el
sil! redi END
en | en
endf
fu! s:strwidth(str)
retu exists('*strdisplaywidth') ? strdisplaywidth(a:str) : strlen(a:str)
endf
fu! s:getenv()
let s:winh = min([s:mxheight, &lines])
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:crline] = [expand('<cword>'), getline('.')]
let [s:tagfiles, s:crcursor] = [s:tagfiles(), getpos('.')]
let [s:winh, s:crcursor] = [min([s:mxheight, &lines]), getpos('.')]
let [s:crbufnr, s:crvisual] = [bufnr('%'), s:lastvisual()]
if exists('g:ctrlp_extensions') && index(g:ctrlp_extensions, 'undo') >= 0
\ && v:version > 702 && has('patch005') && exists('*undotree')
let s:undotree = undotree()
en
let s:currwin = s:mwbottom ? winnr() : winnr() + has('autocmd')
let s:wpmode = exists('b:ctrlp_working_path_mode')
\ ? b:ctrlp_working_path_mode : s:pathmode
if exists('g:ctrlp_extensions')
if index(g:ctrlp_extensions, 'undo') >= 0 && exists('*undotree')
\ && ( v:version > 703 || ( v:version == 703 && has('patch005') ) )
let s:undotree = undotree()
en
if index(g:ctrlp_extensions, 'tag') >= 0
let s:tagfiles = s:tagfiles()
en
en
endf
fu! s:lastvisual()
@@ -1373,8 +1414,8 @@ fu! s:openfile(cmd, fid, tail, ...)
if !empty(a:tail) || j2l
sil! norm! zvzz
en
if exists('*haslocaldir')
cal ctrlp#setdir(getcwd(), haslocaldir() ? 'lc!' : 'cd!')
if cmd != 'bad'
cal ctrlp#setlcdir()
en
endf
@@ -1452,20 +1493,6 @@ fu! s:onexit()
en
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()
cal s:PrtExit()
endf
@@ -1473,17 +1500,13 @@ endf
fu! ctrlp#prtclear()
cal s:PrtClear()
endf
fu! ctrlp#setlines(type)
cal s:SetLines(a:type)
endf
"}}}1
" * Initialization {{{1
fu! s:SetLines(type)
fu! ctrlp#setlines(type)
let s:itemtype = a:type
let types = [
\ 's:Files()',
\ 's:Buffers()',
\ 'ctrlp#files()',
\ 'ctrlp#buffers()',
\ 'ctrlp#mrufiles#list(-1)',
\ ]
if exists('g:ctrlp_ext_vars')
@@ -1499,9 +1522,9 @@ fu! ctrlp#init(type, ...)
cal s:SetWD(a:0 ? a:1 : '')
cal s:MapKeys()
if has('syntax') && exists('g:syntax_on')
cal s:syntax()
cal ctrlp#syntax()
en
cal s:SetLines(a:type)
cal ctrlp#setlines(a:type)
cal s:BuildPrompt(1)
endf
if has('autocmd') "{{{1

View File

@@ -198,17 +198,20 @@ fu! s:parseline(line)
endf
" Public {{{1
fu! ctrlp#buffertag#init(fname)
let fname = exists('s:bufname') ? s:bufname : a:fname
let bufs = exists('s:btmode') && s:btmode ? ctrlp#allbufs() : [fname]
let bufs = exists('s:btmode') && s:btmode
\ ? filter(ctrlp#buffers(), 'filereadable(v:val)')
\ : [exists('s:bufname') ? s:bufname : a:fname]
let lines = []
for each in bufs
let tftype = get(split(getbufvar(each, '&ft'), '\.'), 0, '')
cal extend(lines, s:process(each, tftype))
endfo
if !hlexists('CtrlPTabExtra')
hi link CtrlPTabExtra Comment
if has('syntax') && exists('g:syntax_on')
if !hlexists('CtrlPTabExtra')
hi link CtrlPTabExtra Comment
en
sy match CtrlPTabExtra '\zs\t.*\ze$'
en
sy match CtrlPTabExtra '\zs\t.*\ze$'
retu lines
endf

View File

@@ -0,0 +1,106 @@
" =============================================================================
" File: autoload/ctrlp/changes.vim
" Description: Change list extension - Jump to a recent change in any buffer
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" User Configuration {{{1
" Enable:
" let g:ctrlp_extensions += ['changes']
" Create Some Commands:
" " Single buffer
" com! -n=? -com=buffer CtrlPChange
" \ cal ctrlp#init(ctrlp#changes#cmd(0, <q-args>))
" " All listed buffers
" com! CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1))
"}}}
" Init {{{1
if exists('g:loaded_ctrlp_changes') && g:loaded_ctrlp_changes
fini
en
let g:loaded_ctrlp_changes = 1
let s:changes_var = {
\ 'init': 'ctrlp#changes#init(s:bufnr, s:crfile)',
\ 'accept': 'ctrlp#changes#accept',
\ 'lname': 'changes',
\ 'sname': 'chs',
\ 'exit': 'ctrlp#changes#exit()',
\ 'type': 'tabe',
\ }
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
\ ? add(g:ctrlp_ext_vars, s:changes_var) : [s:changes_var]
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
" Utilities {{{1
fu! s:changelist(bufnr)
sil! exe 'noa hid b' a:bufnr
redi => result
sil! changes
redi END
retu map(split(result, "\n")[1:], 'tr(v:val, " ", " ")')
endf
fu! s:process(clines, ...)
let [clines, evas] = [[], []]
for each in a:clines
let parts = matchlist(each, '\v^.\s*\d+\s+(\d+)\s+(\d+)\s(.*)$')
if !empty(parts)
if parts[3] == '' | let parts[3] = ' ' | en
cal add(clines, parts[3].' |'.a:1.':'.a:2.'|'.parts[1].':'.parts[2].'|')
en
endfo
retu reverse(filter(clines, 'count(clines, v:val) == 1'))
endf
" Public {{{1
fu! ctrlp#changes#init(original_bufnr, fname)
let fname = exists('s:bufname') ? s:bufname : a:fname
let bufs = exists('s:clmode') && s:clmode
\ ? filter(ctrlp#buffers(), 'filereadable(v:val)') : [fname]
let [swb, &swb] = [&swb, '']
let lines = []
for each in bufs
let [bufnr, fnamet] = [bufnr('^'.each.'$'), fnamemodify(each, ':t')]
if bufnr > 0
cal extend(lines, s:process(s:changelist(bufnr), bufnr, fnamet))
en
endfo
sil! exe 'noa hid b' a:original_bufnr
let &swb = swb
let g:ctrlp_nolimit = 1
if has('syntax') && exists('g:syntax_on')
cal ctrlp#syntax()
if !hlexists('CtrlPTabExtra')
hi link CtrlPTabExtra Comment
en
sy match CtrlPTabExtra '\zs\t.*\ze$'
en
retu lines
endf
fu! ctrlp#changes#accept(mode, str)
let info = matchlist(a:str, '\t|\(\d\+\):[^|]\+|\(\d\+\):\(\d\+\)|$')
let bufnr = str2nr(get(info, 1))
if bufnr
cal ctrlp#acceptfile(a:mode, fnamemodify(bufname(bufnr), ':p'))
cal cursor(get(info, 2), get(info, 3))
sil! norm! zvzz
en
endf
fu! ctrlp#changes#cmd(mode, ...)
let s:clmode = a:mode
if a:0 && !empty(a:1)
let s:bufname = fnamemodify(a:1, ':p')
en
retu s:id
endf
fu! ctrlp#changes#exit()
unl! s:clmode s:bufname
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@@ -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)
" Public {{{1
fu! ctrlp#line#init()
let [bufs, lines] = [ctrlp#allbufs(), []]
let [bufs, lines] = [filter(ctrlp#buffers(), 'filereadable(v:val)'), []]
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, '' '', '' '')')
let [id, len_ff, bufnr] = [1, len(from_file), bufnr('^'.each.'$')]
wh id <= len_ff
let from_file[id-1] .= ' #:'.bufnr.':'.id
let from_file[id-1] .= ' |'.fnamet.'|'.bufnr.':'.id.'|'
let id += 1
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)
endfo
if !hlexists('CtrlPTabExtra')
hi link CtrlPTabExtra Comment
if has('syntax') && exists('g:syntax_on')
if !hlexists('CtrlPTabExtra')
hi link CtrlPTabExtra Comment
en
sy match CtrlPTabExtra '\zs\t.*\ze$'
en
sy match CtrlPTabExtra '\zs\t.*\ze$'
retu lines
endf
fu! ctrlp#line#accept(mode, str)
let info = get(split(a:str, '\t#:\ze\d\+:\d\+$'), 1, 0)
let bufnr = str2nr(get(split(info, ':'), 0, 0))
let linenr = get(split(info, ':'), 1, 0)
if bufnr
let info = matchlist(a:str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$')
let [bufnr, linenr] = [str2nr(get(info, 1)), get(info, 2)]
if bufnr > 0
cal ctrlp#acceptfile(a:mode, fnamemodify(bufname(bufnr), ':p'), linenr)
en
endf

View File

@@ -36,8 +36,13 @@ fu! ctrlp#mrufiles#list(bufnr, ...) "{{{1
let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt'
en
if a:0 && a:1 == 2
cal ctrlp#utils#writecache([], s:cadir, s:cafile)
retu []
let mrufs = []
if a:0 == 2
let mrufs = ctrlp#utils#readfile(s:cafile)
cal filter(mrufs, 'index(a:2, v:val) < 0')
en
cal ctrlp#utils#writecache(mrufs, s:cadir, s:cafile)
retu map(mrufs, 'fnamemodify(v:val, '':.'')')
en
" Get the list
let mrufs = ctrlp#utils#readfile(s:cafile)
@@ -52,15 +57,11 @@ fu! ctrlp#mrufiles#list(bufnr, ...) "{{{1
en
" Return the list with the active buffer removed
if bufnr == -1
let crf = fnamemodify(bufname(winbufnr(winnr('#'))), ':p')
let crf = exists('+ssl') ? tr(crf, '/', '\') : crf
let mrufs = empty(crf) ? mrufs : filter(mrufs, 'v:val !='.s:csen.' crf')
if s:re
let cwd = exists('+ssl') ? tr(getcwd(), '/', '\') : getcwd()
cal filter(mrufs, '!stridx(v:val, cwd)')
en
cal map(mrufs, 'fnamemodify(v:val, '':.'')')
retu mrufs
retu map(mrufs, 'fnamemodify(v:val, '':.'')')
en
" Remove old entry
cal filter(mrufs, 'v:val !='.s:csen.' fn')

View File

@@ -30,10 +30,12 @@ endf
" Public {{{1
fu! ctrlp#quickfix#init()
let g:ctrlp_nolimit = 1
if !hlexists('CtrlPqfLineCol')
hi link CtrlPqfLineCol Search
if has('syntax') && exists('g:syntax_on')
if !hlexists('CtrlPqfLineCol')
hi link CtrlPqfLineCol Search
en
sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|'
en
sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|'
retu map(getqflist(), 's:lineout(v:val)')
endf
@@ -48,6 +50,7 @@ fu! ctrlp#quickfix#accept(mode, str)
exe cmd ctrlp#fnesc(filpath)
cal cursor(items[2], items[3])
sil! norm! zvzz
cal ctrlp#setlcdir()
endf
fu! ctrlp#quickfix#id()

View File

@@ -23,14 +23,6 @@ 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)
" Utilities {{{1
fu! s:nodup(items)
let dict = {}
for each in a:items
cal extend(dict, { each : 0 })
endfo
retu keys(dict)
endf
fu! s:findcount(str)
let [tg, fname] = split(a:str, '\t\+\ze[^\t]\+$')
let [fname, tgs] = [expand(fname, 1), taglist('^'.tg.'$')]
@@ -67,30 +59,32 @@ endf
" Public {{{1
fu! ctrlp#tag#init(tagfiles)
if empty(a:tagfiles) | retu [] | en
let [tagfiles, g:ctrlp_alltags] = [sort(s:nodup(a:tagfiles)), []]
let g:ctrlp_alltags = []
let tagfiles = sort(filter(a:tagfiles, 'count(a:tagfiles, v:val) == 1'))
for each in tagfiles
let alltags = s:filter(ctrlp#utils#readfile(each))
cal extend(g:ctrlp_alltags, alltags)
endfo
if !hlexists('CtrlPTabExtra')
hi link CtrlPTabExtra Comment
if has('syntax') && exists('g:syntax_on')
if !hlexists('CtrlPTabExtra')
hi link CtrlPTabExtra Comment
en
sy match CtrlPTabExtra '\zs\t.*\ze$'
en
sy match CtrlPTabExtra '\zs\t.*\ze$'
retu g:ctrlp_alltags
endf
fu! ctrlp#tag#accept(mode, str)
cal ctrlp#exit()
let str = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\ze\t')
let [md, tg] = [a:mode, split(str, '^[^\t]\+\zs\t')[0]]
let fnd = s:findcount(str)
let [tg, fnd] = [split(str, '^[^\t]\+\zs\t')[0], s:findcount(str)]
let cmds = {
\ 't': ['tab sp', 'tab stj'],
\ 'h': ['sp', 'stj'],
\ 'v': ['vs', 'vert stj'],
\ 'e': ['', 'tj'],
\ }
let cmd = fnd[0] == 1 ? cmds[md][0] : cmds[md][1]
let cmd = fnd[0] == 1 ? cmds[a:mode][0] : cmds[a:mode][1]
let cmd = cmd == 'tj' && &modified ? 'hid '.cmd : cmd
let cmd = cmd =~ '^tab' ? tabpagenr('$').cmd : cmd
if fnd[0] == 1
@@ -101,6 +95,7 @@ fu! ctrlp#tag#accept(mode, str)
el
exe cmd tg
en
cal ctrlp#setlcdir()
endf
fu! ctrlp#tag#id()

View File

@@ -13,7 +13,7 @@
" Init {{{1
if ( exists('g:loaded_ctrlp_undo') && g:loaded_ctrlp_undo )
\ || !( v:version > 702 && has('patch005') )
\ || !( v:version > 703 || ( v:version == 703 && has('patch005') ) )
fini
en
let g:loaded_ctrlp_undo = 1
@@ -102,7 +102,9 @@ endf
fu! ctrlp#undo#init(undo)
let entries = a:undo['entries']
if empty(entries) | retu [] | en
cal s:syntax()
if has('syntax') && exists('g:syntax_on')
cal s:syntax()
en
let g:ctrlp_nolimit = 1
let entries = sort(s:dict2list(s:flatten(entries)), 's:compval')
retu map(entries, 'v:val[1]." [".v:val[0]."]"')

View File

@@ -1,4 +1,4 @@
*ctrlp.txt* Fuzzy file, buffer, mru and tag finder. v1.7.1
*ctrlp.txt* Fuzzy file, buffer, mru and tag finder. v1.7.2
*CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'*
===============================================================================
# #
@@ -21,7 +21,7 @@ CONTENTS *ctrlp-contents*
6. Extensions...................................|ctrlp-extensions|
===============================================================================
1. Intro *ctrlp-intro*
INTRO *ctrlp-intro*
Full path fuzzy file, buffer, mru and tag finder with an intuitive interface.
Written in pure Vimscript for MacVim and Vim version 7.0+. Has full support for
@@ -31,7 +31,7 @@ finder, and more.
To enable optional extensions (tag, dir, rtscript...), see |ctrlp-extensions|.
===============================================================================
2. Options *ctrlp-options*
OPTIONS *ctrlp-options*
Below are the available options and their default values:~
@@ -51,14 +51,16 @@ Use this to disable the plugin completely: >
<
*'g:ctrlp_by_filename'*
Set this to 1 to set search by filename (not full path) as the default: >
Set this to 1 to set searching by filename (not full path) as the default: >
let g:ctrlp_by_filename = 0
<
Can be toggled on/off by pressing <c-d> inside the prompt.
*'g:ctrlp_regexp_search'*
*'g:ctrlp_regexp'*
Set this to 1 to set |regexp| search as the default: >
let g:ctrlp_regexp_search = 0
let g:ctrlp_regexp = 0
<
Can be toggled on/off by pressing <c-r> inside the prompt.
*'g:ctrlp_match_window_bottom'*
Set this to 0 to show the match window at the top of the screen: >
@@ -66,8 +68,8 @@ Set this to 0 to show the match window at the top of the screen: >
<
*'g:ctrlp_match_window_reversed'*
Change the listing order of the matched files in the match window. The default
setting (1) is from bottom to top: >
Change the listing order of the files in the match window. The default setting
(1) is from bottom to top: >
let g:ctrlp_match_window_reversed = 1
<
@@ -76,28 +78,37 @@ Set the maximum height of the match window: >
let g:ctrlp_max_height = 10
<
*'g:ctrlp_jump_to_buffer'*
When opening a file with <cr> or <c-t>, if the file's already opened somewhere
*'g:ctrlp_switch_buffer'*
When opening a file with <cr> or <c-t>, if the files already opened somewhere
|CtrlP| will try to jump to it instead of opening a new instance: >
let g:ctrlp_jump_to_buffer = 2
let g:ctrlp_switch_buffer = 2
<
1 - only jump to the buffer if its opened in the current tab.
2 - jump tab as well if the buffer's opened in another tab.
2 - jump tab as well if the buffers opened in another tab.
0 - disable this feature.
*'g:ctrlp_reuse_window'*
When opening a file with <cr>, |CtrlP| avoids opening it in windows created by
plugins, help and quickfix. Use this to setup some exceptions: >
let g:ctrlp_reuse_window = 'netrw'
<
Acceptable values are partial name, filetype or buftype of the special buffers.
Use |regexp| to specify the pattern.
Example: >
let g:ctrlp_reuse_window = 'netrw\|help\|quickfix'
<
*'g:ctrlp_working_path_mode'*
When starting up, |CtrlP| sets its local working directory according to this
variable: >
let g:ctrlp_working_path_mode = 2
<
1 - the parent directory of the current file.
2 - the nearest ancestor that contains one of these directories/files:
.git/
.hg/
.bzr/
_darcs/
root.dir
2 - the nearest ancestor that contains one of these directories or files:
.git/ .hg/ .svn/ .bzr/ _darcs/
0 - dont manage working directory.
Note: you can use b:ctrlp_working_path_mode (a |b:var|) to set this option on a
per buffer basis.
*'g:ctrlp_root_markers'*
Use this to set your own root markers in addition to the default ones. Your
@@ -105,7 +116,7 @@ markers will take precedence: >
let g:ctrlp_root_markers = ['']
<
These markers (builtins and yours) will serve as identifiers for the '/' and
'\' special inputs (section 5.e).
'\' special inputs (|ctrlp-input-formats| (e)).
*'g:ctrlp_use_caching'*
Set this to 0 to disable per-session caching. When disabled, caching will still
@@ -165,11 +176,10 @@ only need to keep the lines that youve changed the values (inside []): >
<
Note: In some terminals, its not possible to remap <c-h> without also changing
<bs> (|key-codes|). So if pressing <bs> moves the cursor to the left instead of
deleting a char for you, add this to your |vimrc| to change the default <c-h>
deleting a char for you, add this to your |vimrc| to disable the default <c-h>
mapping: >
let g:ctrlp_prompt_mappings = {
\ 'PrtBS()': ['<bs>', '<c-]>', '<c-h>'],
\ 'PrtCurLeft()': ['<left>', '<c-^>'],
\ 'PrtCurLeft()': ['<left>', '<c-^>']
\ }
<
@@ -213,7 +223,7 @@ Set to 1 to sort the MRU file list to most-recently-entered-buffer order: >
<
*'g:ctrlp_dotfiles'*
Set this to 0 if you dont want |CtrlP| to search for dotfiles and dotdirs: >
Set this to 0 if you dont want |CtrlP| to scan for dotfiles and dotdirs: >
let g:ctrlp_dotfiles = 1
<
You can use |'wildignore'| to exclude anything from the search.
@@ -225,9 +235,9 @@ Examples: >
Note #1: the `*/` in front of each directory glob is required.
Note #2: |wildignore| influences the result of |expand()|, |globpath()| and
|glob()| which many plugins use to find stuff on the system (e.g. fugitive.vim
looks for .git/, some other plugins look for external .exe tools on Windows).
So be a little mindful of what you put in your |wildignore|.
|glob()| which many plugins use to find stuff on the system (e.g. VCS related
plugins look for .git/, .hg/,... some other plugins look for external *.exe
tools on Windows). So be a little mindful of what you put in your |wildignore|.
*'g:ctrlp_custom_ignore'*
In addition to |'wildignore'|, use this for files and directories you want only
@@ -243,12 +253,6 @@ Examples: >
\ }
<
*'g:ctrlp_highlight_match'*
Use this to enable/disable highlighting of the matched patterns and to specify
the highlight group thatll be used: >
let g:ctrlp_highlight_match = [1, 'Identifier']
<
*'g:ctrlp_max_files'*
The maximum number of files to scan, set to 0 for no limit: >
let g:ctrlp_max_files = 10000
@@ -317,20 +321,21 @@ pressing <c-y>:
let g:ctrlp_open_new_file = 'v'
<
*'g:ctrlp_open_multi'*
*'g:ctrlp_open_multiple_files'*
If non-zero, this will enable opening multiple files with <c-z> and <c-o>: >
let g:ctrlp_open_multi = '1v'
let g:ctrlp_open_multiple_files = 'v'
<
Example: >
let g:ctrlp_open_multiple_files = '2vr'
<
For the number:
- If bigger than 1, itll be used as the maximum number of windows or tabs to
create when opening the files (the rest will be hidden buffers).
- If is 1, <c-o> will open all files, each in a new window or new tab.
- If no number is given, only the first file will be opened in a window,
either new window or reused, and the rest will be hidden buffers.
- If given, itll be used as the maximum number of windows or tabs to create
when opening the files (the rest will be opened as hidden buffers).
- If not given, <c-o> will open all files, each in a new window or new tab.
For the letters:
t - each in a new tab
h - each in a new horizontal split
v - each in a new vertical split
t - each file in a new tab.
h - each file in a new horizontal split.
v - each file in a new vertical split.
Reuse the current window:
tr,
hr,
@@ -349,17 +354,7 @@ Pressing <c-o> or <c-y> will then prompt for a keypress. The key can be:
r - open in current window (for <c-y> only)
<esc>, <c-c> - cancel and go back to the prompt.
Any other key - use the behavior specified with |g:ctrlp_open_new_file| and
|g:ctrlp_open_multi|.
*'g:ctrlp_dont_split'*
When opening a file with <cr>, |CtrlP| avoids opening it in windows created by
plugins, help and quickfix. Use this to setup some exceptions: >
let g:ctrlp_dont_split = 'netrw'
<
Acceptable values are partial names or filetypes of the special buffers. Use
|regexp| to specify the pattern. Example: >
let g:ctrlp_dont_split = 'netrw\|help\|quickfix'
<
|g:ctrlp_open_multiple_files|.
*'g:ctrlp_follow_symlinks'*
Set this to 1 to follow symbolic links when listing files: >
@@ -394,7 +389,7 @@ Example: >
See https://gist.github.com/1610859 for a working example.
===============================================================================
3. Commands *ctrlp-commands*
COMMANDS *ctrlp-commands*
*:CtrlP*
:CtrlP [starting-directory]
@@ -412,19 +407,19 @@ See https://gist.github.com/1610859 for a working example.
:CtrlPMRU
Open |CtrlP| in find Most-Recently-Used file mode.
*:ClearCtrlPCache*
:ClearCtrlPCache
*:CtrlPClearCache*
:CtrlPClearCache
Flush the cache for the current working directory. The same as pressing <F5>
inside |CtrlP|.
You can also enable/disable caching with the option |g:ctrlp_use_caching|.
*:ClearAllCtrlPCaches*
:ClearAllCtrlPCaches
*:CtrlPClearAllCaches*
:CtrlPClearAllCaches
Delete all the cache files saved in |g:ctrlp_cache_dir|.
*:ResetCtrlP*
:ResetCtrlP
Reset all options and take in new values of the option variables.
*:CtrlPReload*
:CtrlPReload
Load new values for the option variables.
-------------------------------------------------------------------------------
The following commands ignore the current value of |g:ctrlp_working_path_mode|:
@@ -439,7 +434,7 @@ The following commands ignore the current value of |g:ctrlp_working_path_mode|:
This acts like |:CtrlP| with |path_mode| = 2
===============================================================================
4. Mappings *ctrlp-mappings*
MAPPINGS *ctrlp-mappings*
*'ctrlp-<c-p>'*
<c-p>
@@ -448,14 +443,14 @@ The following commands ignore the current value of |g:ctrlp_working_path_mode|:
Once inside the prompt:~
<c-r> *'ctrlp-fullregexp'*
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 '>>>')
Toggle between the string mode and full |regexp| mode.
Note: in full |regexp| mode, the prompts base is 'r>>' instead of '>>>'
See also |input-formats| (guide) and |g:ctrlp_regexp_search| (option).
<c-d>
Toggle between full-path search and filename only search.
(note: in filename mode, the prompts base is '>d>' instead of '>>>')
Note: in filename mode, the prompts base is '>d>' instead of '>>>'
<c-f>, 'forward'
<c-up>
@@ -543,7 +538,8 @@ Once inside the prompt:~
- Remove deleted files from MRU list.
<F7>
Clear MRU list.
- Wipe MRU list.
- Delete MRU entries marked by <c-z>.
<insert>
Insert the word under the cursor (in the active buffer) into the prompt.
@@ -552,7 +548,7 @@ Once inside the prompt:~
<c-c>,
<c-g>
Exit |CtrlP|.
<c-c> can also be used to stop the scan if its taking too long.
Note: <c-c> can also be used to stop the scan if its taking too long.
Choose your own mappings with |g:ctrlp_prompt_mappings|.
@@ -565,7 +561,7 @@ When inside the match window (press <s-tab> to switch):~
matches that key.
===============================================================================
5. Input Formats *ctrlp-input-formats*
INPUT FORMATS *ctrlp-input-formats*
Formats for inputting in the prompt:~
@@ -613,7 +609,7 @@ f) Type the name of a non-existent file and press <c-y> to create it. Mark a
g) Submit ? to open this help file.
===============================================================================
6. Extensions *g:ctrlp-extensions*
EXTENSIONS *g:ctrlp-extensions*
Extensions are optional. To enable an extension, add its name to the variable
g:ctrlp_extensions: >
@@ -720,6 +716,48 @@ Statuslines:~
For rebuilding the statuslines, see |g:ctrlp_status_func|.
===============================================================================
MISCELLANEOUS CONFIGS *ctrlp-miscellaneous-configs*
* Use |wildignore| for |g:ctrlp_user_command|:
>
function! s:wig2cmd()
" Change wildignore into space or | separated groups
" e.g. .aux .out .toc .jpg .bmp .gif
" or .aux$\|.out$\|.toc$\|.jpg$\|.bmp$\|.gif$
let pats = ['[*\/]*\([?_.0-9A-Za-z]\+\)\([*\/]*\)\(\\\@<!,\|$\)','\\\@<!,']
let subs = has('win32') || has('win64') ? ['\1\3', ' '] : ['\1\2\3', '\\|']
let expr = substitute(&wig, pats[0], subs[0], 'g')
let expr = substitute(expr, pats[1], subs[1], 'g')
let expr = substitute(expr, '\\,', ',', 'g')
" Set the user_command option
let g:ctrlp_user_command = has('win32') || has('win64')
\ ? 'dir %s /-n /b /s /a-d | findstr /V /l "'.expr.'"'
\ : 'find %s -type f | grep -v "'.expr .'"'
endfunction
call s:wig2cmd()
<
(submitted by Rich Alesi <github.com/ralesi>)
* A standalone function to set the working directory to the projects root, or
to the parent directory of the current file if a root cant be found:
>
function! s:setcwd()
let cph = expand('%:p:h', 1)
if match(cph, '\v^<.+>://') >= 0 | retu | en
for mkr in ['.git/', '.hg/', '.svn/', '.bzr/', '_darcs/', '.vimprojects']
let wd = call('find'.(mkr =~ '/$' ? 'dir' : 'file'), [mkr, cph.';'])
if wd != '' | let &acd = 0 | brea | en
endfo
exe 'lc!' fnameescape(wd == '' ? cph : substitute(wd, mkr.'$', '.', ''))
endfunction
autocmd BufEnter * call s:setcwd()
<
(requires Vim 7.1.299+)
===============================================================================
CREDITS *ctrlp-credits*
@@ -736,32 +774,37 @@ gibhub, bitbucket, and through email.
Special thanks:~
* Woojong Koh <github.com/wjkoh>
Forked and suggested the support for VCS listing commands.
* Yasuhiro Matsumoto <github.com/mattn>
Added option to use Migemo for Japanese filenames.
* Kyo Nagashima <github.com/hail2u>
Made some enhancements to file opening mappings.
* Piet Delport <github.com/pjdelport>
Changed the default cache directory to meet XDG spec.
* Kent Sibilev <github.com/datanoise>
Debugged and made various patches.
* Simon Ruderich
* Yasuhiro Matsumoto <github.com/mattn>
* Ken Earley <github.com/kenearley>
* Kyo Nagashima <github.com/hail2u>
* Zak Johnson <github.com/zakj>
* Diego Viola <github.com/diegoviola>
* Piet Delport <github.com/pjdelport>
* Thibault Duplessis <github.com/ornicar>
* Kent Sibilev <github.com/datanoise>
* Tacahiroy <github.com/tacahiroy>
Bugfixes/Corrections.
* Luca Pette <github.com/lucapette>
===============================================================================
CHANGELOG *ctrlp-changelog*
+ New option: |g:ctrlp_mruf_last_entered| change MRU to recently-entered.
+ Rename:
*ClearCtrlPCache* -> |CtrlPClearCache|
*ClearAllCtrlPCaches* -> |CtrlPClearAllCaches|
*ResetCtrlP* -> |CtrlPReload|
Before 2012/03/02~
+ Rename:
*g:ctrlp_regexp_search* -> |g:ctrlp_regexp|,
*g:ctrlp_dont_split* -> |g:ctrlp_reuse_window|,
*g:ctrlp_jump_to_buffer* -> |g:ctrlp_switch_buffer|.
+ Rename and tweak:
*g:ctrlp_open_multi* -> |g:ctrlp_open_multiple_files|.
+ Deprecate *g:ctrlp_highlight_match*
+ Extend |g:ctrlp_user_command| to support multiple commands.
+ New option: |g:ctrlp_mruf_last_entered| change MRU to Recently-Entered.
Before 2012/01/15~
@@ -770,7 +813,7 @@ Before 2012/01/15~
+ New options: |g:ctrlp_arg_map| for <c-y>, <c-o> to accept an argument.
|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.
Before 2012/01/05~
@@ -790,29 +833,29 @@ Before 2011/11/30~
Before 2011/11/13~
+ New special input: '/' and '\' find root (section 5.e)
+ New special input: '/' and '\' find root (|ctrlp-input-formats| (e))
+ Remove ctrlp#SetWorkingPath().
+ Remove |g:ctrlp_mru_files|, make MRU permanent.
+ Extend |g:ctrlp_open_multi|, add new ways to open files.
+ New option: |g:ctrlp_dont_split|,
+ Remove *g:ctrlp_mru_files* and make MRU mode permanent.
+ Extend g:ctrlp_open_multi, add new ways to open files.
+ New option: g:ctrlp_dont_split,
|g:ctrlp_mruf_case_sensitive|
Before 2011/10/30~
+ New feature: Support for custom extensions.
<F5> also removes non-existent files from MRU list.
+ New option: |g:ctrlp_jump_to_buffer|
+ New option: g:ctrlp_jump_to_buffer
Before 2011/10/12~
+ New features: Open multiple files.
Pass Vims |++opt| and |+cmd| to the opening file
(section 5.c)
(|ctrlp-input-formats| (c))
Auto-complete each dir for |:CtrlP| [starting-directory]
+ New mappings: <c-z> mark/unmark a file to be opened with <c-o>.
<c-o> open all marked files.
+ New option: |g:ctrlp_open_multi|
+ Remove |g:ctrlp_persistent_input|, |g:ctrlp_live_update| and <c-^>.
+ New option: g:ctrlp_open_multi
+ Remove *g:ctrlp_persistent_input* *g:ctrlp_live_update* and <c-^>.
Before 2011/09/29~
@@ -824,22 +867,22 @@ Before 2011/09/29~
Before 2011/09/19~
+ New command: |ResetCtrlP|
+ New command: ResetCtrlP
+ New options: |g:ctrlp_max_files|,
|g:ctrlp_max_depth|,
|g:ctrlp_live_update|
g:ctrlp_live_update
+ New mapping: <c-^>
Before 2011/09/12~
+ Ability to cycle through matched lines in the match window.
+ Extend the behavior of |g:ctrlp_persistent_input|
+ Extend the behavior of g:ctrlp_persistent_input
+ Extend the behavior of |:CtrlP|
+ New options: |g:ctrlp_dotfiles|,
|g:ctrlp_clear_cache_on_exit|,
|g:ctrlp_highlight_match|,
g:ctrlp_highlight_match,
|g:ctrlp_user_command|
+ New special input: '..' (section 5.d)
+ New special input: '..' (|ctrlp-input-formats| (d))
+ New mapping: <F5>.
+ New commands: |:CtrlPCurWD|,
|:CtrlPCurFile|,
@@ -848,11 +891,11 @@ Before 2011/09/12~
+ New feature: Search in most recently used (MRU) files
+ New mapping: <c-b>.
+ Extended the behavior of <c-f>.
+ New options: |g:ctrlp_mru_files|,
+ New options: g:ctrlp_mru_files,
|g:ctrlp_mruf_max|,
|g:ctrlp_mruf_exclude|,
|g:ctrlp_mruf_include|
+ New command: |:CtrlPMRUFiles|
+ New command: |:CtrlPMRU|
First public release: 2011/09/06~

View File

@@ -18,6 +18,10 @@ com! -n=? -com=dir CtrlP cal ctrlp#init(0, <q-args>)
com! CtrlPBuffer cal ctrlp#init(1)
com! CtrlPMRUFiles cal ctrlp#init(2)
com! CtrlPClearCache cal ctrlp#clr()
com! CtrlPClearAllCaches cal ctrlp#clra()
com! CtrlPReload cal ctrlp#reset()
com! ClearCtrlPCache cal ctrlp#clr()
com! ClearAllCtrlPCaches cal ctrlp#clra()
com! ResetCtrlP cal ctrlp#reset()
@@ -26,7 +30,7 @@ com! CtrlPCurWD cal ctrlp#init(0, 0)
com! CtrlPCurFile cal ctrlp#init(0, 1)
com! CtrlPRoot cal ctrlp#init(0, 2)
if g:ctrlp_map != ''
if g:ctrlp_map != '' && !hasmapto(':<c-u>'.g:ctrlp_cmd.'<cr>', 'n')
exe 'nn <silent>' g:ctrlp_map ':<c-u>'.g:ctrlp_cmd.'<cr>'
en

View File

@@ -16,14 +16,17 @@ Full path fuzzy __file__, __buffer__, __mru__ and __tag__ finder for Vim.
Once CtrlP is open:
* Press `<c-f>` and `<c-b>` to switch between find file, buffer, and MRU file modes.
* Press `<c-f>` and `<c-b>` to switch between find file, buffer, and MRU file
modes.
* Press `<c-d>` to switch to filename only search instead of full path.
* Press `<F5>` to purge the cache for the current directory and get new files.
* Use `*` or `|` in the prompt to submit the string as a Vims regexp pattern.
* Or press `<c-r>` to switch to regexp mode.
* End the input string with a colon `:` followed by a command to execute after opening the file.
* End the input string with a colon `:` followed by a command to execute after
opening the file.
e.g. `abc:45` will open the file matched the pattern and jump to line 45.
* Submit two dots `..` as the input string to go backward the directory tree by 1 level.
* Submit two dots `..` as the input string to go backward the directory tree by
1 level.
* Use `<c-y>` to create a new file and its parent dirs.
* Use `<c-z>` to mark/unmark files and `<c-o>` to open them.
@@ -34,7 +37,8 @@ e.g. `abc:45` will open the file matched the pattern and jump to line 45.
let g:ctrlp_map = '<c-p>'
```
* When CtrlP is invoked, it automatically sets the working directory according to this variable:
* When CtrlP is invoked, it automatically sets its local working directory
according to this variable:
```vim
let g:ctrlp_working_path_mode = 2
@@ -43,19 +47,14 @@ e.g. `abc:45` will open the file matched the pattern and jump to line 45.
0 - dont manage working directory.
1 - the parent directory of the current file.
2 - the nearest ancestor that contains one of these directories or files:
`.git/` `.hg/` `.svn/` `.bzr/` `_darcs/`
.git/
.hg/
.bzr/
_darcs/
root.dir
* If you want to exclude directories or files from the search, you can use the Vims option `wildignore`
and/or the option `g:ctrlp_custom_ignore`. Examples:
* If you want to exclude directories or files from the search, use the Vims
option `wildignore` and/or the option `g:ctrlp_custom_ignore`. Examples:
```vim
set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " for Linux/MacOSX
set wildignore+=.git\*,.hg\*,.svn\* " for Windows
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
set wildignore+=tmp\*,*.swp,*.zip,*.exe " Windows
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$'
let g:ctrlp_custom_ignore = {
@@ -68,8 +67,8 @@ and/or the option `g:ctrlp_custom_ignore`. Examples:
* Use a custom file listing command with:
```vim
let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux
let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows
let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux
let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows
```
_Check [the docs][2] for more mappings, commands and options._