diff --git a/GetLatest/GetLatestVimScripts.dat b/GetLatest/GetLatestVimScripts.dat index a6a1772..469ffe4 100644 --- a/GetLatest/GetLatestVimScripts.dat +++ b/GetLatest/GetLatestVimScripts.dat @@ -7,7 +7,7 @@ ScriptID SourceID Filename 3304 18081 gundo.vim 2727 11120 jsbeautify.vim 2289 8922 loremipsum -2666 18218 Mark +2666 18598 Mark 1218 14455 nerdcommenter 2262 8944 occur.vim 2136 8206 repeat.vim diff --git a/bundle/git_ctrlp/.gitignore b/bundle/git_ctrlp/.gitignore index 299a816..06fcd83 100644 --- a/bundle/git_ctrlp/.gitignore +++ b/bundle/git_ctrlp/.gitignore @@ -1,8 +1,6 @@ -.hgignore *.markdown *.zip -wiki.md note.txt tags -.hg/* +.hg* tmp/* diff --git a/bundle/git_ctrlp/autoload/ctrlp.vim b/bundle/git_ctrlp/autoload/ctrlp.vim index 8444da6..f01f208 100644 --- a/bundle/git_ctrlp/autoload/ctrlp.vim +++ b/bundle/git_ctrlp/autoload/ctrlp.vim @@ -2,32 +2,33 @@ " File: autoload/ctrlp.vim " Description: Fuzzy file, buffer, mru, tag, etc finder. " Author: Kien Nguyen -" Version: 1.7.7 +" Version: 1.78 " ============================================================================= " ** Static variables {{{1 -fu! s:ignore() "{{{2 +" s:ignore() {{{2 +fu! s:ignore() let igdirs = [ - \ '\.git$', - \ '\.hg$', - \ '\.svn$', - \ '_darcs$', - \ '\.bzr$', - \ '\.cdv$', - \ '\~\.dep$', - \ '\~\.dot$', - \ '\~\.nib$', - \ '\~\.plst$', - \ '\.pc$', - \ '_MTN$', - \ ' ', { @@ -133,14 +143,15 @@ let [s:lcmap, s:prtmaps] = ['nn ', { \ 'PrtExit()': ['', '', ''], \ }] -if !has('gui_running') && ( has('win32') || has('win64') ) +if !has('gui_running') cal add(s:prtmaps['PrtBS()'], remove(s:prtmaps['PrtCurLeft()'], 0)) en -let s:lash = ctrlp#utils#lash() +let s:compare_lim = 3000 -" Limiters -let [s:compare_lim, s:nocache_lim] = [3000, 4000] +let s:ficounts = {} + +let s:ccex = s:pref.'clear_cache_on_exit' " Regexp let s:fpats = { @@ -150,22 +161,6 @@ let s:fpats = { \ '^\S\\?$': '\\?', \ } -" Specials -let s:prtunmaps = [ - \ 'PrtBS()', - \ 'PrtDelete()', - \ 'PrtDeleteWord()', - \ 'PrtClear()', - \ 'PrtCurStart()', - \ 'PrtCurEnd()', - \ 'PrtCurLeft()', - \ 'PrtCurRight()', - \ 'PrtHistory(-1)', - \ 'PrtHistory(1)', - \ 'PrtInsert("c")', - \ 'PrtInsert()', - \ ] - " Keypad let s:kprange = { \ 'Plus': '+', @@ -186,9 +181,8 @@ let s:hlgrps = { \ 'PrtText': 'Normal', \ 'PrtCursor': 'Constant', \ } - -fu! s:opts() "{{{2 - " Options +" s:opts() {{{2 +fu! s:opts(...) unl! s:usrign s:usrcmd s:urprtmaps for each in ['byfname', 'regexp', 'extensions'] | if exists('s:'.each) let {each} = s:{each} @@ -200,14 +194,36 @@ fu! s:opts() "{{{2 for [ke, va] in items(s:new_opts) let {va} = {exists(s:pref.ke) ? s:pref.ke : va} endfo + unl va + for [ke, va] in items(s:lc_opts) + if exists(s:bpref.ke) + unl {va} + let {va} = {s:bpref.ke} + en + endfo + if a:0 && a:1 != {} + unl va + for [ke, va] in items(a:1) + let opke = substitute(ke, '\(\w:\)\?ctrlp_', '', '') + if has_key(s:lc_opts, opke) + let sva = s:lc_opts[opke] + unl {sva} + let {sva} = va + en + endfo + en for each in ['byfname', 'regexp'] | if exists(each) let s:{each} = {each} en | 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]) - let s:glob = s:dotfiles ? '.*\|*' : '*' + let s:glob = s:showhidden ? '.*\|*' : '*' let s:igntype = empty(s:usrign) ? -1 : type(s:usrign) + let s:lash = ctrlp#utils#lash() + if s:keyloop + let [s:lazy, s:glbs['imd']] = [0, 0] + en if s:lazy cal extend(s:glbs, { 'ut': ( s:lazy > 1 ? s:lazy : 250 ) }) en @@ -225,13 +241,13 @@ endf "}}}1 " * Open & Close {{{1 fu! s:Open() - let s:ermsg = v:errmsg cal s:log(1) cal s:getenv() cal s:execextvar('enter') sil! exe 'keepa' ( s:mwbottom ? 'bo' : 'to' ) '1new ControlP' cal s:buffunc(1) - let [s:bufnr, s:prompt, s:winw] = [bufnr('%'), ['', '', ''], winwidth(0)] + let [s:bufnr, s:winw] = [bufnr('%'), winwidth(0)] + let [s:focus, s:prompt] = [1, ['', '', '']] abc if !exists('s:hstry') let hst = filereadable(s:gethistloc()[1]) ? s:gethistdata() : [''] @@ -260,7 +276,7 @@ fu! s:Close() exe s:winres[0] en unl! s:focus s:hisidx s:hstgot s:marked s:statypes s:cline s:init s:savestr - \ s:mrbs + \ s:mrbs s:did_exp cal ctrlp#recordhist() cal s:execextvar('exit') cal s:log(0) @@ -273,18 +289,19 @@ fu! ctrlp#clr(...) endf fu! ctrlp#clra() - let cache_dir = ctrlp#utils#cachedir() - if isdirectory(cache_dir) - let cache_files = split(s:glbpath(cache_dir, '**', 1), "\n") + let cadir = ctrlp#utils#cachedir() + if isdirectory(cadir) + let cafiles = split(s:glbpath(s:fnesc(cadir, 'g', ','), '**', 1), "\n") let eval = '!isdirectory(v:val) && fnamemodify(v:val, ":t") !~' \ . ' ''\v^[.a-z]+$|\.log$''' - sil! cal map(filter(cache_files, eval), 'delete(v:val)') + sil! cal map(filter(cafiles, eval), 'delete(v:val)') en cal ctrlp#clr() endf -fu! ctrlp#reset() - cal s:opts() +fu! s:Reset(args) + let opts = has_key(a:args, 'opts') ? [a:args['opts']] : [] + cal call('s:opts', opts) cal s:autocmds() cal ctrlp#utils#opts() cal s:execextvar('opts') @@ -292,11 +309,11 @@ endf " * Files {{{1 fu! ctrlp#files() let cafile = ctrlp#utils#cachefile() - if g:ctrlp_newcache || !filereadable(cafile) || !s:caching + if g:ctrlp_newcache || !filereadable(cafile) || s:nocache(cafile) let [lscmd, s:initcwd, g:ctrlp_allfiles] = [s:lsCmd(), s:dyncwd, []] " Get the list of files if empty(lscmd) - cal s:GlobPath(s:dyncwd, 0) + cal s:GlobPath(s:fnesc(s:dyncwd, 'g', ','), 0) el sil! cal ctrlp#progress('Indexing...') try | cal s:UserCmd(lscmd) @@ -308,12 +325,16 @@ fu! ctrlp#files() cal sort(g:ctrlp_allfiles, 'ctrlp#complen') en cal s:writecache(cafile) + let catime = getftime(cafile) el + let catime = getftime(cafile) if !( exists('s:initcwd') && s:initcwd == s:dyncwd ) + \ || get(s:ficounts, s:dyncwd, [0, catime])[1] != catime let s:initcwd = s:dyncwd let g:ctrlp_allfiles = ctrlp#utils#readfile(cafile) en en + cal extend(s:ficounts, { s:dyncwd : [len(g:ctrlp_allfiles), catime] }) retu g:ctrlp_allfiles endf @@ -323,7 +344,7 @@ fu! s:GlobPath(dirs, depth) 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), 1) - cal s:GlobPath(join(dnf[0], ','), depth) + cal s:GlobPath(join(map(dnf[0], 's:fnesc(v:val, "g", ",")'), ','), depth) en endf @@ -344,6 +365,14 @@ fu! s:UserCmd(lscmd) if exists('s:vcscmd') && s:vcscmd cal map(g:ctrlp_allfiles, 'tr(v:val, "/", "\\")') en + if type(s:usrcmd) == 4 && has_key(s:usrcmd, 'ignore') && s:usrcmd['ignore'] + if !empty(s:usrign) + let g:ctrlp_allfiles = ctrlp#dirnfile(g:ctrlp_allfiles)[1] + en + if &wig != '' + cal filter(g:ctrlp_allfiles, 'glob(v:val) != ""') + en + en endf fu! s:lsCmd() @@ -351,26 +380,28 @@ fu! s:lsCmd() if type(cmd) == 1 retu cmd elsei type(cmd) == 3 && len(cmd) >= 2 && cmd[:1] != ['', ''] - " Find a repo root - cal s:findroot(s:dyncwd, cmd[0], 0, 1) - if !exists('s:vcsroot') - " Try the secondary_command + if s:findroot(s:dyncwd, cmd[0], 0, 1) == [] retu len(cmd) == 3 ? cmd[2] : '' en - unl s:vcsroot - let s:vcscmd = s:lash == '\' ? 1 : 0 + let s:vcscmd = s:lash == '\' retu cmd[1] - elsei type(cmd) == 4 && has_key(cmd, 'types') - for key in sort(keys(cmd['types']), 's:compval') - cal s:findroot(s:dyncwd, cmd['types'][key][0], 0, 1) - if exists('s:vcsroot') | brea | en - endfo - if !exists('s:vcsroot') + elsei type(cmd) == 4 && ( has_key(cmd, 'types') || has_key(cmd, 'fallback') ) + let fndroot = [] + if has_key(cmd, 'types') && cmd['types'] != {} + let [markrs, cmdtypes] = [[], values(cmd['types'])] + for pair in cmdtypes + cal add(markrs, pair[0]) + endfo + let fndroot = s:findroot(s:dyncwd, markrs, 0, 1) + en + if fndroot == [] retu has_key(cmd, 'fallback') ? cmd['fallback'] : '' en - unl s:vcsroot - let s:vcscmd = s:lash == '\' ? 1 : 0 - retu cmd['types'][key][1] + for pair in cmdtypes + if pair[0] == fndroot[0] | brea | en + endfo + let s:vcscmd = s:lash == '\' + retu pair[1] en endf " - Buffers {{{1 @@ -382,7 +413,9 @@ endf " * MatchedItems() {{{1 fu! s:MatchIt(items, pat, limit, exc) let [lines, id] = [[], 0] - let pat = s:byfname ? split(a:pat, '^[^;]\+\zs;', 1) : a:pat + let pat = + \ s:byfname ? map(split(a:pat, '^[^;]\+\\\@= 0 @@ -404,6 +437,7 @@ fu! s:MatchedItems(items, pat, limit) let lines = s:MatchIt(items, a:pat, a:limit, exc) en let s:matches = len(lines) + unl! s:did_exp retu lines endf @@ -442,7 +476,7 @@ endf " * BuildPrompt() {{{1 fu! s:Render(lines, pat) let [&ma, lines, s:height] = [1, a:lines, min([len(a:lines), s:winh])] - let pat = s:byfname ? split(a:pat, '^[^;]\+\zs;', 1)[0] : a:pat + let pat = s:byfname ? split(a:pat, '^[^;]\+\\\@' ).( s:byfname ? 'd' : '>' ).'> ' - let [estr, prt] = ['"\', copy(s:prompt)] - cal map(prt, 'escape(v:val, estr)') - let str = join(prt, '') - let lazy = empty(str) || exists('s:force') || !has('autocmd') ? 0 : s:lazy - if a:upd && !lazy && ( s:matches || s:regexp + let str = escape(s:getinput(), '\') + let lazy = str == '' || exists('s:force') || !has('autocmd') ? 0 : s:lazy + if a:upd && !lazy && ( s:matches || s:regexp || exists('s:did_exp') \ || str =~ '\(\\\(<\|>\)\|[*|]\)\|\(\\\:\([^:]\|\\:\)*$\)' ) sil! cal s:Update(str) en sil! cal ctrlp#statusline() " Toggling - let [hiactive, hicursor, base] = a:0 && !a:1 - \ ? ['CtrlPPrtBase', 'CtrlPPrtBase', tr(base, '>', '-')] - \ : ['CtrlPPrtText', 'CtrlPPrtCursor', base] + let [hiactive, hicursor, base] = s:focus + \ ? ['CtrlPPrtText', 'CtrlPPrtCursor', base] + \ : ['CtrlPPrtBase', 'CtrlPPrtBase', tr(base, '>', '-')] let hibase = 'CtrlPPrtBase' " Build it redr + let prt = copy(s:prompt) + cal map(prt, 'escape(v:val, ''"\'')') exe 'echoh' hibase '| echon "'.base.'" \ | echoh' hiactive '| echon "'.prt[0].'" \ | echoh' hicursor '| echon "'.prt[1].'" \ | echoh' hiactive '| echon "'.prt[2].'" | echoh None' " Append the cursor at the end - if empty(prt[1]) && !( a:0 && !a:1 ) + if empty(prt[1]) && s:focus exe 'echoh' hibase '| echon "_" | echoh None' en endf " - SetDefTxt() {{{1 fu! s:SetDefTxt() - if s:deftxt == '0' || !s:ispath | retu | en + if s:deftxt == '0' || ( s:deftxt == 1 && !s:ispath ) | retu | en let txt = s:deftxt if !type(txt) let txt = txt && !stridx(s:crfpath, s:dyncwd) @@ -540,6 +573,7 @@ endf " ** Prt Actions {{{1 " Editing {{{2 fu! s:PrtClear() + if !s:focus | retu | en unl! s:hstgot let [s:prompt, s:matches] = [['', '', ''], 1] cal s:BuildPrompt(1) @@ -554,12 +588,14 @@ fu! s:PrtAdd(char) endf fu! s:PrtBS() + if !s:focus | retu | en unl! s:hstgot let [s:prompt[0], s:matches] = [substitute(s:prompt[0], '.$', '', ''), 1] cal s:BuildPrompt(1) endf fu! s:PrtDelete() + if !s:focus | retu | en unl! s:hstgot let [prt, s:matches] = [s:prompt, 1] let prt[1] = matchstr(prt[2], '^.') @@ -568,6 +604,7 @@ fu! s:PrtDelete() endf fu! s:PrtDeleteWord() + if !s:focus | retu | en unl! s:hstgot let [str, s:matches] = [s:prompt[0], 1] let str = str =~ '\W\w\+$' ? matchstr(str, '^.\+\W\ze\w\+$') @@ -579,6 +616,7 @@ fu! s:PrtDeleteWord() endf fu! s:PrtInsert(...) + if !s:focus | retu | en let type = !a:0 ? '' : a:1 if !a:0 let type = s:insertstr() @@ -601,7 +639,8 @@ fu! s:PrtInsert(...) endf fu! s:PrtExpandDir() - let str = s:prompt[0] + if !s:focus | retu | en + let str = s:getinput('c') if str =~ '\v^\@(cd|lc[hd]?|chd)\s.+' && s:spi let hasat = split(str, '\v^\@(cd|lc[hd]?|chd)\s*\zs') let str = get(hasat, 1, '') @@ -622,6 +661,7 @@ fu! s:PrtExpandDir() endf " Movement {{{2 fu! s:PrtCurLeft() + if !s:focus | retu | en let prt = s:prompt if !empty(prt[0]) let s:prompt = [substitute(prt[0], '.$', '', ''), matchstr(prt[0], '.$'), @@ -631,6 +671,7 @@ fu! s:PrtCurLeft() endf fu! s:PrtCurRight() + if !s:focus | retu | en let prt = s:prompt let s:prompt = [prt[0] . prt[1], matchstr(prt[2], '^.'), \ substitute(prt[2], '^.', '', '')] @@ -638,12 +679,14 @@ fu! s:PrtCurRight() endf fu! s:PrtCurStart() + if !s:focus | retu | en let str = join(s:prompt, '') let s:prompt = ['', matchstr(str, '^.'), substitute(str, '^.', '', '')] cal s:BuildPrompt(0) endf fu! s:PrtCurEnd() + if !s:focus | retu | en let s:prompt = [join(s:prompt, ''), '', ''] cal s:BuildPrompt(0) endf @@ -653,33 +696,38 @@ fu! s:PrtSelectMove(dir) let dirs = {'t': 'gg','b': 'G','j': 'j','k': 'k','u': wht.'k','d': wht.'j'} exe 'keepj norm!' dirs[a:dir] if s:nolim != 1 | let s:cline = line('.') | en - if line('$') > winheight(0) | cal s:BuildPrompt(0, s:Focus()) | en + if line('$') > winheight(0) | cal s:BuildPrompt(0) | en endf -fu! s:PrtSelectJump(char, ...) +fu! s:PrtSelectJump(char) let lines = copy(s:lines) - if a:0 + if s:byfname cal map(lines, 'split(v:val, ''[\/]\ze[^\/]\+$'')[-1]') en " Cycle through matches, use s:jmpchr to store last jump - let chr = escape(a:char, '.~') - if match(lines, '\c^'.chr) >= 0 + let chr = escape(matchstr(a:char, '^.'), '.~') + let smartcs = &scs && chr =~ '\u' ? '\C' : '' + if match(lines, smartcs.'^'.chr) >= 0 " If not exists or does but not for the same char - let pos = match(lines, '\c^'.chr) + let pos = match(lines, smartcs.'^'.chr) if !exists('s:jmpchr') || ( exists('s:jmpchr') && s:jmpchr[0] != chr ) let [jmpln, s:jmpchr] = [pos, [chr, pos]] elsei exists('s:jmpchr') && s:jmpchr[0] == chr " Start of lines if s:jmpchr[1] == -1 | let s:jmpchr[1] = pos | en - let npos = match(lines, '\c^'.chr, s:jmpchr[1] + 1) + let npos = match(lines, smartcs.'^'.chr, s:jmpchr[1] + 1) let [jmpln, s:jmpchr] = [npos == -1 ? pos : npos, [chr, npos]] en - keepj exe jmpln + 1 + exe 'keepj norm!' ( jmpln + 1 ).'G' if s:nolim != 1 | let s:cline = line('.') | en - if line('$') > winheight(0) | cal s:BuildPrompt(0, s:Focus()) | en + if line('$') > winheight(0) | cal s:BuildPrompt(0) | en en endf " Misc {{{2 +fu! s:PrtFocusMap(char) + cal call(( s:focus ? 's:PrtAdd' : 's:PrtSelectJump' ), [a:char]) +endf + fu! s:PrtClearCache() if s:itemtype == 0 cal ctrlp#clr() @@ -716,7 +764,7 @@ fu! s:PrtExit() endf fu! s:PrtHistory(...) - if !s:maxhst | retu | en + if !s:focus || !s:maxhst | retu | en let [str, hst, s:matches] = [join(s:prompt, ''), s:hstry, 1] " Save to history if not saved before let [hst[0], hslen] = [exists('s:hstgot') ? hst[0] : str, len(hst)] @@ -729,67 +777,72 @@ fu! s:PrtHistory(...) unl s:force endf "}}}1 -" * MapKeys() {{{1 -fu! s:MapKeys(...) - " Normal keys - let pfunc = a:0 && !a:1 ? 'PrtSelectJump' : 'PrtAdd' - let dojmp = s:byfname && a:0 && !a:1 ? ', 1' : '' - let pcmd = "nn \ \ \ :\cal \%s(\"%s\"%s)\" +" * Mappings {{{1 +fu! s:MapNorms() + if exists('s:nmapped') && s:nmapped == s:bufnr | retu | en + let pcmd = "nn \ \ \ :\cal \%s(\"%s\")\" let cmd = substitute(pcmd, 'k%s', 'char-%d', '') - for each in range(32, 126) - exe printf(cmd, each, pfunc, escape(nr2char(each), '"|\'), dojmp) + let pfunc = 'PrtFocusMap' + let ranges = [32, 33, 125, 126] + range(35, 91) + range(93, 123) + for each in [34, 92, 124] + exe printf(cmd, each, pfunc, escape(nr2char(each), '"|\')) + endfo + for each in ranges + exe printf(cmd, each, pfunc, nr2char(each)) endfo for each in range(0, 9) - exe printf(pcmd, each, pfunc, each, dojmp) + exe printf(pcmd, each, pfunc, each) endfo for [ke, va] in items(s:kprange) - exe printf(pcmd, ke, pfunc, va, dojmp) + exe printf(pcmd, ke, pfunc, va) endfo - " Special keys - if a:0 < 2 - cal call('s:MapSpecs', a:0 && !a:1 ? [1] : []) - en + let s:nmapped = s:bufnr endf -fu! s:MapSpecs(...) - " Correct arrow keys in terminal - if ( has('termresponse') && v:termresponse =~ "\" ) - \ || &term =~? '\vxterm|','\B ','\C ','\D '] - exe s:lcmap.' ['.each - endfo - en - if a:0 - for ke in s:prtunmaps | for kp in s:prtmaps[ke] - exe s:lcmap kp '' - endfo | endfo - el - for [ke, va] in items(s:prtmaps) | for kp in va - exe s:lcmap kp ':cal '.ke.'' - endfo | endfo +fu! s:MapSpecs() + if !( exists('s:smapped') && s:smapped == s:bufnr ) + " Correct arrow keys in terminal + if ( has('termresponse') && v:termresponse =~ "\" ) + \ || &term =~? '\vxterm|','\B ','\C ','\D '] + exe s:lcmap.' ['.each + endfo + en en + for [ke, va] in items(s:prtmaps) | for kp in va + exe s:lcmap kp ':cal '.ke.'' + endfo | endfo + let s:smapped = s:bufnr +endf + +fu! s:KeyLoop() + wh exists('s:init') && s:keyloop + redr + let nr = getchar() + let chr = !type(nr) ? nr2char(nr) : nr + if nr >=# 0x20 + cal s:PrtFocusMap(chr) + el + let cmd = matchstr(maparg(chr), ':\zs.\+\ze$') + exe ( cmd != '' ? cmd : 'norm '.chr ) + en + endw endf " * Toggling {{{1 -fu! s:Focus() - retu !exists('s:focus') ? 1 : s:focus -endf - fu! s:ToggleFocus() - let s:focus = !exists('s:focus') || s:focus ? 0 : 1 - cal s:MapKeys(s:focus) - cal s:BuildPrompt(0, s:focus) + let s:focus = !s:focus + cal s:BuildPrompt(0) endf fu! s:ToggleRegex() - let s:regexp = s:regexp ? 0 : 1 + let s:regexp = !s:regexp cal s:PrtSwitcher() endf fu! s:ToggleByFname() if s:ispath - let s:byfname = s:byfname ? 0 : 1 + let s:byfname = !s:byfname let s:mfunc = s:mfunc() - cal s:MapKeys(s:Focus(), 1) cal s:PrtSwitcher() en endf @@ -802,52 +855,70 @@ fu! s:ToggleType(dir) cal s:PrtSwitcher() endf +fu! s:ToggleKeyLoop() + let s:keyloop = !s:keyloop + if exists('+imd') + let &imd = !s:keyloop + en + if s:keyloop + let [&ut, s:lazy] = [0, 0] + cal s:KeyLoop() + elsei has_key(s:glbs, 'ut') + let [&ut, s:lazy] = [s:glbs['ut'], 1] + en +endf + fu! s:PrtSwitcher() let [s:force, s:matches] = [1, 1] - cal s:BuildPrompt(1, s:Focus()) + cal s:BuildPrompt(1) unl s:force endf " - SetWD() {{{1 -fu! s:SetWD(...) - let pathmode = s:wpmode +fu! s:SetWD(args) + if has_key(a:args, 'args') && stridx(a:args['args'], '--dir') >= 0 + \ && exists('s:dyncwd') + cal ctrlp#setdir(s:dyncwd) | retu + en + if has_key(a:args, 'dir') && a:args['dir'] != '' + cal ctrlp#setdir(a:args['dir']) | retu + en + let pmode = has_key(a:args, 'mode') ? a:args['mode'] : s:pathmode let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()] - if a:0 && strlen(a:1) | if type(a:1) - cal ctrlp#setdir(a:1) | retu - el - let pathmode = a:1 - en | en - if a:0 < 2 - if s:crfile =~ '^.\+://' || !pathmode | retu | en + if s:crfile =~ '^.\+://' | retu | en + if pmode =~ 'c' || ( pmode =~ 'a' && stridx(s:crfpath, s:cwd) < 0 ) + \ || ( !type(pmode) && pmode ) if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en cal ctrlp#setdir(s:crfpath) en - if pathmode == 1 | retu | en - let markers = ['.git', '.hg', '.svn', '.bzr', '_darcs'] - if type(s:rmarkers) == 3 && !empty(s:rmarkers) - cal extend(markers, s:rmarkers, 0) - let markers = reverse(filter(reverse(markers), 'count(markers, v:val) == 1')) + if pmode =~ 'r' || pmode == 2 + let markers = ['.git', '.hg', '.svn', '.bzr', '_darcs'] + let spath = pmode =~ 'd' ? s:dyncwd : pmode =~ 'w' ? s:cwd : s:crfpath + if type(s:rmarkers) == 3 && !empty(s:rmarkers) + if s:findroot(spath, s:rmarkers, 0, 0) != [] | retu | en + cal filter(markers, 'index(s:rmarkers, v:val) < 0') + en + cal s:findroot(spath, markers, 0, 0) en - for marker in markers - cal s:findroot(s:dyncwd, marker, 0, 0) - if exists('s:foundroot') | brea | en - endfo - unl! s:foundroot endf " * AcceptSelection() {{{1 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*')) - if s:jmptobuf && bufnr > 0 && md =~ 'e\|t' + let j2l = a:0 ? a:1 : matchstr(tail, '^ +\zs\d\+$') + if ( s:jmptobuf =~ md || ( s:jmptobuf && md =~ '[et]' ) ) && bufnr > 0 + \ && !( md == 'e' && bufnr == bufnr('%') ) let [jmpb, bufwinnr] = [1, bufwinnr(bufnr)] - let buftab = s:jmptobuf > 1 ? s:buftab(bufnr, md) : [0, 0] + let buftab = ( s:jmptobuf =~# '[tTVH]' || s:jmptobuf > 1 ) + \ ? s:buftab(bufnr, md) : [0, 0] en " Switch to existing buffer or open new one - if exists('jmpb') && bufwinnr > 0 && md != 't' + if exists('jmpb') && bufwinnr > 0 + \ && !( md == 't' && ( s:jmptobuf !~# toupper(md) || buftab[0] ) ) exe bufwinnr.'winc w' if j2l | cal ctrlp#j2l(j2l) | en elsei exists('jmpb') && buftab[0] + \ && !( md =~ '[evh]' && s:jmptobuf !~# toupper(md) ) exe 'tabn' buftab[0] exe buftab[1].'winc w' if j2l | cal ctrlp#j2l(j2l) | en @@ -862,7 +933,8 @@ fu! ctrlp#acceptfile(mode, line, ...) " Reset &switchbuf option let [swb, &swb] = [&swb, ''] " Open new window/buffer - let args = [cmd, useb ? bufnr : filpath, a:0 ? ' +'.a:1 : tail, useb, j2l] + let [fid, tail] = [( useb ? bufnr : filpath ), ( a:0 ? ' +'.a:1 : tail )] + let args = [cmd, fid, tail, 1, [useb, j2l]] cal call('s:openfile', args) let &swb = swb en @@ -877,7 +949,7 @@ fu! s:SpecInputs(str) cal s:PrtClear() retu 1 elsei a:str == s:lash && s:spi - cal s:SetWD(2, 0) + cal s:SetWD({ 'mode': 'rd' }) cal ctrlp#setlines() cal s:PrtClear() retu 1 @@ -894,22 +966,26 @@ endf fu! s:AcceptSelection(mode) if a:mode != 'e' && s:OpenMulti(a:mode) != -1 | retu | en - let str = join(s:prompt, '') + let str = s:getinput() if a:mode == 'e' | if s:SpecInputs(str) | retu | en | en " Get the selected line - let line = !empty(s:lines) ? s:lines[line('.') - 1] : '' + let line = ctrlp#getcline() if a:mode != 'e' && !s:itemtype && line == '' \ && str !~ '\v^(\.\.([\/]\.\.)*[\/]?[.\/]*|/|\\|\?|\@.+)$' cal s:CreateNewFile(a:mode) | retu en if empty(line) | retu | en " Do something with it - let actfunc = s:itemtype < 3 ? 'ctrlp#acceptfile' : s:getextvar('accept') + if s:openfunc != {} && has_key(s:openfunc, s:ctype) + let actfunc = s:openfunc[s:ctype] + el + let actfunc = s:itemtype < 3 ? 'ctrlp#acceptfile' : s:getextvar('accept') + en cal call(actfunc, [a:mode, line]) endf " - CreateNewFile() {{{1 fu! s:CreateNewFile(...) - let [md, str] = ['', join(s:prompt, '')] + let [md, str] = ['', s:getinput('n')] if empty(str) | retu | en if s:argmap && !a:0 " Get the extra argument @@ -937,7 +1013,7 @@ fu! s:CreateNewFile(...) \ 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, tail) + cal s:openfile(cmd, filpath, tail, 1) endf " * OpenMulti() {{{1 fu! s:MarkToOpen() @@ -945,7 +1021,7 @@ fu! s:MarkToOpen() \ || ( s:itemtype > 2 && s:getextvar('opmul') != 1 ) retu en - let line = !empty(s:lines) ? s:lines[line('.') - 1] : '' + let line = ctrlp#getcline() if empty(line) | retu | en let filpath = s:ispath ? fnamemodify(line, ':p') : line if exists('s:marked') && s:dictindex(s:marked, filpath) > 0 @@ -973,29 +1049,42 @@ fu! s:MarkToOpen() endf fu! s:OpenMulti(...) - if !exists('s:marked') || s:opmul == '0' || !s:ispath | retu -1 | en + let has_marked = exists('s:marked') + if ( !has_marked && a:0 ) || s:opmul == '0' || !s:ispath + \ || ( s:itemtype > 2 && s:getextvar('opmul') != 1 ) + retu -1 + en " Get the options let [nr, md] = [matchstr(s:opmul, '\d\+'), matchstr(s:opmul, '[thvi]')] - let [ur, jf] = [matchstr(s:opmul, 'r') == 'r', matchstr(s:opmul, 'j') == 'j'] + let [ur, jf] = [s:opmul =~ 'r', s:opmul =~ 'j'] let md = a:0 ? a:1 : ( md == '' ? 'v' : md ) let nopt = exists('g:ctrlp_open_multiple_files') - if s:argmap && !a:0 - let md = s:argmaps(md, 0) + if !has_marked + let line = ctrlp#getcline() + if line == '' | retu | en + let marked = { 1 : fnamemodify(line, ':p') } + let [nr, ur, jf, nopt] = ['1', 0, 0, 1] + en + if ( s:argmap || !has_marked ) && !a:0 + let md = s:argmaps(md, !has_marked ? 2 : 0) if md == 'c' cal s:unmarksigns() unl! s:marked cal s:BuildPrompt(0) + elsei !has_marked && md =~ '[axd]' + retu s:OpenNoMarks(md, line) en if md =~ '\v^c(ancel)?$' | retu | en let nr = nr == '0' ? ( nopt ? '' : '1' ) : nr + let ur = !has_marked && md == 'r' ? 1 : ur en - let mkd = values(s:marked) + let mkd = values(has_marked ? s:marked : marked) cal s:sanstail(join(s:prompt, '')) cal s:PrtExit() if nr == '0' || md == 'i' - retu map(mkd, "s:openfile('bad', fnamemodify(v:val, ':.'), '')") + retu map(mkd, "s:openfile('bad', v:val, '', 0)") en - let [tail, fnesc] = [s:tail(), exists('*fnameescape') && v:version > 701] + let tail = s:tail() let [emptytail, bufnr] = [empty(tail), bufnr('^'.mkd[0].'$')] let useb = bufnr > 0 && buflisted(bufnr) && emptytail " Move to a replaceable window @@ -1003,11 +1092,14 @@ fu! s:OpenMulti(...) \ + ( ur ? [] : ['ignruw'] ) let fst = call('ctrlp#normcmd', ncmd) " Check if the current window has a replaceable buffer - let repabl = empty(bufname('%')) && empty(&l:ft) + let repabl = !( md == 't' && !ur ) && empty(bufname('%')) && empty(&l:ft) " Commands for the rest of the files let [ic, cmds] = [1, { 'v': ['vert sb', 'vne'], 'h': ['sb', 'new'], \ 't': ['tab sb', 'tabe'] }] let [swb, &swb] = [&swb, ''] + if md == 't' && ctrlp#tabcount() < tabpagenr() + let s:tabct = ctrlp#tabcount() + en " Open the files for va in mkd let bufnr = bufnr('^'.va.'$') @@ -1019,25 +1111,45 @@ fu! s:OpenMulti(...) let conds = [( nr != '' && nr > 1 && nr < ic ) || ( nr == '' && ic > 1 ), \ nr != '' && nr < ic] if conds[nopt] - if bufnr <= 0 | if fnesc - cal s:openfile('bad', fnamemodify(va, ':.'), '') - el - cal s:openfile(cmd, va, tail) | sil! hid clo! - en | en + if !buflisted(bufnr) | cal s:openfile('bad', va, '', 0) | en el - cal s:openfile(cmd, useb ? bufnr : va, tail) | let ic += 1 - if jf | if ic == 2 + cal s:openfile(cmd, useb ? bufnr : va, tail, ic == 1) + if jf | if ic == 1 let crpos = [tabpagenr(), winnr()] el - let crpos[0] += tabpagenr() == crpos[0] - let crpos[1] += winnr() == crpos[1] + let crpos[0] += tabpagenr() <= crpos[0] + let crpos[1] += winnr() <= crpos[1] en | en + let ic += 1 en endfo if jf && exists('crpos') && ic > 2 exe ( md == 't' ? 'tabn '.crpos[0] : crpos[1].'winc w' ) en let &swb = swb + unl! s:tabct +endf + +fu! s:OpenNoMarks(md, line) + if a:md == 'a' + let [s:marked, key] = [{}, 1] + for line in s:lines + let s:marked = extend(s:marked, { key : fnamemodify(line, ':p') }) + let key += 1 + endfo + cal s:remarksigns() + cal s:BuildPrompt(0) + elsei a:md == 'x' + cal call(s:openfunc[s:ctype], [a:md, a:line]) + elsei a:md == 'd' + let dir = fnamemodify(a:line, ':h') + if isdirectory(dir) + cal ctrlp#setdir(dir) + cal ctrlp#switchtype(0) + cal ctrlp#recordhist() + cal s:PrtClear() + en + en endf " ** Helper functions {{{1 " Sorting {{{2 @@ -1157,21 +1269,21 @@ fu! ctrlp#statusline() let max = len(tps) - 1 let nxt = tps[s:walker(max, s:itemtype, 1)][1] let prv = tps[s:walker(max, s:itemtype, -1)][1] - let item = tps[s:itemtype][0] - let focus = s:Focus() ? 'prt' : 'win' + let s:ctype = tps[s:itemtype][0] + let focus = s:focus ? 'prt' : 'win' let byfname = s:byfname ? 'file' : 'path' let marked = s:opmul != '0' ? \ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <->' : '' if s:status != {} - let args = [focus, byfname, s:regexp, prv, item, nxt, marked] + let args = [focus, byfname, s:regexp, prv, s:ctype, nxt, marked] let &l:stl = call(s:status['main'], args) el - let item = '%#CtrlPMode1# '.item.' %*' + let item = '%#CtrlPMode1# '.s:ctype.' %*' let focus = '%#CtrlPMode2# '.focus.' %*' let byfname = '%#CtrlPMode1# '.byfname.' %*' let regex = s:regexp ? '%#CtrlPMode2# regex %*' : '' let slider = ' <'.prv.'>={'.item.'}=<'.nxt.'>' - let dir = ' %=%<%#CtrlPMode2# '.s:dyncwd.' %*' + let dir = ' %=%<%#CtrlPMode2# %{getcwd()} %*' let &l:stl = focus.byfname.regex.slider.marked.dir en endf @@ -1185,10 +1297,11 @@ fu! ctrlp#progress(enum, ...) if has('macunix') || has('mac') | sl 1m | en let txt = a:0 ? '(press ctrl-c to abort)' : '' let &l:stl = s:status != {} ? call(s:status['prog'], [a:enum]) - \ : '%#CtrlPStats# '.a:enum.' %* '.txt.'%=%<%#CtrlPMode2# '.s:dyncwd.' %*' + \ : '%#CtrlPStats# '.a:enum.' %* '.txt.'%=%<%#CtrlPMode2# %{getcwd()} %*' redraws endf -" Paths {{{2 +" *** Paths {{{2 +" Line formatting {{{3 fu! s:formatline(str) let cond = s:ispath && ( s:winw - 4 ) < s:strwidth(a:str) retu '> '.( cond ? s:pathshorten(a:str) : a:str ) @@ -1198,11 +1311,11 @@ fu! s:pathshorten(str) retu matchstr(a:str, '^.\{9}').'...' \ .matchstr(a:str, '.\{'.( s:winw - 16 ).'}$') endf - +" Directory completion {{{3 fu! s:dircompl(be, sd) if a:sd == '' | retu [] | en let [be, sd] = a:be == '' ? [s:dyncwd, a:sd] : [a:be, a:be.s:lash(a:be).a:sd] - let dirs = ctrlp#rmbasedir(split(globpath(be, a:sd.'*/'), "\n")) + let dirs = ctrlp#rmbasedir(split(globpath(s:fnesc(be, 'g', ','), a:sd.'*/'), "\n")) cal filter(dirs, '!match(v:val, escape(sd, ''~$.\''))' \ . ' && v:val !~ ''\v(^|[\/])\.{1,2}[\/]$''') retu dirs @@ -1221,7 +1334,7 @@ fu! s:findcommon(items, seed) endfo retu cmn endf - +" Misc {{{3 fu! s:headntail(str) let parts = split(a:str, '[\/]\ze[^\/]\+[\/:]\?$') retu len(parts) == 1 ? ['', parts[0]] : len(parts) == 2 ? parts : [] @@ -1241,7 +1354,7 @@ fu! ctrlp#dirnfile(entries) let etype = getftype(each) if s:igntype >= 0 && s:usrign(each, etype) | con | en if etype == 'dir' - if s:dotfiles | if each !~ '[\/]\.\{1,2}$' + if s:showhidden | if each !~ '[\/]\.\{1,2}$' cal add(items[0], each) en | el cal add(items[0], each) @@ -1279,7 +1392,7 @@ fu! ctrlp#rmbasedir(items) en retu a:items endf - +" Working directory {{{3 fu! s:getparent(item) let parent = substitute(a:item, '[\/][^\/]\+[\/:]\?$', '', '') if parent == '' || parent !~ '[\/]' @@ -1289,34 +1402,44 @@ fu! s:getparent(item) endf fu! s:findroot(curr, mark, depth, type) - let [depth, notfound] = [a:depth + 1, empty(s:glbpath(a:curr, a:mark, 1))] - if !notfound || depth > s:maxdepth - if notfound | cal ctrlp#setdir(s:cwd) | en - if a:type && depth <= s:maxdepth - let s:vcsroot = a:curr - elsei !a:type && !notfound - cal ctrlp#setdir(a:curr) | let s:foundroot = 1 - en + let [depth, fnd] = [a:depth + 1, 0] + if type(a:mark) == 1 + let fnd = s:glbpath(s:fnesc(a:curr, 'g', ','), a:mark, 1) != '' + elsei type(a:mark) == 3 + for markr in a:mark + if s:glbpath(s:fnesc(a:curr, 'g', ','), markr, 1) != '' + let fnd = 1 + brea + en + endfo + en + if fnd + if !a:type | cal ctrlp#setdir(a:curr) | en + retu [exists('markr') ? markr : a:mark, a:curr] + elsei depth > s:maxdepth + cal ctrlp#setdir(s:cwd) el let parent = s:getparent(a:curr) - if parent != a:curr | cal s:findroot(parent, a:mark, depth, a:type) | en + if parent != a:curr + retu s:findroot(parent, a:mark, depth, a:type) + en en -endf - -fu! s:glbpath(...) - let cond = v:version > 702 || ( v:version == 702 && has('patch051') ) - retu call('globpath', cond ? a:000 : a:000[:1]) -endf - -fu! ctrlp#fnesc(path) - retu exists('*fnameescape') ? fnameescape(a:path) : escape(a:path, " %#*?|<\"\n") + retu [] endf fu! ctrlp#setdir(path, ...) let cmd = a:0 ? a:1 : 'lc!' - sil! exe cmd ctrlp#fnesc(a:path) + sil! exe cmd s:fnesc(a:path, 'c') let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()] endf +" Fallbacks {{{3 +fu! s:glbpath(...) + retu call('ctrlp#utils#globpath', a:000) +endf + +fu! s:fnesc(...) + retu call('ctrlp#utils#fnesc', a:000) +endf fu! ctrlp#setlcdir() if exists('*haslocaldir') @@ -1346,7 +1469,7 @@ fu! s:highlight(pat, grp) let pat = substitute(pat, '\[\^\(.\{-}\)\]\\{-}', '[^\\/\1]\\{-}', 'g') let pat = substitute(pat, '\$\@') en endf @@ -1434,6 +1557,14 @@ fu! s:buftab(bufnr, md) retu [0, 0] endf +fu! s:bufwins(bufnr) + let winns = 0 + for tabnr in range(1, tabpagenr('$')) + let winns += count(tabpagebuflist(tabnr), a:bufnr) + endfo + retu winns +endf + fu! ctrlp#normcmd(cmd, ...) if a:0 < 2 && s:nosplit() | retu a:cmd | en let norwins = filter(range(1, winnr('$')), @@ -1454,6 +1585,11 @@ fu! ctrlp#normcmd(cmd, ...) retu a:0 ? a:1 : 'bo vne' endf +fu! ctrlp#modfilecond(w) + retu &mod && !&hid && &bh != 'hide' && s:bufwins(bufnr('%')) == 1 && !&cf && + \ ( ( !&awa && a:w ) || filewritable(fnamemodify(bufname('%'), ':p')) != 1 ) +endf + fu! s:nosplit() retu !empty(s:nosplit) && match([bufname('%'), &l:ft, &l:bt], s:nosplit) >= 0 endf @@ -1468,7 +1604,7 @@ endf fu! s:leavepre() if exists('s:bufnr') && s:bufnr == bufnr('%') | bw! | en - if !( exists('g:ctrlp_clear_cache_on_exit') && !g:ctrlp_clear_cache_on_exit ) + if !( exists(s:ccex) && !{s:ccex} ) \ && !( has('clientserver') && len(split(serverlist(), "\n")) > 1 ) cal ctrlp#clra() en @@ -1529,9 +1665,20 @@ endf fu! s:argmaps(md, i) let roh = [ - \ ['OpenMulti', '/h[i]dden/[c]lear', ['i', 'c']], - \ ['CreateNewFile', '/[r]eplace', ['r']], + \ ['Open Multiple Files', '/h[i]dden/[c]lear', ['i', 'c']], + \ ['Create a New File', '/[r]eplace', ['r']], + \ ['Open Selected', '/[r]eplace', ['r', 'd', 'a']], \ ] + if a:i == 2 + if !buflisted(bufnr('^'.fnamemodify(ctrlp#getcline(), ':p').'$')) + let roh[2][1] .= '/h[i]dden' + let roh[2][2] += ['i'] + en + if s:openfunc != {} && has_key(s:openfunc, s:ctype) + let roh[2][1] .= '/e[x]ternal' + let roh[2][2] += ['x'] + en + en let str = roh[a:i][0].': [t]ab/[v]ertical/[h]orizontal'.roh[a:i][1].'? ' retu s:choices(str, ['t', 'v', 'h'] + roh[a:i][2], 's:argmaps', [a:md, a:i]) endf @@ -1592,14 +1739,40 @@ endf fu! s:narrowable() retu exists('s:act_add') && exists('s:matched') && s:matched != [] \ && exists('s:mdata') && s:mdata[:2] == [s:dyncwd, s:itemtype, s:regexp] - \ && s:matcher == {} + \ && s:matcher == {} && !exists('s:did_exp') +endf + +fu! s:getinput(...) + let [prt, spi] = [s:prompt, ( a:0 ? a:1 : '' )] + if s:abbrev != {} + let gmd = has_key(s:abbrev, 'gmode') ? s:abbrev['gmode'] : '' + let str = ( gmd =~ 't' && !a:0 ) || spi == 'c' ? prt[0] : join(prt, '') + if gmd =~ 't' && gmd =~ 'k' && !a:0 && matchstr(str, '.$') =~ '\k' + retu join(prt, '') + en + let [pf, rz] = [( s:byfname ? 'f' : 'p' ), ( s:regexp ? 'r' : 'z' )] + for dict in s:abbrev['abbrevs'] + let dmd = has_key(dict, 'mode') ? dict['mode'] : '' + let pat = escape(dict['pattern'], '~') + if ( dmd == '' || ( dmd =~ pf && dmd =~ rz && !a:0 ) + \ || dmd =~ '['.spi.']' ) && str =~ pat + let [str, s:did_exp] = [join(split(str, pat, 1), dict['expanded']), 1] + en + endfo + if gmd =~ 't' && !a:0 + let prt[0] = str + el + retu str + en + en + retu spi == 'c' ? prt[0] : join(prt, '') endf fu! s:migemo(str) - let str = a:str - let dict = s:glbpath(&rtp, printf("dict/%s/migemo-dict", &enc), 1) + let [str, rtp] = [a:str, s:fnesc(&rtp, 'g')] + let dict = s:glbpath(rtp, printf("dict/%s/migemo-dict", &enc), 1) if !len(dict) - let dict = s:glbpath(&rtp, "dict/migemo-dict", 1) + let dict = s:glbpath(rtp, "dict/migemo-dict", 1) en if len(dict) let [tokens, str, cmd] = [split(str, '\s'), '', 'cmigemo -v -w %s -d %s'] @@ -1616,12 +1789,12 @@ fu! s:strwidth(str) endf fu! ctrlp#j2l(nr) - exe a:nr + exe 'norm!' a:nr.'G' sil! norm! zvzz endf fu! s:maxf(len) - retu s:maxfiles && a:len > s:maxfiles ? 1 : 0 + retu s:maxfiles && a:len > s:maxfiles endf fu! s:regexfilter(str) @@ -1633,7 +1806,7 @@ fu! s:regexfilter(str) endf fu! s:walker(m, p, d) - retu a:d > 0 ? a:p < a:m ? a:p + a:d : 0 : a:p > 0 ? a:p + a:d : a:m + retu a:d >= 0 ? a:p < a:m ? a:p + a:d : 0 : a:p > 0 ? a:p + a:d : a:m endf fu! s:delent(rfunc) @@ -1661,8 +1834,6 @@ fu! s:getenv() let [s:crword, s:crline] = [expand('', 1), getline('.')] let [s:winh, s:crcursor] = [min([s:mxheight, &lines]), getpos('.')] let [s:crbufnr, s:crvisual] = [bufnr('%'), s:lastvisual()] - let s:wpmode = exists('b:ctrlp_working_path_mode') - \ ? b:ctrlp_working_path_mode : s:pathmode let [s:mrbs, s:crgfile] = [ctrlp#mrufiles#bufs(), expand('', 1)] endf @@ -1695,15 +1866,18 @@ fu! s:buffunc(e) en endf -fu! s:openfile(cmd, fid, tail, ...) - let cmd = a:cmd =~ '^[eb]$' && &modified ? 'hid '.a:cmd : a:cmd - let cmd = cmd =~ '^tab' ? tabpagenr('$').cmd : cmd - let j2l = a:0 && a:1 ? a:2 : 0 - exe cmd.( a:0 && a:1 ? '' : a:tail ) ctrlp#fnesc(a:fid) - if j2l - exe j2l +fu! s:openfile(cmd, fid, tail, chkmod, ...) + let cmd = a:cmd + if a:chkmod && cmd =~ '^[eb]$' && ctrlp#modfilecond(!( cmd == 'b' && &aw )) + let cmd = cmd == 'b' ? 'sb' : 'sp' en - if !empty(a:tail) || j2l + let cmd = cmd =~ '^tab' ? ctrlp#tabcount().cmd : cmd + let j2l = a:0 && a:1[0] ? a:1[1] : 0 + exe cmd.( a:0 && a:1[0] ? '' : a:tail ) s:fnesc(a:fid, 'f') + if j2l + cal ctrlp#j2l(j2l) + en + if !empty(a:tail) sil! norm! zvzz en if cmd != 'bad' @@ -1711,6 +1885,26 @@ fu! s:openfile(cmd, fid, tail, ...) en endf +fu! ctrlp#tabcount() + if exists('s:tabct') + let tabct = s:tabct + let s:tabct += 1 + elsei !type(s:tabpage) + let tabct = s:tabpage + elsei type(s:tabpage) == 1 + let tabpos = + \ s:tabpage =~ 'c' ? tabpagenr() : + \ s:tabpage =~ 'f' ? 1 : + \ s:tabpage =~ 'l' ? tabpagenr('$') : + \ tabpagenr() + let tabct = + \ s:tabpage =~ 'a' ? tabpos : + \ s:tabpage =~ 'b' ? tabpos - 1 : + \ tabpos + en + retu tabct < 0 ? 0 : tabct +endf + fu! s:settype(type) retu a:type < 0 ? exists('s:itemtype') ? s:itemtype : 0 : a:type endf @@ -1763,15 +1957,27 @@ fu! s:mmode() retu matchmodes[s:mfunc] endf " Cache {{{2 -fu! s:writecache(cache_file) - let fwrite = len(g:ctrlp_allfiles) > s:nocache_lim - if ( g:ctrlp_newcache || !filereadable(a:cache_file) ) && s:caching || fwrite - if fwrite | let s:caching = 1 | en +fu! s:writecache(cafile) + if ( g:ctrlp_newcache || !filereadable(a:cafile) ) && !s:nocache() cal ctrlp#utils#writecache(g:ctrlp_allfiles) let g:ctrlp_newcache = 0 en endf +fu! s:nocache(...) + if !s:caching + retu 1 + elsei s:caching > 1 + if !( exists(s:ccex) && !{s:ccex} ) || has_key(s:ficounts, s:dyncwd) + retu get(s:ficounts, s:dyncwd, [0, 0])[0] < s:caching + elsei a:0 && filereadable(a:1) + retu len(ctrlp#utils#readfile(a:1)) < s:caching + en + retu 1 + en + retu 0 +endf + fu! s:insertcache(str) let [data, g:ctrlp_newcache, str] = [g:ctrlp_allfiles, 1, a:str] if strlen(str) <= strlen(data[0]) @@ -1808,6 +2014,14 @@ fu! s:getextvar(key) retu -1 endf +fu! ctrlp#getcline() + retu !empty(s:lines) ? s:lines[line('.') - 1] : '' +endf + +fu! ctrlp#getmarkedlist() + retu exists('s:marked') ? values(s:marked) : [] +endf + fu! ctrlp#exit() cal s:PrtExit() endf @@ -1847,15 +2061,18 @@ endf fu! ctrlp#init(type, ...) if exists('s:init') || s:iscmdwin() | retu | en + let [s:ermsg, v:errmsg] = [v:errmsg, ''] let [s:matches, s:init] = [1, 1] - cal ctrlp#reset() + cal s:Reset(a:0 ? a:1 : {}) noa cal s:Open() - cal s:SetWD(a:0 ? a:1 : '') - cal s:MapKeys() + cal s:SetWD(a:0 ? a:1 : {}) + cal s:MapNorms() + cal s:MapSpecs() cal ctrlp#syntax() cal ctrlp#setlines(s:settype(a:type)) cal s:SetDefTxt() cal s:BuildPrompt(1) + if s:keyloop | cal s:KeyLoop() | en endf " - Autocmds {{{1 if has('autocmd') diff --git a/bundle/git_ctrlp/autoload/ctrlp/buffertag.vim b/bundle/git_ctrlp/autoload/ctrlp/buffertag.vim index 73c5d9b..0a24eef 100644 --- a/bundle/git_ctrlp/autoload/ctrlp/buffertag.vim +++ b/bundle/git_ctrlp/autoload/ctrlp/buffertag.vim @@ -149,8 +149,11 @@ fu! s:esctagscmd(bin, args, ...) if exists('+ssl') let [ssl, &ssl] = [&ssl, 0] en - let fname = a:0 == 1 ? shellescape(a:1) : '' + let fname = a:0 ? shellescape(a:1) : '' let cmd = shellescape(a:bin).' '.a:args.' '.fname + if &sh =~ 'cmd\.exe' + let cmd = substitute(cmd, '[&()@^<>|]', '^\0', 'g') + en if exists('+ssl') let &ssl = ssl en @@ -170,12 +173,14 @@ fu! s:process(fname, ftype) el let data = s:exectagsonfile(a:fname, a:ftype) let [raw, lines] = [split(data, '\n\+'), []] - for line in raw | if len(split(line, ';"')) == 2 - let parsed_line = s:parseline(line) - if parsed_line != '' - cal add(lines, parsed_line) + for line in raw + if line !~# '^!_TAG_' && len(split(line, ';"')) == 2 + let parsed_line = s:parseline(line) + if parsed_line != '' + cal add(lines, parsed_line) + en en - en | endfo + endfo let cache = { a:fname : { 'time': ftime, 'lines': lines } } cal extend(g:ctrlp_buftags, cache) en @@ -183,8 +188,8 @@ fu! s:process(fname, ftype) endf fu! s:parseline(line) - let eval = '\v^([^\t]+)\t(.+)\t\/\^(.+)\$\/\;\"\t(.+)\tline(no)?\:(\d+)' - let vals = matchlist(a:line, eval) + let vals = matchlist(a:line, + \ '\v^([^\t]+)\t(.+)\t[?/]\^?(.{-1,})\$?[?/]\;\"\t(.+)\tline(no)?\:(\d+)') if vals == [] | retu '' | en let [bufnr, bufname] = [bufnr('^'.vals[2].'$'), fnamemodify(vals[2], ':p:t')] retu vals[1].' '.vals[4].'|'.bufnr.':'.bufname.'|'.vals[6].'| '.vals[3] @@ -200,6 +205,19 @@ fu! s:syntax() sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName,CtrlPTagKind en endf + +fu! s:chknearby(pat) + if match(getline('.'), a:pat) < 0 + let [int, forw, maxl] = [1, 1, line('$')] + wh !search(a:pat, 'W'.( forw ? '' : 'b' )) + if !forw + if int > maxl | brea | en + let int += int + en + let forw = !forw + endw + en +endf " Public {{{1 fu! ctrlp#buffertag#init(fname) let bufs = exists('s:btmode') && s:btmode @@ -208,7 +226,7 @@ fu! ctrlp#buffertag#init(fname) let lines = [] for each in bufs let bname = fnamemodify(each, ':p') - let tftype = get(split(getbufvar(bname, '&ft'), '\.'), 0, '') + let tftype = get(split(getbufvar('^'.bname.'$', '&ft'), '\.'), 0, '') cal extend(lines, s:process(bname, tftype)) endfo cal s:syntax() @@ -216,10 +234,15 @@ fu! ctrlp#buffertag#init(fname) endf fu! ctrlp#buffertag#accept(mode, str) - let vals = matchlist(a:str, '\v^[^\t]+\t+[^\t|]+\|(\d+)\:[^\t|]+\|(\d+)\|') - if vals == [] | retu | en - let [bufnm, linenr] = [fnamemodify(bufname(str2nr(vals[1])), ':p'), vals[2]] - cal ctrlp#acceptfile(a:mode, bufnm, linenr) + let vals = matchlist(a:str, + \ '\v^[^\t]+\t+[^\t|]+\|(\d+)\:[^\t|]+\|(\d+)\|\s(.+)$') + let bufnr = str2nr(get(vals, 1)) + if bufnr + cal ctrlp#acceptfile(a:mode, bufname(bufnr)) + exe 'norm!' str2nr(get(vals, 2, line('.'))).'G' + cal s:chknearby('\V\C'.get(vals, 3, '')) + sil! norm! zvzz + en endf fu! ctrlp#buffertag#cmd(mode, ...) diff --git a/bundle/git_ctrlp/autoload/ctrlp/changes.vim b/bundle/git_ctrlp/autoload/ctrlp/changes.vim index a658a80..c391aad 100644 --- a/bundle/git_ctrlp/autoload/ctrlp/changes.vim +++ b/bundle/git_ctrlp/autoload/ctrlp/changes.vim @@ -71,10 +71,9 @@ endf fu! ctrlp#changes#accept(mode, str) let info = matchlist(a:str, '\t|\(\d\+\):[^|]\+|\(\d\+\):\(\d\+\)|$') - if info == [] | retu | en let bufnr = str2nr(get(info, 1)) if bufnr - cal ctrlp#acceptfile(a:mode, fnamemodify(bufname(bufnr), ':p')) + cal ctrlp#acceptfile(a:mode, bufname(bufnr)) cal cursor(get(info, 2), get(info, 3)) sil! norm! zvzz en diff --git a/bundle/git_ctrlp/autoload/ctrlp/dir.vim b/bundle/git_ctrlp/autoload/ctrlp/dir.vim index b775408..2589a0b 100644 --- a/bundle/git_ctrlp/autoload/ctrlp/dir.vim +++ b/bundle/git_ctrlp/autoload/ctrlp/dir.vim @@ -10,12 +10,7 @@ if exists('g:loaded_ctrlp_dir') && g:loaded_ctrlp_dir en let [g:loaded_ctrlp_dir, g:ctrlp_newdir] = [1, 0] -let s:ars = [ - \ 's:maxdepth', - \ 's:maxfiles', - \ 's:compare_lim', - \ 's:glob', - \ ] +let s:ars = ['s:maxdepth', 's:maxfiles', 's:compare_lim', 's:glob', 's:caching'] cal add(g:ctrlp_ext_vars, { \ 'init': 'ctrlp#dir#init('.join(s:ars, ', ').')', @@ -27,6 +22,8 @@ cal add(g:ctrlp_ext_vars, { \ }) let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) + +let s:dircounts = {} " Utilities {{{1 fu! s:globdirs(dirs, depth) let entries = split(globpath(a:dirs, s:glob), "\n") @@ -35,12 +32,17 @@ fu! s:globdirs(dirs, depth) let nr = len(g:ctrlp_alldirs) if !empty(dirs) && !s:max(nr, s:maxfiles) && depth <= s:maxdepth sil! cal ctrlp#progress(nr) + cal map(dirs, 'ctrlp#utils#fnesc(v:val, "g", ",")') cal s:globdirs(join(dirs, ','), depth) en endf fu! s:max(len, max) - retu a:max && a:len > a:max ? 1 : 0 + retu a:max && a:len > a:max +endf + +fu! s:nocache() + retu !s:caching || ( s:caching > 1 && get(s:dircounts, s:cwd) < s:caching ) endf " Public {{{1 fu! ctrlp#dir#init(...) @@ -50,9 +52,9 @@ fu! ctrlp#dir#init(...) endfo let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'dir' let cafile = cadir.ctrlp#utils#lash().ctrlp#utils#cachefile('dir') - if g:ctrlp_newdir || !filereadable(cafile) + if g:ctrlp_newdir || s:nocache() || !filereadable(cafile) let [s:initcwd, g:ctrlp_alldirs] = [s:cwd, []] - cal s:globdirs(s:cwd, 0) + cal s:globdirs(ctrlp#utils#fnesc(s:cwd, 'g', ','), 0) cal ctrlp#rmbasedir(g:ctrlp_alldirs) if len(g:ctrlp_alldirs) <= s:compare_lim cal sort(g:ctrlp_alldirs, 'ctrlp#complen') @@ -65,6 +67,7 @@ fu! ctrlp#dir#init(...) let g:ctrlp_alldirs = ctrlp#utils#readfile(cafile) en en + cal extend(s:dircounts, { s:cwd : len(g:ctrlp_alldirs) }) retu g:ctrlp_alldirs endf diff --git a/bundle/git_ctrlp/autoload/ctrlp/line.vim b/bundle/git_ctrlp/autoload/ctrlp/line.vim index 10a45fa..a2e0dde 100644 --- a/bundle/git_ctrlp/autoload/ctrlp/line.vim +++ b/bundle/git_ctrlp/autoload/ctrlp/line.vim @@ -48,10 +48,9 @@ endf fu! ctrlp#line#accept(mode, str) let info = matchlist(a:str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$') - if info == [] | retu | en - let [bufnr, linenr] = [str2nr(get(info, 1)), get(info, 2)] - if bufnr > 0 - cal ctrlp#acceptfile(a:mode, fnamemodify(bufname(bufnr), ':p'), linenr) + let bufnr = str2nr(get(info, 1)) + if bufnr + cal ctrlp#acceptfile(a:mode, bufname(bufnr), get(info, 2)) en endf diff --git a/bundle/git_ctrlp/autoload/ctrlp/mrufiles.vim b/bundle/git_ctrlp/autoload/ctrlp/mrufiles.vim index 161df2d..10d7813 100644 --- a/bundle/git_ctrlp/autoload/ctrlp/mrufiles.vim +++ b/bundle/git_ctrlp/autoload/ctrlp/mrufiles.vim @@ -48,15 +48,19 @@ endf fu! s:record(bufnr) if s:locked | retu | en let bufnr = a:bufnr + 0 - if bufnr <= 0 | retu | en let bufname = bufname(bufnr) - if empty(bufname) | retu | en - let fn = fnamemodify(bufname, ':p') + if bufnr > 0 && !empty(bufname) + cal filter(s:mrbs, 'v:val != bufnr') + cal insert(s:mrbs, bufnr) + cal s:addtomrufs(bufname) + en +endf + +fu! s:addtomrufs(fname) + let fn = fnamemodify(a:fname, ':p') let fn = exists('+ssl') ? tr(fn, '/', '\') : fn - cal filter(s:mrbs, 'v:val != bufnr') - cal insert(s:mrbs, bufnr) if ( !empty({s:in}) && fn !~# {s:in} ) || ( !empty({s:ex}) && fn =~# {s:ex} ) - \ || !empty(&bt) || !filereadable(fn) | retu + \ || !empty(getbufvar('^'.fn.'$', '&bt')) || !filereadable(fn) | retu en cal filter(s:mrufs, 'v:val !='.( {s:cseno} ? '#' : '?' ).' fn') cal insert(s:mrufs, fn) @@ -87,6 +91,12 @@ fu! ctrlp#mrufiles#remove(files) retu s:reformat(copy(s:mrufs)) endf +fu! ctrlp#mrufiles#add(fn) + if !empty(a:fn) + cal s:addtomrufs(a:fn) + en +endf + fu! ctrlp#mrufiles#list(...) retu a:0 ? a:1 == 'raw' ? s:mergelists() : 0 : s:reformat(s:mergelists()) endf diff --git a/bundle/git_ctrlp/autoload/ctrlp/quickfix.vim b/bundle/git_ctrlp/autoload/ctrlp/quickfix.vim index 144851d..03ab921 100644 --- a/bundle/git_ctrlp/autoload/ctrlp/quickfix.vim +++ b/bundle/git_ctrlp/autoload/ctrlp/quickfix.vim @@ -40,18 +40,15 @@ fu! ctrlp#quickfix#init() endf fu! ctrlp#quickfix#accept(mode, str) - let items = matchlist(a:str, '^\([^|]\+\ze\)|\(\d\+\):\(\d\+\)|') - if items == [] | retu | en - let [md, filpath] = [a:mode, fnamemodify(items[1], ':p')] - if empty(filpath) | retu | en - cal ctrlp#exit() - let cmd = md == 't' ? 'tabe' : md == 'h' ? 'new' : md == 'v' ? 'vne' - \ : ctrlp#normcmd('e') - let cmd = cmd == 'e' && &modified ? 'hid e' : cmd - exe cmd ctrlp#fnesc(filpath) - cal cursor(items[2], items[3]) + let vals = matchlist(a:str, '^\([^|]\+\ze\)|\(\d\+\):\(\d\+\)|') + if vals == [] || vals[1] == '' | retu | en + cal ctrlp#acceptfile(a:mode, vals[1]) + let cur_pos = getpos('.')[1:2] + if cur_pos != [1, 1] && cur_pos != map(vals[2:3], 'str2nr(v:val)') + mark ' + en + cal cursor(vals[2], vals[3]) sil! norm! zvzz - cal ctrlp#setlcdir() endf fu! ctrlp#quickfix#id() diff --git a/bundle/git_ctrlp/autoload/ctrlp/rtscript.vim b/bundle/git_ctrlp/autoload/ctrlp/rtscript.vim index c55889e..eed21c6 100644 --- a/bundle/git_ctrlp/autoload/ctrlp/rtscript.vim +++ b/bundle/git_ctrlp/autoload/ctrlp/rtscript.vim @@ -11,7 +11,7 @@ en let [g:loaded_ctrlp_rtscript, g:ctrlp_newrts] = [1, 0] cal add(g:ctrlp_ext_vars, { - \ 'init': 'ctrlp#rtscript#init()', + \ 'init': 'ctrlp#rtscript#init(s:caching)', \ 'accept': 'ctrlp#acceptfile', \ 'lname': 'runtime scripts', \ 'sname': 'rts', @@ -20,24 +20,34 @@ cal add(g:ctrlp_ext_vars, { \ }) let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) + +let s:filecounts = {} +" Utilities {{{1 +fu! s:nocache() + retu g:ctrlp_newrts || + \ !s:caching || ( s:caching > 1 && get(s:filecounts, s:cwd) < s:caching ) +endf " Public {{{1 -fu! ctrlp#rtscript#init() - if g:ctrlp_newrts - \ || !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[0] == &rtp ) +fu! ctrlp#rtscript#init(caching) + let [s:caching, s:cwd] = [a:caching, getcwd()] + if s:nocache() || + \ !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[0] == &rtp ) sil! cal ctrlp#progress('Indexing...') - let entries = split(globpath(&rtp, '**/*.*'), "\n") + let entries = split(globpath(ctrlp#utils#fnesc(&rtp, 'g'), '**/*.*'), "\n") cal filter(entries, 'count(entries, v:val) == 1') let [entries, echoed] = [ctrlp#dirnfile(entries)[1], 1] el let [entries, results] = g:ctrlp_rtscache[2:3] en - let cwd = getcwd() - if g:ctrlp_newrts - \ || !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[:1] == [&rtp, cwd] ) - if !exists('echoed') | sil! cal ctrlp#progress('Processing...') | en + if s:nocache() || + \ !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[:1] == [&rtp, s:cwd] ) + if !exists('echoed') + sil! cal ctrlp#progress('Processing...') + en let results = map(copy(entries), 'fnamemodify(v:val, '':.'')') en - let [g:ctrlp_rtscache, g:ctrlp_newrts] = [[&rtp, cwd, entries, results], 0] + let [g:ctrlp_rtscache, g:ctrlp_newrts] = [[&rtp, s:cwd, entries, results], 0] + cal extend(s:filecounts, { s:cwd : len(results) }) retu results endf diff --git a/bundle/git_ctrlp/autoload/ctrlp/tag.vim b/bundle/git_ctrlp/autoload/ctrlp/tag.vim index 26af1a0..83921a5 100644 --- a/bundle/git_ctrlp/autoload/ctrlp/tag.vim +++ b/bundle/git_ctrlp/autoload/ctrlp/tag.vim @@ -23,9 +23,20 @@ let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) " Utilities {{{1 fu! s:findcount(str) let [tg, fname] = split(a:str, '\t\+\ze[^\t]\+$') - let [fname, tgs] = [expand(fname, 1), taglist('^'.tg.'$')] - if empty(tgs) | retu [1, 1] | en - let [fnd, ct, pos] = [0, 0, 0] + let tgs = taglist('^'.tg.'$') + if len(tgs) < 2 + retu [1, 1] + en + let bname = fnamemodify(bufname('%'), ':p') + let fname = expand(fnamemodify(simplify(fname), ':s?^[.\/]\+??:p:.'), 1) + let [fnd, ct, pos, idx] = [0, 0, 0, 0] + wh idx < len(tgs) + if bname == fnamemodify(tgs[idx]["filename"], ':p') + cal insert(tgs, remove(tgs, idx)) + brea + en + let idx += 1 + endw for each in tgs let ct += 1 let fulname = fnamemodify(each["filename"], ':p') @@ -43,11 +54,11 @@ fu! s:filter(tags) let nr = 0 wh 0 < 1 if a:tags == [] | brea | en - if a:tags[nr] =~ '^!' && a:tags[nr] !~ '^!_TAG_' + if a:tags[nr] =~ '^!' && a:tags[nr] !~# '^!_TAG_' let nr += 1 con en - if a:tags[nr] =~ '^!_TAG_' && len(a:tags) > nr + if a:tags[nr] =~# '^!_TAG_' && len(a:tags) > nr cal remove(a:tags, nr) el brea @@ -86,8 +97,9 @@ fu! ctrlp#tag#accept(mode, str) \ 'e': ['', 'tj'], \ } 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 + let cmd = a:mode == 'e' && ctrlp#modfilecond(!&aw) + \ ? ( cmd == 'tj' ? 'stj' : 'sp' ) : cmd + let cmd = a:mode == 't' ? ctrlp#tabcount().cmd : cmd if fnd[0] == 1 if cmd != '' exe cmd diff --git a/bundle/git_ctrlp/autoload/ctrlp/utils.vim b/bundle/git_ctrlp/autoload/ctrlp/utils.vim index f2aa905..7a74b7f 100644 --- a/bundle/git_ctrlp/autoload/ctrlp/utils.vim +++ b/bundle/git_ctrlp/autoload/ctrlp/utils.vim @@ -8,25 +8,28 @@ fu! ctrlp#utils#lash() retu &ssl || !exists('+ssl') ? '/' : '\' endf -let s:lash = ctrlp#utils#lash() fu! s:lash(...) retu ( a:0 ? a:1 : getcwd() ) !~ '[\/]$' ? s:lash : '' endf fu! ctrlp#utils#opts() + let s:lash = ctrlp#utils#lash() let usrhome = $HOME.s:lash($HOME) let cahome = exists('$XDG_CACHE_HOME') ? $XDG_CACHE_HOME : usrhome.'.cache' - let s:cache_dir = isdirectory(usrhome.'.ctrlp_cache') + let cadir = isdirectory(usrhome.'.ctrlp_cache') \ ? usrhome.'.ctrlp_cache' : cahome.s:lash(cahome).'ctrlp' if exists('g:ctrlp_cache_dir') - let s:cache_dir = expand(g:ctrlp_cache_dir, 1) - if isdirectory(s:cache_dir.s:lash(s:cache_dir).'.ctrlp_cache') - let s:cache_dir = s:cache_dir.s:lash(s:cache_dir).'.ctrlp_cache' + let cadir = expand(g:ctrlp_cache_dir, 1) + if isdirectory(cadir.s:lash(cadir).'.ctrlp_cache') + let cadir = cadir.s:lash(cadir).'.ctrlp_cache' en en + let s:cache_dir = cadir endf cal ctrlp#utils#opts() + +let s:wig_cond = v:version > 702 || ( v:version == 702 && has('patch051') ) " Files and Directories {{{1 fu! ctrlp#utils#cachedir() retu s:cache_dir @@ -64,8 +67,53 @@ fu! ctrlp#utils#writecache(lines, ...) endf fu! ctrlp#utils#glob(...) - let cond = v:version > 702 || ( v:version == 702 && has('patch051') ) - retu call('glob', cond ? a:000 : [a:1]) + let path = ctrlp#utils#fnesc(a:1, 'g') + retu s:wig_cond ? glob(path, a:2) : glob(path) +endf + +fu! ctrlp#utils#globpath(...) + retu call('globpath', s:wig_cond ? a:000 : a:000[:1]) +endf + +fu! ctrlp#utils#fnesc(path, type, ...) + if exists('*fnameescape') + if exists('+ssl') + if a:type == 'c' + let path = escape(a:path, '%#') + elsei a:type == 'f' + let path = fnameescape(a:path) + elsei a:type == 'g' + let path = escape(a:path, '?*') + en + let path = substitute(path, '[', '[[]', 'g') + el + let path = fnameescape(a:path) + en + el + if exists('+ssl') + if a:type == 'c' + let path = escape(a:path, '%#') + elsei a:type == 'f' + let path = escape(a:path, " \t\n%#*?|<\"") + elsei a:type == 'g' + let path = escape(a:path, '?*') + en + let path = substitute(path, '[', '[[]', 'g') + el + let path = escape(a:path, " \t\n*?[{`$\\%#'\"|!<") + en + en + retu a:0 ? escape(path, a:1) : path +endf + +fu! ctrlp#utils#dircompl(...) + let [hsl, str] = [match(a:1, '[\/]'), ''] + let par = substitute(a:1, '[^\/]*$', '', '') + let path = !hsl ? par : hsl > 0 ? getcwd().s:lash().par : getcwd() + for dir in split(globpath(ctrlp#utils#fnesc(path, 'g', ','), '*/'), '\n') + let str .= par.split(dir, '[\/]')[-1]."\n" + endfo + retu str endf "}}} diff --git a/bundle/git_ctrlp/doc/ctrlp.txt b/bundle/git_ctrlp/doc/ctrlp.txt index daa18b4..9431009 100644 --- a/bundle/git_ctrlp/doc/ctrlp.txt +++ b/bundle/git_ctrlp/doc/ctrlp.txt @@ -1,4 +1,4 @@ -*ctrlp.txt* Fuzzy file, buffer, mru, tag, ... finder. v1.7.7 +*ctrlp.txt* Fuzzy file, buffer, mru, tag, ... finder. v1.78 *CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'* =============================================================================== # # @@ -35,48 +35,52 @@ OPTIONS *ctrlp-options* Overview:~ - |loaded_ctrlp| Disable the plugin. - |ctrlp_map| Default mapping. - |ctrlp_cmd| Default command used for the default mapping. - |ctrlp_by_filename| Default to filename mode or not. - |ctrlp_regexp| Default to regexp mode or not. - |ctrlp_match_window_bottom| Where to show the match window. - |ctrlp_match_window_reversed| Sort order in the match window. - |ctrlp_max_height| Max height of the match window. - |ctrlp_switch_buffer| Jump to an open buffer if already opened. - |ctrlp_reuse_window| Reuse special windows (help, quickfix, etc). - |ctrlp_working_path_mode| How to set CtrlP's local working directory. - |ctrlp_root_markers| Additional, high priority root markers. - |ctrlp_use_caching| Use per-session caching or not. - |ctrlp_clear_cache_on_exit| Keep cache after exiting Vim or not. - |ctrlp_cache_dir| Location of the cache directory. - |ctrlp_dotfiles| Ignore dotfiles and dotdirs or not. - |ctrlp_custom_ignore| Hide stuff when using |globpath()|. - |ctrlp_max_files| Number of files to scan initially. - |ctrlp_max_depth| Directory depth to recurse into when scanning. - |ctrlp_user_command| Use an external scanner. - |ctrlp_max_history| Number of entries saved in the prompt history. - |ctrlp_open_new_file| How to open a file created by . - |ctrlp_open_multiple_files| How to open files selected by . - |ctrlp_arg_map| Intercept and or not. - |ctrlp_follow_symlinks| Follow symbolic links or not. - |ctrlp_lazy_update| Only update when typing has stopped. - |ctrlp_default_input| Seed the prompt with an initial string. - |ctrlp_use_migemo| Use Migemo patterns for Japanese filenames. - |ctrlp_prompt_mappings| Change the mappings in the prompt. + |loaded_ctrlp|................Disable the plugin. + |ctrlp_map|...................Default mapping. + |ctrlp_cmd|...................Default command used for the default mapping. + |ctrlp_by_filename|...........Default to filename mode or not. + |ctrlp_regexp|................Default to regexp mode or not. + |ctrlp_match_window_bottom|...Where to show the match window. + |ctrlp_match_window_reversed|.Sort order in the match window. + |ctrlp_max_height|............Max height of the match window. + |ctrlp_switch_buffer|.........Jump to an open buffer if already opened. + |ctrlp_reuse_window|..........Reuse special windows (help, quickfix, etc). + |ctrlp_tabpage_position|......Where to put the new tab page. + |ctrlp_working_path_mode|.....How to set CtrlP's local working directory. + |ctrlp_root_markers|..........Additional, high priority root markers. + |ctrlp_use_caching|...........Use per-session caching or not. + |ctrlp_clear_cache_on_exit|...Keep cache after exiting Vim or not. + |ctrlp_cache_dir|.............Location of the cache directory. + |ctrlp_show_hidden|...........Ignore dotfiles and dotdirs or not. + |ctrlp_custom_ignore|.........Hide stuff when using |globpath()|. + |ctrlp_max_files|.............Number of files to scan initially. + |ctrlp_max_depth|.............Directory depth to recurse into when scanning. + |ctrlp_user_command|..........Use an external scanner. + |ctrlp_max_history|...........Number of entries saved in the prompt history. + |ctrlp_open_new_file|.........How to open a file created by . + |ctrlp_open_multiple_files|...How to open files selected by . + |ctrlp_arg_map|...............Intercept and or not. + |ctrlp_follow_symlinks|.......Follow symbolic links or not. + |ctrlp_lazy_update|...........Only update when typing has stopped. + |ctrlp_default_input|.........Seed the prompt with an initial string. + |ctrlp_abbrev|................Input abbreviations. + |ctrlp_key_loop|..............Use input looping for multi-byte input. + |ctrlp_use_migemo|............Use Migemo patterns for Japanese filenames. + |ctrlp_prompt_mappings|.......Change the mappings inside the prompt. MRU mode: - |ctrlp_mruf_max| Max MRU entries to remember. - |ctrlp_mruf_exclude| Files that shouldn't be remembered. - |ctrlp_mruf_include| Files to be remembered. - |ctrlp_mruf_relative| Show only MRU files in the working directory. - |ctrlp_mruf_default_order| Disable sorting. - |ctrlp_mruf_case_sensitive| MRU files are case sensitive or not. + |ctrlp_mruf_max|..............Max MRU entries to remember. + |ctrlp_mruf_exclude|..........Files that shouldn't be remembered. + |ctrlp_mruf_include|..........Files to be remembered. + |ctrlp_mruf_relative|.........Show only MRU files in the working directory. + |ctrlp_mruf_default_order|....Disable sorting. + |ctrlp_mruf_case_sensitive|...MRU files are case sensitive or not. Advanced options: - |ctrlp_status_func| Change CtrlP's two statuslines. - |ctrlp_buffer_func| Call custom functions in the CtrlP buffer. - |ctrlp_match_func| Replace the built-in matching algorithm. + |ctrlp_open_func|.............Use custom file opening functions. + |ctrlp_status_func|...........Change CtrlP's two statuslines. + |ctrlp_buffer_func|...........Call custom functions in the CtrlP buffer. + |ctrlp_match_func|............Replace the built-in matching algorithm. ------------------------------------------------------------------------------- Detailed descriptions and default values:~ @@ -126,13 +130,16 @@ Set the maximum height of the match window: > < *'g:ctrlp_switch_buffer'* -When opening a file with or , if the file's already opened somewhere -CtrlP will try to jump to it instead of opening a new instance: > - let g:ctrlp_switch_buffer = 2 +When opening a file, if it's already open in a window somewhere, CtrlP will try +to jump to it instead of opening a new instance: > + let g:ctrlp_switch_buffer = 'Et' < - 1 - only jump to the buffer if it's opened in the current tab. - 2 - jump tab as well if the buffer's opened in another tab. - 0 - disable this feature. + e - jump when is pressed, but only to windows in the current tab. + t - jump when is pressed, but only to windows in another tab. + v - like "e", but jump when is pressed. + h - like "e", but jump when is pressed. + E, T, V, H - like "e", "t", "v", and "h", but jump to windows anywhere. + 0 or - disable this feature. *'g:ctrlp_reuse_window'* When opening a file with , CtrlP avoids opening it in windows created by @@ -145,29 +152,52 @@ Example: > let g:ctrlp_reuse_window = 'netrw\|help\|quickfix' < + *'g:ctrlp_tabpage_position'* +Where to put the new tab page when opening one: > + let g:ctrlp_tabpage_position = 'ac' +< + a - after. + b - before. + c - the current tab page. + l - the last tab page. + f - the first tab page. + *'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 + let g:ctrlp_working_path_mode = 'ra' < - 1 - the directory of the current file. - 2 - the nearest ancestor that contains one of these directories or files: + c - the directory of the current file. + a - like "c", but only applies when the current working directory outside of + CtrlP isn't a direct ancestor of the directory of the current file. + r - the nearest ancestor that contains one of these directories or files: .git .hg .svn .bzr _darcs - 0 - don't manage working directory. -Note: you can use b:ctrlp_working_path_mode (a |b:var|) to set this option on a -per buffer basis. + w - begin finding a root from the current working directory outside of CtrlP + instead of from the directory of the current file (default). Only applies + when "r" is also present. + 0 or - disable this feature. + +Note #1: if "a" or "c" is included with "r", use the behavior of "a" or "c" (as +a fallback) when a root can't be found. + +Note #2: you can use 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 (.git, .hg, .svn, .bzr, and _darcs). Your markers will take precedence: > let g:ctrlp_root_markers = [''] < +Note: you can use a |b:var| to set this option on a per buffer basis. *'g:ctrlp_use_caching'* -Set this to 0 to disable per-session caching. When disabled, caching will still -be enabled for directories that have more than 4000 files: > +Enable/Disable per-session caching: > let g:ctrlp_use_caching = 1 < + 0 - Disable caching. + 1 - Enable caching. + n - When bigger than 1, disable caching and use the number as the limit to + enable caching again. + Note: you can quickly purge the cache by pressing while inside CtrlP. *'g:ctrlp_clear_cache_on_exit'* @@ -181,15 +211,20 @@ Set the directory to store the cache files: > let g:ctrlp_cache_dir = $HOME.'/.cache/ctrlp' < - *'g:ctrlp_dotfiles'* -Set this to 0 if you don't want CtrlP to scan for dotfiles and dotdirs: > - let g:ctrlp_dotfiles = 1 + *'g:ctrlp_show_hidden'* +Set this to 1 if you want CtrlP to scan for dotfiles and dotdirs: > + let g:ctrlp_show_hidden = 0 < -You can use |'wildignore'| to exclude anything from the search. +Note: does not apply when a command defined with |g:ctrlp_user_command| is +being used. + + *'ctrlp-wildignore'* +You can use Vim's |'wildignore'| to exclude files and directories from the +results. Examples: > " Excluding version control directories - set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " Linux/MacOSX - set wildignore+=.git\*,.hg\*,.svn\* " Windows + set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " Linux/MacOSX + set wildignore+=*\\.git\\*,*\\.hg\\*,*\\.svn\\* " Windows ('noshellslash') < Note #1: the `*/` in front of each directory glob is required. @@ -204,25 +239,36 @@ CtrlP to not show. Use regexp to specify the patterns: > let g:ctrlp_custom_ignore = '' < Examples: > - let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$' + let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$' let g:ctrlp_custom_ignore = { - \ 'dir': '\.git$\|\.hg$\|\.svn$', - \ 'file': '\.exe$\|\.so$\|\.dll$', + \ 'dir': '\v[\/]\.(git|hg|svn)$', + \ 'file': '\v\.(exe|so|dll)$', \ 'link': 'SOME_BAD_SYMBOLIC_LINKS', \ } + let g:ctrlp_custom_ignore = { + \ 'file': '\v(\.cpp|\.h|\.hh|\.cxx)@ let g:ctrlp_max_files = 10000 < +Note: does not apply when a command defined with |g:ctrlp_user_command| is +being used. *'g:ctrlp_max_depth'* The maximum depth of a directory tree to recurse into: > let g:ctrlp_max_depth = 40 < -Note: the larger these values, the more memory Vim uses. +Note: does not apply when a command defined with |g:ctrlp_user_command| is +being used. *'g:ctrlp_user_command'* Specify an external tool to use for listing files instead of using Vim's @@ -235,8 +281,10 @@ Examples: > < You can also use 'grep', 'findstr' or something else to filter the results. Examples: > - let g:ctrlp_user_command = 'find %s -type f | grep (?!tmp/.*)' - let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d | findstr .*\.py$' + let g:ctrlp_user_command = + \ 'find %s -type f | grep -v -P "\.jpg$|/tmp/"' " MacOSX/Linux + let g:ctrlp_user_command = + \ 'dir %s /-n /b /s /a-d | findstr /v /l ".jpg \\tmp\\"' " Windows < Use a version control listing command when inside a repository, this is faster when scanning large projects: > @@ -246,22 +294,46 @@ when scanning large projects: > \ 1: [root_marker_1, listing_command_1], \ n: [root_marker_n, listing_command_n], \ }, - \ 'fallback': fallback_command + \ 'fallback': fallback_command, + \ 'ignore': 0 or 1 \ } < -Examples: > - let g:ctrlp_user_command = ['.git/', 'cd %s && git ls-files'] - let g:ctrlp_user_command = ['.hg/', 'hg --cwd %s locate -I .'] +Some examples: > + " Single VCS, listing command does not list untracked files: + let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files'] + let g:ctrlp_user_command = ['.hg', 'hg --cwd %s locate -I .'] + + " Multiple VCS's: let g:ctrlp_user_command = { \ 'types': { - \ 1: ['.git/', 'cd %s && git ls-files'], - \ 2: ['.hg/', 'hg --cwd %s locate -I .'], + \ 1: ['.git', 'cd %s && git ls-files'], + \ 2: ['.hg', 'hg --cwd %s locate -I .'], \ }, \ 'fallback': 'find %s -type f' \ } + + " Single VCS, listing command lists untracked files (slower): + let g:ctrlp_user_command = + \ ['.git', 'cd %s && git ls-files . -co --exclude-standard'] + + let g:ctrlp_user_command = + \ ['.hg', 'hg --cwd %s status -numac -I . $(hg root)'] " MacOSX/Linux + + let g:ctrlp_user_command = ['.hg', 'for /f "tokens=1" %%a in (''hg root'') ' + \ . 'do hg --cwd %s status -numac -I . %%a'] " Windows < -If the fallback_command is empty or not defined, |globpath()| will then be used -when searching outside a repo. +Note #1: if the fallback_command is empty or the 'fallback' key is not defined, +|globpath()| will then be used when scanning outside of a repository. + +Note #2: unless the |Dictionary| format is used and 'ignore' is defined and set +to 1, the |wildignore| and |g:ctrlp_custom_ignore| options do not apply when +these custom commands are being used. When not present, 'ignore' is set to 0 by +default to retain the performance advantage of using external commands. + +Note #3: when changing the option's variable type, remember to |:unlet| it +first or restart Vim to avoid the "E706: Variable type mismatch" error. + +Note #4: you can use a |b:var| to set this option on a per buffer basis. *'g:ctrlp_max_history'* The maximum number of input strings you want CtrlP to remember. The default @@ -272,14 +344,13 @@ Set to 0 to disable prompt's history. Browse the history with and . *'g:ctrlp_open_new_file'* Use this option to specify how the newly created file is to be opened when -pressing : - t - in a new tab - h - in a new horizontal split - v - in a new vertical split - r - in the current window -> +pressing : > let g:ctrlp_open_new_file = 'v' < + t - in a new tab. + h - in a new horizontal split. + v - in a new vertical split. + r - in the current window. *'g:ctrlp_open_multiple_files'* If non-zero, this will enable opening multiple files with and : > @@ -292,17 +363,16 @@ For the number: - If given, it'll 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, will open all files, each in a new window or new tab. + For the letters: t - each file in a new tab. h - each file in a new horizontal split. v - each file in a new vertical split. i - all files as hidden buffers. j - after opening, jump to the first opened tab or window. - Reuse the current window: - tr, - hr, - vr - open the first file in the current window, then the remaining files in - new splits or new tabs just like with t, h, v. + r - open the first file in the current window, then the remaining files in + new splits or new tabs depending on which of "h", "v" and "t" is also + present. *'g:ctrlp_arg_map'* When this is set to 1, the and mappings will accept one extra key @@ -328,6 +398,9 @@ If non-zero, CtrlP will follow symbolic links when listing files: > 1 - follow but ignore looped internal symlinks to avoid duplicates. 2 - follow all symlinks indiscriminately. +Note: does not apply when a command defined with |g:ctrlp_user_command| is +being used. + *'g:ctrlp_lazy_update'* Set this to 1 to enable the lazy-update feature: only update the match window after typing's been stopped for a certain amount of time: > @@ -341,6 +414,72 @@ Set this to 1 to enable seeding the prompt with the current file's relative path: > let g:ctrlp_default_input = 0 < +Instead of 1 or 0, if the value of the option is a string, it'll be used as-is +as the default input: > + let g:ctrlp_default_input = 'anystring' +< + + *'g:ctrlp_abbrev'* +Define input abbreviations that can be expanded (either internally or visibly) +in the prompt: > + let g:ctrlp_abbrev = {} +< +Examples: > + let g:ctrlp_abbrev = { + \ 'gmode': 'i', + \ 'abbrevs': [ + \ { + \ 'pattern': '^cd b', + \ 'expanded': '@cd ~/.vim/bundle', + \ 'mode': 'pfrz', + \ }, + \ { + \ 'pattern': '\(^@.\+\|\\\@ (use the expanded string in the + new filename). + c - only when auto-completing directory names with (expand the pattern + immediately before doing the auto-completion). + or not defined - always enable. + +Note: the abbrev entries are evaluated in sequence, so a later entry can be +evaluated against the expanded result of a previous entry; this includes itself +when 'gmode' is "t". + + *'g:ctrlp_key_loop'* +An experimental feature. Set this to 1 to enable input looping for the typing +of multi-byte characters: > + let g:ctrlp_key_loop = 0 +< +Note #1: when set, this option resets the |g:ctrlp_lazy_update| option. + +Note #2: you can toggle this feature inside the prompt with a custom mapping: > + let g:ctrlp_prompt_mappings = { 'ToggleKeyLoop()': [''] } +< *'g:ctrlp_use_migemo'* Set this to 1 to use Migemo Pattern for Japanese filenames. Migemo Search only @@ -388,9 +527,8 @@ only need to keep the lines that you've changed the values (inside []): > \ 'PrtExit()': ['', '', ''], \ } < -Note: In some terminals, it's not possible to remap without also changing - (|keycodes|). So if pressing moves the cursor to the left instead of -deleting a char for you, add this to your |.vimrc| to disable the plugin's +Note: if pressing moves the cursor one character to the left instead of +deleting a character for you, add this to your |.vimrc| to disable the plugin's default mapping: > let g:ctrlp_prompt_mappings = { 'PrtCurLeft()': ['', ''] } < @@ -439,6 +577,65 @@ MRU entries: > ---------------------------------------- Advanced options:~ + *'g:ctrlp_open_func'* +Define a custom function to open the selected file: > + let g:ctrlp_open_func = {} +< +Example: > + let g:ctrlp_open_func = { + \ 'files' : 'Function_Name_1', + \ 'buffers' : 'Function_Name_2', + \ 'mru files' : 'Function_Name_3', + \ } +< +Structure of the functions: > + function! Function_Name(action, line) + " Arguments: + " | + " +- a:action : The opening action: + " | + 'e' : user pressed (default) + " | + 'h' : user pressed (default) + " | + 'v' : user pressed (default) + " | + 't' : user pressed (default) + " | + 'x' : user used the console dialog (default) and + " | chose "e[x]ternal". + " | + " +- a:line : The selected line. + + endfunction +< +Note: does not apply when opening multiple files with and . + +Example: open HTML files in the default web browser when is pressed and +in Vim otherwise > + function! HTMLOpenFunc(action, line) + if a:action =~ '^[tx]$' && fnamemodify(a:line, ':e') =~? '^html\?$' + + " Get the filename + let filename = fnameescape(fnamemodify(a:line, ':p')) + + " Close CtrlP + call ctrlp#exit() + + " Open the file + silent! execute '!xdg-open' filename + + elseif a:action == 'x' && fnamemodify(a:line, ':e') !~? '^html\?$' + + " Not a HTML file, simulate pressing again and wait for new input + call feedkeys("\") + + else + + " Use CtrlP's default file opening function + call call('ctrlp#acceptfile', [a:action, a:line]) + + endif + endfunction + + let g:ctrlp_open_func = { 'files': 'HTMLOpenFunc' } +< + *'g:ctrlp_status_func'* Use this to customize the statuslines for the CtrlP window: > let g:ctrlp_status_func = {} @@ -551,13 +748,14 @@ COMMANDS *ctrlp-commands* Open CtrlP in find Most-Recently-Used file mode. *:CtrlPLastMode* -:CtrlPLastMode - Open CtrlP in the last mode used. +:CtrlPLastMode [--dir] + Open CtrlP in the last mode used. When having the "--dir" argument, also + reuse the last working directory. *:CtrlPRoot* :CtrlPRoot - This acts like |:CtrlP| with |g:ctrlp_working_path_mode| = 2 (ignores the - variable's current value). + This acts like |:CtrlP| with |g:ctrlp_working_path_mode| = 'r' and ignores + the variable's current value. *:CtrlPClearCache* :CtrlPClearCache @@ -665,7 +863,7 @@ Opening/Creating a file:~ Open the selected file in the 'current' window if possible. - Open the selected file in a new 'tab' after the last tabpage. + Open the selected file in a new 'tab'. Open the selected file in a 'vertical' split. @@ -685,7 +883,22 @@ Opening multiple files:~ - Mark/unmark a file to create a new file in its directory using . - Open files marked by . + - Open files marked by . + - When no file has been marked by , open a console dialog with the + following options: + + Open the selected file: + t - in a tab page. + v - in a vertical split. + h - in a horizontal split. + r - in the current window. + i - as a hidden buffer. + x - (optional) with the function defined in |g:ctrlp_open_func|. + + Other options (not shown): + a - mark all files in the match window. + d - change CtrlP's local working directory to the selected file's + directory and switch to find file mode. Function keys:~ @@ -704,7 +917,7 @@ Pasting:~ Paste the clipboard content into the prompt. - Open a text dialog to paste , , the content of the search + Open a console dialog to paste , , the content of the search register, the last visual selection, the clipboard or any register into the prompt. @@ -716,8 +929,7 @@ When inside the match window (press to switch):~ a-z 0-9 ~^-=;`',.+!@#$%&_(){}[] - Cycle through the lines with the first letter (of paths or filenames) that - matches that key. + Cycle through the lines which have the matching first character. =============================================================================== INPUT FORMATS *ctrlp-input-formats* @@ -809,7 +1021,7 @@ Available extensions:~ *:CtrlPTag* * Tag mode:~ - Name: 'tag' - - Command: ':CtrlPTag' + - Command: ":CtrlPTag" - Search for a tag within a generated central tags file, and jump to the definition. Use the Vim's option |'tags'| to specify the names and the locations of the tags file(s). @@ -819,21 +1031,21 @@ Available extensions:~ *:CtrlPBufTagAll* * Buffer Tag mode:~ - Name: 'buffertag' - - Commands: ':CtrlPBufTag [buffer]', - ':CtrlPBufTagAll'. + - Commands: ":CtrlPBufTag [buffer]", + ":CtrlPBufTagAll". - Search for a tag within the current buffer or all listed buffers and jump to the definition. Requires |exuberant_ctags| or compatible programs. *:CtrlPQuickfix* * Quickfix mode:~ - Name: 'quickfix' - - Command: ':CtrlPQuickfix' + - Command: ":CtrlPQuickfix" - Search for an entry in the current quickfix errors and jump to it. *:CtrlPDir* * Directory mode:~ - Name: 'dir' - - Command: ':CtrlPDir [starting-directory]' + - Command: ":CtrlPDir [starting-directory]" - Search for a directory and change the working directory to it. - Mappings: + change the local working directory for CtrlP and keep it open. @@ -845,42 +1057,42 @@ Available extensions:~ *:CtrlPRTS* * Runtime script mode:~ - Name: 'rtscript' - - Command: ':CtrlPRTS' + - Command: ":CtrlPRTS" - Search for files (vimscripts, docs, snippets...) in runtimepath. *:CtrlPUndo* * Undo mode:~ - Name: 'undo' - - Command: ':CtrlPUndo' + - Command: ":CtrlPUndo" - Browse undo history. *:CtrlPLine* * Line mode:~ - Name: 'line' - - Command: ':CtrlPLine' + - Command: ":CtrlPLine" - Search for a line in all listed buffers. *:CtrlPChange* *:CtrlPChangeAll* * Change list mode:~ - Name: 'changes' - - Commands: ':CtrlPChange [buffer]', - ':CtrlPChangeAll'. + - Commands: ":CtrlPChange [buffer]", + ":CtrlPChangeAll". - Search for and jump to a recent change in the current buffer or in all listed buffers. *:CtrlPMixed* * Mixed mode:~ - Name: 'mixed' - - Command: ':CtrlPMixed' + - Command: ":CtrlPMixed" - Search in files, buffers and MRU files at the same time. *:CtrlPBookmarkDir* *:CtrlPBookmarkDirAdd* * BookmarkDir mode:~ - Name: 'bookmarkdir' - - Commands: ':CtrlPBookmarkDir', - ':CtrlPBookmarkDirAdd [directory]'. + - Commands: ":CtrlPBookmarkDir", + ":CtrlPBookmarkDirAdd [directory]". - Search for a bookmarked directory and change the working directory to it. - Mappings: + change the local working directory for CtrlP, keep it open and @@ -1026,11 +1238,22 @@ Special thanks:~ * Tacahiroy * Luca Pette * Seth Fowler - * Lowe Thiderman + * Lowe Thiderman + * Christopher Fredén =============================================================================== CHANGELOG *ctrlp-changelog* + + New options: |g:ctrlp_abbrev|, + |g:ctrlp_key_loop|, + |g:ctrlp_open_func|, + |g:ctrlp_tabpage_position| + + Rename: + *g:ctrlp_dotfiles* -> |g:ctrlp_show_hidden|. + + Change |g:ctrlp_switch_buffer|'s and |g:ctrlp_working_path_mode|'s type + (old values still work). + + New key for |g:ctrlp_user_command| when it's a Dictionary: 'ignore'. + Before 2012/06/15~ + New value for |g:ctrlp_follow_symlinks|: 2. diff --git a/bundle/git_ctrlp/plugin/ctrlp.vim b/bundle/git_ctrlp/plugin/ctrlp.vim index 245f712..68cae86 100644 --- a/bundle/git_ctrlp/plugin/ctrlp.vim +++ b/bundle/git_ctrlp/plugin/ctrlp.vim @@ -17,24 +17,24 @@ let [g:ctrlp_lines, g:ctrlp_allfiles, g:ctrlp_alltags, g:ctrlp_alldirs, if !exists('g:ctrlp_map') | let g:ctrlp_map = '' | en if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en -com! -n=? -com=dir CtrlP cal ctrlp#init(0, ) +com! -n=? -com=custom,ctrlp#utils#dircompl CtrlP + \ cal ctrlp#init(0, { 'dir': }) -com! CtrlPBuffer cal ctrlp#init(1) -com! CtrlPMRUFiles cal ctrlp#init(2) +com! -n=? -com=custom,ctrlp#utils#dircompl CtrlPMRUFiles + \ cal ctrlp#init(2, { 'dir': }) -com! CtrlPLastMode cal ctrlp#init(-1) +com! -bar CtrlPBuffer cal ctrlp#init(1) +com! -n=? CtrlPLastMode cal ctrlp#init(-1, { 'args': }) -com! CtrlPClearCache cal ctrlp#clr() -com! CtrlPClearAllCaches cal ctrlp#clra() -com! CtrlPReload cal ctrlp#reset() +com! -bar CtrlPClearCache cal ctrlp#clr() +com! -bar CtrlPClearAllCaches cal ctrlp#clra() -com! ClearCtrlPCache cal ctrlp#clr() -com! ClearAllCtrlPCaches cal ctrlp#clra() -com! ResetCtrlP cal ctrlp#reset() +com! -bar ClearCtrlPCache cal ctrlp#clr() +com! -bar ClearAllCtrlPCaches cal ctrlp#clra() -com! CtrlPCurWD cal ctrlp#init(0, 0) -com! CtrlPCurFile cal ctrlp#init(0, 1) -com! CtrlPRoot cal ctrlp#init(0, 2) +com! -bar CtrlPCurWD cal ctrlp#init(0, { 'mode': '' }) +com! -bar CtrlPCurFile cal ctrlp#init(0, { 'mode': 'c' }) +com! -bar CtrlPRoot cal ctrlp#init(0, { 'mode': 'r' }) if g:ctrlp_map != '' && !hasmapto(':'.g:ctrlp_cmd.'', 'n') exe 'nn ' g:ctrlp_map ':'.g:ctrlp_cmd.'' @@ -42,20 +42,28 @@ en cal ctrlp#mrufiles#init() -com! CtrlPTag cal ctrlp#init(ctrlp#tag#id()) -com! CtrlPQuickfix cal ctrlp#init(ctrlp#quickfix#id()) -com! -n=? -com=dir CtrlPDir - \ cal ctrlp#init(ctrlp#dir#id(), ) +com! -bar CtrlPTag cal ctrlp#init(ctrlp#tag#id()) +com! -bar CtrlPQuickfix cal ctrlp#init(ctrlp#quickfix#id()) + +com! -n=? -com=custom,ctrlp#utils#dircompl CtrlPDir + \ cal ctrlp#init(ctrlp#dir#id(), { 'dir': }) + com! -n=? -com=buffer CtrlPBufTag \ cal ctrlp#init(ctrlp#buffertag#cmd(0, )) -com! CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1)) -com! CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id()) -com! CtrlPUndo cal ctrlp#init(ctrlp#undo#id()) -com! CtrlPLine cal ctrlp#init(ctrlp#line#id()) + +com! -bar CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1)) +com! -bar CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id()) +com! -bar CtrlPUndo cal ctrlp#init(ctrlp#undo#id()) +com! -bar CtrlPLine cal ctrlp#init(ctrlp#line#id()) + com! -n=? -com=buffer CtrlPChange \ cal ctrlp#init(ctrlp#changes#cmd(0, )) -com! CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1)) -com! CtrlPMixed cal ctrlp#init(ctrlp#mixed#id()) -com! CtrlPBookmarkDir cal ctrlp#init(ctrlp#bookmarkdir#id()) -com! -n=? -com=dir CtrlPBookmarkDirAdd + +com! -bar CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1)) +com! -bar CtrlPMixed cal ctrlp#init(ctrlp#mixed#id()) +com! -bar CtrlPBookmarkDir cal ctrlp#init(ctrlp#bookmarkdir#id()) + +com! -n=? -com=custom,ctrlp#utils#dircompl CtrlPBookmarkDirAdd \ cal ctrlp#call('ctrlp#bookmarkdir#add', ) + +" vim:ts=2:sw=2:sts=2 diff --git a/bundle/git_ctrlp/readme.md b/bundle/git_ctrlp/readme.md index af6b554..2525b83 100644 --- a/bundle/git_ctrlp/readme.md +++ b/bundle/git_ctrlp/readme.md @@ -1,5 +1,5 @@ # ctrlp.vim -Fuzzy __file__, __buffer__, __mru__, __tag__, ... finder for Vim. +Full path fuzzy __file__, __buffer__, __mru__, __tag__, __...__ finder for Vim. * Written in pure Vimscript for MacVim, gVim and Vim 7.0+. * Full support for Vim's regexp as search patterns. @@ -11,68 +11,60 @@ Fuzzy __file__, __buffer__, __mru__, __tag__, ... finder for Vim. ![ctrlp][1] -## Installation -1. Clone the plugin into a separate directory: +## Basic Usage +* Run `:CtrlP` or `:CtrlP [starting-directory]` to invoke CtrlP in find file mode. +* Run `:CtrlPBuffer` or `:CtrlPMRU` to invoke CtrlP in find buffer or find MRU file mode. +* Run `:CtrlPMixed` to search in Files, Buffers and MRU files at the same time. - ``` - $ cd ~/.vim - $ git clone https://github.com/kien/ctrlp.vim.git bundle/ctrlp.vim - ``` +Check `:help ctrlp-commands` and `:help ctrlp-extensions` for other commands. -2. Add to your `~/.vimrc`: +##### Once CtrlP is open: +* Press `` to purge the cache for the current directory to get new files, remove deleted files and apply new ignore options. +* Press `` and `` to cycle between modes. +* Press `` to switch to filename only search instead of full path. +* Press `` to switch to regexp mode. +* Use ``, `` to select the next/previous string in the prompt's history. +* Use `` to create a new file and its parent directories. +* Use `` to mark/unmark multiple files and `` to open them. + +Run `:help ctrlp-mappings` or submit `?` in CtrlP for more mapping help. + +* Submit two or more dots `..` to go up the directory tree by one or multiple levels. +* End the input string with a colon `:` followed by a command to execute it on the opening file(s): +Use `:25` to jump to line 25. +Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 files. + +## Basic Options +* Change the default mapping and the default command to invoke CtrlP: ```vim - set runtimepath^=~/.vim/bundle/ctrlp.vim + let g:ctrlp_map = '' + let g:ctrlp_cmd = 'CtrlP' ``` -3. Run at Vim's command line: - - ``` - :helptags ~/.vim/bundle/ctrlp.vim/doc - ``` - -4. Restart Vim and start reading `:help ctrlp.txt` for usage and configuration details. - -On Windows, use the `$HOME/vimfiles` or the `$VIM/vimfiles` directory instead of the `~/.vim` directory. - -## Usage -1. See `:help ctrlp-commands` and `:help ctrlp-extensions`. -2. Once the prompt's open: - * Press `` and `` to cycle between modes. - * Press `` to switch to filename only search instead of full path. - * Press `` to purge the cache for the current directory and get new files. - * Submit two or more dots `..` to go up the directory tree by one or multiple levels. - * Use ``, `` to go to the next/previous string in the prompt's history. - * Use `` to create a new file and its parent dirs. - * Use `` to mark/unmark multiple files and `` to open them. - * End the input string with a colon `:` followed by a command to execute it on the opening file(s). - - More at `:help ctrlp-mappings`. - -## Configuration -* Unless a starting directory is specified, the local working directory will be set according to this variable: +* When invoked, unless a starting directory is specified, CtrlP will set its local working directory according to this variable: ```vim - let g:ctrlp_working_path_mode = 2 + let g:ctrlp_working_path_mode = 'ra' ``` - 0 - don't manage working directory. - 1 - the directory of the current file. - 2 - the nearest ancestor that contains one of these directories or files: - `.git` `.hg` `.svn` `.bzr` `_darcs` + `'c'` - the directory of the current file. + `'r'` - the nearest ancestor that contains one of these directories or files: `.git` `.hg` `.svn` `.bzr` `_darcs` + `'a'` - like c, but only if the current working directory outside of CtrlP is not a direct ancestor of the directory of the current file. + `0` or `''` (empty string) - disable this feature. Define additional root markers with the `g:ctrlp_root_markers` option. -* Exclude files and directories: +* Exclude files and directories using Vim's `wildignore` and CtrlP's own `g:ctrlp_custom_ignore`: ```vim - set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux - set wildignore+=tmp\*,*.swp,*.zip,*.exe " 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 = '\v[\/]\.(git|hg|svn)$' let g:ctrlp_custom_ignore = { - \ 'dir': '\.git$\|\.hg$\|\.svn$', - \ 'file': '\.exe$\|\.so$\|\.dll$', + \ 'dir': '\v[\/]\.(git|hg|svn)$', + \ 'file': '\v\.(exe|so|dll)$', \ 'link': 'some_bad_symbolic_links', \ } ``` @@ -84,7 +76,11 @@ On Windows, use the `$HOME/vimfiles` or the `$VIM/vimfiles` directory instead of let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows ``` -More at `:help ctrlp-options`. +Check `:help ctrlp-options` for other options. + +## Installation +Use your favorite method or check the homepage for a [quick installation guide][3]. [1]: http://i.imgur.com/yIynr.png [2]: https://github.com/kien/ctrlp.vim/tree/extensions +[3]: http://kien.github.com/ctrlp.vim#installation diff --git a/bundle/git_syntastic/README.markdown b/bundle/git_syntastic/README.markdown index 78f97c6..a8ed1aa 100644 --- a/bundle/git_syntastic/README.markdown +++ b/bundle/git_syntastic/README.markdown @@ -50,12 +50,44 @@ enabled. Installation ------------ -[pathogen.vim](https://github.com/tpope/vim-pathogen) is the recommended way to install syntastic. +Installing syntastic is easy but first you need to have the pathogen plugin installed. If you already +have pathogen working then skip Step 1 and go to Step 2. + +Step 1: Install pathogen.vim +---------------------------- + +First I'll show you how to install tpope's [pathogen.vim](https://github.com/tpope/vim-pathogen) so that +it's easy to install syntastic. Do this in your Terminal so that you get the pathogen.vim file +and the directories it needs: + + mkdir -p ~/.vim/autoload ~/.vim/bundle; \ + curl -so ~/.vim/autoload/pathogen.vim \ + https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim + +Next you *need to add this* to your ~/.vimrc: + + call pathogen#infect() + +Step 2: Install syntastic as a pathogen bundle +---------------------------------------------- + +You now have pathogen installed and can put syntastic into ~/.vim/bundle like this: + cd ~/.vim/bundle git clone https://github.com/scrooloose/syntastic.git -Then reload vim, run `:Helptags`, and check out `:help syntastic.txt`. +Quit vim and start it back up to reload it, then type: + + :Helptags + +If you get an error when you do this, then you probably didn't install pathogen right. Go back to +step 1 and make sure you did the following: + +1. Created both the ~/.vim/autoload and ~/.vim/bundle directories. +2. Added the "call pathogen#infect()" line to your ~/.vimrc file +3. Did the git clone of syntastic inside ~/.vim/bundle +4. Have permissions to access all of these directories. Google group @@ -69,10 +101,15 @@ FAQ __Q. I installed syntastic but it isn't reporting any errors ...__ -A. The most likely reason is that the syntax checker that it requires isn't installed. For example: python requires either `flake8`, `pyflakes` or `pylint` to be installed and in `$PATH`. To see which executable is required, just look in `syntax_checkers/.vim`. +A. The most likely reason is that the syntax checker that it requires isn't installed. For example: python requires either `flake8`, `pyflakes` or `pylint` to be installed and in `$PATH`. To see which executable is required, just look in `syntax_checkers/.vim`. Note that aliases do not work; the actual executable must be available in your `$PATH`. Symbolic links are okay. Another reason it could fail is that the error output for the syntax checker may have changed. In this case, make sure you have the latest version of the syntax checker installed. If it still fails then create an issue - or better yet, create a pull request. +__Q. How can I jump between the different errors without using the location list at the bottom of the window?__ + +A. Vim provides several built in commands for this. See `:help :lnext` and `:help :lprev`. + +If you use these commands a lot then you may want to add shortcut mappings to your vimrc, or install something like [unimpaired](https://github.com/tpope/vim-unimpaired) - which provides such mappings (among other things). Changelog --------- diff --git a/bundle/git_syntastic/doc/syntastic.txt b/bundle/git_syntastic/doc/syntastic.txt index f0cede3..694fd28 100644 --- a/bundle/git_syntastic/doc/syntastic.txt +++ b/bundle/git_syntastic/doc/syntastic.txt @@ -163,6 +163,20 @@ syntax errors: > let g:syntastic_enable_signs=1 < + *'syntastic_error_symbol'* *'syntastic_style_error_symbol'* + *'syntastic_warning_symbol'* *'syntastic_style_warning_symbol'* +Use this option to control what the syntastic |:sign| text contains. Several +error symobls can be customized: + syntastic_error_symbol - For syntax errors, defaults to '>>' + syntastic_style_error_symbol - For style errors, defaults to 'S>' + syntastic_warning_symbol - For syntax warnings, defaults to '>>' + syntastic_style_warning_symbol - For style warnings, defaults to 'S>' + +Example: > + let g:syntastic_error_symbol='✗' + let g:syntastic_warning_symbol='⚠' +< + *'syntastic_enable_balloons'* Default: 1 Use this option to tell syntastic whether to display error messages in balloons @@ -340,7 +354,7 @@ The author of syntastic is a mighty wild stallion, hear him roar! > < He likes to trot around in the back yard reading his emails and sipping a -scolding hot cup of Earl Grey. Email him at martin.grenfell at gmail dot com. +scalding hot cup of Earl Grey. Email him at martin.grenfell at gmail dot com. He can also be found trolling the #vim channel on the freenode IRC network as scrooloose. diff --git a/bundle/git_syntastic/plugin/syntastic.vim b/bundle/git_syntastic/plugin/syntastic.vim index 39e9a55..2cddcee 100644 --- a/bundle/git_syntastic/plugin/syntastic.vim +++ b/bundle/git_syntastic/plugin/syntastic.vim @@ -26,6 +26,23 @@ endif if !exists("g:syntastic_enable_signs") let g:syntastic_enable_signs = 1 endif + +if !exists("g:syntastic_error_symbol") + let g:syntastic_error_symbol = '>>' +endif + +if !exists("g:syntastic_warning_symbol") + let g:syntastic_warning_symbol = '>>' +endif + +if !exists("g:syntastic_style_error_symbol") + let g:syntastic_style_error_symbol = 'S>' +endif + +if !exists("g:syntastic_style_warning_symbol") + let g:syntastic_style_warning_symbol = 'S>' +endif + if !has('signs') let g:syntastic_enable_signs = 0 endif @@ -115,9 +132,7 @@ function! s:UpdateErrors(auto_invoked) call s:CacheErrors() end - if s:BufHasErrorsOrWarningsToDisplay() - call setloclist(0, s:LocList()) - endif + call setloclist(0, s:LocList()) if g:syntastic_enable_balloons call s:RefreshBalloons() @@ -183,7 +198,7 @@ function! s:CacheErrors() "functions legally for filetypes like "gentoo-metadata" let fts = substitute(&ft, '-', '_', 'g') for ft in split(fts, '\.') - if s:Checkable(ft) + if SyntasticCheckable(ft) let errors = SyntaxCheckers_{ft}_GetLocList() "keep only lines that effectively match an error/warning let errors = s:FilterLocList({'valid': 1}, errors) @@ -226,7 +241,10 @@ function! s:ModeMapAllowsAutoChecking() endfunction function! s:BufHasErrorsOrWarningsToDisplay() - return len(s:Errors()) || (!g:syntastic_quiet_warnings && !empty(s:LocList())) + if empty(s:LocList()) + return 0 + endif + return len(s:Errors()) || !g:syntastic_quiet_warnings endfunction function! s:Errors() @@ -274,10 +292,10 @@ endfunction if g:syntastic_enable_signs "define the signs used to display syntax and style errors/warns - sign define SyntasticError text=>> texthl=error - sign define SyntasticWarning text=>> texthl=todo - sign define SyntasticStyleError text=S> texthl=error - sign define SyntasticStyleWarning text=S> texthl=todo + exe 'sign define SyntasticError text='.g:syntastic_error_symbol.' texthl=error' + exe 'sign define SyntasticWarning text='.g:syntastic_warning_symbol.' texthl=todo' + exe 'sign define SyntasticStyleError text='.g:syntastic_style_error_symbol.' texthl=error' + exe 'sign define SyntasticStyleWarning text='.g:syntastic_style_warning_symbol.' texthl=todo' endif "start counting sign ids at 5000, start here to hopefully avoid conflicting @@ -348,6 +366,7 @@ endfunction "display the cached errors for this buf in the location list function! s:ShowLocList() if !empty(s:LocList()) + call setloclist(0, s:LocList()) let num = winnr() exec "lopen " . g:syntastic_loc_list_height if num != winnr() @@ -402,16 +421,6 @@ function! s:ClearErrorHighlights() endfor endfunction -"check if a syntax checker exists for the given filetype - and attempt to -"load one -function! s:Checkable(ft) - if !exists("g:loaded_" . a:ft . "_syntax_checker") - exec "runtime syntax_checkers/" . a:ft . ".vim" - endif - - return exists("*SyntaxCheckers_". a:ft ."_GetLocList") -endfunction - "set up error ballons for the current set of errors function! s:RefreshBalloons() let b:syntastic_balloons = {} @@ -472,6 +481,25 @@ function! s:LoadChecker(checker, ft) exec "runtime syntax_checkers/" . a:ft . "/" . a:checker . ".vim" endfunction +"the script changes &shellpipe and &shell to stop the screen flicking when +"shelling out to syntax checkers. Not all OSs support the hacks though +function! s:OSSupportsShellpipeHack() + if !exists("s:os_supports_shellpipe_hack") + let s:os_supports_shellpipe_hack = !s:running_windows && (s:uname !~ "FreeBSD") && (s:uname !~ "OpenBSD") + endif + return s:os_supports_shellpipe_hack +endfunction + +"check if a syntax checker exists for the given filetype - and attempt to +"load one +function! SyntasticCheckable(ft) + if !exists("g:loaded_" . a:ft . "_syntax_checker") + exec "runtime syntax_checkers/" . a:ft . ".vim" + endif + + return exists("*SyntaxCheckers_". a:ft ."_GetLocList") +endfunction + "return a string representing the state of buffer according to "g:syntastic_stl_format " @@ -536,7 +564,7 @@ function! SyntasticMake(options) let old_shell = &shell let old_errorformat = &l:errorformat - if !s:running_windows && (s:uname !~ "FreeBSD") + if s:OSSupportsShellpipeHack() "this is a hack to stop the screen needing to be ':redraw'n when "when :lmake is run. Otherwise the screen flickers annoyingly let &shellpipe='&>' @@ -560,7 +588,7 @@ function! SyntasticMake(options) let &shellpipe=old_shellpipe let &shell=old_shell - if !s:running_windows && s:uname =~ "FreeBSD" + if s:OSSupportsShellpipeHack() redraw! endif @@ -613,7 +641,7 @@ function! SyntasticLoadChecker(checkers, ft) if exists(opt_name) let opt_val = {opt_name} - if index(a:checkers, opt_val) != -1 && executable(opt_val) + if index(a:checkers, opt_val) != -1 call s:LoadChecker(opt_val, a:ft) else echoerr &ft . " syntax not supported or not installed." diff --git a/bundle/git_syntastic/syntax_checkers/c.vim b/bundle/git_syntastic/syntax_checkers/c.vim index a2cedfb..55b06de 100644 --- a/bundle/git_syntastic/syntax_checkers/c.vim +++ b/bundle/git_syntastic/syntax_checkers/c.vim @@ -58,6 +58,11 @@ " setting are removed from the result set: " " let g:syntastic_c_remove_include_errors = 1 +" +" Use the variable 'g:syntastic_c_errorformat' to override the default error +" format: +" +" let g:syntastic_c_errorformat = '%f:%l:%c: %trror: %m' if exists('loaded_c_syntax_checker') finish @@ -84,7 +89,13 @@ function! SyntaxCheckers_c_GetLocList() let errorformat = '%-G%f:%s:,%-G%f:%l: %#error: %#(Each undeclared '. \ 'identifier is reported only%.%#,%-G%f:%l: %#error: %#for '. \ 'each function it appears%.%#,%-GIn file included%.%#,'. - \ '%-G %#from %f:%l\,,%f:%l:%c: %m,%f:%l: %trror: %m,%f:%l: %m' + \ '%-G %#from %f:%l\,,%f:%l:%c: %trror: %m,%f:%l:%c: '. + \ '%tarning: %m,%f:%l:%c: %m,%f:%l: %trror: %m,'. + \ '%f:%l: %tarning: %m,%f:%l: %m' + + if exists('g:syntastic_c_errorformat') + let errorformat = g:syntastic_c_errorformat + endif " add optional user-defined compiler options let makeprg .= g:syntastic_c_compiler_options diff --git a/bundle/git_syntastic/syntax_checkers/coffee.vim b/bundle/git_syntastic/syntax_checkers/coffee.vim index 59dca75..7a8ca7f 100644 --- a/bundle/git_syntastic/syntax_checkers/coffee.vim +++ b/bundle/git_syntastic/syntax_checkers/coffee.vim @@ -19,9 +19,31 @@ if !executable("coffee") finish endif +if !exists('g:syntastic_coffee_lint_options') + let g:syntastic_coffee_lint_options = "" +endif + + function! SyntaxCheckers_coffee_GetLocList() let makeprg = 'coffee -c -l -o /tmp '.shellescape(expand('%')) let errorformat = 'Syntax%trror: In %f\, %m on line %l,%EError: In %f\, Parse error on line %l: %m,%EError: In %f\, %m on line %l,%W%f(%l): lint warning: %m,%-Z%p^,%W%f(%l): warning: %m,%-Z%p^,%E%f(%l): SyntaxError: %m,%-Z%p^,%-G%.%#' - return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) + let coffee_results = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) + + if !empty(coffee_results) + return coffee_results + endif + + if executable("coffeelint") + return s:GetCoffeeLintErrors() + endif + + return [] +endfunction + +function s:GetCoffeeLintErrors() + let coffeelint = 'coffeelint --csv '.g:syntastic_coffee_lint_options.' '.shellescape(expand('%')) + let lint_results = SyntasticMake({ 'makeprg': coffeelint, 'errorformat': '%f\,%l\,%trror\,%m', 'subtype': 'Style' }) + + return lint_results endfunction diff --git a/bundle/git_syntastic/syntax_checkers/cpp.vim b/bundle/git_syntastic/syntax_checkers/cpp.vim index 16bebde..8aae1fe 100644 --- a/bundle/git_syntastic/syntax_checkers/cpp.vim +++ b/bundle/git_syntastic/syntax_checkers/cpp.vim @@ -58,13 +58,26 @@ " g:syntastic_cpp_include_dirs' setting are removed from the result set: " " let g:syntastic_cpp_remove_include_errors = 1 +" +" Use the variable 'g:syntastic_cpp_errorformat' to override the default error +" format: +" +" let g:syntastic_cpp_errorformat = '%f:%l:%c: %trror: %m' +" +" Set your compiler executable with e.g. (defaults to g++) +" +" let g:syntastic_cpp_compiler = 'clang++' if exists('loaded_cpp_syntax_checker') finish endif let loaded_cpp_syntax_checker = 1 -if !executable('g++') +if !exists('g:syntastic_cpp_compiler') + let g:syntastic_cpp_compiler = 'g++' +endif + +if !executable(g:syntastic_cpp_compiler) finish endif @@ -76,8 +89,14 @@ if !exists('g:syntastic_cpp_config_file') endif function! SyntaxCheckers_cpp_GetLocList() - let makeprg = 'g++ -fsyntax-only ' - let errorformat = '%-G%f:%s:,%f:%l:%c: %m,%f:%l: %m' + let makeprg = g:syntastic_cpp_compiler . ' -fsyntax-only ' + let errorformat = '%-G%f:%s:,%f:%l:%c: %trror: %m,%f:%l:%c: %tarning: '. + \ '%m,%f:%l:%c: %m,%f:%l: %trror: %m,%f:%l: %tarning: %m,'. + \ '%f:%l: %m' + + if exists('g:syntastic_cpp_errorformat') + let errorformat = g:syntastic_cpp_errorformat + endif if exists('g:syntastic_cpp_compiler_options') let makeprg .= g:syntastic_cpp_compiler_options @@ -88,7 +107,7 @@ function! SyntaxCheckers_cpp_GetLocList() if expand('%') =~? '\%(.h\|.hpp\|.hh\)$' if exists('g:syntastic_cpp_check_header') - let makeprg = 'g++ -c '.shellescape(expand('%')). + let makeprg = g:syntastic_cpp_compiler.' -c '.shellescape(expand('%')). \ ' ' . syntastic#c#GetIncludeDirs('cpp') else return [] diff --git a/bundle/git_syntastic/syntax_checkers/css.vim b/bundle/git_syntastic/syntax_checkers/css.vim index 99a16b8..3c9f826 100644 --- a/bundle/git_syntastic/syntax_checkers/css.vim +++ b/bundle/git_syntastic/syntax_checkers/css.vim @@ -8,18 +8,29 @@ " Want To Public License, Version 2, as published by Sam Hocevar. " See http://sam.zoy.org/wtfpl/COPYING for more details. "============================================================================ +" +" Specify additional options to csslint with this option. e.g. to disable +" warnings: +" +" let g:syntastic_csslint_options = "--warnings=none" + if exists("loaded_css_syntax_checker") finish endif let loaded_css_syntax_checker = 1 +if !exists('g:syntastic_csslint_options') + let g:syntastic_csslint_options = "" +endif + " Bail if the user doesn't have `csslint` installed. if !executable("csslint") finish endif function! SyntaxCheckers_css_GetLocList() - let makeprg = 'csslint --format=compact '.shellescape(expand('%')) + let makeprg = 'csslint --format=compact '.g:syntastic_csslint_options.' '. + \ shellescape(expand('%')) " Print CSS Lint's error/warning messages from compact format. Ignores blank lines. let errorformat = '%-G,%-G%f: lint free!,%f: line %l\, col %c\, %trror - %m,%f: line %l\, col %c\, %tarning - %m,%f: line %l\, col %c\, %m,' diff --git a/bundle/git_syntastic/syntax_checkers/cuda.vim b/bundle/git_syntastic/syntax_checkers/cuda.vim index 816505e..0829e7c 100644 --- a/bundle/git_syntastic/syntax_checkers/cuda.vim +++ b/bundle/git_syntastic/syntax_checkers/cuda.vim @@ -11,6 +11,13 @@ " " let g:syntastic_cuda_check_header = 1 +" By default, nvcc and thus syntastic, defaults to the most basic architecture. +" This can produce false errors if the developer intends to compile for newer +" hardware and use newer features, eg. double precision numbers. To pass a +" specific target arch to nvcc, e.g. add the following to your .vimrc: +" +" let g:syntastic_cuda_arch = "sm_20" + if exists('loaded_cuda_syntax_checker') finish endif @@ -21,13 +28,18 @@ if !executable('nvcc') endif function! SyntaxCheckers_cuda_GetLocList() - let makeprg = 'nvcc --cuda -O0 -I . -Xcompiler -fsyntax-only '.shellescape(expand('%')).' -o /dev/null' + if exists('g:syntastic_cuda_arch') + let arch_flag = '-arch='.g:syntastic_cuda_arch + else + let arch_flag = '' + endif + let makeprg = 'nvcc '.arch_flag.' --cuda -O0 -I . -Xcompiler -fsyntax-only '.shellescape(expand('%')).' -o /dev/null' "let errorformat = '%-G%f:%s:,%f:%l:%c: %m,%f:%l: %m' let errorformat = '%*[^"]"%f"%*\D%l: %m,"%f"%*\D%l: %m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,"%f"\, line %l%*\D%c%*[^ ] %m,%D%*\a[%*\d]: Entering directory `%f'',%X%*\a[%*\d]: Leaving directory `%f'',%D%*\a: Entering directory `%f'',%X%*\a: Leaving directory `%f'',%DMaking %*\a in %f,%f|%l| %m' if expand('%') =~? '\%(.h\|.hpp\|.cuh\)$' if exists('g:syntastic_cuda_check_header') - let makeprg = 'echo > .syntastic_dummy.cu ; nvcc --cuda -O0 -I . .syntastic_dummy.cu -Xcompiler -fsyntax-only -include '.shellescape(expand('%')).' -o /dev/null' + let makeprg = 'echo > .syntastic_dummy.cu ; nvcc '.arch_flag.' --cuda -O0 -I . .syntastic_dummy.cu -Xcompiler -fsyntax-only -include '.shellescape(expand('%')).' -o /dev/null' else return [] endif diff --git a/bundle/git_syntastic/syntax_checkers/efm_perl.pl b/bundle/git_syntastic/syntax_checkers/efm_perl.pl index 3d75418..a193456 100644 --- a/bundle/git_syntastic/syntax_checkers/efm_perl.pl +++ b/bundle/git_syntastic/syntax_checkers/efm_perl.pl @@ -70,11 +70,11 @@ use strict; use Getopt::Std; -use vars qw/$opt_c $opt_w $opt_f $opt_h/; # needed for Getopt in combination with use strict 'vars' +use vars qw/$opt_I $opt_c $opt_w $opt_f $opt_h/; # needed for Getopt in combination with use strict 'vars' use constant VERSION => 0.2; -getopts('cwf:h'); +getopts('cwf:hI:'); &usage if $opt_h; # not necessarily needed, but good for further extension @@ -92,13 +92,13 @@ my $handle = (defined $opt_f ? \*FILE : \*STDOUT); (my $file = shift) or &usage; # display usage if no filename is supplied my $args = (@ARGV ? ' ' . join ' ', @ARGV : ''); -my @error_lines = `perl @{[defined $opt_c ? '-c ' : '' ]} @{[defined $opt_w ? '-X ' : '-w ']} "$file$args" 2>&1`; +my @error_lines = `perl @{[defined $opt_I ? "-I$opt_I" : '']} @{[defined $opt_c ? '-c ' : '' ]} @{[defined $opt_w ? '-X ' : '-w ']} "$file$args" 2>&1`; my @lines = map { "E:$_" } @error_lines; my @warn_lines; if(defined($opt_w)) { - @warn_lines = `perl @{[defined $opt_c ? '-c ' : '' ]} -w "$file$args" 2>&1`; + @warn_lines = `perl @{[defined $opt_I ? $opt_I : '']} @{[defined $opt_c ? '-c ' : '' ]} -w "$file$args" 2>&1`; } # Any new errors must be warnings @@ -114,7 +114,7 @@ foreach my $line (@lines) { chomp($line); my ($file, $lineno, $message, $rest, $severity); - if ($line =~ /^(.*)\sat\s(.*)\sline\s(\d+)(.*)$/) { + if ($line =~ /^([EW]):(.*)\sat\s(.*)\sline\s(\d+)(.*)$/) { ($severity, $message, $file, $lineno, $rest) = ($1, $2, $3, $4, $5); $errors++; $message .= $rest if ($rest =~ s/^,//); @@ -153,6 +153,7 @@ Usage: -c compile only, don't run (executes 'perl -c') -w output warnings as warnings instead of errors (slightly slower) -f write errors to + -I specify \@INC/#include directory Examples: * At the command line: diff --git a/bundle/git_syntastic/syntax_checkers/go/go.vim b/bundle/git_syntastic/syntax_checkers/go/go.vim index 8b3dd5c..3cbbc02 100644 --- a/bundle/git_syntastic/syntax_checkers/go/go.vim +++ b/bundle/git_syntastic/syntax_checkers/go/go.vim @@ -11,7 +11,7 @@ "============================================================================ function! SyntaxCheckers_go_GetLocList() let makeprg = 'go build -o /dev/null' - let errorformat = '%f:%l:%c:%m,%f:%l%m,%-G#%.%#' + let errorformat = '%f:%l:%c:%m,%E%f:%l:%m,%C%m,%-G#%.%#' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endfunction diff --git a/bundle/git_syntastic/syntax_checkers/html/tidy.vim b/bundle/git_syntastic/syntax_checkers/html/tidy.vim index 5e52f80..f48fae7 100644 --- a/bundle/git_syntastic/syntax_checkers/html/tidy.vim +++ b/bundle/git_syntastic/syntax_checkers/html/tidy.vim @@ -50,7 +50,7 @@ endfunction function! SyntaxCheckers_html_GetLocList() let encopt = s:TidyEncOptByFenc() - let makeprg="tidy ".encopt." --new-blocklevel-tags ".shellescape('section, article, aside, hgroup, header, footer, nav, figure, figcaption')." --new-inline-tags ".shellescape('video, audio, embed, mark, progress, meter, time, ruby, rt, rp, canvas, command, details, datalist')." --new-empty-tags ".shellescape('wbr, keygen')." -e ".shellescape(expand('%'))." 2>&1" + let makeprg="tidy ".encopt." --new-blocklevel-tags ".shellescape('section, article, aside, hgroup, header, footer, nav, figure, figcaption')." --new-inline-tags ".shellescape('video, audio, source, embed, mark, progress, meter, time, ruby, rt, rp, canvas, command, details, datalist')." --new-empty-tags ".shellescape('wbr, keygen')." -e ".shellescape(expand('%'))." 2>&1" let errorformat='%Wline %l column %c - Warning: %m,%Eline %l column %c - Error: %m,%-G%.%#,%-G%.%#' let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) diff --git a/bundle/git_syntastic/syntax_checkers/javascript.vim b/bundle/git_syntastic/syntax_checkers/javascript.vim index 3d5236c..61f9cd8 100644 --- a/bundle/git_syntastic/syntax_checkers/javascript.vim +++ b/bundle/git_syntastic/syntax_checkers/javascript.vim @@ -19,5 +19,5 @@ if exists("loaded_javascript_syntax_checker") endif let loaded_javascript_syntax_checker = 1 -let s:supported_checkers = ["gjslint", "jslint", "jsl", "jshint"] +let s:supported_checkers = ["gjslint", "jslint", "jsl", "jshint", "closurecompiler"] call SyntasticLoadChecker(s:supported_checkers, 'javascript') diff --git a/bundle/git_syntastic/syntax_checkers/ocaml.vim b/bundle/git_syntastic/syntax_checkers/ocaml.vim index 6a2470f..a065c30 100644 --- a/bundle/git_syntastic/syntax_checkers/ocaml.vim +++ b/bundle/git_syntastic/syntax_checkers/ocaml.vim @@ -10,6 +10,20 @@ " "============================================================================ " +" The more reliable way to check for a single .ml file is to use ocamlc. +" You can do that setting this in your .vimrc: +" +" let g:syntastic_ocaml_use_ocamlc = 1 +" It's possible to use ocamlc in conjuction with Jane Street's Core. In order +" to do that, you have to specify this in your .vimrc: +" +" let g:syntastic_ocaml_use_janestreet_core = 1 +" let g:syntastic_ocaml_janestreet_core_dir = +" +" Where path is the path to your core installation (usually a collection of +" .cmx and .cmxa files). +" +" " By default the camlp4o preprocessor is used to check the syntax of .ml, and .mli files, " ocamllex is used to check .mll files and menhir is used to check .mly files. " The output is all redirected to /dev/null, nothing is written to the disk. @@ -51,30 +65,24 @@ if !executable(s:ocamlpp) finish endif +if !exists('g:syntastic_ocaml_use_ocamlc') || !executable('ocamlc') + let g:syntastic_ocaml_use_ocamlc = 0 +endif + +if !exists('g:syntastic_ocaml_use_janestreet_core') + let g:syntastic_ocaml_use_ocamlc = 0 +endif + +if !exists('g:syntastic_ocaml_use_ocamlbuild') || !executable("ocamlbuild") + let g:syntastic_ocaml_use_ocamlbuild = 0 +endif + function! SyntaxCheckers_ocaml_GetLocList() - if exists('g:syntastic_ocaml_use_ocamlbuild') && - \ g:syntastic_ocaml_use_ocamlbuild != 0 && - \ executable("ocamlbuild") && - \ isdirectory('_build') - let makeprg = "ocamlbuild -quiet -no-log -tag annot,". s:ocamlpp. " -no-links -no-hygiene -no-sanitize ". - \ shellescape(expand('%:r')).".cmi" - else - let extension = expand('%:e') - if match(extension, 'mly') >= 0 - " ocamlyacc output can't be redirected, so use menhir - if !executable("menhir") - return [] - endif - let makeprg = "menhir --only-preprocess ".shellescape(expand('%')) . " >/dev/null" - elseif match(extension,'mll') >= 0 - if !executable("ocamllex") - return [] - endif - let makeprg = "ocamllex -q -o /dev/null ".shellescape(expand('%')) - else - let makeprg = "camlp4o -o /dev/null ".shellescape(expand('%')) - endif + let makeprg = s:GetMakeprg() + if makeprg == "" + return [] endif + let errorformat = '%AFile "%f"\, line %l\, characters %c-%*\d:,'. \ '%AFile "%f"\, line %l\, characters %c-%*\d (end at line %*\d\, character %*\d):,'. \ '%AFile "%f"\, line %l\, character %c:,'. @@ -87,3 +95,51 @@ function! SyntaxCheckers_ocaml_GetLocList() return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endfunction + +function s:GetMakeprg() + if g:syntastic_ocaml_use_ocamlc + return s:GetOcamlcMakeprg() + endif + + if g:syntastic_ocaml_use_ocamlbuild && isdirectory('_build') + return s:GetOcamlBuildMakeprg() + endif + + return s:GetOtherMakeprg() +endfunction + +function s:GetOcamlcMakeprg() + if g:syntastic_ocaml_use_janestreet_core + let build_cmd = "ocamlc -I " + let build_cmd .= expand(g:syntastic_ocaml_janestreet_core_dir) + let build_cmd .= " -c ".expand('%') + return build_cmd + else + return "ocamlc -c ". expand('%') + endif +endfunction + +function s:GetOcamlBuildMakeprg() + return "ocamlbuild -quiet -no-log -tag annot,". s:ocamlpp. " -no-links -no-hygiene -no-sanitize ". + \ shellescape(expand('%:r')).".cmi" +endfunction + +function s:GetOtherMakeprg() + "TODO: give this function a better name? + " + "TODO: should use throw/catch instead of returning an empty makeprg + + let extension = expand('%:e') + let makeprg = "" + + if match(extension, 'mly') >= 0 && executable("menhir") + " ocamlyacc output can't be redirected, so use menhir + let makeprg = "menhir --only-preprocess ".shellescape(expand('%')) . " >/dev/null" + elseif match(extension,'mll') >= 0 && executable("ocamllex") + let makeprg = "ocamllex -q -o /dev/null ".shellescape(expand('%')) + else + let makeprg = "camlp4o -o /dev/null ".shellescape(expand('%')) + endif + + return makeprg +endfunction diff --git a/bundle/git_syntastic/syntax_checkers/perl.vim b/bundle/git_syntastic/syntax_checkers/perl.vim index 1d48f61..d5e1754 100644 --- a/bundle/git_syntastic/syntax_checkers/perl.vim +++ b/bundle/git_syntastic/syntax_checkers/perl.vim @@ -10,6 +10,20 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " "============================================================================ +" +" In order to add some custom lib directories that should be added to the +" perl command line you can add those to the global variable +" g:syntastic_perl_lib_path. +" +" let g:syntastic_perl_lib_path = './lib' +" +" To use your own perl error output munger script, use the +" g:syntastic_perl_efm_program option. Any command line parameters should be +" included in the variable declaration. The program should expect a single +" parameter; the fully qualified filename of the file to be checked. +" +" let g:syntastic_perl_efm_program = "foo.pl -o -m -g" +" if exists("loaded_perl_syntax_checker") finish endif @@ -20,11 +34,16 @@ if !executable("perl") finish endif -"remove '-w' switch to change all warnings to errors -let s:checker = 'perl ' . shellescape(expand(':p:h') . '/efm_perl.pl') . ' -c -w' +if !exists("g:syntastic_perl_efm_program") + let g:syntastic_perl_efm_program = 'perl ' . shellescape(expand(':p:h') . '/efm_perl.pl') . ' -c -w' +endif function! SyntaxCheckers_perl_GetLocList() - let makeprg = s:checker . ' ' . shellescape(expand('%')) + if exists("g:syntastic_perl_lib_path") + let makeprg = g:syntastic_perl_efm_program . ' -I' . g:syntastic_perl_lib_path . ' ' . shellescape(expand('%')) + else + let makeprg = g:syntastic_perl_efm_program . ' ' . shellescape(expand('%')) + endif let errorformat = '%t:%f:%l:%m' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) diff --git a/bundle/git_syntastic/syntax_checkers/puppet.vim b/bundle/git_syntastic/syntax_checkers/puppet.vim index 28c9e33..a675a83 100644 --- a/bundle/git_syntastic/syntax_checkers/puppet.vim +++ b/bundle/git_syntastic/syntax_checkers/puppet.vim @@ -19,6 +19,10 @@ if !executable("puppet") finish endif +if !exists("g:syntastic_puppet_validate_disable") + let g:syntastic_puppet_validate_disable = 0 +endif + if !exists("g:syntastic_puppet_lint_disable") let g:syntastic_puppet_lint_disable = 0 endif @@ -27,25 +31,43 @@ if !executable("puppet-lint") let g:syntastic_puppet_lint_disable = 1 endif -function! s:PuppetExtractVersion() - let output = system("puppet --version") - let output = substitute(output, '\n$', '', '') - return split(output, '\.') +function! s:PuppetVersion() + if !exists("s:puppet_version") + let output = system("puppet --version 2>/dev/null") + let output = substitute(output, '\n$', '', '') + let s:puppet_version = split(output, '\.') + endif + return s:puppet_version endfunction -function! s:PuppetLintExtractVersion() - let output = system("puppet-lint --version") - let output = substitute(output, '\n$', '', '') - let output = substitute(output, '^puppet-lint ', '', 'i') - return split(output, '\.') +function! s:PuppetLintVersion() + if !exists("s:puppet_lint_version") + let output = system("puppet-lint --version 2>/dev/null") + let output = substitute(output, '\n$', '', '') + let output = substitute(output, '^puppet-lint ', '', 'i') + let s:puppet_lint_version = split(output, '\.') + endif + return s:puppet_lint_version endfunction -let s:puppetVersion = s:PuppetExtractVersion() -let s:lintVersion = s:PuppetLintExtractVersion() +"the args must be arrays of the form [major, minor, macro] +function s:IsVersionAtLeast(installed, required) + if a:installed[0] != a:required[0] + return a:installed[0] > a:required[0] + endif -if !(s:lintVersion[0] >= '0' && s:lintVersion[1] >= '1' && s:lintVersion[2] >= '10') - let g:syntastic_puppet_lint_disable = 1 -endif + if a:installed[1] != a:required[1] + return a:installed[1] > a:required[1] + endif + + return a:installed[2] >= a:required[2] +endfunction + +if !g:syntastic_puppet_lint_disable + if !s:IsVersionAtLeast(s:PuppetLintVersion(), [0,1,10]) + let g:syntastic_puppet_lint_disable = 1 + endif +end function! s:getPuppetLintErrors() if !exists("g:syntastic_puppet_lint_arguments") @@ -57,15 +79,15 @@ function! s:getPuppetLintErrors() return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'subtype': 'Style' }) endfunction -function! s:getPuppetMakeprg() +function! s:getPuppetMakeprg() "If puppet is >= version 2.7 then use the new executable - if s:puppetVersion[0] >= '2' && s:puppetVersion[1] >= '7' + if s:IsVersionAtLeast(s:PuppetVersion(), [2,7,0]) let makeprg = 'puppet parser validate ' . \ shellescape(expand('%')) . \ ' --color=false' "add --ignoreimport for versions < 2.7.10 - if s:puppetVersion[2] < '10' + if s:PuppetVersion()[2] < '10' let makeprg .= ' --ignoreimport' endif @@ -76,16 +98,19 @@ function! s:getPuppetMakeprg() endfunction function! SyntaxCheckers_puppet_GetLocList() + let errors = [] - let makeprg = s:getPuppetMakeprg() + if !g:syntastic_puppet_validate_disable + let makeprg = s:getPuppetMakeprg() - "some versions of puppet (e.g. 2.7.10) output the message below if there - "are any syntax errors - let errorformat = '%-Gerr: Try ''puppet help parser validate'' for usage,' - let errorformat .= 'err: Could not parse for environment %*[a-z]: %m at %f:%l' + "some versions of puppet (e.g. 2.7.10) output the message below if there + "are any syntax errors + let errorformat = '%-Gerr: Try ''puppet help parser validate'' for usage,' + let errorformat .= 'err: Could not parse for environment %*[a-z]: %m at %f:%l' + + let errors = errors + SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) + endif - let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) - if !g:syntastic_puppet_lint_disable let errors = errors + s:getPuppetLintErrors() endif diff --git a/bundle/git_syntastic/syntax_checkers/python/pylint.vim b/bundle/git_syntastic/syntax_checkers/python/pylint.vim index 64adbc5..fd35e08 100644 --- a/bundle/git_syntastic/syntax_checkers/python/pylint.vim +++ b/bundle/git_syntastic/syntax_checkers/python/pylint.vim @@ -7,8 +7,8 @@ function! SyntaxCheckers_python_GetLocList() let makeprg = 'pylint '.g:syntastic_python_checker_args.' -f parseable -r n -i y ' . \ shellescape(expand('%')) . - \ ' 2>&1 \| sed ''s_: \[[RC]_: \[W_''' . - \ ' \| sed ''s_: \[[F]_:\ \[E_''' - let errorformat = '%f:%l: [%t%n%.%#] %m,%f:%l: [%t%.%#] %m,%Z,%-GNo config%m' + \ ' 2>&1 \| sed ''s_: \[\([RCW]\)_: \[W] \[\1_''' . + \ ' \| sed ''s_: \[\([FE]\)_:\ \[E] \[\1_''' + let errorformat = '%f:%l: [%t] %m,%Z,%-GNo config %m' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endfunction diff --git a/bundle/git_syntastic/syntax_checkers/ruby.vim b/bundle/git_syntastic/syntax_checkers/ruby.vim index 17d00ca..aab7c6b 100644 --- a/bundle/git_syntastic/syntax_checkers/ruby.vim +++ b/bundle/git_syntastic/syntax_checkers/ruby.vim @@ -18,8 +18,12 @@ if exists("loaded_ruby_syntax_checker") endif let loaded_ruby_syntax_checker = 1 -"bail if the user doesnt have ruby installed -if !executable("ruby") +if !exists("g:syntastic_ruby_exec") + let g:syntastic_ruby_exec = "ruby" +endif + +"bail if the user doesnt have ruby installed where they said it is +if !executable(expand(g:syntastic_ruby_exec)) finish endif diff --git a/bundle/git_syntastic/syntax_checkers/ruby/jruby.vim b/bundle/git_syntastic/syntax_checkers/ruby/jruby.vim index bec5168..b3c416d 100644 --- a/bundle/git_syntastic/syntax_checkers/ruby/jruby.vim +++ b/bundle/git_syntastic/syntax_checkers/ruby/jruby.vim @@ -10,7 +10,12 @@ " "============================================================================ function! SyntaxCheckers_ruby_GetLocList() - "let makeprg = '' - "let errorformat = '' - "return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) + if has('win32') + let makeprg = 'jruby -W1 -T1 -c '.shellescape(expand('%')) + else + let makeprg = 'RUBYOPT= jruby -W1 -c '.shellescape(expand('%')) + endif + let errorformat = '%-GSyntax OK for %f,%ESyntaxError in %f:%l: syntax error\, %m,%Z%p^,%W%f:%l: warning: %m,%Z%p^,%W%f:%l: %m,%-C%.%#' + + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endfunction diff --git a/bundle/git_syntastic/syntax_checkers/ruby/mri.vim b/bundle/git_syntastic/syntax_checkers/ruby/mri.vim index ee72b5a..42a7770 100644 --- a/bundle/git_syntastic/syntax_checkers/ruby/mri.vim +++ b/bundle/git_syntastic/syntax_checkers/ruby/mri.vim @@ -10,13 +10,20 @@ " "============================================================================ function! SyntaxCheckers_ruby_GetLocList() - " we cannot set RUBYOPT on windows like that - if has('win32') - let makeprg = 'ruby -W1 -T1 -c '.shellescape(expand('%')) - else - let makeprg = 'RUBYOPT= ruby -W1 -c '.shellescape(expand('%')) + let makeprg = expand(g:syntastic_ruby_exec).' -w -T1 -c '.shellescape(expand('%')) + if !has('win32') + let makeprg = 'RUBYOPT= ' . makeprg endif - let errorformat = '%-GSyntax OK,%E%f:%l: syntax error\, %m,%Z%p^,%W%f:%l: warning: %m,%Z%p^,%W%f:%l: %m,%-C%.%#' + "this is a hack to filter out a repeated useless warning in rspec files + "containing lines like + " + " foo.should == 'bar' + " + "Which always generate the warning below. Note that ruby >= 1.9.3 includes + "the word "possibly" in the warning + let errorformat = '%-G%.%#warning: %\(possibly %\)%\?useless use of == in void context' + + let errorformat .= ',%-GSyntax OK,%E%f:%l: syntax error\, %m,%Z%p^,%W%f:%l: warning: %m,%Z%p^,%W%f:%l: %m,%-C%.%#' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endfunction diff --git a/bundle/git_syntastic/syntax_checkers/sh.vim b/bundle/git_syntastic/syntax_checkers/sh.vim index 5b55172..f6581ed 100644 --- a/bundle/git_syntastic/syntax_checkers/sh.vim +++ b/bundle/git_syntastic/syntax_checkers/sh.vim @@ -31,22 +31,29 @@ function! s:GetShell() return b:shell endfunction -function! SyntaxCheckers_sh_GetLocList() - if len(s:GetShell()) == 0 || !executable(s:GetShell()) +function! s:ForwardToZshChecker() + if SyntasticCheckable('zsh') + return SyntaxCheckers_zsh_GetLocList() + else return [] endif - let output = split(system(s:GetShell().' -n '.shellescape(expand('%'))), '\n') - if v:shell_error != 0 - let result = [] - for err_line in output - let line = substitute(err_line, '^[^:]*:\D\{-}\(\d\+\):.*', '\1', '') - let msg = substitute(err_line, '^[^:]*:\D\{-}\d\+: \(.*\)', '\1', '') - call add(result, {'lnum' : line, - \ 'text' : msg, - \ 'bufnr': bufnr(''), - \ 'type': 'E' }) - endfor - return result - endif - return [] + +endfunction + +function! s:IsShellValid() + return len(s:GetShell()) > 0 && executable(s:GetShell()) +endfunction + +function! SyntaxCheckers_sh_GetLocList() + if s:GetShell() == 'zsh' + return s:ForwardToZshChecker() + endif + + if !s:IsShellValid() + return [] + endif + + let makeprg = s:GetShell() . ' -n ' . shellescape(expand('%')) + let errorformat = '%f: line %l: %m' + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat}) endfunction diff --git a/bundle/git_syntastic/syntax_checkers/yaml.vim b/bundle/git_syntastic/syntax_checkers/yaml.vim index f45d849..7b8d95d 100644 --- a/bundle/git_syntastic/syntax_checkers/yaml.vim +++ b/bundle/git_syntastic/syntax_checkers/yaml.vim @@ -9,7 +9,7 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. " " -"Installation: $ npm install -g js-yaml.bin +"Installation: $ npm install -g js-yaml " "============================================================================ if exists("loaded_yaml_syntax_checker") diff --git a/bundle/git_tagbar/autoload/tagbar.vim b/bundle/git_tagbar/autoload/tagbar.vim index 1e28051..b852099 100644 --- a/bundle/git_tagbar/autoload/tagbar.vim +++ b/bundle/git_tagbar/autoload/tagbar.vim @@ -4,7 +4,7 @@ " Author: Jan Larres " Licence: Vim licence " Website: http://majutsushi.github.com/tagbar/ -" Version: 2.4 +" Version: 2.4.1 " Note: This plugin was heavily inspired by the 'Taglist' plugin by " Yegappan Lakshmanan and uses a small amount of code from it. " @@ -22,46 +22,14 @@ scriptencoding utf-8 " Initialization {{{1 -" Basic init {{{2 - -if !exists('g:tagbar_ctags_bin') - let ctagsbins = [] - let ctagsbins += ['ctags-exuberant'] " Debian - let ctagsbins += ['exuberant-ctags'] - let ctagsbins += ['exctags'] " FreeBSD, NetBSD - let ctagsbins += ['/usr/local/bin/ctags'] " Homebrew - let ctagsbins += ['/opt/local/bin/ctags'] " Macports - let ctagsbins += ['ectags'] " OpenBSD - let ctagsbins += ['ctags'] - let ctagsbins += ['ctags.exe'] - let ctagsbins += ['tags'] - for ctags in ctagsbins - if executable(ctags) - let g:tagbar_ctags_bin = ctags - break - endif - endfor - if !exists('g:tagbar_ctags_bin') - echomsg 'Tagbar: Exuberant ctags not found, skipping plugin' - finish - endif -else - " reset 'wildignore' temporarily in case *.exe is included in it - let wildignore_save = &wildignore - set wildignore& - - let g:tagbar_ctags_bin = expand(g:tagbar_ctags_bin) - - let &wildignore = wildignore_save - - if !executable(g:tagbar_ctags_bin) - echomsg "Tagbar: Exuberant ctags not found at " . - \ "'" . g:tagbar_ctags_bin . "', " . - \ "skipping plugin" - finish - endif +" If another plugin calls an autoloaded Tagbar function on startup before the +" plugin/tagbar.vim file got loaded, load it explicitly +if exists(':Tagbar') == 0 + runtime plugin/tagbar.vim endif +" Basic init {{{2 + redir => s:ftype_out silent filetype redir END @@ -77,10 +45,19 @@ let s:icon_open = g:tagbar_iconchars[1] let s:type_init_done = 0 let s:autocommands_done = 0 +" 0: not checked yet; 1: checked and found; 2: checked and not found let s:checked_ctags = 0 let s:checked_ctags_types = 0 let s:ctags_types = {} -let s:window_expanded = 0 + +let s:new_window = 1 +let s:is_maximized = 0 +let s:short_help = 1 +let s:window_expanded = 0 + +" Script-local variable needed since compare functions can't +" take extra arguments +let s:compare_typeinfo = {} let s:access_symbols = { @@ -96,9 +73,11 @@ let s:debug = 0 let s:debug_file = '' " s:Init() {{{2 -function! s:Init() - if !s:checked_ctags - if !s:CheckForExCtags() +function! s:Init(silent) abort + if s:checked_ctags == 2 && a:silent + return 0 + elseif s:checked_ctags != 1 + if !s:CheckForExCtags(a:silent) return 0 endif endif @@ -113,14 +92,14 @@ function! s:Init() if !s:autocommands_done call s:CreateAutocommands() - doautocmd CursorHold + call s:AutoUpdate(fnamemodify(expand('%'), ':p'), 0) endif return 1 endfunction " s:InitTypes() {{{2 -function! s:InitTypes() +function! s:InitTypes() abort call s:LogDebugMessage('Initializing types') let s:known_types = {} @@ -334,9 +313,9 @@ function! s:InitTypes() " guesses and probably requires " http://www.vim.org/scripts/script.php?script_id=2909 " Improvements welcome! - let type_mxml = s:TypeInfo.New() - let type_mxml.ctagstype = 'flex' - let type_mxml.kinds = [ + let type_as = s:TypeInfo.New() + let type_as.ctagstype = 'flex' + let type_as.kinds = [ \ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0}, \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, @@ -344,14 +323,15 @@ function! s:InitTypes() \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, \ {'short' : 'x', 'long' : 'mxtags', 'fold' : 0, 'stl' : 0} \ ] - let type_mxml.sro = '.' - let type_mxml.kind2scope = { + let type_as.sro = '.' + let type_as.kind2scope = { \ 'c' : 'class' \ } - let type_mxml.scope2kind = { + let type_as.scope2kind = { \ 'class' : 'c' \ } - let s:known_types.mxml = type_mxml + let s:known_types.mxml = type_as + let s:known_types.actionscript = type_as " Fortran {{{3 let type_fortran = s:TypeInfo.New() let type_fortran.ctagstype = 'fortran' @@ -456,6 +436,7 @@ function! s:InitTypes() \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} \ ] let s:known_types.lisp = type_lisp + let s:known_types.clojure = type_lisp " Lua {{{3 let type_lua = s:TypeInfo.New() let type_lua.ctagstype = 'lua' @@ -626,6 +607,7 @@ function! s:InitTypes() let type_sql.ctagstype = 'sql' let type_sql.kinds = [ \ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 1}, + \ {'short' : 'd', 'long' : 'prototypes', 'fold' : 0, 'stl' : 1}, \ {'short' : 'c', 'long' : 'cursors', 'fold' : 0, 'stl' : 1}, \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, \ {'short' : 'F', 'long' : 'record fields', 'fold' : 0, 'stl' : 1}, @@ -643,7 +625,8 @@ function! s:InitTypes() \ {'short' : 'V', 'long' : 'views', 'fold' : 0, 'stl' : 1}, \ {'short' : 'n', 'long' : 'synonyms', 'fold' : 0, 'stl' : 1}, \ {'short' : 'x', 'long' : 'MobiLink Table Scripts', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'y', 'long' : 'MobiLink Conn Scripts', 'fold' : 0, 'stl' : 1} + \ {'short' : 'y', 'long' : 'MobiLink Conn Scripts', 'fold' : 0, 'stl' : 1}, + \ {'short' : 'z', 'long' : 'MobiLink Properties', 'fold' : 0, 'stl' : 1} \ ] let s:known_types.sql = type_sql " Tcl {{{3 @@ -787,6 +770,7 @@ function! s:InitTypes() let type_vim = s:TypeInfo.New() let type_vim.ctagstype = 'vim' let type_vim.kinds = [ + \ {'short' : 'n', 'long' : 'vimball filenames', 'fold' : 0, 'stl' : 1}, \ {'short' : 'v', 'long' : 'variables', 'fold' : 1, 'stl' : 0}, \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, \ {'short' : 'a', 'long' : 'autocommand groups', 'fold' : 1, 'stl' : 1}, @@ -813,7 +797,7 @@ function! s:InitTypes() endfunction " s:LoadUserTypeDefs() {{{2 -function! s:LoadUserTypeDefs(...) +function! s:LoadUserTypeDefs(...) abort if a:0 > 0 let type = a:1 @@ -880,7 +864,7 @@ function! s:LoadUserTypeDefs(...) endfunction " s:CreateTypeKinddict() {{{2 -function! s:CreateTypeKinddict(type) +function! s:CreateTypeKinddict(type) abort " Create a dictionary of the kind order for fast access in sorting " functions let i = 0 @@ -892,7 +876,7 @@ endfunction " s:RestoreSession() {{{2 " Properly restore Tagbar after a session got loaded -function! s:RestoreSession() +function! s:RestoreSession() abort call s:LogDebugMessage('Restoring session') let curfile = fnamemodify(bufname('%'), ':p') @@ -911,11 +895,11 @@ function! s:RestoreSession() let s:last_autofocus = 0 - call s:Init() + call s:Init(0) call s:InitWindow(g:tagbar_autoclose) - call s:AutoUpdate(curfile) + call s:AutoUpdate(curfile, 0) if !in_tagbar call s:winexec('wincmd p') @@ -923,7 +907,7 @@ function! s:RestoreSession() endfunction " s:MapKeys() {{{2 -function! s:MapKeys() +function! s:MapKeys() abort call s:LogDebugMessage('Mapping keys') nnoremap