# HG changeset patch # User Brian Neal # Date 1325727442 21600 # Node ID 92af3257a26194846c2633be6a9241de2b705941 # Parent 611e13daeafb0d06bb345313a688d400c5e8c46f Update to latest ctrlp.vim. diff -r 611e13daeafb -r 92af3257a261 vim/vimfiles/autoload/ctrlp.vim --- a/vim/vimfiles/autoload/ctrlp.vim Wed Jan 04 19:34:22 2012 -0600 +++ b/vim/vimfiles/autoload/ctrlp.vim Wed Jan 04 19:37:22 2012 -0600 @@ -2,7 +2,7 @@ " File: autoload/ctrlp.vim " Description: Fuzzy file, buffer, mru and tag finder. " Author: Kien Nguyen -" Version: 1.6.4 +" Version: 1.6.5 " ============================================================================= " Static variables {{{1 @@ -11,13 +11,14 @@ let opts = { \ 'g:ctrlp_by_filename': ['s:byfname', 0], \ 'g:ctrlp_clear_cache_on_exit': ['s:clrex', 1], + \ 'g:ctrlp_custom_ignore': ['s:usrign', ''], \ 'g:ctrlp_dont_split': ['s:nosplit', ''], \ 'g:ctrlp_dotfiles': ['s:dotfiles', 1], \ 'g:ctrlp_extensions': ['s:extensions', []], \ 'g:ctrlp_follow_symlinks': ['s:folsym', 0], \ 'g:ctrlp_highlight_match': ['s:mathi', [1, 'Identifier']], \ 'g:ctrlp_lazy_update': ['s:lazy', 0], - \ 'g:ctrlp_jump_to_buffer': ['s:jmptobuf', 1], + \ 'g:ctrlp_jump_to_buffer': ['s:jmptobuf', 2], \ 'g:ctrlp_match_window_bottom': ['s:mwbottom', 1], \ 'g:ctrlp_match_window_reversed': ['s:mwreverse', 1], \ 'g:ctrlp_max_depth': ['s:maxdepth', 40], @@ -53,7 +54,7 @@ " 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:block-PmenuSel-blinkon0' } + \ 'gcr': 'a:blinkon0' } if s:lazy cal extend(s:glbs, { 'ut': ( s:lazy > 1 ? s:lazy : 250 ) }) @@ -63,6 +64,9 @@ let [s:compare_lim, s:nocache_lim, s:mltipats_lim] = [3000, 4000, 2000] " * Open & Close {{{1 fu! s:Open() + if exists('g:ctrlp_log') && g:ctrlp_log + sil! exe 'redi >>' ctrlp#utils#cachedir().s:lash.'ctrlp.log' + en let [s:cwd, s:winres] = [getcwd(), winrestcmd()] let [s:crfile, s:crfpath] = [expand('%:p', 1), expand('%:p:h', 1)] let [s:crword, s:crline] = [expand(''), getline('.')] @@ -95,9 +99,11 @@ let [g:ctrlp_lines, g:ctrlp_allfiles] = [[], []] exe s:winres unl! s:focus s:hisidx s:hstgot s:marked s:statypes s:cline s:init s:savestr - \ s:crfile s:crfpath s:crword s:crvisual s:tagfiles s:crline s:crcursor - \ g:ctrlp_nolimit s:crbufnr + \ g:ctrlp_nolimit cal ctrlp#recordhist() + if exists('g:ctrlp_log') && g:ctrlp_log + sil! redi END + en ec endf " * Clear caches {{{1 @@ -126,23 +132,45 @@ unl! s:cline endf " * Files() {{{1 -fu! s:GlobPath(dirs, allfiles, depth) +fu! s:Files() + let [cwd, cafile, g:ctrlp_allfiles] = [getcwd(), ctrlp#utils#cachefile(), []] + if g:ctrlp_newcache || !filereadable(cafile) || !s:caching + let lscmd = s:lsCmd() + " Get the list of files + if empty(lscmd) + cal s:GlobPath(cwd, 0) + el + sil! cal ctrlp#progress('Indexing...') + try | cal s:UserCmd(cwd, lscmd) | cat | retu [] | endt + en + " Remove base directory + cal ctrlp#rmbasedir(g:ctrlp_allfiles) + let read_cache = 0 + el + let g:ctrlp_allfiles = ctrlp#utils#readfile(cafile) + let read_cache = 1 + en + if len(g:ctrlp_allfiles) <= s:compare_lim + cal sort(g:ctrlp_allfiles, 'ctrlp#complen') + en + cal s:writecache(read_cache, cafile) + retu g:ctrlp_allfiles +endf + +fu! s:GlobPath(dirs, depth) let entries = split(globpath(a:dirs, s:glob), "\n") - if !s:folsym - let entries = filter(entries, 'getftype(v:val) != "link"') + if s:usrign != '' + cal filter(entries, 'v:val !~ s:usrign') en - let g:ctrlp_allfiles = filter(copy(entries), '!isdirectory(v:val)') - let ftrfunc = s:dotfiles ? 'ctrlp#dirfilter(v:val)' : 'isdirectory(v:val)' - let alldirs = filter(entries, ftrfunc) - cal extend(g:ctrlp_allfiles, a:allfiles, 0) - let depth = a:depth + 1 - if !empty(alldirs) && !s:maxfiles(len(g:ctrlp_allfiles)) && depth <= s:maxdepth + let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1] + cal extend(g:ctrlp_allfiles, dnf[1]) + if !empty(dnf[0]) && !s:maxf(len(g:ctrlp_allfiles)) && depth <= s:maxdepth sil! cal ctrlp#progress(len(g:ctrlp_allfiles)) - cal s:GlobPath(join(alldirs, ','), g:ctrlp_allfiles, depth) + cal s:GlobPath(join(dnf[0], ','), depth) en endf -fu! s:UserCommand(path, lscmd) +fu! s:UserCmd(path, lscmd) let path = a:path if exists('+ssl') && &ssl let [ssl, &ssl, path] = [&ssl, 0, tr(path, '/', '\')] @@ -158,34 +186,26 @@ en endf -fu! s:Files() - let [cwd, cache_file] = [getcwd(), ctrlp#utils#cachefile()] - if g:ctrlp_newcache || !filereadable(cache_file) || !s:caching - let lscmd = s:lscommand() - " Get the list of files - if empty(lscmd) - cal s:GlobPath(cwd, [], 0) - el - sil! cal ctrlp#progress('Waiting...') - try | cal s:UserCommand(cwd, lscmd) | cat | retu [] | endt +fu! s:lsCmd() + let cmd = s:usrcmd + if type(cmd) == 1 + retu cmd + elsei type(cmd) == 3 && len(cmd) >= 2 && !empty(cmd[0]) && !empty(cmd[1]) + let rmarker = cmd[0] + " Find a repo root + cal s:findroot(getcwd(), rmarker, 0, 1) + if !exists('s:vcsroot') || ( exists('s:vcsroot') && empty(s:vcsroot) ) + " Try the secondary_command + retu len(cmd) == 3 ? cmd[2] : '' en - " Remove base directory - cal ctrlp#rmbasedir(g:ctrlp_allfiles) - let read_cache = 0 - el - let g:ctrlp_allfiles = ctrlp#utils#readfile(cache_file) - let read_cache = 1 + let s:vcscmd = s:lash == '\' ? 1 : 0 + retu cmd[1] en - if len(g:ctrlp_allfiles) <= s:compare_lim - cal sort(g:ctrlp_allfiles, 'ctrlp#complen') - en - cal s:writecache(read_cache, cache_file) - retu g:ctrlp_allfiles endf fu! s:Buffers() "{{{1 let allbufs = [] for each in range(1, bufnr('$')) - if getbufvar(each, '&bl') && each != 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, ':p')) @@ -195,14 +215,11 @@ retu allbufs endf " * MatchedItems() {{{1 -fu! s:MatchIt(items, pat, limit, ispathitem) - let [items, pat, limit, newitems] = [a:items, a:pat, a:limit, []] - let mfunc = s:byfname && a:ispathitem ? 's:matchfname' - \ : s:itemtype > 2 && len(items) < 30000 && !a:ispathitem ? 's:matchtab' - \ : 'match' - for item in items - if call(mfunc, [item, pat]) >= 0 | cal add(newitems, item) | en - if limit > 0 && len(newitems) >= limit | brea | en +fu! s:MatchIt(items, pat, limit, ispathitem, mfunc) + let newitems = [] + for item in a:items + if call(a:mfunc, [item, a:pat]) >= 0 | cal add(newitems, item) | en + if a:limit > 0 && len(newitems) >= a:limit | brea | en endfo retu newitems endf @@ -213,8 +230,11 @@ if len(items) >= s:mltipats_lim | let pats = [pats[-1]] | en cal map(pats, 'substitute(v:val, "\\\~", "\\\\\\~", "g")') if !s:regexp | cal map(pats, 'escape(v:val, ".")') | en + let mfunc = s:byfname && ipt ? 's:matchfname' + \ : s:itemtype > 2 && len(items) < 30000 && !ipt ? 's:matchtab' + \ : 'match' " Loop through the patterns - for each in pats + for pat in pats " If newitems is small, set it as items to search in if exists('newitems') && len(newitems) < limit let items = copy(newitems) @@ -223,7 +243,7 @@ retu exists('newitems') ? newitems : [] el " Start here, go back up if have 2 or more in pats " Loop through the items - let newitems = s:MatchIt(items, each, limit, ipt) + let newitems = s:MatchIt(items, pat, limit, ipt, mfunc) en endfo let s:matches = len(newitems) @@ -263,7 +283,7 @@ if len(array) > 1 for item in range(1, len(array) - 1) " Separator - let sep = exists('a:1') ? a:1 : '[^'.array[item-1].']\{-}' + let sep = a:0 ? a:1 : '[^'.array[item-1].']\{-}' let nitem .= sep.array[item] cal add(newpats, nitem) endfo @@ -294,7 +314,7 @@ en if s:mwreverse | cal reverse(lines) | en let s:matched = copy(lines) - cal map(lines, 'substitute(v:val, "^", "> ", "")') + cal map(lines, '"> ".v:val') cal setline(1, lines) exe 'keepj norm!' s:mwreverse ? 'G' : 'gg' keepj norm! 1| @@ -312,13 +332,15 @@ let oldstr = exists('s:savestr') ? s:savestr : '' let pats = s:SplitPattern(a:str) " Get the new string sans tail - let notail = substitute(a:str, ':\([^:]\|\\:\)*$', '', 'g') + let notail = substitute(a:str, '\\\\', '\', 'g') + let notail = substitute(notail, '\\\@= 0 ) && !lazy + if a:upd && !lazy && ( s:matches || s:regexp + \ || match(str, '[*|]') >= 0 || match(str, '\\\:\([^:]\|\\:\)*$') >= 0 ) sil! cal s:Update(str) en sil! cal ctrlp#statusline() @@ -541,7 +564,7 @@ \ 'ToggleFocus()': [''], \ 'ToggleRegex()': [''], \ 'ToggleByFname()': [''], - \ 'ToggleType(1)': ['', '', ''], \ 'ToggleType(-1)': ['', ''], \ 'PrtInsert("w")': [''], \ 'PrtInsert("s")': [''], @@ -563,7 +586,7 @@ en " Correct arrow keys in terminal if ( has('termresponse') && !empty(v:termresponse) ) - \ || &term =~? 'xterm\|\','\B ','\C ','\D '] exe lcmap.' ['.each endfo @@ -669,19 +692,19 @@ let filpath = s:itemtype ? matchstr : getcwd().s:lash.matchstr cal s:PrtExit() let bufnum = bufnr(filpath) - if s:jmptobuf && bufnum > 0 && md == 'e' + if s:jmptobuf && bufnum > 0 && md =~ 'e\|t' let [jmpb, bufwinnr] = [1, bufwinnr(bufnum)] - let buftab = s:jmptobuf > 1 ? s:buftab(bufnum) : [0, 0] + let buftab = s:jmptobuf > 1 ? s:buftab(bufnum, md) : [0, 0] let j2l = a:0 ? a:1 : str2nr(matchstr(s:tail(), '^ +\zs\d\+$')) en " Switch to existing buffer or open new one - if exists('jmpb') && buftab[0] - exe 'tabn' buftab[1] - exe buftab[0].'winc w' - if j2l | cal s:j2l(j2l) | en - elsei exists('jmpb') && bufwinnr > 0 + if exists('jmpb') && bufwinnr > 0 && md != 't' exe bufwinnr.'winc w' - if j2l | cal s:j2l(j2l) | en + if j2l | cal ctrlp#j2l(j2l) | en + elsei exists('jmpb') && buftab[0] + exe 'tabn' buftab[0] + exe buftab[1].'winc w' + if j2l | cal ctrlp#j2l(j2l) | en el " Determine the command to use let cmd = md == 't' || s:splitwin == 1 ? 'tabe' @@ -692,8 +715,31 @@ en endf +fu! s:SpecInputs() + let str = join(s:prompt, '') + let type = s:itemtype > 2 ? + \ g:ctrlp_ext_vars[s:itemtype - ( g:ctrlp_builtins + 1 )][3] : s:itemtype + if str == '..' && type =~ '0\|dir' + cal s:parentdir(getcwd()) + cal s:SetLines(s:itemtype) + cal s:PrtClear() + retu 1 + elsei ( str == '/' || str == '\' ) && type =~ '0\|dir' + cal s:SetWD(2, 0) + cal s:SetLines(s:itemtype) + cal s:PrtClear() + retu 1 + elsei str == '?' + cal s:PrtExit() + let hlpwin = &columns > 159 ? '| vert res 80' : '' + sil! exe 'bo vert h ctrlp-mappings' hlpwin '| norm! 0' + retu 1 + en + retu 0 +endf + fu! s:AcceptSelection(mode) - if a:mode == 'e' | if s:specinputs() | retu | en | en + if a:mode == 'e' | if s:SpecInputs() | retu | en | en " Get the selected line let matchstr = matchstr(getline('.'), '^> \zs.\+\ze\t*$') if empty(matchstr) | retu | en @@ -778,7 +824,7 @@ let spt = len(s:opmul) > 1 ? cmds[matchstr(s:opmul, '\w$')] : 'vne' let nr = matchstr(s:opmul, '^\d\+') exe wnr.'winc w' - for [ke, va] in items(mkd) + for va in values(mkd) let cmd = ic == 1 ? 'e' : spt cal s:openfile(cmd, va) if nr > 1 && nr < ic | clo! | el | let ic += 1 | en @@ -885,22 +931,44 @@ redr endf " Paths {{{2 -fu! ctrlp#dirfilter(val) - retu isdirectory(a:val) && match(a:val, '[\/]\.\{,2}$') < 0 ? 1 : 0 +fu! s:ispathitem() + let ext = s:itemtype - ( g:ctrlp_builtins + 1 ) + retu s:itemtype < 3 || ( s:itemtype > 2 && g:ctrlp_ext_vars[ext][3] == 'dir' ) endf -fu! s:ispathitem() - let ext = s:itemtype - ( g:ctrlp_builtins + 1 ) - if s:itemtype < 3 || ( s:itemtype > 2 && g:ctrlp_ext_vars[ext][3] == 'dir' ) - retu 1 - en - retu 0 +fu! ctrlp#dirnfile(entries) + let [items, cwd] = [[[], []], getcwd().s:lash] + for each in a:entries + let etype = getftype(each) + if etype == 'dir' + if s:dotfiles | if match(each, '[\/]\.\{,2}$') < 0 + cal add(items[0], each) + en | el + cal add(items[0], each) + en + elsei etype == 'link' + if s:folsym + let isfile = !isdirectory(each) + if !s:samerootsyml(each, isfile, cwd) + cal add(items[isfile], each) + en + en + elsei etype == 'file' + cal add(items[1], each) + en + endfo + retu items +endf + +fu! s:samerootsyml(each, isfile, cwd) + let resolve = resolve(a:each) + let resolve = ( a:isfile ? fnamemodify(resolve, ':p:h') : resolve ).s:lash + retu !( stridx(resolve, a:cwd) && ( stridx(a:cwd, resolve) || a:isfile ) ) endf fu! ctrlp#rmbasedir(items) - let path = &ssl || !exists('+ssl') ? getcwd().'/' : - \ substitute(getcwd(), '\\', '\\\\', 'g').'\\' - retu map(a:items, 'substitute(v:val, path, "", "g")') + let idx = strlen(getcwd()) + 1 + retu map(a:items, 'strpart(v:val, idx)') endf fu! s:parentdir(curr) @@ -981,7 +1049,7 @@ fu! s:highlight(pat, grp) cal clearmatches() - if !empty(a:pat) && a:pat != '..' && s:itemtype < 3 + if !empty(a:pat) && s:itemtype < 3 let pat = substitute(a:pat, '\~', '\\~', 'g') if !s:regexp | let pat = escape(pat, '.') | en " Match only filename @@ -995,7 +1063,7 @@ endf fu! s:dohighlight() - retu type(s:mathi) == 3 && len(s:mathi) == 2 && s:mathi[0] + retu type(s:mathi) == 3 && len(s:mathi) > 1 && s:mathi[0] \ && exists('*clearmatches') endf " Prompt history {{{2 @@ -1026,9 +1094,9 @@ fu! s:remarksigns() if !s:dosigns() | retu | en - let nls = s:matched + let [nls, head] = [s:matched, s:itemtype ? '' : getcwd().s:lash] for ic in range(1, len(nls)) - let filpath = s:itemtype ? nls[ic - 1] : getcwd().s:lash.nls[ic - 1] + let filpath = head.nls[ic - 1] let key = s:dictindex(s:marked, filpath) if key > 0 exe 'sign place' key 'line='.ic.' name=ctrlpmark buffer='.s:bufnr @@ -1051,14 +1119,14 @@ retu filter(range(1, max(keys(a:dict))), '!has_key(a:dict, v:val)') endf " Buffers {{{2 -fu! s:buftab(bufnum) - for nr in range(1, tabpagenr('$')) - let buflist = tabpagebuflist(nr) - if match(buflist, a:bufnum) >= 0 - let [buftabnr, tabwinnrs] = [nr, tabpagewinnr(nr, '$')] - for ewin in range(1, tabwinnrs) - if buflist[ewin - 1] == a:bufnum - retu [ewin, buftabnr] +fu! s:buftab(bufnum, md) + for tabnr in range(1, tabpagenr('$')) + if tabpagenr() == tabnr && a:md == 't' | con | en + let buflist = tabpagebuflist(tabnr) + if index(buflist, a:bufnum) >= 0 + for winnr in range(1, tabpagewinnr(tabnr, '$')) + if buflist[winnr - 1] == a:bufnum + retu [tabnr, winnr] en endfo en @@ -1097,7 +1165,7 @@ fu! s:setupblank() setl noswf nobl nonu nowrap nolist nospell nocuc wfh setl fdc=0 fdl=99 tw=0 bt=nofile bh=unload - if v:version >= 703 + if v:version > 702 setl nornu noudf cc=0 en endf @@ -1126,39 +1194,15 @@ endf fu! s:sanstail(str) - " Restore the number of backslashes - let str = substitute(a:str, '\\\\', '\', 'g') + let [str, pat] = [substitute(a:str, '\\\\', '\', 'g'), '\([^:]\|\\:\)*$'] unl! s:optail - if match(str, ':\([^:]\|\\:\)*$') >= 0 - let s:optail = matchstr(str, ':\zs\([^:]\|\\:\)*$') - retu substitute(str, ':\([^:]\|\\:\)*$', '', 'g') + if match(str, '\\\@= 0 + let s:optail = matchstr(str, '\\\@ 2 ? - \ g:ctrlp_ext_vars[s:itemtype - ( g:ctrlp_builtins + 1 )][3] : s:itemtype - if str == '..' && type =~ '0\|dir' - cal s:parentdir(getcwd()) - cal s:SetLines(s:itemtype) - cal s:PrtClear() - retu 1 - elsei ( str == '/' || str == '\' ) && type =~ '0\|dir' - cal s:SetWD(2, 0) - cal s:SetLines(s:itemtype) - cal s:PrtClear() - retu 1 - elsei str == '?' - cal s:PrtExit() - let hlpwin = &columns > 159 ? '| vert res 80' : '' - sil! exe 'bo vert h ctrlp-mappings' hlpwin '| norm! 0' - retu 1 - en - retu 0 -endf - fu! s:lastvisual() let cview = winsaveview() let [ovreg, ovtype] = [getreg('v'), getregtype('v')] @@ -1172,7 +1216,7 @@ endf fu! ctrlp#msg(msg) - echoh Identifier | echon "CtrlP: ".a:msg | echoh None + redr | echoh Identifier | echon "CtrlP: ".a:msg | echoh None endf fu! s:openfile(cmd, filpath, ...) @@ -1181,10 +1225,9 @@ try exe cmd.tail.' '.ctrlp#fnesc(a:filpath) cat - cal ctrlp#msg("Operation can't be completed. Make sure filename is valid.") fina if !empty(tail) - sil! norm! zOzz + sil! norm! zvzz en endt endf @@ -1197,9 +1240,9 @@ en endf -fu! s:j2l(nr) +fu! ctrlp#j2l(nr) exe a:nr - sil! norm! zOzz + sil! norm! zvzz endf fu! s:regexfilter(str) @@ -1228,7 +1271,7 @@ retu match(split(a:item, '\t\+[^\t]\+$')[0], a:pat) endf -fu! s:maxfiles(len) +fu! s:maxf(len) retu s:maxfiles && a:len > s:maxfiles ? 1 : 0 endf @@ -1248,23 +1291,6 @@ cal insert(data, str, pos) cal s:writecache(0, ctrlp#utils#cachefile()) endf - -fu! s:lscommand() - let cmd = s:usrcmd - if type(cmd) == 1 - retu cmd - elsei type(cmd) == 3 && len(cmd) >= 2 && !empty(cmd[0]) && !empty(cmd[1]) - let rmarker = cmd[0] - " Find a repo root - cal s:findroot(getcwd(), rmarker, 0, 1) - if !exists('s:vcsroot') || ( exists('s:vcsroot') && empty(s:vcsroot) ) - " Try the secondary_command - retu len(cmd) == 3 ? cmd[2] : '' - en - let s:vcscmd = s:lash == '\' ? 1 : 0 - retu cmd[1] - en -endf " Extensions {{{2 fu! s:tagfiles() retu filter(map(tagfiles(), 'fnamemodify(v:val, ":p")'), 'filereadable(v:val)') @@ -1300,13 +1326,11 @@ if exists('s:init') | retu | en let [s:matches, s:init] = [1, 1] cal s:Open() - cal s:SetWD(exists('a:1') ? a:1 : '') + cal s:SetWD(a:0 ? a:1 : '') cal s:MapKeys() cal s:SetLines(a:type) cal s:BuildPrompt(1) - if has('syntax') && exists('g:syntax_on') - cal s:syntax() - en + if has('syntax') && exists('g:syntax_on') | cal s:syntax() | en endf if has('autocmd') "{{{1 aug CtrlPAug diff -r 611e13daeafb -r 92af3257a261 vim/vimfiles/autoload/ctrlp/buffertag.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/vimfiles/autoload/ctrlp/buffertag.vim Wed Jan 04 19:37:22 2012 -0600 @@ -0,0 +1,213 @@ +" ============================================================================= +" File: autoload/ctrlp/buffertag.vim +" Description: Buffer Tag extension +" Maintainer: Kien Nguyen +" ============================================================================= + +" Init {{{1 +if exists('g:loaded_ctrlp_buftag') && g:loaded_ctrlp_buftag + fini +en +let g:loaded_ctrlp_buftag = 1 + +let s:buftag_var = ['ctrlp#buffertag#init(s:crfile, s:crbufnr)', + \ 'ctrlp#buffertag#accept', 'buffer tags', 'bft'] + +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] + +let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) + +fu! s:opts() + let opts = { + \ 'g:ctrlp_buftag_systemenc': ['s:enc', &enc], + \ 'g:ctrlp_buftag_ctags_bin': ['s:bin', ''], + \ 'g:ctrlp_buftag_types': ['s:usr_types', ''], + \ } + for [ke, va] in items(opts) + exe 'let' va[0] '=' string(exists(ke) ? eval(ke) : va[1]) + endfo +endf +cal s:opts() + +fu! s:bins() + let bins = [ + \ 'ctags-exuberant', + \ 'exuberant-ctags', + \ 'exctags', + \ '/usr/local/bin/ctags', + \ '/opt/local/bin/ctags', + \ 'ctags', + \ 'ctags.exe', + \ 'tags', + \ ] + if empty(s:bin) + for bin in bins | if executable(bin) + let s:bin = bin + brea + en | endfo + el + let s:bin = expand(s:bin, 1) + en +endf +cal s:bins() + +" s:types {{{2 +let s:types = { + \ 'asm' : '%sasm%sasm%sdlmt', + \ 'aspperl': '%sasp%sasp%sfsv', + \ 'aspvbs' : '%sasp%sasp%sfsv', + \ 'awk' : '%sawk%sawk%sf', + \ 'beta' : '%sbeta%sbeta%sfsv', + \ 'c' : '%sc%sc%sdgsutvf', + \ 'cpp' : '%sc++%sc++%snvdtcgsuf', + \ 'cs' : '%sc#%sc#%sdtncEgsipm', + \ 'cobol' : '%scobol%scobol%sdfgpPs', + \ 'eiffel' : '%seiffel%seiffel%scf', + \ 'erlang' : '%serlang%serlang%sdrmf', + \ 'expect' : '%stcl%stcl%scfp', + \ 'fortran': '%sfortran%sfortran%spbceiklmntvfs', + \ 'html' : '%shtml%shtml%saf', + \ 'java' : '%sjava%sjava%spcifm', + \ 'javascript': '%sjavascript%sjavascript%sf', + \ 'lisp' : '%slisp%slisp%sf', + \ 'lua' : '%slua%slua%sf', + \ 'make' : '%smake%smake%sm', + \ 'pascal' : '%spascal%spascal%sfp', + \ 'perl' : '%sperl%sperl%sclps', + \ 'php' : '%sphp%sphp%scdvf', + \ 'python' : '%spython%spython%scmf', + \ 'rexx' : '%srexx%srexx%ss', + \ 'ruby' : '%sruby%sruby%scfFm', + \ 'scheme' : '%sscheme%sscheme%ssf', + \ 'sh' : '%ssh%ssh%sf', + \ 'csh' : '%ssh%ssh%sf', + \ 'zsh' : '%ssh%ssh%sf', + \ 'slang' : '%sslang%sslang%snf', + \ 'sml' : '%ssml%ssml%secsrtvf', + \ 'sql' : '%ssql%ssql%scFPrstTvfp', + \ 'tcl' : '%stcl%stcl%scfmp', + \ 'vera' : '%svera%svera%scdefgmpPtTvx', + \ 'verilog': '%sverilog%sverilog%smcPertwpvf', + \ 'vim' : '%svim%svim%savf', + \ 'yacc' : '%syacc%syacc%sl', + \ } + +cal map(s:types, 'printf(v:val, "--language-force=", " --", "-types=")') + +if executable('jsctags') + cal extend(s:types, { 'javascript': { 'args': '-f -', 'bin': 'jsctags' } }) +en + +if type(s:usr_types) == 4 + cal extend(s:types, s:usr_types) +en +" Utilities {{{1 +fu! s:validfile(fname, ftype) + if ( !empty(a:fname) || !empty(a:ftype) ) && filereadable(a:fname) + \ && index(keys(s:types), a:ftype) >= 0 | retu 1 | en + retu 0 +endf + +fu! s:exectags(cmd) + if exists('+ssl') + let [ssl, &ssl] = [&ssl, 0] + en + if &sh =~ 'cmd\.exe' + let [sxq, &sxq, shcf, &shcf] = [&sxq, '"', &shcf, '/s /c'] + en + let output = system(a:cmd) + if &sh =~ 'cmd\.exe' + let [&sxq, &shcf] = [sxq, shcf] + en + if exists('+ssl') + let &ssl = ssl + en + retu output +endf + +fu! s:exectagsonfile(fname, ftype) + let [ags, ft] = ['-f - --sort=no --excmd=pattern --fields=nKs ', a:ftype] + if type(s:types[ft]) == 1 + let ags .= s:types[ft] + let bin = s:bin + elsei type(s:types[ft]) == 4 + let ags = s:types[ft]['args'] + let bin = expand(s:types[ft]['bin'], 1) + en + if empty(bin) | retu '' | en + let cmd = s:esctagscmd(bin, ags, a:fname) + if empty(cmd) | retu '' | en + let output = s:exectags(cmd) + if v:shell_error || output =~ 'Warning: cannot open' | retu '' | en + retu output +endf + +fu! s:esctagscmd(bin, args, ...) + if exists('+ssl') + let [ssl, &ssl] = [&ssl, 0] + en + let fname = a:0 == 1 ? shellescape(a:1) : '' + let cmd = shellescape(a:bin).' '.a:args.' '.fname + if exists('+ssl') + let &ssl = ssl + en + if has('iconv') + let last = s:enc != &enc ? s:enc : !empty($LANG) ? $LANG : &enc + let cmd = iconv(cmd, &enc, last) + en + if empty(cmd) + cal ctrlp#msg("Encoding conversion failed!") + en + retu cmd +endf + +fu! s:process(fname, ftype) + if !s:validfile(a:fname, a:ftype) | retu [] | endif + let ftime = getftime(a:fname) + if has_key(g:ctrlp_buftags, a:fname) + \ && g:ctrlp_buftags[a:fname]['time'] >= ftime + let data = g:ctrlp_buftags[a:fname]['data'] + el + let data = s:exectagsonfile(a:fname, a:ftype) + let cache = { a:fname : { 'time': ftime, 'data': data } } + cal extend(g:ctrlp_buftags, cache) + en + let [raw, lines] = [split(data, '\n\+'), []] + for line in raw | if len(split(line, ';"')) == 2 + cal add(lines, s:parseline(line)) + en | endfo + retu lines +endf + +fu! s:parseline(line) + let eval = '\v^([^\t]+)\t(.+)\t\/\^(.+)\$\/\;\"\t(.+)\tline(no)?\:(\d+)' + let vals = matchlist(a:line, eval) + if empty(vals) | retu '' | en + retu vals[1].' '.vals[4].'|'.vals[6].'| '.vals[3] +endf +" Public {{{1 +fu! ctrlp#buffertag#init(fname, bufnr) + sy match CtrlPTabExtra '\zs\t.*\ze$' + hi link CtrlPTabExtra Comment + retu s:process(a:fname, get(split(getbufvar(a:bufnr, '&ft'), '\.'), 0, '')) +endf + +fu! ctrlp#buffertag#accept(mode, str) + cal ctrlp#exit() + if a:mode == 't' + tab sp + elsei a:mode == 'h' + sp + elsei a:mode == 'v' + vs + en + cal ctrlp#j2l(matchstr(a:str, '^[^\t]\+\t\+[^\t|]\+|\zs\d\+\ze|')) +endf + +fu! ctrlp#buffertag#id() + retu s:id +endf +"}}} + +" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 diff -r 611e13daeafb -r 92af3257a261 vim/vimfiles/autoload/ctrlp/dir.vim --- a/vim/vimfiles/autoload/ctrlp/dir.vim Wed Jan 04 19:34:22 2012 -0600 +++ b/vim/vimfiles/autoload/ctrlp/dir.vim Wed Jan 04 19:37:22 2012 -0600 @@ -11,12 +11,11 @@ let [g:loaded_ctrlp_dir, g:ctrlp_newdir] = [1, 0] let s:ars = [ - \ 's:folsym', - \ 's:dotfiles', \ 's:maxdepth', \ 's:maxfiles', \ 's:compare_lim', \ 's:glob', + \ 's:usrign', \ ] let s:dir_var = ['ctrlp#dir#init('.join(s:ars, ', ').')', 'ctrlp#dir#accept', @@ -29,17 +28,15 @@ " Utilities {{{1 fu! s:globdirs(dirs, depth) let entries = split(globpath(a:dirs, s:glob), "\n") - if !s:folsym - let entries = filter(entries, 'getftype(v:val) != "link"') + if s:usrign != '' + cal filter(entries, 'v:val !~ s:usrign') en - let ftrfunc = s:dotfiles ? 'ctrlp#dirfilter(v:val)' : 'isdirectory(v:val)' - let alldirs = filter(entries, ftrfunc) - cal extend(g:ctrlp_alldirs, alldirs) - let depth = a:depth + 1 - if !empty(g:ctrlp_alldirs) && !s:max(len(g:ctrlp_alldirs), s:maxfiles) + let [dirs, depth] = [ctrlp#dirnfile(entries)[0], a:depth + 1] + cal extend(g:ctrlp_alldirs, dirs) + if !empty(dirs) && !s:max(len(g:ctrlp_alldirs), s:maxfiles) \ && depth <= s:maxdepth sil! cal ctrlp#progress(len(g:ctrlp_alldirs)) - cal s:globdirs(join(alldirs, ','), depth) + cal s:globdirs(join(dirs, ','), depth) en endf diff -r 611e13daeafb -r 92af3257a261 vim/vimfiles/autoload/ctrlp/line.vim --- a/vim/vimfiles/autoload/ctrlp/line.vim Wed Jan 04 19:34:22 2012 -0600 +++ b/vim/vimfiles/autoload/ctrlp/line.vim Wed Jan 04 19:37:22 2012 -0600 @@ -10,7 +10,7 @@ en let g:loaded_ctrlp_line = 1 -let s:line_var = ['ctrlp#line#init()', 'ctrlp#line#accept', 'lines', 'line'] +let s:line_var = ['ctrlp#line#init()', 'ctrlp#line#accept', 'lines', 'lns'] 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] diff -r 611e13daeafb -r 92af3257a261 vim/vimfiles/autoload/ctrlp/quickfix.vim --- a/vim/vimfiles/autoload/ctrlp/quickfix.vim Wed Jan 04 19:34:22 2012 -0600 +++ b/vim/vimfiles/autoload/ctrlp/quickfix.vim Wed Jan 04 19:37:22 2012 -0600 @@ -43,7 +43,7 @@ cat cal ctrlp#msg("Invalid command or argument.") fina - cal cursor(items[2], items[3]) | sil! norm! zOzz + cal cursor(items[2], items[3]) | sil! norm! zvzz endt endf diff -r 611e13daeafb -r 92af3257a261 vim/vimfiles/autoload/ctrlp/utils.vim --- a/vim/vimfiles/autoload/ctrlp/utils.vim Wed Jan 04 19:34:22 2012 -0600 +++ b/vim/vimfiles/autoload/ctrlp/utils.vim Wed Jan 04 19:37:22 2012 -0600 @@ -61,7 +61,7 @@ endf fu! ctrlp#utils#glob(...) - retu call('glob', v:version > 701 ? a:000 : a:1) + retu call('glob', v:version > 701 ? a:000 : [a:1]) endf "}}} diff -r 611e13daeafb -r 92af3257a261 vim/vimfiles/doc/ctrlp.txt --- a/vim/vimfiles/doc/ctrlp.txt Wed Jan 04 19:34:22 2012 -0600 +++ b/vim/vimfiles/doc/ctrlp.txt Wed Jan 04 19:37:22 2012 -0600 @@ -1,4 +1,4 @@ -*ctrlp.txt* Fuzzy file, buffer, mru and tag finder. v1.6.4 +*ctrlp.txt* Fuzzy file, buffer, mru and tag finder. v1.6.5 *CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'* =============================================================================== # # @@ -23,9 +23,9 @@ =============================================================================== 1. Intro *ctrlp-intro* -Full path fuzzy file, buffer and MRU file finder with an intuitive interface. +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 -Vim’s |regexp| as search pattern, built-in MRU monitoring, project’s root +Vim’s |regexp| as search pattern, built-in MRU files monitoring, project’s root finder, and more. To enable optional extensions (tag, quickfix, dir...), see |ctrlp-extensions|. @@ -40,8 +40,13 @@ let g:ctrlp_map = '' < + *'g:ctrlp_cmd'* +Set the default opening command to use when pressing the above mapping: > + let g:ctrlp_cmd = 'CtrlP' +< + *'g:loaded_ctrlp'* -Use this option to disable the plugin completely: > +Use this to disable the plugin completely: > let g:loaded_ctrlp = 1 < @@ -72,9 +77,10 @@ < *'g:ctrlp_jump_to_buffer'* -Set this to 0 to disable the jump-to-open-buffer feature. Set to 2 to also jump -tab if the selected buffer’s opened in another tab: > - let g:ctrlp_jump_to_buffer = 1 +Set this to 0 to disable the jump-to-open-buffer feature. +Set to 2 to also jump tab if the selected buffer’s opened in another tab. +Set to 1 to only jump to it if it’s opened in the current tab: > + let g:ctrlp_jump_to_buffer = 2 < *'g:ctrlp_working_path_mode'* @@ -137,7 +143,7 @@ \ 'ToggleFocus()': [''], \ 'ToggleRegex()': [''], \ 'ToggleByFname()': [''], - \ 'ToggleType(1)': ['', '', ''], \ 'ToggleType(-1)': ['', ''], \ 'PrtCurStart()': [''], \ 'PrtCurEnd()': [''], @@ -192,21 +198,24 @@ Set this to 0 if you don’t want |CtrlP| to search for dotfiles and dotdirs: > let g:ctrlp_dotfiles = 1 < -You can also use |'wildignore'| to exclude anything from the search. -e.g. exclude version control directories from the results: > +You can use |'wildignore'| to exclude anything from the search. +e.g. exclude version control directories: > set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " Linux/MacOSX set wildignore+=.git\*,.hg\*,.svn\* " Windows < -Note: the `*/` in front of each dotfile glob is required for the dotfiles -search feature to work correctly along side with |wildignore|. If you’ve -disabled dotfiles search (set |g:ctrlp_dotfiles| to 0), then you can ignore -this. +Note: the `*/` in front of each glob is required. Other note: |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|. + *'g:ctrlp_custom_ignore'* +In addition to |'wildignore'|, use this for files and directories you want only +|CtrlP| to not show. Use |regexp| to specify the pattern: > + let g:ctrlp_custom_ignore = '' +< + *'g:ctrlp_highlight_match'* Use this to enable/disable highlighting of the matched patterns and to specify the highlight group that’ll be used: > @@ -491,7 +500,7 @@ backward in the directory tree by 1 level. If the parent directory is large, this might be slow. -e) Similarly submit '/' or '\' to find and go to the project’s root. If the +e) Similarly, submit '/' or '\' to find and go to the project’s root. If the 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). @@ -507,7 +516,7 @@ Extensions are optional. To enable an extension, add its name to the variable g:ctrlp_extensions: > - let g:ctrlp_extensions = ['tag', 'quickfix', 'dir'] + let g:ctrlp_extensions = ['tag', 'buffertag', 'quickfix', 'dir'] < The order of the items will be the order they appear on the statusline and when using , . @@ -522,6 +531,13 @@ definition. Use the Vim’s option |'tags'| to specify the names and the locations of the tags file(s). Example: `set tags+=tags/help,doc/tags` + *:CtrlPBufTag* + * Buffer Tag mode:~ + - Name: 'buffertag' + - Command: ':CtrlPBufTag' + - Search for a tag within the current buffer and jump to the definition. + Requires |exuberant_ctags|. + *:CtrlPQuickfix* * Quickfix mode:~ - Name: 'quickfix' @@ -540,6 +556,34 @@ + change the global working directory to |CtrlP|’s current local working directory (exit). +------------------------------------------------------------------------------- +Buffer Tag mode options:~ + + *'g:ctrlp_buftag_ctags_bin'* +If ctags isn’t in your $PATH, use this to set its location: > + let g:ctrlp_buftag_ctags_bin = '' +< + + *'g:ctrlp_buftag_systemenc'* +Match this with your OS’s encoding (not Vim’s). The default value mirrors Vim’s +global |'encoding'| option: > + let g:ctrlp_buftag_systemenc = &encoding +< + + *'g:ctrlp_buftag_types'* +Use this to set the arguments for ctags, jsctags... for a given filetype: > + let g:ctrlp_buftag_types = '' +< +Examples: > + let g:ctrlp_buftag_types = { + \ 'erlang' : '--language-force=erlang --erlang-types=drmf', + \ 'javascript' : { + \ 'bin': 'jsctags', + \ 'args': '-f -', + \ }, + \ } +< + =============================================================================== EXTENDING *ctrlp-extending* @@ -590,6 +634,11 @@ =============================================================================== CHANGELOG *ctrlp-changelog* + + New feature: Buffer Tag extension. + + New command: |:CtrlPBufTag|. + + New options: |g:ctrlp_cmd|, + |g:ctrlp_custom_ignore| + Before 2011/11/30~ + New features: Tag, Quickfix and Directory extensions. diff -r 611e13daeafb -r 92af3257a261 vim/vimfiles/plugin/ctrlp.vim --- a/vim/vimfiles/plugin/ctrlp.vim Wed Jan 04 19:34:22 2012 -0600 +++ b/vim/vimfiles/plugin/ctrlp.vim Wed Jan 04 19:37:22 2012 -0600 @@ -11,21 +11,22 @@ let [g:loaded_ctrlp, g:ctrlp_lines, g:ctrlp_allfiles] = [1, [], []] if !exists('g:ctrlp_map') | let g:ctrlp_map = '' | en +if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en -com! -na=? -comp=custom,ctrlp#cpl CtrlP cal ctrlp#init(0, ) +com! -n=? -com=custom,ctrlp#cpl CtrlP cal ctrlp#init(0, ) com! CtrlPBuffer cal ctrlp#init(1) com! CtrlPMRUFiles cal ctrlp#init(2) -com! ClearCtrlPCache cal ctrlp#clr() +com! ClearCtrlPCache cal ctrlp#clr() com! ClearAllCtrlPCaches cal ctrlp#clra() -com! ResetCtrlP cal ctrlp#reset() +com! ResetCtrlP cal ctrlp#reset() com! CtrlPCurWD cal ctrlp#init(0, 0) com! CtrlPCurFile cal ctrlp#init(0, 1) com! CtrlPRoot cal ctrlp#init(0, 2) -exe 'nn ' g:ctrlp_map ':CtrlP' +exe 'nn ' g:ctrlp_map ':'.g:ctrlp_cmd.'' cal ctrlp#mrufiles#init() @@ -40,5 +41,12 @@ en if index(g:ctrlp_extensions, 'dir') >= 0 - let g:ctrlp_alldirs = [] | com! CtrlPDir cal ctrlp#init(ctrlp#dir#id()) + let g:ctrlp_alldirs = [] + com! -n=? -com=custom,ctrlp#cpl CtrlPDir + \ cal ctrlp#init(ctrlp#dir#id(), ) en + +if index(g:ctrlp_extensions, 'buffertag') >= 0 + let g:ctrlp_buftags = {} + com! CtrlPBufTag cal ctrlp#init(ctrlp#buffertag#id()) +en