From 9159b4c2850bc15fa4e074e3e4a9a14f3a3fd5cd Mon Sep 17 00:00:00 2001
From: "lilei (Cloud)"
Date: Fri, 7 Sep 2018 17:41:59 +0800
Subject: [PATCH] plugin: add ctrlp.vim.
https://github.com/ctrlpvim/ctrlp.vim
commit 43cc73b8e7d4ab45f17118573eb81fd45704b989
Signed-off-by: lilei (Cloud)
---
vim/bundle/ctrlp.vim/autoload/ctrlp.vim | 2671 +++++++++++++++++
.../ctrlp.vim/autoload/ctrlp/autoignore.vim | 173 ++
.../ctrlp.vim/autoload/ctrlp/bookmarkdir.vim | 147 +
.../ctrlp.vim/autoload/ctrlp/buffertag.vim | 277 ++
.../ctrlp.vim/autoload/ctrlp/changes.vim | 98 +
vim/bundle/ctrlp.vim/autoload/ctrlp/dir.vim | 95 +
vim/bundle/ctrlp.vim/autoload/ctrlp/line.vim | 81 +
vim/bundle/ctrlp.vim/autoload/ctrlp/mixed.vim | 88 +
.../ctrlp.vim/autoload/ctrlp/mrufiles.vim | 158 +
.../ctrlp.vim/autoload/ctrlp/quickfix.vim | 59 +
.../ctrlp.vim/autoload/ctrlp/rtscript.vim | 59 +
vim/bundle/ctrlp.vim/autoload/ctrlp/tag.vim | 146 +
vim/bundle/ctrlp.vim/autoload/ctrlp/undo.vim | 154 +
vim/bundle/ctrlp.vim/autoload/ctrlp/utils.vim | 110 +
vim/bundle/ctrlp.vim/doc/ctrlp.cnx | 1616 ++++++++++
vim/bundle/ctrlp.vim/doc/ctrlp.txt | 1682 +++++++++++
vim/bundle/ctrlp.vim/plugin/ctrlp.vim | 72 +
vim/bundle/ctrlp.vim/readme.md | 105 +
vim/bundles.vim | 2 +
vimrc | 19 +-
20 files changed, 7807 insertions(+), 5 deletions(-)
create mode 100644 vim/bundle/ctrlp.vim/autoload/ctrlp.vim
create mode 100644 vim/bundle/ctrlp.vim/autoload/ctrlp/autoignore.vim
create mode 100644 vim/bundle/ctrlp.vim/autoload/ctrlp/bookmarkdir.vim
create mode 100644 vim/bundle/ctrlp.vim/autoload/ctrlp/buffertag.vim
create mode 100644 vim/bundle/ctrlp.vim/autoload/ctrlp/changes.vim
create mode 100644 vim/bundle/ctrlp.vim/autoload/ctrlp/dir.vim
create mode 100644 vim/bundle/ctrlp.vim/autoload/ctrlp/line.vim
create mode 100644 vim/bundle/ctrlp.vim/autoload/ctrlp/mixed.vim
create mode 100644 vim/bundle/ctrlp.vim/autoload/ctrlp/mrufiles.vim
create mode 100644 vim/bundle/ctrlp.vim/autoload/ctrlp/quickfix.vim
create mode 100644 vim/bundle/ctrlp.vim/autoload/ctrlp/rtscript.vim
create mode 100644 vim/bundle/ctrlp.vim/autoload/ctrlp/tag.vim
create mode 100644 vim/bundle/ctrlp.vim/autoload/ctrlp/undo.vim
create mode 100644 vim/bundle/ctrlp.vim/autoload/ctrlp/utils.vim
create mode 100644 vim/bundle/ctrlp.vim/doc/ctrlp.cnx
create mode 100644 vim/bundle/ctrlp.vim/doc/ctrlp.txt
create mode 100644 vim/bundle/ctrlp.vim/plugin/ctrlp.vim
create mode 100644 vim/bundle/ctrlp.vim/readme.md
diff --git a/vim/bundle/ctrlp.vim/autoload/ctrlp.vim b/vim/bundle/ctrlp.vim/autoload/ctrlp.vim
new file mode 100644
index 0000000..6128e28
--- /dev/null
+++ b/vim/bundle/ctrlp.vim/autoload/ctrlp.vim
@@ -0,0 +1,2671 @@
+" =============================================================================
+" File: autoload/ctrlp.vim
+" Description: Fuzzy file, buffer, mru, tag, etc finder.
+" Author: CtrlP Dev Team
+" Original: Kien Nguyen
+" Version: 1.80
+" =============================================================================
+
+" ** Static variables {{{1
+" s:ignore() {{{2
+fu! s:ignore()
+ let igdirs = [
+ \ '\.git',
+ \ '\.hg',
+ \ '\.svn',
+ \ '_darcs',
+ \ '\.bzr',
+ \ '\.cdv',
+ \ '\~\.dep',
+ \ '\~\.dot',
+ \ '\~\.nib',
+ \ '\~\.plst',
+ \ '\.pc',
+ \ '_MTN',
+ \ 'blib',
+ \ 'CVS',
+ \ 'RCS',
+ \ 'SCCS',
+ \ '_sgbak',
+ \ 'autom4te\.cache',
+ \ 'cover_db',
+ \ '_build',
+ \ ]
+ let igfiles = [
+ \ '\~$',
+ \ '#.+#$',
+ \ '[._].*\.swp$',
+ \ 'core\.\d+$',
+ \ '\.exe$',
+ \ '\.so$',
+ \ '\.bak$',
+ \ '\.png$',
+ \ '\.jpg$',
+ \ '\.gif$',
+ \ '\.zip$',
+ \ '\.rar$',
+ \ '\.tar\.gz$',
+ \ ]
+ retu {
+ \ 'dir': '\v[\/]('.join(igdirs, '|').')$',
+ \ 'file': '\v'.join(igfiles, '|'),
+ \ }
+endf
+" Script local vars {{{2
+let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
+ \ ['g:ctrlp_', 'b:ctrlp_', {
+ \ 'abbrev': ['s:abbrev', {}],
+ \ 'arg_map': ['s:argmap', 0],
+ \ 'buffer_func': ['s:buffunc', {}],
+ \ 'by_filename': ['s:byfname', 0],
+ \ 'custom_ignore': ['s:usrign', s:ignore()],
+ \ 'default_input': ['s:deftxt', 0],
+ \ 'dont_split': ['s:nosplit', 'netrw'],
+ \ 'dotfiles': ['s:showhidden', 0],
+ \ 'extensions': ['s:extensions', []],
+ \ 'follow_symlinks': ['s:folsym', 0],
+ \ 'highlight_match': ['s:mathi', [1, 'CtrlPMatch']],
+ \ 'jump_to_buffer': ['s:jmptobuf', 'Et'],
+ \ 'key_loop': ['s:keyloop', 0],
+ \ 'lazy_update': ['s:lazy', 0],
+ \ 'match_func': ['s:matcher', {}],
+ \ 'match_window': ['s:mw', ''],
+ \ 'match_window_bottom': ['s:mwbottom', 1],
+ \ 'match_window_reversed': ['s:mwreverse', 1],
+ \ 'max_depth': ['s:maxdepth', 40],
+ \ 'max_files': ['s:maxfiles', 10000],
+ \ 'max_height': ['s:mxheight', 10],
+ \ 'max_history': ['s:maxhst', exists('+hi') ? &hi : 20],
+ \ 'mruf_default_order': ['s:mrudef', 0],
+ \ 'open_func': ['s:openfunc', {}],
+ \ 'open_multi': ['s:opmul', '1v'],
+ \ 'open_new_file': ['s:newfop', 'v'],
+ \ 'prompt_mappings': ['s:urprtmaps', 0],
+ \ 'regexp_search': ['s:regexp', 0],
+ \ 'root_markers': ['s:rmarkers', []],
+ \ 'split_window': ['s:splitwin', 0],
+ \ 'status_func': ['s:status', {}],
+ \ 'tabpage_position': ['s:tabpage', 'ac'],
+ \ 'use_caching': ['s:caching', 1],
+ \ 'user_command': ['s:usrcmd', ''],
+ \ 'validate': ['s:validate', ''],
+ \ 'working_path_mode': ['s:pathmode', 'ra'],
+ \ 'line_prefix': ['s:lineprefix', '> '],
+ \ 'open_single_match': ['s:opensingle', []],
+ \ 'brief_prompt': ['s:brfprt', 0],
+ \ 'match_current_file': ['s:matchcrfile', 0],
+ \ 'match_natural_name': ['s:matchnatural', 0],
+ \ 'compare_lim': ['s:compare_lim', 3000],
+ \ 'bufname_mod': ['s:bufname_mod', ':t'],
+ \ 'bufpath_mod': ['s:bufpath_mod', ':~:.:h'],
+ \ 'formatline_func': ['s:flfunc', 's:formatline(v:val)'],
+ \ 'user_command_async': ['s:usrcmdasync', 0],
+ \ }, {
+ \ 'open_multiple_files': 's:opmul',
+ \ 'regexp': 's:regexp',
+ \ 'reuse_window': 's:nosplit',
+ \ 'show_hidden': 's:showhidden',
+ \ 'switch_buffer': 's:jmptobuf',
+ \ }, {
+ \ 'root_markers': 's:rmarkers',
+ \ 'user_command': 's:usrcmd',
+ \ 'working_path_mode': 's:pathmode',
+ \ }]
+
+" Global options
+let s:glbs = { 'magic': 1, 'to': 1, 'tm': 0, 'sb': 1, 'hls': 0, 'im': 0,
+ \ 'report': 9999, 'sc': 0, 'ss': 0, 'siso': 0, 'mfd': 200, 'ttimeout': 0,
+ \ 'gcr': 'a:blinkon0', 'ic': 1, 'lmap': '', 'mousef': 0, 'imd': 1 }
+
+" Keymaps
+let [s:lcmap, s:prtmaps] = ['nn ', {
+ \ 'PrtBS()': ['', ''],
+ \ 'PrtDelete()': [''],
+ \ 'PrtDeleteWord()': [''],
+ \ 'PrtClear()': [''],
+ \ 'PrtSelectMove("j")': ['', ''],
+ \ 'PrtSelectMove("k")': ['', ''],
+ \ 'PrtSelectMove("t")': ['', ''],
+ \ 'PrtSelectMove("b")': ['', ''],
+ \ 'PrtSelectMove("u")': ['', ''],
+ \ 'PrtSelectMove("d")': ['', ''],
+ \ 'PrtHistory(-1)': [''],
+ \ 'PrtHistory(1)': [''],
+ \ 'AcceptSelection("e")': ['', '<2-LeftMouse>'],
+ \ 'AcceptSelection("h")': ['', '', ''],
+ \ 'AcceptSelection("t")': [''],
+ \ 'AcceptSelection("v")': ['', ''],
+ \ 'ToggleFocus()': [''],
+ \ 'ToggleRegex()': [''],
+ \ 'ToggleByFname()': [''],
+ \ 'ToggleType(1)': ['', ''],
+ \ 'ToggleType(-1)': ['', ''],
+ \ 'PrtExpandDir()': [''],
+ \ 'PrtInsert("c")': ['', ''],
+ \ 'PrtInsert()': [''],
+ \ 'PrtCurStart()': [''],
+ \ 'PrtCurEnd()': [''],
+ \ 'PrtCurLeft()': ['', '', ''],
+ \ 'PrtCurRight()': ['', ''],
+ \ 'PrtClearCache()': [''],
+ \ 'PrtDeleteEnt()': [''],
+ \ 'CreateNewFile()': [''],
+ \ 'MarkToOpen()': [''],
+ \ 'OpenMulti()': [''],
+ \ 'YankLine()': [],
+ \ 'PrtExit()': ['', '', ''],
+ \ }]
+
+if !has('gui_running')
+ cal add(s:prtmaps['PrtBS()'], remove(s:prtmaps['PrtCurLeft()'], 0))
+en
+
+let s:ficounts = {}
+
+let s:ccex = s:pref.'clear_cache_on_exit'
+
+" Regexp
+let s:fpats = {
+ \ '^\(\\|\)\|\(\\|\)$': '\\|',
+ \ '^\\\(zs\|ze\|<\|>\)': '^\\\(zs\|ze\|<\|>\)',
+ \ '^\S\*$': '\*',
+ \ '^\S\\?$': '\\?',
+ \ }
+
+let s:has_conceal = has('conceal')
+let s:bufnr_width = 3
+
+" Keypad
+let s:kprange = {
+ \ 'Plus': '+',
+ \ 'Minus': '-',
+ \ 'Divide': '/',
+ \ 'Multiply': '*',
+ \ 'Point': '.',
+ \ }
+
+" Highlight groups
+let s:hlgrps = {
+ \ 'NoEntries': 'Error',
+ \ 'Mode1': 'Character',
+ \ 'Mode2': 'LineNr',
+ \ 'Stats': 'Function',
+ \ 'Match': 'Identifier',
+ \ 'PrtBase': 'Comment',
+ \ 'PrtText': 'Normal',
+ \ 'PrtCursor': 'Constant',
+ \ 'BufferNr': 'Constant',
+ \ 'BufferInd': 'Normal',
+ \ 'BufferHid': 'Comment',
+ \ 'BufferHidMod': 'String',
+ \ 'BufferVis': 'Normal',
+ \ 'BufferVisMod': 'Identifier',
+ \ 'BufferCur': 'Question',
+ \ 'BufferCurMod': 'WarningMsg',
+ \ 'BufferPath': 'Comment',
+ \ }
+
+" lname, sname of the basic(non-extension) modes
+let s:types = ['fil', 'buf', 'mru']
+if !exists('g:ctrlp_types')
+ let g:ctrlp_types = s:types
+el
+ call filter(g:ctrlp_types, "index(['fil', 'buf', 'mru'], v:val)!=-1")
+en
+let g:ctrlp_builtins = len(g:ctrlp_types)-1
+
+let s:coretype_names = {
+ \ 'fil' : 'files',
+ \ 'buf' : 'buffers',
+ \ 'mru' : 'mru files',
+ \ }
+
+let s:coretypes = map(copy(g:ctrlp_types), '[s:coretype_names[v:val], v:val]')
+
+" Get the options {{{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}
+ en | endfo
+ for [ke, va] in items(s:opts)
+ let {va[0]} = exists(s:pref.ke) ? {s:pref.ke} : va[1]
+ endfo
+ unl va
+ 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
+ " Match window options
+ cal s:match_window_opts()
+ " One-time values
+ 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_tilde_homedir') | let g:ctrlp_tilde_homedir = 0 | en
+ if !exists('g:ctrlp_newcache') | let g:ctrlp_newcache = 0 | en
+ let s:maxdepth = min([s:maxdepth, 100])
+ 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
+ " Extensions
+ if !( exists('extensions') && extensions == s:extensions )
+ for each in s:extensions
+ exe 'ru autoload/ctrlp/'.each.'.vim'
+ endfo
+ en
+ " Keymaps
+ if type(s:urprtmaps) == 4
+ cal extend(s:prtmaps, s:urprtmaps)
+ en
+endf
+
+fu! s:match_window_opts()
+ let s:mw_pos =
+ \ s:mw =~ 'top\|bottom' ? matchstr(s:mw, 'top\|bottom') :
+ \ exists('g:ctrlp_match_window_bottom') ? ( s:mwbottom ? 'bottom' : 'top' )
+ \ : 'bottom'
+ let s:mw_order =
+ \ s:mw =~ 'order:[^,]\+' ? matchstr(s:mw, 'order:\zs[^,]\+') :
+ \ exists('g:ctrlp_match_window_reversed') ? ( s:mwreverse ? 'btt' : 'ttb' )
+ \ : 'btt'
+ let s:mw_max =
+ \ s:mw =~ 'max:[^,]\+' ? str2nr(matchstr(s:mw, 'max:\zs\d\+')) :
+ \ exists('g:ctrlp_max_height') ? s:mxheight
+ \ : 10
+ let s:mw_min =
+ \ s:mw =~ 'min:[^,]\+' ? str2nr(matchstr(s:mw, 'min:\zs\d\+')) : 1
+ let [s:mw_max, s:mw_min] = [max([s:mw_max, 1]), max([s:mw_min, 1])]
+ let s:mw_min = min([s:mw_min, s:mw_max])
+ let s:mw_res =
+ \ s:mw =~ 'results:[^,]\+' ? str2nr(matchstr(s:mw, 'results:\zs\d\+'))
+ \ : min([s:mw_max, &lines])
+endf
+"}}}1
+" * Open & Close {{{1
+fu! s:Open()
+ cal s:log(1)
+ cal s:getenv()
+ cal s:execextvar('enter')
+ sil! exe 'keepa' ( s:mw_pos == 'top' ? 'to' : 'bo' ) '1new ControlP'
+ cal s:buffunc(1)
+ 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() : ['']
+ let s:hstry = empty(hst) || !s:maxhst ? [''] : hst
+ en
+ for [ke, va] in items(s:glbs) | if exists('+'.ke)
+ sil! exe 'let s:glb_'.ke.' = &'.ke.' | let &'.ke.' = '.string(va)
+ en | endfo
+ if s:opmul != '0' && has('signs')
+ sign define ctrlpmark text=+> texthl=CtrlPMark
+ hi def link CtrlPMark Search
+ en
+ cal s:setupblank()
+endf
+
+fu! s:Close()
+ cal s:buffunc(0)
+ if winnr('$') == 1
+ bw!
+ el
+ try | bun!
+ cat | clo! | endt
+ cal s:unmarksigns()
+ en
+ for key in keys(s:glbs) | if exists('+'.key)
+ sil! exe 'let &'.key.' = s:glb_'.key
+ en | endfo
+ if exists('s:glb_acd') | let &acd = s:glb_acd | en
+ let g:ctrlp_lines = []
+ if s:winres[1] >= &lines && s:winres[2] == winnr('$')
+ exe s:winres[0].s:winres[0]
+ en
+ unl! s:focus s:hisidx s:hstgot s:marked s:statypes s:init s:savestr
+ \ s:mrbs s:did_exp
+ cal ctrlp#recordhist()
+ cal s:execextvar('exit')
+ cal s:log(0)
+ let v:errmsg = s:ermsg
+ ec
+endf
+" * Clear caches {{{1
+fu! ctrlp#clr(...)
+ let [s:matches, g:ctrlp_new{ a:0 ? a:1 : 'cache' }] = [1, 1]
+endf
+
+fu! ctrlp#clra()
+ let cadir = ctrlp#utils#cachedir()
+ if isdirectory(cadir)
+ let cafiles = split(s:glbpath(s:fnesc(cadir, 'g', ','), '**', 1), "\n")
+ let eval = '!isdirectory(v:val) && v:val !~ ''\v[\/]cache[.a-z]+$|\.log$'''
+ sil! cal map(s:ifilter(cafiles, eval), 'delete(v:val)')
+ en
+ cal ctrlp#clr()
+endf
+
+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')
+endf
+" * Files {{{1
+fu! ctrlp#files()
+ let cafile = ctrlp#utils#cachefile()
+ 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)
+ if !ctrlp#igncwd(s:dyncwd)
+ cal s:InitCustomFuncs()
+ cal s:GlobPath(s:fnesc(s:dyncwd, 'g', ','), 0)
+ cal s:CloseCustomFuncs()
+ en
+ el
+ sil! cal ctrlp#progress('Indexing...')
+ try | cal s:UserCmd(lscmd)
+ cat | retu [] | endt
+ en
+ " Remove base directory
+ cal ctrlp#rmbasedir(g:ctrlp_allfiles)
+ if len(g:ctrlp_allfiles) <= s:compare_lim
+ 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
+
+fu! s:InitCustomFuncs()
+ if s:igntype == 4 && has_key(s:usrign, 'func-init') && s:usrign['func-init'] != ''
+ exe call(s:usrign['func-init'], [])
+ en
+endf
+
+fu! s:CloseCustomFuncs()
+ if s:igntype == 4 && has_key(s:usrign, 'func-close') && s:usrign['func-close'] != ''
+ exe call(s:usrign['func-close'], [])
+ en
+endf
+
+fu! s:GlobPath(dirs, depth)
+ let entries = split(globpath(a:dirs, s:glob), "\n")
+ let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1]
+ cal extend(g:ctrlp_allfiles, dnf[1])
+ if !empty(dnf[0]) && !s:maxf(len(g:ctrlp_allfiles)) && depth <= s:maxdepth
+ sil! cal ctrlp#progress(len(g:ctrlp_allfiles), 1)
+ cal s:GlobPath(join(map(dnf[0], 's:fnesc(v:val, "g", ",")'), ','), depth)
+ en
+endf
+
+fu! ctrlp#addfile(ch, file)
+ call add(g:ctrlp_allfiles, a:file)
+ cal s:BuildPrompt(1)
+endf
+
+fu! s:safe_printf(format, ...)
+ try
+ retu call('printf', [a:format] + a:000)
+ cat
+ retu a:format
+ endt
+endf
+
+fu! s:UserCmd(lscmd)
+ let [path, lscmd] = [s:dyncwd, a:lscmd]
+ let do_ign =
+ \ type(s:usrcmd) == 4 && has_key(s:usrcmd, 'ignore') && s:usrcmd['ignore']
+ if do_ign && ctrlp#igncwd(s:cwd) | retu | en
+ if exists('+ssl') && &ssl && &shell !~ 'sh'
+ let [ssl, &ssl, path] = [&ssl, 0, tr(path, '/', '\')]
+ en
+ if (has('win32') || has('win64')) && match(&shellcmdflag, "/") != -1
+ let lscmd = substitute(lscmd, '\v(^|\&\&\s*)\zscd (/d)@!', 'cd /d ', '')
+ en
+ let path = exists('*shellescape') ? shellescape(path) : path
+ if (has('win32') || has('win64')) && match(&shell, 'sh') != -1
+ let path = tr(path, '\', '/')
+ en
+ if s:usrcmdasync && v:version >= 800 && exists('*job_start')
+ if exists('s:job')
+ call job_stop(s:job)
+ en
+ let g:ctrlp_allfiles = []
+ let s:job = job_start([&shell, &shellcmdflag, printf(lscmd, path)], {'callback': 'ctrlp#addfile'})
+ elsei has('patch-7.4-597') && !(has('win32') || has('win64'))
+ let g:ctrlp_allfiles = systemlist(s:safe_printf(lscmd, path))
+ el
+ let g:ctrlp_allfiles = split(system(s:safe_printf(lscmd, path)), "\n")
+ en
+ if exists('+ssl') && exists('ssl')
+ let &ssl = ssl
+ cal map(g:ctrlp_allfiles, 'tr(v:val, "\\", "/")')
+ en
+ if exists('s:vcscmd') && s:vcscmd
+ cal map(g:ctrlp_allfiles, 'tr(v:val, "/", "\\")')
+ en
+ if do_ign
+ 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()
+ let cmd = s:usrcmd
+ if type(cmd) == 1
+ retu cmd
+ elsei type(cmd) == 3 && len(cmd) >= 2 && cmd[:1] != ['', '']
+ if s:findroot(s:dyncwd, cmd[0], 0, 1) == []
+ retu len(cmd) == 3 ? cmd[2] : ''
+ en
+ let s:vcscmd = s:lash == '\'
+ retu cmd[1]
+ 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
+ for pair in cmdtypes
+ if pair[0] == fndroot[0] | brea | en
+ endfo
+ let s:vcscmd = s:lash == '\'
+ retu pair[1]
+ en
+endf
+" - Buffers {{{1
+fu! s:bufparts(bufnr)
+ let idc = (a:bufnr == bufnr('#') ? '#' : '') " alternative
+ let idc .= (getbufvar(a:bufnr, '&mod') ? '+' : '') " modified
+ let idc .= (getbufvar(a:bufnr, '&ma') ? '' : '-') " nomodifiable
+ let idc .= (getbufvar(a:bufnr, '&ro') ? '=' : '') " readonly
+
+ " flags for highlighting
+ let hiflags = (bufwinnr(a:bufnr) != -1 ? '*' : '') " visible
+ let hiflags .= (getbufvar(a:bufnr, '&mod') ? '+' : '') " modified
+ let hiflags .= (a:bufnr == s:crbufnr ? '!' : '') " current
+
+ let bname = bufname(a:bufnr)
+ let bname = (bname == '' ? '[No Name]' : fnamemodify(bname, s:bufname_mod))
+
+ let bpath = empty(s:bufpath_mod) ? '' : fnamemodify(bufname(a:bufnr), s:bufpath_mod).s:lash()
+
+ retu [idc, hiflags, bname, bpath]
+endf
+fu! ctrlp#buffers(...)
+ let ids = sort(filter(range(1, bufnr('$')), '(empty(getbufvar(v:val, "&bt"))'
+ \ .' || s:isterminal(v:val)) && getbufvar(v:val, "&bl")'), 's:compmreb')
+ if a:0 && a:1 == 'id'
+ retu ids
+ el
+ let bufs = [[], []]
+ for id in ids
+ let bname = bufname(id)
+ let ebname = bname == ''
+ let fname = fnamemodify(ebname ? '['.id.'*No Name]' : bname, ':.')
+ cal add(bufs[ebname], fname)
+ endfo
+ retu bufs[0] + bufs[1]
+ en
+endf
+" * MatchedItems() {{{1
+fu! s:MatchIt(items, pat, limit, exc)
+ let [lines, id] = [[], 0]
+ let pat =
+ \ s:byfname() ? map(split(a:pat, '^[^;]\+\\\@= 0
+ cal add(lines, item)
+ en
+ cat | brea | endt
+ if a:limit > 0 && len(lines) >= a:limit | brea | en
+ endfo
+ let s:mdata = [s:dyncwd, s:itemtype, s:regexp, s:sublist(a:items, id, -1)]
+ retu lines
+endf
+
+fu! s:MatchedItems(items, pat, limit)
+ let exc = exists('s:crfilerel') ? s:crfilerel : ''
+ let items = s:narrowable() ? s:matched + s:mdata[3] : a:items
+ let matcher = s:getextvar('matcher')
+ if empty(matcher) || type(matcher) != 4 || !has_key(matcher, 'match')
+ unlet matcher
+ let matcher = s:matcher
+ en
+ if matcher != {}
+ let argms =
+ \ has_key(matcher, 'arg_type') && matcher['arg_type'] == 'dict' ? [{
+ \ 'items': items,
+ \ 'str': a:pat,
+ \ 'limit': a:limit,
+ \ 'mmode': s:mmode(),
+ \ 'ispath': s:ispath,
+ \ 'crfile': exc,
+ \ 'regex': s:regexp,
+ \ }] : [items, a:pat, a:limit, s:mmode(), s:ispath, exc, s:regexp]
+ let lines = call(matcher['match'], argms, matcher)
+ el
+ let lines = s:MatchIt(items, a:pat, a:limit, exc)
+ en
+ let s:matches = len(lines)
+ unl! s:did_exp
+ retu lines
+endf
+
+fu! s:SplitPattern(str)
+ let str = a:str
+ let s:savestr = str
+ if s:regexp
+ let pat = s:regexfilter(str)
+ el
+ let lst = split(str, '\zs')
+ if exists('+ssl') && !&ssl
+ cal map(lst, 'escape(v:val, ''\'')')
+ en
+ for each in ['^', '$', '.']
+ cal map(lst, 'escape(v:val, each)')
+ endfo
+ en
+ if exists('lst')
+ let pat = ''
+ if !empty(lst)
+ if s:byfname() && index(lst, ';') > 0
+ let fbar = index(lst, ';')
+ let lst_1 = s:sublist(lst, 0, fbar - 1)
+ let lst_2 = len(lst) - 1 > fbar ? s:sublist(lst, fbar + 1, -1) : ['']
+ let pat = s:buildpat(lst_1).';'.s:buildpat(lst_2)
+ el
+ let pat = s:buildpat(lst)
+ en
+ en
+ en
+ retu escape(pat, '~')
+endf
+" * BuildPrompt() {{{1
+fu! s:Render(lines, pat)
+ let [&ma, lines, s:res_count] = [1, a:lines, len(a:lines)]
+ let height = min([max([s:mw_min, s:res_count]), s:winmaxh])
+ let pat = s:byfname() ? split(a:pat, '^[^;]\+\\\@' ).( s:byfname() ? 'd' : '>' ).'> '
+ 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] = 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]) && s:focus
+ exe 'echoh' hibase '| echon "_" | echoh None'
+ en
+endf
+" - SetDefTxt() {{{1
+fu! s:SetDefTxt()
+ if s:deftxt == '0' || ( s:deftxt == 1 && !s:ispath ) | retu | en
+ let txt = s:deftxt
+ if !type(txt)
+ let path = s:crfpath.s:lash(s:crfpath)
+ let txt = txt && !stridx(path, s:dyncwd) ? ctrlp#rmbasedir([path])[0] : ''
+ en
+ let s:prompt[0] = txt
+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)
+endf
+
+fu! s:PrtAdd(char)
+ unl! s:hstgot
+ let s:act_add = 1
+ let s:prompt[0] .= a:char
+ cal s:BuildPrompt(1)
+ unl s:act_add
+endf
+
+fu! s:PrtBS()
+ if !s:focus | retu | en
+ if empty(s:prompt[0]) && s:brfprt != 0
+ cal s:PrtExit()
+ 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], '^.')
+ let prt[2] = substitute(prt[2], '^.', '', '')
+ cal s:BuildPrompt(1)
+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\+$')
+ \ : str =~ '\w\W\+$' ? matchstr(str, '^.\+\w\ze\W\+$')
+ \ : str =~ '\s\+$' ? matchstr(str, '^.*\S\ze\s\+$')
+ \ : str =~ '\v^(\S+|\s+)$' ? '' : str
+ let s:prompt[0] = str
+ cal s:BuildPrompt(1)
+endf
+
+fu! s:PrtInsert(...)
+ if !s:focus | retu | en
+ let type = !a:0 ? '' : a:1
+ if !a:0
+ let type = s:insertstr()
+ if type == 'cancel' | retu | en
+ en
+ if type ==# 'r'
+ let regcont = s:getregs()
+ if regcont < 0 | retu | en
+ en
+ unl! s:hstgot
+ let s:act_add = 1
+ let s:prompt[0] .= type ==# 'w' ? s:crword
+ \ : type ==# 'f' ? s:crgfile
+ \ : type ==# 's' ? s:regisfilter('/')
+ \ : type ==# 'v' ? s:crvisual
+ \ : type ==# 'c' ? s:regisfilter('+')
+ \ : type ==# 'r' ? regcont : ''
+ cal s:BuildPrompt(1)
+ unl s:act_add
+endf
+
+fu! s:PrtExpandDir()
+ 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, '')
+ if str =~# '\v^[~$]\i{-}[\/]?|^#(\\d+)?:(p|h|8|\~|\.|g?s+)'
+ let str = expand(s:fnesc(str, 'g'))
+ elsei str =~# '\v^(\%|\):(p|h|8|\~|\.|g?s+)'
+ let spc = str =~# '^%' ? s:crfile
+ \ : str =~# '^' ? s:crgfile
+ \ : str =~# '^' ? s:crword
+ \ : str =~# '^' ? s:crnbword : ''
+ let pat = '(:(p|h|8|\~|\.|g?s(.)[^\3]*\3[^\3]*\3))+'
+ let mdr = matchstr(str, '\v^[^:]+\zs'.pat)
+ let nmd = matchstr(str, '\v^[^:]+'.pat.'\zs.{-}$')
+ let str = fnamemodify(s:fnesc(spc, 'g'), mdr).nmd
+ en
+ en
+ if str == '' | retu | en
+ unl! s:hstgot
+ let s:act_add = 1
+ let [base, seed] = s:headntail(str)
+ if str =~# '^[\/]'
+ let base = expand('/').base
+ en
+ let dirs = s:dircompl(base, seed)
+ if len(dirs) == 1
+ let str = dirs[0]
+ elsei len(dirs) > 1
+ let str .= s:findcommon(dirs, str)
+ en
+ let s:prompt[0] = exists('hasat') ? hasat[0].str : str
+ cal s:BuildPrompt(1)
+ unl s:act_add
+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], '.$'),
+ \ prt[1] . prt[2]]
+ en
+ cal s:BuildPrompt(0)
+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], '^.', '', '')]
+ cal s:BuildPrompt(0)
+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
+
+fu! s:PrtSelectMove(dir)
+ let wht = winheight(0)
+ let dirs = {'t': 'gg','b': 'G','j': 'j','k': 'k','u': wht.'k','d': wht.'j'}
+ exe 'keepj norm!' dirs[a:dir]
+ let pos = exists('*getcurpos') ? getcurpos() : getpos('.')
+ cal s:BuildPrompt(0)
+ cal setpos('.', pos)
+endf
+
+fu! s:PrtSelectJump(char)
+ let lines = copy(s:lines)
+ 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(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, 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, smartcs.'^'.chr, s:jmpchr[1] + 1)
+ let [jmpln, s:jmpchr] = [npos == -1 ? pos : npos, [chr, npos]]
+ en
+ exe 'keepj norm!' ( jmpln + 1 ).'G'
+ let pos = exists('*getcurpos') ? getcurpos() : getpos('.')
+ cal s:BuildPrompt(0)
+ cal setpos('.', pos)
+ en
+endf
+" Misc {{{2
+fu! s:PrtFocusMap(char)
+ cal call(( s:focus ? 's:PrtAdd' : 's:PrtSelectJump' ), [a:char])
+endf
+
+fu! s:PrtClearCache()
+ let ct = s:curtype()
+ if ct == 'fil'
+ cal ctrlp#clr()
+ elsei s:itemtype >= len(s:coretypes)
+ cal ctrlp#clr(s:statypes[s:itemtype][1])
+ en
+ if ct == 'mru'
+ let g:ctrlp_lines = ctrlp#mrufiles#refresh()
+ el
+ cal ctrlp#setlines()
+ en
+ let s:force = 1
+ cal s:BuildPrompt(1)
+ unl s:force
+endf
+
+fu! s:PrtDeleteEnt()
+ let ct = s:curtype()
+ if ct == 'mru'
+ cal s:PrtDeleteMRU()
+ elsei ct == 'buf'
+ cal s:delbuf()
+ elsei type(s:getextvar('wipe')) == 1
+ cal s:delent(s:getextvar('wipe'))
+ en
+endf
+
+fu! s:PrtDeleteMRU()
+ if s:curtype() == 'mru'
+ cal s:delent('ctrlp#mrufiles#remove')
+ en
+endf
+
+fu! s:PrtExit()
+ let bw = bufwinnr('%')
+ exe bufwinnr(s:bufnr).'winc w'
+ if bufnr('%') == s:bufnr && bufname('%') == 'ControlP'
+ noa cal s:Close()
+ noa winc p
+ els
+ exe bw.'winc w'
+ en
+endf
+
+fu! s:PrtHistory(...)
+ 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)]
+ let idx = exists('s:hisidx') ? s:hisidx + a:1 : a:1
+ " Limit idx within 0 and hslen
+ let idx = idx < 0 ? 0 : idx >= hslen ? hslen > 1 ? hslen - 1 : 0 : idx
+ let s:prompt = [hst[idx], '', '']
+ let [s:hisidx, s:hstgot, s:force] = [idx, 1, 1]
+ cal s:BuildPrompt(1)
+ unl s:force
+endf
+"}}}1
+" * 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', '')
+ 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)
+ endfo
+ for [ke, va] in items(s:kprange)
+ exe printf(pcmd, ke, pfunc, va)
+ endfo
+ let s:nmapped = s:bufnr
+endf
+
+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()
+ let [t_ve, guicursor] = [&t_ve, &guicursor]
+ wh exists('s:init') && s:keyloop
+ try
+ set t_ve=
+ if guicursor != ''
+ set guicursor=a:NONE
+ en
+ let nr = getchar()
+ fina
+ let &t_ve = t_ve
+ let &guicursor = guicursor
+ endt
+ let chr = !type(nr) ? nr2char(nr) : nr
+ if nr >=# 0x20
+ cal s:PrtFocusMap(chr)
+ el
+ let cmd = matchstr(maparg(chr), ':\zs.\+\ze$')
+ try
+ exe ( cmd != '' ? cmd : 'norm '.chr )
+ cat
+ endt
+ en
+ endw
+endf
+" * Toggling {{{1
+fu! s:ToggleFocus()
+ let s:focus = !s:focus
+ cal s:BuildPrompt(0)
+endf
+
+fu! s:ToggleRegex()
+ let s:regexp = !s:regexp
+ cal s:PrtSwitcher()
+endf
+
+fu! s:ToggleByFname()
+ if s:ispath
+ let s:byfname = !s:byfname
+ let s:mfunc = s:mfunc()
+ cal s:PrtSwitcher()
+ en
+endf
+
+fu! s:ToggleType(dir)
+ let max = len(g:ctrlp_ext_vars) + len(s:coretypes) - 1
+ let next = s:walker(max, s:itemtype, a:dir)
+ cal ctrlp#setlines(next)
+ cal ctrlp#syntax()
+ 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:ToggleMRURelative()
+ cal ctrlp#mrufiles#tgrel()
+ cal s:PrtClearCache()
+endf
+
+fu! s:PrtSwitcher()
+ let [s:force, s:matches] = [1, 1]
+ cal s:BuildPrompt(1)
+ unl s:force
+endf
+" - SetWD() {{{1
+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 pmodes = has_key(a:args, 'mode') ? a:args['mode'] : s:pathmode
+ let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()]
+ if (!type(pmodes))
+ let pmodes =
+ \ pmodes == 0 ? '' :
+ \ pmodes == 1 ? 'a' :
+ \ pmodes == 2 ? 'r' :
+ \ 'c'
+ en
+ let spath = pmodes =~ 'd' ? s:dyncwd : pmodes =~ 'w' ? s:cwd : s:crfpath
+ for pmode in split(pmodes, '\zs')
+ if ctrlp#setpathmode(pmode, spath) | retu | en
+ endfo
+endf
+" * AcceptSelection() {{{1
+fu! ctrlp#acceptfile(...)
+ let useb = 0
+ if a:0 == 1 && type(a:1) == 4
+ let [md, line] = [a:1['action'], a:1['line']]
+ let atl = has_key(a:1, 'tail') ? a:1['tail'] : ''
+ el
+ let [md, line] = [a:1, a:2]
+ let atl = a:0 > 2 ? a:3 : ''
+ en
+ if !type(line)
+ let [filpath, bufnr, useb] = [line, line, 1]
+ el
+ let [bufnr, filpath] = s:bufnrfilpath(line)
+ if bufnr == filpath
+ let useb = 1
+ en
+ en
+ cal s:PrtExit()
+ let tail = s:tail()
+ let j2l = atl != '' ? atl : matchstr(tail, '^ +\zs\d\+$')
+ if bufnr > 0 && ( !empty(s:jmptobuf) && s:jmptobuf =~ md )
+ \ && !( md == 'e' && bufnr == bufnr('%') )
+ let [jmpb, bufwinnr] = [1, bufwinnr(bufnr)]
+ 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' && ( 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
+ el
+ " Determine the command to use
+ let useb = bufnr > 0 && buflisted(bufnr) && ( empty(tail) || useb )
+ let cmd =
+ \ md == 't' || s:splitwin == 1 ? ( useb ? 'tab sb' : 'tabe' ) :
+ \ md == 'h' || s:splitwin == 2 ? ( useb ? 'sb' : 'new' ) :
+ \ md == 'v' || s:splitwin == 3 ? ( useb ? 'vert sb' : 'vne' ) :
+ \ call('ctrlp#normcmd', useb ? ['b', 'bo vert sb'] : ['e'])
+ " Reset &switchbuf option
+ let [swb, &swb] = [&swb, '']
+ " Open new window/buffer
+ let [fid, tail] = [( useb ? bufnr : filpath ), ( atl != '' ? ' +'.atl : tail )]
+ let args = [cmd, fid, tail, 1, [useb, j2l]]
+ cal call('s:openfile', args)
+ let &swb = swb
+ en
+endf
+
+fu! s:SpecInputs(str)
+ if a:str =~ '\v^(\.\.([\/]\.\.)*[\/]?[.\/]*)$' && s:spi
+ let cwd = s:dyncwd
+ cal ctrlp#setdir(a:str =~ '^\.\.\.*$' ?
+ \ '../'.repeat('../', strlen(a:str) - 2) : a:str)
+ if cwd != s:dyncwd | cal ctrlp#setlines() | en
+ cal s:PrtClear()
+ retu 1
+ elsei a:str == s:lash && s:spi
+ cal s:SetWD({ 'mode': 'rd' })
+ cal ctrlp#setlines()
+ cal s:PrtClear()
+ retu 1
+ elsei a:str =~ '^@.\+' && s:spi
+ retu s:at(a:str)
+ elsei a:str == '?'
+ cal s:PrtExit()
+ let hlpwin = &columns > 159 ? '| vert res 80' : ''
+ sil! exe 'bo vert h ctrlp-mappings' hlpwin '| norm! 0'
+ retu 1
+ en
+ retu 0
+endf
+
+fu! s:AcceptSelection(action)
+ let [md, icr] = [a:action[0], match(a:action, 'r') >= 0]
+ let subm = icr || ( !icr && md == 'e' )
+ if !subm && s:OpenMulti(md) != -1 | retu | en
+ let str = s:getinput()
+ if subm | if s:SpecInputs(str) | retu | en | en
+ " Get the selected line
+ let line = ctrlp#getcline()
+ if !subm && s:curtype() != 'fil' && line == '' && line('.') > s:offset
+ \ && str !~ '\v^(\.\.([\/]\.\.)*[\/]?[.\/]*|/|\\|\?|\@.+)$'
+ cal s:CreateNewFile(md) | retu
+ en
+ if empty(line) | retu | en
+ " Do something with it
+ if s:openfunc != {} && has_key(s:openfunc, s:ctype)
+ let actfunc = s:openfunc[s:ctype]
+ let type = has_key(s:openfunc, 'arg_type') ? s:openfunc['arg_type'] : 'list'
+ el
+ if s:itemtype < len(s:coretypes)
+ let [actfunc, type] = ['ctrlp#acceptfile', 'dict']
+ el
+ let [actfunc, exttype] = [s:getextvar('accept'), s:getextvar('act_farg')]
+ let type = exttype == 'dict' ? exttype : 'list'
+ en
+ en
+ let actargs = type == 'dict' ? [{ 'action': md, 'line': line, 'icr': icr, 'input': str}]
+ \ : [md, line]
+ cal call(actfunc, actargs)
+endf
+" - CreateNewFile() {{{1
+fu! s:CreateNewFile(...)
+ let [md, str] = ['', s:getinput('n')]
+ if empty(str) | retu | en
+ if s:argmap && !a:0
+ " Get the extra argument
+ let md = s:argmaps(md, 1)
+ if md == 'cancel' | retu | en
+ en
+ let str = s:sanstail(str)
+ let [base, fname] = s:headntail(str)
+ if fname =~ '^[\/]$' | retu | en
+ if exists('s:marked') && len(s:marked)
+ " Use the first marked file's path
+ let path = fnamemodify(values(s:marked)[0], ':p:h')
+ let base = path.s:lash(path).base
+ let str = fnamemodify(base.s:lash.fname, ':.')
+ en
+ if base != '' | if isdirectory(ctrlp#utils#mkdir(base))
+ let optyp = str | en | el | let optyp = fname
+ en
+ if !exists('optyp') | retu | en
+ let [filpath, tail] = [fnamemodify(optyp, ':p'), s:tail()]
+ if !stridx(filpath, s:dyncwd) | cal s:insertcache(str) | en
+ cal s:PrtExit()
+ let cmd = md == 'r' ? ctrlp#normcmd('e') :
+ \ s:newfop =~ '1\|t' || ( a:0 && a:1 == 't' ) || md == 't' ? 'tabe' :
+ \ 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, 1)
+endf
+" * OpenMulti() {{{1
+fu! s:MarkToOpen()
+ let ct = s:curtype()
+ if s:bufnr <= 0 || s:opmul == '0'
+ \ || ( s:itemtype >= len(s:coretypes) && s:getextvar('opmul') != 1 )
+ retu
+ en
+ let line = ctrlp#getcline()
+
+ " Do not allow to mark modified or current buffer
+ let bufnr = s:bufnrfilpath(line)[0]
+ if (ct == 'buf' && s:delbufcond(bufnr))
+ retu
+ en
+
+ if empty(line) | retu | en
+ let filpath = s:ispath ? fnamemodify(line, ':p') : line
+ if exists('s:marked') && s:dictindex(s:marked, filpath) > 0
+ " Unmark and remove the file from s:marked
+ let key = s:dictindex(s:marked, filpath)
+ cal remove(s:marked, key)
+ if empty(s:marked) | unl s:marked | en
+ if has('signs')
+ exe 'sign unplace' key 'buffer='.s:bufnr
+ en
+ el
+ " Add to s:marked and place a new sign
+ if exists('s:marked')
+ let vac = s:vacantdict(s:marked)
+ let key = empty(vac) ? len(s:marked) + 1 : vac[0]
+ let s:marked = extend(s:marked, { key : filpath })
+ el
+ let [key, s:marked] = [1, { 1 : filpath }]
+ en
+ if has('signs')
+ exe 'sign place' key 'line='.line('.').' name=ctrlpmark buffer='.s:bufnr
+ en
+ en
+ sil! cal ctrlp#statusline()
+endf
+
+fu! s:OpenMulti(...)
+ let has_marked = exists('s:marked')
+ if ( !has_marked && a:0 ) || s:opmul == '0' || !s:ispath
+ \ || ( s:itemtype >= len(s:coretypes) && s:getextvar('opmul') != 1 )
+ retu -1
+ en
+ " Get the options
+ let [nr, md] = [matchstr(s:opmul, '\d\+'), matchstr(s:opmul, '[thvi]')]
+ 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 !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(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', v:val, '', 0)")
+ en
+ let tail = s:tail()
+ let [emptytail, bufnr] = [empty(tail), bufnr('^'.mkd[0].'$')]
+ let useb = bufnr > 0 && buflisted(bufnr) && emptytail
+ " Move to a replaceable window
+ let ncmd = ( useb ? ['b', 'bo vert sb'] : ['e', 'bo vne'] )
+ \ + ( ur ? [] : ['ignruw'] )
+ let fst = call('ctrlp#normcmd', ncmd)
+ " Check if the current window has a replaceable buffer
+ 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.'$')
+ if bufnr < 0 && getftype(va) == '' | con | en
+ let useb = bufnr > 0 && buflisted(bufnr) && emptytail
+ let snd = md != '' && has_key(cmds, md) ?
+ \ ( useb ? cmds[md][0] : cmds[md][1] ) : ( useb ? 'vert sb' : 'vne' )
+ let cmd = ic == 1 && ( !( !ur && fst =~ '^[eb]$' ) || repabl ) ? fst : snd
+ let conds = [( nr != '' && nr > 1 && nr < ic ) || ( nr == '' && ic > 1 ),
+ \ nr != '' && nr < ic]
+ if conds[nopt]
+ if !buflisted(bufnr) | cal s:openfile('bad', va, '', 0) | en
+ el
+ 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]
+ 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:YankLine(...)
+ let @" = s:getinput()
+ let has_marked = exists('s:marked')
+ if !has_marked
+ let line = ctrlp#getcline()
+ if line == '' | retu | en
+ let marked = { 1 : fnamemodify(line, ':p') }
+ en
+ let @" = join(values(has_marked ? s:marked : marked), "\n")
+ cal s:PrtExit()
+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'
+ let type = has_key(s:openfunc, 'arg_type') ? s:openfunc['arg_type'] : 'dict'
+ let argms = type == 'dict' ? [{ 'action': a:md, 'line': a:line }]
+ \ : [a:md, a:line]
+ cal call(s:openfunc[s:ctype], argms, s:openfunc)
+ 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
+fu! ctrlp#complen(...)
+ " By length
+ let [len1, len2] = [strlen(a:1), strlen(a:2)]
+ retu len1 == len2 ? 0 : len1 > len2 ? 1 : -1
+endf
+
+fu! s:compmatlen(...)
+ " By match length
+ let mln1 = s:shortest(s:matchlens(a:1, s:compat))
+ let mln2 = s:shortest(s:matchlens(a:2, s:compat))
+ retu mln1 == mln2 ? 0 : mln1 > mln2 ? 1 : -1
+endf
+
+fu! s:comptime(...)
+ " By last modified time
+ let [time1, time2] = [getftime(a:1), getftime(a:2)]
+ retu time1 == time2 ? 0 : time1 < time2 ? 1 : -1
+endf
+
+fu! s:compmreb(...)
+ " By last entered time (bufnr)
+ let [id1, id2] = [index(s:mrbs, a:1), index(s:mrbs, a:2)]
+ if id1 == id2
+ return 0
+ endif
+ if id1 < 0
+ return 1
+ endif
+ if id2 < 0
+ return -1
+ endif
+ return id1 > id2 ? 1 : -1
+endf
+
+fu! s:compmref(...)
+ " By last entered time (MRU)
+ let [id1, id2] = [index(g:ctrlp_lines, a:1), index(g:ctrlp_lines, a:2)]
+ retu id1 == id2 ? 0 : id1 > id2 ? 1 : -1
+endf
+
+fu! s:comparent(...)
+ " By same parent dir
+ if !stridx(s:crfpath, s:dyncwd)
+ let [as1, as2] = [s:dyncwd.s:lash().a:1, s:dyncwd.s:lash().a:2]
+ let [loc1, loc2] = [s:getparent(as1), s:getparent(as2)]
+ if loc1 == s:crfpath && loc2 != s:crfpath | retu -1 | en
+ if loc2 == s:crfpath && loc1 != s:crfpath | retu 1 | en
+ retu 0
+ en
+ retu 0
+endf
+
+fu! s:compfnlen(...)
+ " By filename length
+ let len1 = strlen(split(a:1, s:lash)[-1])
+ let len2 = strlen(split(a:2, s:lash)[-1])
+ retu len1 == len2 ? 0 : len1 > len2 ? 1 : -1
+endf
+
+fu! s:matchlens(str, pat, ...)
+ if empty(a:pat) || index(['^', '$'], a:pat) >= 0 | retu {} | en
+ let st = a:0 ? a:1 : 0
+ let lens = a:0 >= 2 ? a:2 : {}
+ let nr = a:0 >= 3 ? a:3 : 0
+ if nr > 20 | retu {} | en
+ if match(a:str, a:pat, st) >= 0
+ let [mst, mnd] = [matchstr(a:str, a:pat, st), matchend(a:str, a:pat, st)]
+ let lens = extend(lens, { nr : [strlen(mst), mst] })
+ let lens = s:matchlens(a:str, a:pat, mnd, lens, nr + 1)
+ en
+ retu lens
+endf
+
+fu! s:shortest(lens)
+ retu min(map(values(a:lens), 'v:val[0]'))
+endf
+
+fu! s:mixedsort(...)
+ let ct = s:curtype()
+ if ct == 'buf'
+ let pat = '[\/]\?\[\d\+\*No Name\]$'
+ if a:1 =~# pat && a:2 =~# pat | retu 0
+ elsei a:1 =~# pat | retu 1
+ elsei a:2 =~# pat | retu -1 | en
+ en
+ let [cln, cml] = [ctrlp#complen(a:1, a:2), s:compmatlen(a:1, a:2)]
+ if s:ispath
+ let ms = []
+ if s:res_count < 21
+ let ms += [s:compfnlen(a:1, a:2)]
+ if ct !~ '^\(buf\|mru\)$' | let ms += [s:comptime(a:1, a:2)] | en
+ if !s:itemtype | let ms += [s:comparent(a:1, a:2)] | en
+ en
+ if ct =~ '^\(buf\|mru\)$'
+ let ms += [s:compmref(a:1, a:2)]
+ let cln = cml ? cln : 0
+ en
+ let ms += [cml, 0, 0, 0]
+ let mp = call('s:multipliers', ms[:3])
+ retu cln + ms[0] * mp[0] + ms[1] * mp[1] + ms[2] * mp[2] + ms[3] * mp[3]
+ en
+ retu cln + cml * 2
+endf
+
+fu! s:multipliers(...)
+ let mp0 = !a:1 ? 0 : 2
+ let mp1 = !a:2 ? 0 : 1 + ( !mp0 ? 1 : mp0 )
+ let mp2 = !a:3 ? 0 : 1 + ( !( mp0 + mp1 ) ? 1 : ( mp0 + mp1 ) )
+ let mp3 = !a:4 ? 0 : 1 + ( !( mp0 + mp1 + mp2 ) ? 1 : ( mp0 + mp1 + mp2 ) )
+ retu [mp0, mp1, mp2, mp3]
+endf
+
+fu! s:compval(...)
+ retu a:1 - a:2
+endf
+" Statusline {{{2
+fu! ctrlp#statusline()
+ if !exists('s:statypes')
+ let s:statypes = copy(s:coretypes)
+ if !empty(g:ctrlp_ext_vars)
+ cal map(copy(g:ctrlp_ext_vars),
+ \ 'add(s:statypes, [ v:val["lname"], v:val["sname"] ])')
+ en
+ en
+ let tps = s:statypes
+ 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 s:ctype = tps[s:itemtype][0]
+ let focus = s:focus ? 'prt' : 'win'
+ let byfname = s:ispath ? s:byfname ? 'file' : 'path' : 'line'
+ let marked = s:opmul != '0' ?
+ \ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <->' : ''
+ if s:status != {}
+ let argms =
+ \ has_key(s:status, 'arg_type') && s:status['arg_type'] == 'dict' ? [{
+ \ 'focus': focus,
+ \ 'byfname': byfname,
+ \ 'regex': s:regexp,
+ \ 'prev': prv,
+ \ 'item': s:ctype,
+ \ 'next': nxt,
+ \ 'marked': marked,
+ \ }] : [focus, byfname, s:regexp, prv, s:ctype, nxt, marked]
+ let &l:stl = call(s:status['main'], argms, s:status)
+ el
+ 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# %{getcwd()} %*'
+ let &l:stl = focus.byfname.regex.slider.marked.dir
+ en
+endf
+
+fu! s:dismrk()
+ retu has('signs') ? len(s:marked) :
+ \ '%<'.join(values(map(copy(s:marked), 'split(v:val, "[\\/]")[-1]')), ', ')
+endf
+
+fu! ctrlp#progress(enum, ...)
+ if has('macunix') || has('mac') | sl 1m | en
+ let txt = a:0 ? '(press ctrl-c to abort)' : ''
+ if s:status != {}
+ let argms = has_key(s:status, 'arg_type') && s:status['arg_type'] == 'dict'
+ \ ? [{ 'str': a:enum }] : [a:enum]
+ let &l:stl = call(s:status['prog'], argms, s:status)
+ el
+ let &l:stl = '%#CtrlPStats# '.a:enum.' %* '.txt.'%=%<%#CtrlPMode2# %{getcwd()} %*'
+ en
+ redraws
+endf
+" *** Paths {{{2
+" Line formatting {{{3
+fu! s:formatline(str)
+ let str = a:str
+ let ct = s:curtype()
+ if ct == 'buf'
+ let bufnr = s:bufnrfilpath(str)[0]
+ let parts = s:bufparts(bufnr)
+ let str = printf('%'.s:bufnr_width.'s', bufnr)
+ if s:has_conceal
+ let str .= printf(' %-13s %s%-36s',
+ \ ''.parts[0].'',
+ \ ''.parts[1], '{'.parts[2].'}')
+ if (!empty(s:bufpath_mod))
+ let str .= printf(' %s', ''.parts[3].'')
+ en
+ el
+ let str .= printf(' %-5s %-30s',
+ \ parts[0],
+ \ parts[2])
+ if (!empty(s:bufpath_mod))
+ let str .= printf(' %s', parts[3])
+ en
+ en
+ en
+ let cond = ct != 'buf' &&s:ispath && ( s:winw - 4 ) < s:strwidth(str)
+ retu s:lineprefix.( cond ? s:pathshorten(str) : str )
+endf
+
+fu! s:pathshorten(str)
+ retu matchstr(a:str, '^.\{9}').'...'
+ \ .matchstr(a:str, '.\{'.( s:winw - 16 ).'}$')
+endf
+
+fu! s:offset(lines, height)
+ let s:offset = s:mw_order == 'btt' ? ( a:height - s:res_count ) : 0
+ retu s:offset > 0 ? ( repeat([''], s:offset) + a:lines ) : a:lines
+endf
+" Directory completion {{{3
+fu! s:dircompl(be, sd)
+ if a:sd == '' | retu [] | en
+ if a:be == ''
+ let [be, sd] = [s:dyncwd, a:sd]
+ el
+ let be = a:be.s:lash(a:be)
+ let sd = be.a:sd
+ en
+ let dirs = split(globpath(s:fnesc(be, 'g', ','), a:sd.'*/'), "\n")
+ if a:be == ''
+ let dirs = ctrlp#rmbasedir(dirs)
+ en
+ cal filter(dirs, '!match(v:val, escape(sd, ''~$.\''))'
+ \ . ' && v:val !~ ''\v(^|[\/])\.{1,2}[\/]$''')
+ retu dirs
+endf
+
+fu! s:findcommon(items, seed)
+ let [items, id, cmn, ic] = [copy(a:items), strlen(a:seed), '', 0]
+ cal map(items, 'strpart(v:val, id)')
+ for char in split(items[0], '\zs')
+ for item in items[1:]
+ if item[ic] != char | let brk = 1 | brea | en
+ endfo
+ if exists('brk') | brea | en
+ let cmn .= char
+ let ic += 1
+ 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 : []
+endf
+
+fu! s:lash(...)
+ retu ( a:0 ? a:1 : s:dyncwd ) !~ '[\/]$' ? s:lash : ''
+endf
+
+fu! s:ispathitem()
+ retu s:itemtype < len(s:coretypes) || s:getextvar('type') == 'path'
+endf
+
+fu! ctrlp#igncwd(cwd)
+ retu ctrlp#utils#glob(a:cwd, 0) == '' ||
+ \ ( s:igntype >= 0 && s:usrign(a:cwd, getftype(a:cwd)) )
+endf
+
+fu! ctrlp#dirnfile(entries)
+ let [items, cwd] = [[[], []], s:dyncwd.s:lash()]
+ for each in a:entries
+ let etype = getftype(each)
+ if s:igntype >= 0 && s:usrign(each, etype) | con | en
+ if etype == 'dir'
+ if s:showhidden | if each !~ '[\/]\.\{1,2}$'
+ cal add(items[0], each)
+ en | el
+ cal add(items[0], each)
+ en
+ elsei etype == 'link'
+ if s:folsym
+ let isfile = !isdirectory(each)
+ if s:folsym == 2 || !s:samerootsyml(each, isfile, cwd)
+ cal add(items[isfile], each)
+ en
+ en
+ elsei etype == 'file'
+ cal add(items[1], each)
+ en
+ endfo
+ retu items
+endf
+
+fu! s:usrign(item, type)
+ if s:igntype == 1 | retu a:item =~ s:usrign | en
+ if s:igntype == 2
+ if call(s:usrign, [a:item, a:type])
+ retu 1
+ en
+ elsei s:igntype == 4
+ if has_key(s:usrign, a:type) && s:usrign[a:type] != ''
+ \ && a:item =~ s:usrign[a:type]
+ retu 1
+ elsei has_key(s:usrign, 'func') && s:usrign['func'] != ''
+ \ && call(s:usrign['func'], [a:item, a:type])
+ retu 1
+ en
+ en
+ retu 0
+endf
+
+fu! s:samerootsyml(each, isfile, cwd)
+ let resolve = fnamemodify(resolve(a:each), ':p:h')
+ let resolve .= s:lash(resolve)
+ retu !( stridx(resolve, a:cwd) && ( stridx(a:cwd, resolve) || a:isfile ) )
+endf
+
+fu! ctrlp#rmbasedir(items)
+ if a:items == []
+ retu a:items
+ en
+ let cwd = s:dyncwd.s:lash()
+ let first = a:items[0]
+ if has('win32') || has('win64')
+ let cwd = tr(cwd, '\', '/')
+ let first = tr(first, '\', '/')
+ en
+ if !stridx(first, cwd)
+ let idx = strlen(cwd)
+ retu map(a:items, 'strpart(v:val, idx)')
+ en
+ retu a:items
+endf
+" Working directory {{{3
+fu! s:getparent(item)
+ let parent = substitute(a:item, '[\/][^\/]\+[\/:]\?$', '', '')
+ if parent == '' || parent !~ '[\/]'
+ let parent .= s:lash
+ en
+ retu parent
+endf
+
+fu! s:findroot(curr, mark, depth, type)
+ 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
+ retu s:findroot(parent, a:mark, depth, a:type)
+ en
+ en
+ retu []
+endf
+
+fu! ctrlp#setpathmode(pmode, ...)
+ if a:pmode == 'c' || ( a:pmode == 'a' && stridx(s:crfpath, s:cwd) < 0 )
+ if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en
+ cal ctrlp#setdir(s:crfpath)
+ retu 1
+ elsei a:pmode == 'r'
+ let spath = a:0 ? a:1 : s:crfpath
+ let markers = ['.git', '.hg', '.svn', '.bzr', '_darcs']
+ if type(s:rmarkers) == 3 && !empty(s:rmarkers)
+ if s:findroot(spath, s:rmarkers, 0, 0) != [] | retu 1 | en
+ cal filter(markers, 'index(s:rmarkers, v:val) < 0')
+ let markers = s:rmarkers + markers
+ en
+ if s:findroot(spath, markers, 0, 0) != [] | retu 1 | en
+ en
+ retu 0
+endf
+
+fu! ctrlp#setdir(path, ...)
+ let cmd = a:0 ? a:1 : 'lc!'
+ 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')
+ cal ctrlp#setdir(getcwd(), haslocaldir() ? 'lc!' : 'cd!')
+ en
+endf
+" Highlighting {{{2
+fu! ctrlp#syntax()
+ if ctrlp#nosy() | retu | en
+ for [ke, va] in items(s:hlgrps) | cal ctrlp#hicheck('CtrlP'.ke, va) | endfo
+ let bgColor=synIDattr(synIDtrans(hlID('Normal')), 'bg')
+ if bgColor !~ '^-1$\|^$'
+ sil! exe 'hi CtrlPLinePre guifg='.bgColor.' ctermfg='.bgColor
+ en
+ sy match CtrlPNoEntries '^ == NO ENTRIES ==$'
+ if hlexists('CtrlPLinePre')
+ exe "sy match CtrlPLinePre '^".escape(get(g:, 'ctrlp_line_prefix', '>'),'^$.*~\')."'"
+ en
+
+ if s:curtype() == 'buf' && s:has_conceal
+ sy region CtrlPBufferNr matchgroup=CtrlPLinePre start='^>\s\+' end='\s'
+ sy region CtrlPBufferInd concealends matchgroup=Ignore start='' end=''
+ sy region CtrlPBufferRegion concealends matchgroup=Ignore start='' end=''
+ \ contains=CtrlPBufferHid,CtrlPBufferHidMod,CtrlPBufferVis,CtrlPBufferVisMod,CtrlPBufferCur,CtrlPBufferCurMod
+ sy region CtrlPBufferHid concealends matchgroup=Ignore start='\s*{' end='}' contained
+ sy region CtrlPBufferHidMod concealends matchgroup=Ignore start='+\s*{' end='}' contained
+ sy region CtrlPBufferVis concealends matchgroup=Ignore start='\*\s*{' end='}' contained
+ sy region CtrlPBufferVisMod concealends matchgroup=Ignore start='\*+\s*{' end='}' contained
+ sy region CtrlPBufferCur concealends matchgroup=Ignore start='\*!\s*{' end='}' contained
+ sy region CtrlPBufferCurMod concealends matchgroup=Ignore start='\*+!\s*{' end='}' contained
+ sy region CtrlPBufferPath concealends matchgroup=Ignore start='' end=''
+ en
+endf
+
+fu! s:highlight(pat, grp)
+ if s:matcher != {} | retu | en
+ cal clearmatches()
+ if !empty(a:pat) && s:ispath
+ if s:regexp
+ let pat = substitute(a:pat, '\\\@ \\zs', 'g')
+ cal matchadd(a:grp, ( s:martcs == '' ? '\c' : '\C' ).pat)
+ el
+ let pat = a:pat
+
+ " get original characters so we can rebuild pat
+ let chars = split(pat, '\[\^\\\?.\]\\{-}')
+
+ " Build a pattern like /a.*b.*c/ from abc (but with .\{-} non-greedy
+ " matchers instead)
+ let pat = join(chars, '.\{-}')
+ " Ensure we match the last version of our pattern
+ let ending = '\(.*'.pat.'\)\@!'
+ " Case sensitive?
+ let beginning = ( s:martcs == '' ? '\c' : '\C' ).'^.*'
+ if s:byfname()
+ " Make sure there are no slashes in our match
+ let beginning = beginning.'\([^\/]*$\)\@='
+ en
+
+ for i in range(len(chars))
+ " Surround our current target letter with \zs and \ze so it only
+ " actually matches that one letter, but has all preceding and trailing
+ " letters as well.
+ " \zsa.*b.*c
+ " a\(\zsb\|.*\zsb)\ze.*c
+ let charcopy = copy(chars)
+ if i == 0
+ let charcopy[i] = '\zs'.charcopy[i].'\ze'
+ let middle = join(charcopy, '.\{-}')
+ el
+ let before = join(charcopy[0:i-1], '.\{-}')
+ let after = join(charcopy[i+1:-1], '.\{-}')
+ let c = charcopy[i]
+ " for abc, match either ab.\{-}c or a.*b.\{-}c in that order
+ let cpat = '\(\zs'.c.'\|'.'.*\zs'.c.'\)\ze.*'
+ let middle = before.cpat.after
+ en
+
+ " Now we matchadd for each letter, the basic form being:
+ " ^.*\zsx\ze.*$, but with our pattern we built above for the letter,
+ " and a negative lookahead ensuring that we only highlight the last
+ " occurrence of our letters. We also ensure that our matcher is case
+ " insensitive or sensitive depending.
+ cal matchadd(a:grp, beginning.middle.ending)
+ endfo
+ en
+
+ cal matchadd('CtrlPLinePre', '^>')
+ elseif !empty(a:pat) && s:regexp &&
+ \ exists('g:ctrlp_regex_always_higlight') &&
+ \ g:ctrlp_regex_always_higlight
+ let pat = substitute(a:pat, '\\\@ \\zs', 'g')
+ cal matchadd(a:grp, ( s:martcs == '' ? '\c' : '\C').pat)
+ en
+endf
+
+fu! s:dohighlight()
+ retu s:mathi[0] && exists('*clearmatches') && !ctrlp#nosy()
+endf
+" Prompt history {{{2
+fu! s:gethistloc()
+ let utilcadir = ctrlp#utils#cachedir()
+ let cache_dir = utilcadir.s:lash(utilcadir).'hist'
+ retu [cache_dir, cache_dir.s:lash(cache_dir).'cache.txt']
+endf
+
+fu! s:gethistdata()
+ retu ctrlp#utils#readfile(s:gethistloc()[1])
+endf
+
+fu! ctrlp#recordhist()
+ let str = join(s:prompt, '')
+ if empty(str) || !s:maxhst | retu | en
+ let hst = s:hstry
+ if len(hst) > 1 && hst[1] == str | retu | en
+ cal extend(hst, [str], 1)
+ if len(hst) > s:maxhst | cal remove(hst, s:maxhst, -1) | en
+ cal ctrlp#utils#writecache(hst, s:gethistloc()[0], s:gethistloc()[1])
+endf
+" Signs {{{2
+fu! s:unmarksigns()
+ if !s:dosigns() | retu | en
+ for key in keys(s:marked)
+ exe 'sign unplace' key 'buffer='.s:bufnr
+ endfo
+endf
+
+fu! s:remarksigns()
+ if !s:dosigns() | retu | en
+ for ic in range(1, len(s:lines))
+ let line = s:ispath ? fnamemodify(s:lines[ic - 1], ':p') : s:lines[ic - 1]
+ let key = s:dictindex(s:marked, line)
+ if key > 0
+ exe 'sign place' key 'line='.ic.' name=ctrlpmark buffer='.s:bufnr
+ en
+ endfo
+endf
+
+fu! s:dosigns()
+ retu exists('s:marked') && s:bufnr > 0 && s:opmul != '0' && has('signs')
+endf
+" Lists & Dictionaries {{{2
+fu! s:ifilter(list, str)
+ let [rlist, estr] = [[], substitute(a:str, 'v:val', 'each', 'g')]
+ for each in a:list
+ try
+ if eval(estr)
+ cal add(rlist, each)
+ en
+ cat | con | endt
+ endfo
+ retu rlist
+endf
+
+fu! s:dictindex(dict, expr)
+ for key in keys(a:dict)
+ if a:dict[key] ==# a:expr | retu key | en
+ endfo
+ retu -1
+endf
+
+fu! s:vacantdict(dict)
+ retu filter(range(1, max(keys(a:dict))), '!has_key(a:dict, v:val)')
+endf
+
+fu! s:sublist(l, s, e)
+ retu v:version > 701 ? a:l[(a:s):(a:e)] : s:sublist7071(a:l, a:s, a:e)
+endf
+
+fu! s:sublist7071(l, s, e)
+ let [newlist, id, ae] = [[], a:s, a:e == -1 ? len(a:l) - 1 : a:e]
+ wh id <= ae
+ cal add(newlist, get(a:l, id))
+ let id += 1
+ endw
+ retu newlist
+endf
+" Buffers {{{2
+fu! s:buftab(bufnr, md)
+ for tabnr in range(1, tabpagenr('$'))
+ if tabpagenr() == tabnr && a:md == 't' | con | en
+ let buflist = tabpagebuflist(tabnr)
+ if index(buflist, a:bufnr) >= 0
+ for winnr in range(1, tabpagewinnr(tabnr, '$'))
+ if buflist[winnr - 1] == a:bufnr | retu [tabnr, winnr] | en
+ endfo
+ en
+ endfo
+ 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! s:isabs(path)
+ if (has('win32') || has('win64'))
+ return a:path =~ '^\([a-zA-Z]:\)\{-}[/\\]'
+ el
+ return a:path =~ '^[/\\]'
+ en
+endf
+
+fu! s:bufnrfilpath(line)
+ if s:isabs(a:line) || a:line =~ '^\~[/\\]' || a:line =~ '^\w\+:\/\/'
+ let filpath = a:line
+ el
+ let filpath = s:dyncwd.s:lash().a:line
+ en
+ let filpath = fnamemodify(filpath, ':p')
+ let bufnr = bufnr('^'.filpath.'$')
+ if (!filereadable(filpath) && bufnr < 1)
+ if (a:line =~ '[\/]\?\[\d\+\*No Name\]$')
+ let bufnr = str2nr(matchstr(a:line, '[\/]\?\[\zs\d\+\ze\*No Name\]$'))
+ let filpath = bufnr
+ els
+ let bufnr = bufnr(a:line)
+ retu [bufnr, a:line]
+ en
+ en
+ retu [bufnr, filpath]
+endf
+
+fu! ctrlp#normcmd(cmd, ...)
+ let buftypes = [ 'quickfix', 'help', 'nofile' ]
+ if a:0 < 2 && s:nosplit() | retu a:cmd | en
+ let norwins = filter(range(1, winnr('$')),
+ \ 'index(buftypes, getbufvar(winbufnr(v:val), "&bt")) == -1 || s:isterminal(winbufnr(v:val))')
+ for each in norwins
+ let bufnr = winbufnr(each)
+ if empty(bufname(bufnr)) && empty(getbufvar(bufnr, '&ft'))
+ let fstemp = each | brea
+ en
+ endfo
+ let norwin = empty(norwins) ? 0 : norwins[0]
+ if norwin
+ if index(norwins, winnr()) < 0
+ exe ( exists('fstemp') ? fstemp : norwin ).'winc w'
+ en
+ retu a:cmd
+ en
+ 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
+
+fu! s:setupblank()
+ setl noswf nonu nobl nowrap nolist nospell nocuc wfh
+ setl fdc=0 fdl=99 tw=0 bt=nofile bh=unload
+ if v:version > 702
+ setl nornu noudf cc=0
+ en
+ if s:has_conceal
+ setl cole=2 cocu=nc
+ en
+endf
+
+fu! s:leavepre()
+ if exists('s:bufnr') && s:bufnr == bufnr('%') | bw! | en
+ if !( exists(s:ccex) && !{s:ccex} )
+ \ && !( has('clientserver') && len(split(serverlist(), "\n")) > 1 )
+ cal ctrlp#clra()
+ en
+endf
+
+fu! s:checkbuf()
+ if !exists('s:init') && exists('s:bufnr') && s:bufnr > 0
+ exe s:bufnr.'bw!'
+ en
+endf
+
+fu! s:iscmdwin()
+ let [ermsg, v:errmsg] = [v:errmsg, '']
+ sil! noa winc p
+ sil! noa winc p
+ let [v:errmsg, ermsg] = [ermsg, v:errmsg]
+ retu ermsg =~ '^E11:'
+endf
+" Arguments {{{2
+fu! s:at(str)
+ if a:str =~ '\v^\@(cd|lc[hd]?|chd).*'
+ let str = substitute(a:str, '\v^\@(cd|lc[hd]?|chd)\s*', '', '')
+ if str == '' | retu 1 | en
+ let str = str =~ '^%:.\+' ? fnamemodify(s:crfile, str[1:]) : str
+ let path = fnamemodify(expand(str, 1), ':p')
+ if isdirectory(path)
+ if path != s:dyncwd
+ cal ctrlp#setdir(path)
+ cal ctrlp#setlines()
+ en
+ cal ctrlp#recordhist()
+ cal s:PrtClear()
+ en
+ retu 1
+ en
+ retu 0
+endf
+
+fu! s:tail()
+ if exists('s:optail') && !empty('s:optail')
+ let tailpref = s:optail !~ '^\s*+' ? ' +' : ' '
+ retu tailpref.s:optail
+ en
+ retu ''
+endf
+
+fu! s:sanstail(str)
+ let str = s:spi ?
+ \ substitute(a:str, '^\(@.*$\|\\\\\ze@\|\.\.\zs[.\/]\+$\)', '', 'g') : a:str
+ let [str, pat] = [substitute(str, '\\\\', '\', 'g'), '\([^:]\|\\:\)*$']
+ unl! s:optail
+ if str =~ '\\\@= 0
+ retu char
+ elsei char =~# "\\v\|\|\|\|\|\"
+ cal s:BuildPrompt(0)
+ retu 'cancel'
+ elsei char =~# "\" && a:args != []
+ retu a:args[0]
+ en
+ retu call(a:func, a:args)
+endf
+
+fu! s:getregs()
+ let char = s:textdialog('Insert from register: ')
+ if char =~# "\\v\|\|\|\|\|\"
+ cal s:BuildPrompt(0)
+ retu -1
+ elsei char =~# "\"
+ retu s:getregs()
+ en
+ retu s:regisfilter(char)
+endf
+
+fu! s:regisfilter(reg)
+ retu substitute(getreg(a:reg), "[\t\n]", ' ', 'g')
+endf
+" Misc {{{2
+fu! s:modevar()
+ let s:matchtype = s:mtype()
+ let s:ispath = s:ispathitem()
+ let s:mfunc = s:mfunc()
+ let s:nolim = s:getextvar('nolim')
+ let s:dosort = s:getextvar('sort')
+ let s:spi = !s:itemtype || s:getextvar('specinput') > 0
+endf
+
+fu! s:nosort()
+ let ct = s:curtype()
+ retu s:matcher != {} || s:nolim == 1 || ( ct == 'mru' && s:mrudef )
+ \ || ( ct =~ '^\(buf\|mru\)$' && s:prompt == ['', '', ''] ) || !s:dosort
+endf
+
+fu! s:byfname()
+ retu s:curtype() != 'buf' && s:ispath && s:byfname
+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 == {} && !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:strwidth(str)
+ retu exists('*strdisplaywidth') ? strdisplaywidth(a:str) : strlen(a:str)
+endf
+
+fu! ctrlp#j2l(nr)
+ exe 'norm!' a:nr.'G'
+ sil! norm! zvzz
+endf
+
+fu! s:maxf(len)
+ retu s:maxfiles && a:len > s:maxfiles
+endf
+
+fu! s:regexfilter(str)
+ let str = a:str
+ for key in keys(s:fpats) | if str =~ key
+ let str = substitute(str, s:fpats[key], '', 'g')
+ en | endfo
+ retu 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
+endf
+
+fu! s:delent(rfunc)
+ if a:rfunc == '' | retu | en
+ let [s:force, tbrem] = [1, []]
+ if exists('s:marked')
+ let tbrem = values(s:marked)
+ cal s:unmarksigns()
+ unl s:marked
+ en
+ if tbrem == [] && ( has('dialog_gui') || has('dialog_con') ) &&
+ \ confirm("Wipe all entries?", "&OK\n&Cancel") != 1
+ unl s:force
+ cal s:BuildPrompt(0)
+ retu
+ en
+ let g:ctrlp_lines = call(a:rfunc, [tbrem])
+ cal s:BuildPrompt(1)
+ unl s:force
+endf
+
+fu! s:delbufcond(bufnr)
+ retu getbufvar(a:bufnr, "&mod") || a:bufnr == s:crbufnr
+endf
+
+fu! s:delbuf()
+ let lines = []
+ if exists('s:marked')
+ let lines = values(s:marked)
+ cal s:unmarksigns()
+ unl s:marked
+ el
+ let lines += [ctrlp#getcline()]
+ en
+ for line in lines
+ let bufnr = s:bufnrfilpath(line)[0]
+ if (s:delbufcond(bufnr))
+ con
+ en
+ exe 'bd '. bufnr
+ endfo
+ cal s:PrtClearCache()
+endf
+
+fu! s:isterminal(buf)
+ retu getbufvar(a:buf, "&bt") == "terminal"
+endf
+" Entering & Exiting {{{2
+fu! s:getenv()
+ let [s:cwd, s:winres] = [getcwd(), [winrestcmd(), &lines, winnr('$')]]
+ let [s:crword, s:crnbword] = [expand('', 1), expand('', 1)]
+ let [s:crgfile, s:crline] = [expand('', 1), getline('.')]
+ let [s:winmaxh, s:crcursor] = [min([s:mw_max, &lines]), getpos('.')]
+ let [s:crbufnr, s:crvisual] = [bufnr('%'), s:lastvisual()]
+ let s:crfile = bufname('%') == ''
+ \ ? '['.s:crbufnr.'*No Name]' : expand('%:p', 1)
+ let s:crfpath = expand('%:p:h', 1)
+ let s:mrbs = ctrlp#mrufiles#bufs()
+endf
+
+fu! s:lastvisual()
+ let cview = winsaveview()
+ let [ovreg, ovtype] = [getreg('v'), getregtype('v')]
+ let [oureg, outype] = [getreg('"'), getregtype('"')]
+ sil! norm! gV"vy
+ let selected = s:regisfilter('v')
+ cal setreg('v', ovreg, ovtype)
+ cal setreg('"', oureg, outype)
+ cal winrestview(cview)
+ retu selected
+endf
+
+fu! s:log(m)
+ if exists('g:ctrlp_log') && g:ctrlp_log | if a:m
+ let cadir = ctrlp#utils#cachedir()
+ let apd = g:ctrlp_log > 1 ? '>' : ''
+ sil! exe 'redi! >'.apd cadir.s:lash(cadir).'ctrlp.log'
+ el
+ sil! redi END
+ en | en
+endf
+
+fu! s:buffunc(e)
+ if a:e && has_key(s:buffunc, 'enter')
+ cal call(s:buffunc['enter'], [], s:buffunc)
+ elsei !a:e && has_key(s:buffunc, 'exit')
+ cal call(s:buffunc['exit'], [], s:buffunc)
+ en
+endf
+
+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
+ 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'
+ cal ctrlp#setlcdir()
+ 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
+" Matching {{{2
+fu! s:matchfname(item, pat)
+ let parts = split(a:item, '[\/]\ze[^\/]\+$')
+ let mfn = match(parts[-1], a:pat[0])
+ retu len(a:pat) == 1 ? mfn : len(a:pat) == 2 ?
+ \ ( mfn >= 0 && ( len(parts) == 2 ? match(parts[0], a:pat[1]) : -1 ) >= 0
+ \ ? 0 : -1 ) : -1
+endf
+
+fu! s:matchbuf(item, pat)
+ let bufnr = s:bufnrfilpath(a:item)[0]
+ let parts = s:bufparts(bufnr)
+ let item = s:byfname ? parts[2] : bufnr.parts[0].parts[2].s:lash().parts[3]
+ retu match(item, a:pat)
+endf
+
+fu! s:matchtabs(item, pat)
+ retu match(split(a:item, '\t\+')[0], a:pat)
+endf
+
+fu! s:matchtabe(item, pat)
+ retu match(split(a:item, '\t\+[^\t]\+$')[0], a:pat)
+endf
+
+fu! s:buildpat(lst)
+ let pat = a:lst[0]
+ if s:matchnatural == 1
+ for item in range(1, len(a:lst) - 1)
+ let c = a:lst[item - 1]
+ let pat .= (c == '/' ? '[^/]\{-}' : '[^'.c.'/]\{-}').a:lst[item]
+ endfo
+ els
+ for item in range(1, len(a:lst) - 1)
+ let pat .= '[^'.a:lst[item - 1].']\{-}'.a:lst[item]
+ endfo
+ en
+ retu pat
+endf
+
+fu! s:curtype()
+ return s:CurTypeName()[1]
+endf
+
+fu! s:mfunc()
+ let mfunc = 'match'
+ if s:byfname()
+ let mfunc = 's:matchfname'
+ elsei s:curtype() == 'buf'
+ let mfunc = 's:matchbuf'
+ elsei s:itemtype >= len(s:coretypes)
+ let matchtypes = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' }
+ if has_key(matchtypes, s:matchtype)
+ let mfunc = matchtypes[s:matchtype]
+ en
+ en
+ retu mfunc
+endf
+
+fu! s:mmode()
+ let matchmodes = {
+ \ 'match': 'full-line',
+ \ 's:matchfname': 'filename-only',
+ \ 's:matchbuf': 'full-line',
+ \ 's:matchtabs': 'first-non-tab',
+ \ 's:matchtabe': 'until-last-tab',
+ \ }
+ retu matchmodes[s:mfunc]
+endf
+" Cache {{{2
+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 data == [] || strlen(str) <= strlen(data[0])
+ let pos = 0
+ elsei strlen(str) >= strlen(data[-1])
+ let pos = len(data) - 1
+ el
+ let pos = 0
+ for each in data
+ if strlen(each) > strlen(str) | brea | en
+ let pos += 1
+ endfo
+ en
+ cal insert(data, str, pos)
+ cal s:writecache(ctrlp#utils#cachefile())
+endf
+" Extensions {{{2
+fu! s:mtype()
+ retu s:itemtype >= len(s:coretypes) ? s:getextvar('type') : 'path'
+endf
+
+fu! s:execextvar(key)
+ if !empty(g:ctrlp_ext_vars)
+ cal map(filter(copy(g:ctrlp_ext_vars),
+ \ 'has_key(v:val, a:key)'), 'eval(v:val[a:key])')
+ en
+endf
+
+fu! s:getextvar(key)
+ if s:itemtype >= len(s:coretypes) && len(g:ctrlp_ext_vars) > 0
+ let vars = g:ctrlp_ext_vars[s:itemtype - len(s:coretypes)]
+ if has_key(vars, a:key)
+ retu vars[a:key]
+ en
+ en
+ retu get(g:, 'ctrlp_' . s:matchtype . '_' . a:key, -1)
+endf
+
+fu! ctrlp#getcline()
+ let [linenr, offset] = [line('.'), ( s:offset > 0 ? s:offset : 0 )]
+ retu !empty(s:lines) && !( offset && linenr <= offset )
+ \ ? s:lines[linenr - 1 - offset] : ''
+endf
+
+fu! ctrlp#getmarkedlist()
+ retu exists('s:marked') ? values(s:marked) : []
+endf
+
+fu! ctrlp#clearmarkedlist()
+ let s:marked = {}
+endf
+
+fu! ctrlp#exit()
+ cal s:PrtExit()
+endf
+
+fu! ctrlp#prtclear()
+ cal s:PrtClear()
+endf
+
+fu! ctrlp#switchtype(id)
+ cal s:ToggleType(a:id - s:itemtype)
+endf
+
+fu! ctrlp#nosy()
+ retu !( has('syntax') && exists('g:syntax_on') )
+endf
+
+fu! ctrlp#hicheck(grp, defgrp)
+ if !hlexists(a:grp)
+ exe 'hi link' a:grp a:defgrp
+ en
+endf
+
+fu! ctrlp#call(func, ...)
+ retu call(a:func, a:000)
+endf
+
+fu! ctrlp#getvar(var)
+ retu {a:var}
+endf
+"}}}1
+" * Initialization {{{1
+fu! ctrlp#setlines(...)
+ if a:0 | let s:itemtype = a:1 | en
+ cal s:modevar()
+ let inits = {'fil': 'ctrlp#files()', 'buf': 'ctrlp#buffers()', 'mru': 'ctrlp#mrufiles#list()'}
+ let types = map(copy(g:ctrlp_types), 'inits[v:val]')
+ if !empty(g:ctrlp_ext_vars)
+ cal map(copy(g:ctrlp_ext_vars), 'add(types, v:val["init"])')
+ en
+ let g:ctrlp_lines = eval(types[s:itemtype])
+endf
+
+" Returns [lname, sname]
+fu! s:CurTypeName()
+ if s:itemtype < len(s:coretypes)
+ return filter(copy(s:coretypes), 'v:val[1]==g:ctrlp_types[s:itemtype]')[0]
+ el
+ return [s:getextvar("lname"), s:getextvar('sname')]
+ en
+endfu
+
+fu! s:ExitIfSingleCandidate()
+ if len(s:Update(s:prompt[0])) == 1
+ call s:AcceptSelection('e')
+ call ctrlp#exit()
+ return 1
+ en
+ return 0
+endfu
+
+fu! s:IsBuiltin()
+ let builtins = ['tag', 'dir', 'bft', 'rts', 'bkd', 'lns', 'chs', 'mix', 'udo', 'qfx']
+ let curtype = s:getextvar('sname')
+ return s:itemtype < len(s:coretypes) || index(builtins, curtype) > -1
+endfu
+
+fu! s:DetectFileType(type, ft)
+ if s:IsBuiltin() || empty(a:ft) || a:ft ==# 'ctrlp'
+ retu 'ctrlp'
+ el
+ retu 'ctrlp.' . a:ft
+ en
+endfu
+
+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 s:Reset(a:0 ? a:1 : {})
+ noa cal s:Open()
+ cal s:SetWD(a:0 ? a:1 : {})
+ cal s:MapNorms()
+ cal s:MapSpecs()
+ if empty(g:ctrlp_types) && empty(g:ctrlp_ext_vars)
+ call ctrlp#exit()
+ retu
+ en
+ if type(a:type) == 0
+ let type = a:type
+ el
+ let type = index(g:ctrlp_types, a:type)
+ if type == -1
+ call ctrlp#exit()
+ retu
+ en
+ en
+ cal ctrlp#setlines(s:settype(type))
+ let &filetype = s:DetectFileType(type, &filetype)
+ cal ctrlp#syntax()
+ cal s:SetDefTxt()
+ let curName = s:CurTypeName()
+ let shouldExitSingle = index(s:opensingle, curName[0])>=0 || index(s:opensingle, curName[1])>=0
+ if shouldExitSingle && s:ExitIfSingleCandidate()
+ return 0
+ en
+ cal s:BuildPrompt(1)
+ if s:keyloop | cal s:KeyLoop() | en
+ return 1
+endf
+" - Autocmds {{{1
+if has('autocmd')
+ aug CtrlPAug
+ au!
+ au BufEnter ControlP cal s:checkbuf()
+ au BufLeave ControlP noa cal s:Close()
+ au VimLeavePre * cal s:leavepre()
+ aug END
+en
+
+fu! s:autocmds()
+ if !has('autocmd') | retu | en
+ if exists('#CtrlPLazy')
+ au! CtrlPLazy
+ en
+ if s:lazy
+ aug CtrlPLazy
+ au!
+ au CursorHold ControlP cal s:ForceUpdate()
+ aug END
+ en
+endf
+"}}}
+
+" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
diff --git a/vim/bundle/ctrlp.vim/autoload/ctrlp/autoignore.vim b/vim/bundle/ctrlp.vim/autoload/ctrlp/autoignore.vim
new file mode 100644
index 0000000..ec2329e
--- /dev/null
+++ b/vim/bundle/ctrlp.vim/autoload/ctrlp/autoignore.vim
@@ -0,0 +1,173 @@
+" =============================================================================
+" File: autoload/ctrlp/autoignore.vim
+" Description: Auto-ignore Extension
+" Author: Ludovic Chabant
+" =============================================================================
+
+
+" Global Settings {{{
+
+if exists('g:ctrlp_autoignore_loaded') && g:ctrlp_autoignore_loaded
+ \ && !g:ctrlp_autoignore_debug
+ finish
+endif
+let g:ctrlp_autoignore_loaded = 1
+
+if !exists('g:ctrlp_autoignore_debug')
+ let g:ctrlp_autoignore_debug = 0
+endif
+
+if !exists('g:ctrlp_autoignore_trace')
+ let g:ctrlp_autoignore_trace = 0
+endif
+
+" }}}
+
+" Initialization {{{
+
+if !exists('g:ctrlp_custom_ignore')
+ let g:ctrlp_custom_ignore = {}
+endif
+let g:ctrlp_custom_ignore['func'] = 'ctrlp#autoignore#ignore'
+let g:ctrlp_custom_ignore['func-init'] = 'ctrlp#autoignore#ignore_init'
+let g:ctrlp_custom_ignore['func-close'] = 'ctrlp#autoignore#ignore_close'
+
+if !exists('g:ctrlp_root_markers')
+ let g:ctrlp_root_markers = []
+endif
+call add(g:ctrlp_root_markers, '.ctrlpignore')
+
+" }}}
+
+" Internals {{{
+
+function! s:trace(message) abort
+ if g:ctrlp_autoignore_trace
+ echom "ctrlp_autoignore: " . a:message
+ endif
+endfunction
+
+let s:proj_cache = {}
+let s:active_cwd = ''
+let s:active_cwd_len = 0
+let s:active_patterns = []
+let s:changed_wildignore = 0
+let s:prev_wildignore = ''
+
+function! s:load_project_patterns(root_dir) abort
+ let l:ign_path = a:root_dir . '/.ctrlpignore'
+ if !filereadable(l:ign_path)
+ call s:trace("No pattern file at: " . l:ign_path)
+ return []
+ endif
+ let l:cursyntax = 'regexp'
+ let l:knownsyntaxes = ['regexp', 'wildignore']
+ let l:patterns = []
+ let l:lines = readfile(l:ign_path)
+ for line in l:lines
+ " Comment line?
+ if match(line, '\v^\s*$') >= 0 || match(line, '\v^\s*#') >= 0
+ continue
+ endif
+ " Syntax change?
+ let l:matches = matchlist(line, '\v^syntax:\s?(\w+)\s*$')
+ if len(l:matches) > 0
+ let l:cursyntax = l:matches[1]
+ if index(l:knownsyntaxes, l:cursyntax) < 0
+ echoerr "ctrlp_autoignore: Unknown syntax '".l:cursyntax."' in: ".l:ign_path
+ endif
+ continue
+ endif
+ " Patterns!
+ let l:matches = matchlist(line, '\v^((dir|file|link)\:)?(.*)')
+ let l:mtype = l:matches[2]
+ let l:mpat = l:matches[3]
+ call add(l:patterns, {'syn': l:cursyntax, 'type': l:mtype, 'pat': l:mpat})
+ endfor
+ call s:trace("Loaded " . len(l:patterns) . " patterns from: " . l:ign_path)
+ return l:patterns
+endfunction
+
+function! s:get_project_patterns(root_dir) abort
+ let l:ign_path = a:root_dir . '/.ctrlpignore'
+ let l:ign_mtime = getftime(l:ign_path)
+ let l:patterns = get(s:proj_cache, a:root_dir)
+ if type(l:patterns) == type({})
+ " Check that these patterns are still valid.
+ if l:ign_mtime < 0
+ " File got deleted! :(
+ let l:patterns['pats'] = []
+ return l:patterns['pats']
+ elseif l:ign_mtime <= l:patterns['mtime']
+ " File hasn't changed! :)
+ return l:patterns['pats']
+ endif
+ endif
+
+ call s:trace("Loading patterns for project: " . a:root_dir)
+ let l:loaded = s:load_project_patterns(a:root_dir)
+ let s:proj_cache[a:root_dir] = {
+ \'mtime': localtime(),
+ \'pats': l:loaded}
+ return l:loaded
+endfunction
+
+" The custom ignore function that CtrlP will be using in addition to
+" normal pattern-based matching.
+function! ctrlp#autoignore#ignore(item, type) abort
+ let l:cnv_item = tr(strpart(a:item, s:active_cwd_len), "\\", "/")
+ for pat in s:active_patterns
+ if pat['syn'] != 'regexp'
+ continue
+ endif
+ if pat['type'] == '' || pat['type'] == a:type
+ if match(l:cnv_item, pat['pat']) >= 0
+ call s:trace("Ignoring ".l:cnv_item." because of ".pat['pat'])
+ return 1
+ endif
+ endif
+ endfor
+ return 0
+endfunction
+
+function! ctrlp#autoignore#ignore_init() abort
+ let l:root = getcwd()
+ let s:active_cwd = l:root
+ " len+1 is for including the next separator after the root.
+ let s:active_cwd_len = len(l:root) + 1
+ let s:active_patterns = s:get_project_patterns(l:root)
+ call s:trace("Got ".len(s:active_patterns)." patterns for ".l:root)
+
+ let s:changed_wildignore = 0
+ let s:prev_wildignore = &wildignore
+ for pat in s:active_patterns
+ if pat['syn'] == 'wildignore'
+ execute 'set wildignore+='.pat['pat']
+ let s:changed_wildignore = 1
+ endif
+ endfor
+ if s:changed_wildignore
+ call s:trace("Set wildignore to ".&wildignore)
+ endif
+endfunction
+
+function! ctrlp#autoignore#ignore_close() abort
+ if s:changed_wildignore
+ execute 'set wildignore='.s:prev_wildignore
+ let s:prev_wildignore = ''
+ call s:trace("Set wildignore back to ".&wildignore)
+ endif
+endfunction
+
+" List patterns for a given project's root.
+function! ctrlp#autoignore#get_patterns(root_dir) abort
+ let l:patterns = s:get_project_patterns(a:root_dir)
+ for pat in l:patterns
+ let l:prefix = pat['type'] == '' ? '(all)' : pat['type']
+ echom l:prefix . ':' . pat['pat']
+ endfor
+endfunction
+
+" }}}
+
+" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
diff --git a/vim/bundle/ctrlp.vim/autoload/ctrlp/bookmarkdir.vim b/vim/bundle/ctrlp.vim/autoload/ctrlp/bookmarkdir.vim
new file mode 100644
index 0000000..f7fc14d
--- /dev/null
+++ b/vim/bundle/ctrlp.vim/autoload/ctrlp/bookmarkdir.vim
@@ -0,0 +1,147 @@
+" =============================================================================
+" File: autoload/ctrlp/bookmarkdir.vim
+" Description: Bookmarked directories extension
+" Author: Kien Nguyen
+" =============================================================================
+
+" Init {{{1
+if exists('g:loaded_ctrlp_bookmarkdir') && g:loaded_ctrlp_bookmarkdir
+ fini
+en
+let g:loaded_ctrlp_bookmarkdir = 1
+
+cal add(g:ctrlp_ext_vars, {
+ \ 'init': 'ctrlp#bookmarkdir#init()',
+ \ 'accept': 'ctrlp#bookmarkdir#accept',
+ \ 'lname': 'bookmarked dirs',
+ \ 'sname': 'bkd',
+ \ 'type': 'tabs',
+ \ 'opmul': 1,
+ \ 'nolim': 1,
+ \ 'wipe': 'ctrlp#bookmarkdir#remove',
+ \ })
+
+let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
+" Utilities {{{1
+fu! s:getinput(str, ...)
+ echoh Identifier
+ cal inputsave()
+ let input = call('input', a:0 ? [a:str] + a:000 : [a:str])
+ cal inputrestore()
+ echoh None
+ retu input
+endf
+
+fu! s:cachefile()
+ if !exists('s:cadir') || !exists('s:cafile')
+ let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'bkd'
+ let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt'
+ en
+ retu s:cafile
+endf
+
+fu! s:writecache(lines)
+ cal ctrlp#utils#writecache(a:lines, s:cadir, s:cafile)
+endf
+
+fu! s:getbookmarks()
+ retu ctrlp#utils#readfile(s:cachefile())
+endf
+
+fu! s:savebookmark(name, cwd)
+ let cwds = exists('+ssl') ? [tr(a:cwd, '\', '/'), tr(a:cwd, '/', '\')] : [a:cwd]
+ let entries = filter(s:getbookmarks(), 'index(cwds, s:parts(v:val)[1]) < 0')
+ cal s:writecache(insert(entries, a:name.' '.a:cwd))
+endf
+
+fu! s:setentries()
+ let time = getftime(s:cachefile())
+ if !( exists('s:bookmarks') && time == s:bookmarks[0] )
+ let s:bookmarks = [time, s:getbookmarks()]
+ en
+endf
+
+fu! s:parts(str)
+ let mlist = matchlist(a:str, '\v([^\t]+)\t(.*)$')
+ retu mlist != [] ? mlist[1:2] : ['', '']
+endf
+
+fu! s:process(entries, type)
+ retu map(a:entries, 's:modify(v:val, a:type)')
+endf
+
+fu! s:modify(entry, type)
+ let [name, dir] = s:parts(a:entry)
+ let dir = fnamemodify(dir, a:type)
+ retu name.' '.( dir == '' ? '.' : dir )
+endf
+
+fu! s:msg(name, cwd)
+ redr
+ echoh Identifier | echon 'Bookmarked ' | echoh Constant
+ echon a:name.' ' | echoh Directory | echon a:cwd
+ echoh None
+endf
+
+fu! s:syntax()
+ if !ctrlp#nosy()
+ cal ctrlp#hicheck('CtrlPBookmark', 'Identifier')
+ cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
+ sy match CtrlPBookmark '^> [^\t]\+' contains=CtrlPLinePre
+ sy match CtrlPTabExtra '\zs\t.*\ze$'
+ en
+endf
+" Public {{{1
+fu! ctrlp#bookmarkdir#init()
+ cal s:setentries()
+ cal s:syntax()
+ retu s:process(copy(s:bookmarks[1]), ':.')
+endf
+
+fu! ctrlp#bookmarkdir#accept(mode, str)
+ let parts = s:parts(s:modify(a:str, ':p'))
+ cal call('s:savebookmark', parts)
+ if a:mode =~ 't\|v\|h'
+ cal ctrlp#exit()
+ en
+ cal ctrlp#setdir(parts[1], a:mode =~ 't\|h' ? 'chd!' : 'lc!')
+ if a:mode == 'e'
+ cal ctrlp#switchtype(0)
+ cal ctrlp#recordhist()
+ cal ctrlp#prtclear()
+ en
+endf
+
+fu! ctrlp#bookmarkdir#add(bang, dir, ...)
+ let ctrlp_tilde_homedir = get(g:, 'ctrlp_tilde_homedir', 0)
+ let cwd = fnamemodify(getcwd(), ctrlp_tilde_homedir ? ':p:~' : ':p')
+ let dir = fnamemodify(a:dir, ctrlp_tilde_homedir ? ':p:~' : ':p')
+ if a:bang == '!'
+ let cwd = dir != '' ? dir : cwd
+ let name = a:0 && a:1 != '' ? a:1 : cwd
+ el
+ let str = 'Directory to bookmark: '
+ let cwd = dir != '' ? dir : s:getinput(str, cwd, 'dir')
+ if cwd == '' | retu | en
+ let name = a:0 && a:1 != '' ? a:1 : s:getinput('Bookmark as: ', cwd)
+ if name == '' | retu | en
+ en
+ let name = tr(name, ' ', ' ')
+ cal s:savebookmark(name, cwd)
+ cal s:msg(name, cwd)
+endf
+
+fu! ctrlp#bookmarkdir#remove(entries)
+ cal s:process(a:entries, ':p')
+ cal s:writecache(a:entries == [] ? [] :
+ \ filter(s:getbookmarks(), 'index(a:entries, v:val) < 0'))
+ cal s:setentries()
+ retu s:process(copy(s:bookmarks[1]), ':.')
+endf
+
+fu! ctrlp#bookmarkdir#id()
+ retu s:id
+endf
+"}}}
+
+" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
diff --git a/vim/bundle/ctrlp.vim/autoload/ctrlp/buffertag.vim b/vim/bundle/ctrlp.vim/autoload/ctrlp/buffertag.vim
new file mode 100644
index 0000000..f36a5cf
--- /dev/null
+++ b/vim/bundle/ctrlp.vim/autoload/ctrlp/buffertag.vim
@@ -0,0 +1,277 @@
+" =============================================================================
+" File: autoload/ctrlp/buffertag.vim
+" Description: Buffer Tag extension
+" Maintainer: Kien Nguyen
+" Credits: Much of the code was taken from tagbar.vim by Jan Larres, plus
+" a few lines from taglist.vim by Yegappan Lakshmanan and from
+" buffertag.vim by Takeshi Nishida.
+" =============================================================================
+
+" Init {{{1
+if exists('g:loaded_ctrlp_buftag') && g:loaded_ctrlp_buftag
+ fini
+en
+let g:loaded_ctrlp_buftag = 1
+
+cal add(g:ctrlp_ext_vars, {
+ \ 'init': 'ctrlp#buffertag#init(s:crfile)',
+ \ 'accept': 'ctrlp#buffertag#accept',
+ \ 'lname': 'buffer tags',
+ \ 'sname': 'bft',
+ \ 'exit': 'ctrlp#buffertag#exit()',
+ \ 'type': 'tabs',
+ \ 'opts': 'ctrlp#buffertag#opts()',
+ \ })
+
+let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
+
+let [s:pref, s:opts] = ['g:ctrlp_buftag_', {
+ \ 'systemenc': ['s:enc', &enc],
+ \ 'ctags_bin': ['s:bin', ''],
+ \ 'types': ['s:usr_types', {}],
+ \ }]
+
+let s:bins = [
+ \ 'ctags-exuberant',
+ \ 'exuberant-ctags',
+ \ 'exctags',
+ \ '/usr/local/bin/ctags',
+ \ '/opt/local/bin/ctags',
+ \ 'ctags',
+ \ 'ctags.exe',
+ \ 'tags',
+ \ ]
+
+let s:types = {
+ \ 'ant' : '%sant%sant%spt',
+ \ 'asm' : '%sasm%sasm%sdlmt',
+ \ 'aspperl': '%sasp%sasp%sfsv',
+ \ 'aspvbs' : '%sasp%sasp%sfsv',
+ \ 'awk' : '%sawk%sawk%sf',
+ \ 'beta' : '%sbeta%sbeta%sfsv',
+ \ 'c' : '%sc%sc%sdgsutvf',
+ \ 'cpp' : '%sc++%sc++%snvdtcgsuf',
+ \ 'cs' : '%sc#%sc#%sdtncEgsipm',
+ \ 'cobol' : '%scobol%scobol%sdfgpPs',
+ \ 'delphi' : '%spascal%spascal%sfp',
+ \ 'dosbatch': '%sdosbatch%sdosbatch%slv',
+ \ 'eiffel' : '%seiffel%seiffel%scf',
+ \ 'erlang' : '%serlang%serlang%sdrmf',
+ \ 'expect' : '%stcl%stcl%scfp',
+ \ 'fortran': '%sfortran%sfortran%spbceiklmntvfs',
+ \ 'go' : '%sgo%sgo%sfctv',
+ \ 'html' : '%shtml%shtml%saf',
+ \ 'java' : '%sjava%sjava%spcifm',
+ \ 'javascript': '%sjavascript%sjavascript%sf',
+ \ 'lisp' : '%slisp%slisp%sf',
+ \ 'lua' : '%slua%slua%sf',
+ \ 'make' : '%smake%smake%sm',
+ \ 'matlab' : '%smatlab%smatlab%sf',
+ \ 'ocaml' : '%socaml%socaml%scmMvtfCre',
+ \ 'pascal' : '%spascal%spascal%sfp',
+ \ 'perl' : '%sperl%sperl%sclps',
+ \ 'php' : '%sphp%sphp%scdvf',
+ \ 'python' : '%spython%spython%scmf',
+ \ 'rexx' : '%srexx%srexx%ss',
+ \ 'ruby' : '%sruby%sruby%scfFm',
+ \ 'rust' : '%srust%srust%sfTgsmctid',
+ \ 'scheme' : '%sscheme%sscheme%ssf',
+ \ 'sh' : '%ssh%ssh%sf',
+ \ 'csh' : '%ssh%ssh%sf',
+ \ 'zsh' : '%ssh%ssh%sf',
+ \ 'scala' : '%sscala%sscala%sctTmlp',
+ \ 'slang' : '%sslang%sslang%snf',
+ \ 'sml' : '%ssml%ssml%secsrtvf',
+ \ 'sql' : '%ssql%ssql%scFPrstTvfp',
+ \ 'tex' : '%stex%stex%sipcsubPGl',
+ \ 'tcl' : '%stcl%stcl%scfmp',
+ \ 'vera' : '%svera%svera%scdefgmpPtTvx',
+ \ 'verilog': '%sverilog%sverilog%smcPertwpvf',
+ \ 'vhdl' : '%svhdl%svhdl%sPctTrefp',
+ \ 'vim' : '%svim%svim%savf',
+ \ 'yacc' : '%syacc%syacc%sl',
+ \ }
+
+cal map(s:types, 'printf(v:val, "--language-force=", " --", "-types=")')
+
+if executable('jsctags')
+ cal extend(s:types, { 'javascript': { 'args': '-f -', 'bin': 'jsctags' } })
+en
+
+fu! ctrlp#buffertag#opts()
+ for [ke, va] in items(s:opts)
+ let {va[0]} = exists(s:pref.ke) ? {s:pref.ke} : va[1]
+ endfo
+ " Ctags bin
+ if empty(s:bin)
+ for bin in s:bins | if executable(bin)
+ let s:bin = bin
+ brea
+ en | endfo
+ el
+ let s:bin = expand(s:bin, 1)
+ en
+ " Types
+ cal extend(s:types, s:usr_types)
+endf
+" Utilities {{{1
+fu! s:validfile(fname, ftype)
+ if ( !empty(a:fname) || !empty(a:ftype) ) && filereadable(a:fname)
+ \ && index(keys(s:types), a:ftype) >= 0 | retu 1 | en
+ retu 0
+endf
+
+fu! s:exectags(cmd)
+ if exists('+ssl')
+ let [ssl, &ssl] = [&ssl, 0]
+ en
+ if &sh =~ 'cmd\.exe'
+ let [sxq, &sxq, shcf, &shcf] = [&sxq, '"', &shcf, '/s /c']
+ en
+ let output = system(a:cmd)
+ if &sh =~ 'cmd\.exe'
+ let [&sxq, &shcf] = [sxq, shcf]
+ en
+ if exists('+ssl')
+ let &ssl = ssl
+ en
+ retu output
+endf
+
+fu! s:exectagsonfile(fname, ftype)
+ let [ags, ft] = ['-f - --sort=no --excmd=pattern --fields=nKs --extra= --file-scope=yes ', a:ftype]
+ if type(s:types[ft]) == 1
+ let ags .= s:types[ft]
+ let bin = s:bin
+ elsei type(s:types[ft]) == 4
+ let ags = s:types[ft]['args']
+ let bin = expand(s:types[ft]['bin'], 1)
+ en
+ if empty(bin) | retu '' | en
+ let cmd = s:esctagscmd(bin, ags, a:fname)
+ if empty(cmd) | retu '' | en
+ let output = s:exectags(cmd)
+ if v:shell_error || output =~ 'Warning: cannot open' | retu '' | en
+ retu output
+endf
+
+fu! s:esctagscmd(bin, args, ...)
+ if exists('+ssl')
+ let [ssl, &ssl] = [&ssl, 0]
+ en
+ let fname = a:0 ? shellescape(a:1) : ''
+ if (has('win32') || has('win64'))
+ let cmd = a:bin.' '.a:args.' '.fname
+ else
+ let cmd = shellescape(a:bin).' '.a:args.' '.fname
+ endif
+ if &sh =~ 'cmd\.exe'
+ let cmd = substitute(cmd, '[&()@^<>|]', '^\0', 'g')
+ en
+ if exists('+ssl')
+ let &ssl = ssl
+ en
+ if has('iconv')
+ let last = s:enc != &enc ? s:enc : !empty( $LANG ) ? $LANG : &enc
+ let cmd = iconv(cmd, &enc, last)
+ en
+ retu cmd
+endf
+
+fu! s:process(fname, ftype)
+ if !s:validfile(a:fname, a:ftype) | retu [] | endif
+ let ftime = getftime(a:fname)
+ if has_key(g:ctrlp_buftags, a:fname)
+ \ && g:ctrlp_buftags[a:fname]['time'] >= ftime
+ let lines = g:ctrlp_buftags[a:fname]['lines']
+ el
+ let data = s:exectagsonfile(a:fname, a:ftype)
+ let [raw, lines] = [split(data, '\n\+'), []]
+ 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
+ endfo
+ let cache = { a:fname : { 'time': ftime, 'lines': lines } }
+ cal extend(g:ctrlp_buftags, cache)
+ en
+ retu lines
+endf
+
+fu! s:parseline(line)
+ 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]
+endf
+
+fu! s:syntax()
+ if !ctrlp#nosy()
+ cal ctrlp#hicheck('CtrlPTagKind', 'Title')
+ cal ctrlp#hicheck('CtrlPBufName', 'Directory')
+ cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
+ sy match CtrlPTagKind '\zs[^\t|]\+\ze|\d\+:[^|]\+|\d\+|'
+ sy match CtrlPBufName '|\d\+:\zs[^|]\+\ze|\d\+|'
+ 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
+ \ ? filter(ctrlp#buffers(), 'filereadable(v:val)')
+ \ : [exists('s:bufname') ? s:bufname : a:fname]
+ let lines = []
+ for each in bufs
+ let bname = fnamemodify(each, ':p')
+ let tftype = get(split(getbufvar('^'.bname.'$', '&ft'), '\.'), 0, '')
+ cal extend(lines, s:process(bname, tftype))
+ endfo
+ cal s:syntax()
+ retu lines
+endf
+
+fu! ctrlp#buffertag#accept(mode, str)
+ 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, 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, ...)
+ let s:btmode = a:mode
+ if a:0 && !empty(a:1)
+ let s:btmode = 0
+ let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1
+ let s:bufname = fnamemodify(bname, ':p')
+ en
+ retu s:id
+endf
+
+fu! ctrlp#buffertag#exit()
+ unl! s:btmode s:bufname
+endf
+"}}}
+
+" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
diff --git a/vim/bundle/ctrlp.vim/autoload/ctrlp/changes.vim b/vim/bundle/ctrlp.vim/autoload/ctrlp/changes.vim
new file mode 100644
index 0000000..313d8c2
--- /dev/null
+++ b/vim/bundle/ctrlp.vim/autoload/ctrlp/changes.vim
@@ -0,0 +1,98 @@
+" =============================================================================
+" File: autoload/ctrlp/changes.vim
+" Description: Change list extension
+" Author: Kien Nguyen
+" =============================================================================
+
+" Init {{{1
+if exists('g:loaded_ctrlp_changes') && g:loaded_ctrlp_changes
+ fini
+en
+let g:loaded_ctrlp_changes = 1
+
+cal add(g:ctrlp_ext_vars, {
+ \ 'init': 'ctrlp#changes#init(s:bufnr, s:crbufnr)',
+ \ 'accept': 'ctrlp#changes#accept',
+ \ 'lname': 'changes',
+ \ 'sname': 'chs',
+ \ 'exit': 'ctrlp#changes#exit()',
+ \ 'type': 'tabe',
+ \ 'sort': 0,
+ \ 'nolim': 1,
+ \ })
+
+let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
+" Utilities {{{1
+fu! s:changelist(bufnr)
+ sil! exe 'noa hid b' a:bufnr
+ redi => result
+ sil! changes
+ redi END
+ retu map(split(result, "\n")[1:], 'tr(v:val, " ", " ")')
+endf
+
+fu! s:process(clines, ...)
+ let [clines, evas] = [[], []]
+ for each in a:clines
+ let parts = matchlist(each, '\v^.\s*\d+\s+(\d+)\s+(\d+)\s(.*)$')
+ if !empty(parts)
+ if parts[3] == '' | let parts[3] = ' ' | en
+ cal add(clines, parts[3].' |'.a:1.':'.a:2.'|'.parts[1].':'.parts[2].'|')
+ en
+ endfo
+ retu reverse(filter(clines, 'count(clines, v:val) == 1'))
+endf
+
+fu! s:syntax()
+ if !ctrlp#nosy()
+ cal ctrlp#hicheck('CtrlPBufName', 'Directory')
+ cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
+ sy match CtrlPBufName '\t|\d\+:\zs[^|]\+\ze|\d\+:\d\+|$'
+ sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName
+ en
+endf
+" Public {{{1
+fu! ctrlp#changes#init(original_bufnr, bufnr)
+ let bufnr = exists('s:bufnr') ? s:bufnr : a:bufnr
+ let bufs = exists('s:clmode') && s:clmode ? ctrlp#buffers('id') : [bufnr]
+ cal filter(bufs, 'v:val > 0')
+ let [swb, &swb] = [&swb, '']
+ let lines = []
+ for each in bufs
+ let bname = bufname(each)
+ let fnamet = fnamemodify(bname == '' ? '[No Name]' : bname, ':t')
+ cal extend(lines, s:process(s:changelist(each), each, fnamet))
+ endfo
+ sil! exe 'noa hid b' a:original_bufnr
+ let &swb = swb
+ cal ctrlp#syntax()
+ cal s:syntax()
+ retu lines
+endf
+
+fu! ctrlp#changes#accept(mode, str)
+ let info = matchlist(a:str, '\t|\(\d\+\):[^|]\+|\(\d\+\):\(\d\+\)|$')
+ let bufnr = str2nr(get(info, 1))
+ if bufnr
+ cal ctrlp#acceptfile(a:mode, bufnr)
+ cal cursor(get(info, 2), get(info, 3))
+ sil! norm! zvzz
+ en
+endf
+
+fu! ctrlp#changes#cmd(mode, ...)
+ let s:clmode = a:mode
+ if a:0 && !empty(a:1)
+ let s:clmode = 0
+ let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1
+ let s:bufnr = bufnr('^'.fnamemodify(bname, ':p').'$')
+ en
+ retu s:id
+endf
+
+fu! ctrlp#changes#exit()
+ unl! s:clmode s:bufnr
+endf
+"}}}
+
+" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
diff --git a/vim/bundle/ctrlp.vim/autoload/ctrlp/dir.vim b/vim/bundle/ctrlp.vim/autoload/ctrlp/dir.vim
new file mode 100644
index 0000000..4e6d4ad
--- /dev/null
+++ b/vim/bundle/ctrlp.vim/autoload/ctrlp/dir.vim
@@ -0,0 +1,95 @@
+" =============================================================================
+" File: autoload/ctrlp/dir.vim
+" Description: Directory extension
+" Author: Kien Nguyen
+" =============================================================================
+
+" Init {{{1
+if exists('g:loaded_ctrlp_dir') && g:loaded_ctrlp_dir
+ fini
+en
+let [g:loaded_ctrlp_dir, g:ctrlp_newdir] = [1, 0]
+
+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, ', ').')',
+ \ 'accept': 'ctrlp#dir#accept',
+ \ 'lname': 'dirs',
+ \ 'sname': 'dir',
+ \ 'type': 'path',
+ \ 'specinput': 1,
+ \ })
+
+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")
+ let [dirs, depth] = [ctrlp#dirnfile(entries)[0], a:depth + 1]
+ cal extend(g:ctrlp_alldirs, dirs)
+ 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
+endf
+
+fu! s:nocache()
+ retu !s:caching || ( s:caching > 1 && get(s:dircounts, s:cwd) < s:caching )
+endf
+" Public {{{1
+fu! ctrlp#dir#init(...)
+ let s:cwd = getcwd()
+ for each in range(len(s:ars))
+ let {s:ars[each]} = a:{each + 1}
+ endfo
+ let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'dir'
+ let cafile = cadir.ctrlp#utils#lash().ctrlp#utils#cachefile('dir')
+ if g:ctrlp_newdir || s:nocache() || !filereadable(cafile)
+ let [s:initcwd, g:ctrlp_alldirs] = [s:cwd, []]
+ if !ctrlp#igncwd(s:cwd)
+ cal s:globdirs(ctrlp#utils#fnesc(s:cwd, 'g', ','), 0)
+ en
+ cal ctrlp#rmbasedir(g:ctrlp_alldirs)
+ if len(g:ctrlp_alldirs) <= s:compare_lim
+ cal sort(g:ctrlp_alldirs, 'ctrlp#complen')
+ en
+ cal ctrlp#utils#writecache(g:ctrlp_alldirs, cadir, cafile)
+ let g:ctrlp_newdir = 0
+ el
+ if !( exists('s:initcwd') && s:initcwd == s:cwd )
+ let s:initcwd = s:cwd
+ 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
+
+fu! ctrlp#dir#accept(mode, str)
+ let path = a:mode == 'h' ? getcwd() : s:cwd.ctrlp#call('s:lash', s:cwd).a:str
+ if a:mode =~ 't\|v\|h'
+ cal ctrlp#exit()
+ en
+ cal ctrlp#setdir(path, a:mode =~ 't\|h' ? 'chd!' : 'lc!')
+ if a:mode == 'e'
+ sil! cal ctrlp#statusline()
+ cal ctrlp#setlines(s:id)
+ cal ctrlp#recordhist()
+ cal ctrlp#prtclear()
+ en
+endf
+
+fu! ctrlp#dir#id()
+ retu s:id
+endf
+"}}}
+
+" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
diff --git a/vim/bundle/ctrlp.vim/autoload/ctrlp/line.vim b/vim/bundle/ctrlp.vim/autoload/ctrlp/line.vim
new file mode 100644
index 0000000..f5ab83e
--- /dev/null
+++ b/vim/bundle/ctrlp.vim/autoload/ctrlp/line.vim
@@ -0,0 +1,81 @@
+" =============================================================================
+" File: autoload/ctrlp/line.vim
+" Description: Line extension
+" Author: Kien Nguyen
+" =============================================================================
+
+" Init {{{1
+if exists('g:loaded_ctrlp_line') && g:loaded_ctrlp_line
+ fini
+en
+let g:loaded_ctrlp_line = 1
+
+cal add(g:ctrlp_ext_vars, {
+ \ 'init': 'ctrlp#line#init(s:crbufnr)',
+ \ 'accept': 'ctrlp#line#accept',
+ \ 'act_farg' : 'dict',
+ \ 'lname': 'lines',
+ \ 'sname': 'lns',
+ \ 'type': 'tabe',
+ \ })
+
+let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
+" Utilities {{{1
+fu! s:syntax()
+ if !ctrlp#nosy()
+ cal ctrlp#hicheck('CtrlPBufName', 'Directory')
+ cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
+ sy match CtrlPBufName '\t|\zs[^|]\+\ze|\d\+:\d\+|$'
+ sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName
+ en
+endf
+" Public {{{1
+fu! ctrlp#line#init(bufnr)
+ let [lines, bufnr] = [[], exists('s:bufnr') ? s:bufnr : a:bufnr]
+ let bufs = exists('s:lnmode') && !empty(s:lnmode) ? ctrlp#buffers('id') : [bufnr]
+ for bufnr in bufs
+ let [lfb, bufn] = [getbufline(bufnr, 1, '$'), bufname(bufnr)]
+ if lfb == [] && bufn != ''
+ let lfb = ctrlp#utils#readfile(fnamemodify(bufn, ':p'))
+ en
+ cal map(lfb, 'tr(v:val, '' '', '' '')')
+ let [linenr, len_lfb] = [1, len(lfb)]
+ let buft = bufn == '' ? '[No Name]' : fnamemodify(bufn, ':t')
+ wh linenr <= len_lfb
+ let lfb[linenr - 1] .= ' |'.buft.'|'.bufnr.':'.linenr.'|'
+ let linenr += 1
+ endw
+ cal extend(lines, filter(lfb, 'v:val !~ ''^\s*\t|[^|]\+|\d\+:\d\+|$'''))
+ endfo
+ cal s:syntax()
+ retu lines
+endf
+
+fu! ctrlp#line#accept(dict)
+ let mode = a:dict['action']
+ let str = a:dict['line']
+ let input = a:dict['input']
+ let info = matchlist(str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$')
+ let bufnr = str2nr(get(info, 1))
+ if bufnr
+ cal ctrlp#acceptfile(mode, bufnr, get(info, 2))
+ if !empty(input)
+ let @/ = input
+ call search(input, 'c')
+ call histadd("search", input)
+ en
+ en
+endf
+
+fu! ctrlp#line#cmd(mode, ...)
+ let s:lnmode = a:mode
+ if a:0 && !empty(a:1)
+ let s:lnmode = 0
+ let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1
+ let s:bufnr = bufnr('^'.fnamemodify(bname, ':p').'$')
+ en
+ retu s:id
+endf
+"}}}
+
+" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
diff --git a/vim/bundle/ctrlp.vim/autoload/ctrlp/mixed.vim b/vim/bundle/ctrlp.vim/autoload/ctrlp/mixed.vim
new file mode 100644
index 0000000..74d904d
--- /dev/null
+++ b/vim/bundle/ctrlp.vim/autoload/ctrlp/mixed.vim
@@ -0,0 +1,88 @@
+" =============================================================================
+" File: autoload/ctrlp/mixed.vim
+" Description: Mixing Files + MRU + Buffers
+" Author: Kien Nguyen
+" =============================================================================
+
+" Init {{{1
+if exists('g:loaded_ctrlp_mixed') && g:loaded_ctrlp_mixed
+ fini
+en
+let [g:loaded_ctrlp_mixed, g:ctrlp_newmix] = [1, 0]
+
+cal add(g:ctrlp_ext_vars, {
+ \ 'init': 'ctrlp#mixed#init(s:compare_lim)',
+ \ 'accept': 'ctrlp#acceptfile',
+ \ 'lname': 'fil + mru + buf',
+ \ 'sname': 'mix',
+ \ 'type': 'path',
+ \ 'opmul': 1,
+ \ 'specinput': 1,
+ \ })
+
+let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
+" Utilities {{{1
+fu! s:newcache(cwd)
+ if g:ctrlp_newmix || !has_key(g:ctrlp_allmixes, 'data') | retu 1 | en
+ retu g:ctrlp_allmixes['cwd'] != a:cwd
+ \ || g:ctrlp_allmixes['filtime'] < getftime(ctrlp#utils#cachefile())
+ \ || g:ctrlp_allmixes['mrutime'] < getftime(ctrlp#mrufiles#cachefile())
+ \ || g:ctrlp_allmixes['bufs'] < len(ctrlp#mrufiles#bufs())
+endf
+
+fu! s:getnewmix(cwd, clim)
+ if g:ctrlp_newmix
+ cal ctrlp#mrufiles#refresh('raw')
+ let g:ctrlp_newcache = 1
+ en
+ let g:ctrlp_lines = copy(ctrlp#files())
+ cal ctrlp#progress('Mixing...')
+ let mrufs = copy(ctrlp#mrufiles#list('raw'))
+ if exists('+ssl') && &ssl
+ cal map(mrufs, 'tr(v:val, "\\", "/")')
+ en
+ let allbufs = map(ctrlp#buffers(), 'fnamemodify(v:val, ":p")')
+ let [bufs, ubufs] = [[], []]
+ for each in allbufs
+ cal add(filereadable(each) ? bufs : ubufs, each)
+ endfo
+ let mrufs = bufs + filter(mrufs, 'index(bufs, v:val) < 0')
+ if len(mrufs) > len(g:ctrlp_lines)
+ cal filter(mrufs, 'stridx(v:val, a:cwd)')
+ el
+ let cwd_mrufs = filter(copy(mrufs), '!stridx(v:val, a:cwd)')
+ let cwd_mrufs = ctrlp#rmbasedir(cwd_mrufs)
+ for each in cwd_mrufs
+ let id = index(g:ctrlp_lines, each)
+ if id >= 0 | cal remove(g:ctrlp_lines, id) | en
+ endfo
+ en
+ let mrufs += ubufs
+ cal map(mrufs, 'fnamemodify(v:val, ":.")')
+ let g:ctrlp_lines = len(mrufs) > len(g:ctrlp_lines)
+ \ ? g:ctrlp_lines + mrufs : mrufs + g:ctrlp_lines
+ if len(g:ctrlp_lines) <= a:clim
+ cal sort(g:ctrlp_lines, 'ctrlp#complen')
+ en
+ let g:ctrlp_allmixes = { 'filtime': getftime(ctrlp#utils#cachefile()),
+ \ 'mrutime': getftime(ctrlp#mrufiles#cachefile()), 'cwd': a:cwd,
+ \ 'bufs': len(ctrlp#mrufiles#bufs()), 'data': g:ctrlp_lines }
+endf
+" Public {{{1
+fu! ctrlp#mixed#init(clim)
+ let cwd = getcwd()
+ if s:newcache(cwd)
+ cal s:getnewmix(cwd, a:clim)
+ el
+ let g:ctrlp_lines = g:ctrlp_allmixes['data']
+ en
+ let g:ctrlp_newmix = 0
+ retu g:ctrlp_lines
+endf
+
+fu! ctrlp#mixed#id()
+ retu s:id
+endf
+"}}}
+
+" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
diff --git a/vim/bundle/ctrlp.vim/autoload/ctrlp/mrufiles.vim b/vim/bundle/ctrlp.vim/autoload/ctrlp/mrufiles.vim
new file mode 100644
index 0000000..32473da
--- /dev/null
+++ b/vim/bundle/ctrlp.vim/autoload/ctrlp/mrufiles.vim
@@ -0,0 +1,158 @@
+" =============================================================================
+" File: autoload/ctrlp/mrufiles.vim
+" Description: Most Recently Used Files extension
+" Author: Kien Nguyen
+" =============================================================================
+
+" Static variables {{{1
+let [s:mrbs, s:mrufs] = [[], []]
+let s:mruf_map_string = '!stridx(v:val, cwd) ? strpart(v:val, idx) : v:val'
+
+fu! ctrlp#mrufiles#opts()
+ let [pref, opts] = ['g:ctrlp_mruf_', {
+ \ 'max': ['s:max', 250],
+ \ 'include': ['s:in', ''],
+ \ 'exclude': ['s:ex', ''],
+ \ 'case_sensitive': ['s:cseno', 1],
+ \ 'relative': ['s:re', 0],
+ \ 'save_on_update': ['s:soup', 1],
+ \ 'map_string': ['g:ctrlp_mruf_map_string', s:mruf_map_string],
+ \ }]
+ for [ke, va] in items(opts)
+ let [{va[0]}, {pref.ke}] = [pref.ke, exists(pref.ke) ? {pref.ke} : va[1]]
+ endfo
+endf
+cal ctrlp#mrufiles#opts()
+" Utilities {{{1
+fu! s:excl(fn)
+ retu !empty({s:ex}) && a:fn =~# {s:ex}
+endf
+
+fu! s:mergelists()
+ let diskmrufs = ctrlp#utils#readfile(ctrlp#mrufiles#cachefile())
+ cal filter(diskmrufs, 'index(s:mrufs, v:val) < 0')
+ let mrufs = s:mrufs + diskmrufs
+ retu s:chop(mrufs)
+endf
+
+fu! s:chop(mrufs)
+ if len(a:mrufs) > {s:max} | cal remove(a:mrufs, {s:max}, -1) | en
+ retu a:mrufs
+endf
+
+fu! s:reformat(mrufs, ...)
+ let cwd = getcwd()
+ let cwd .= cwd !~ '[\/]$' ? ctrlp#utils#lash() : ''
+ if {s:re}
+ let cwd = exists('+ssl') ? tr(cwd, '/', '\') : cwd
+ cal filter(a:mrufs, '!stridx(v:val, cwd)')
+ en
+ if a:0 && a:1 == 'raw' | retu a:mrufs | en
+ let idx = strlen(cwd)
+ if exists('+ssl') && &ssl
+ let cwd = tr(cwd, '\', '/')
+ cal map(a:mrufs, 'tr(v:val, "\\", "/")')
+ en
+ retu map(a:mrufs, g:ctrlp_mruf_map_string)
+endf
+
+fu! s:record(bufnr)
+ if s:locked | retu | en
+ let bufnr = a:bufnr + 0
+ let bufname = bufname(bufnr)
+ 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, get(g:, 'ctrlp_tilde_homedir', 0) ? ':p:~' : ':p')
+ let fn = exists('+ssl') ? tr(fn, '/', '\') : fn
+ let abs_fn = fnamemodify(fn,':p')
+ if ( !empty({s:in}) && fn !~# {s:in} ) || ( !empty({s:ex}) && fn =~# {s:ex} )
+ \ || !empty(getbufvar('^' . abs_fn . '$', '&bt')) || !filereadable(abs_fn)
+ retu
+ en
+ let idx = index(s:mrufs, fn, 0, !{s:cseno})
+ if idx
+ cal filter(s:mrufs, 'v:val !='.( {s:cseno} ? '#' : '?' ).' fn')
+ cal insert(s:mrufs, fn)
+ if {s:soup} && idx < 0
+ cal s:savetofile(s:mergelists())
+ en
+ en
+endf
+
+fu! s:savetofile(mrufs)
+ cal ctrlp#utils#writecache(a:mrufs, s:cadir, s:cafile)
+endf
+" Public {{{1
+fu! ctrlp#mrufiles#refresh(...)
+ let mrufs = s:mergelists()
+ cal filter(mrufs, '!empty(ctrlp#utils#glob(v:val, 1)) && !s:excl(v:val)')
+ if exists('+ssl')
+ cal map(mrufs, 'tr(v:val, "/", "\\")')
+ cal map(s:mrufs, 'tr(v:val, "/", "\\")')
+ let cond = 'count(mrufs, v:val, !{s:cseno}) == 1'
+ cal filter(mrufs, cond)
+ cal filter(s:mrufs, cond)
+ en
+ cal s:savetofile(mrufs)
+ retu a:0 && a:1 == 'raw' ? [] : s:reformat(mrufs)
+endf
+
+fu! ctrlp#mrufiles#remove(files)
+ let mrufs = []
+ if a:files != []
+ let mrufs = s:mergelists()
+ let cond = 'index(a:files, v:val, 0, !{s:cseno}) < 0'
+ cal filter(mrufs, cond)
+ cal filter(s:mrufs, cond)
+ en
+ cal s:savetofile(mrufs)
+ retu s:reformat(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:reformat(s:mergelists(), a:1) : 0
+ \ : s:reformat(s:mergelists())
+endf
+
+fu! ctrlp#mrufiles#bufs()
+ retu s:mrbs
+endf
+
+fu! ctrlp#mrufiles#tgrel()
+ let {s:re} = !{s:re}
+endf
+
+fu! ctrlp#mrufiles#cachefile()
+ if !exists('s:cadir') || !exists('s:cafile')
+ let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru'
+ let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt'
+ en
+ retu s:cafile
+endf
+
+fu! ctrlp#mrufiles#init()
+ if !has('autocmd') | retu | en
+ let s:locked = 0
+ aug CtrlPMRUF
+ au!
+ au BufWinEnter,BufWinLeave,BufWritePost * cal s:record(expand('', 1))
+ au QuickFixCmdPre *vimgrep* let s:locked = 1
+ au QuickFixCmdPost *vimgrep* let s:locked = 0
+ au VimLeavePre * cal s:savetofile(s:mergelists())
+ aug END
+endf
+"}}}
+
+" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
diff --git a/vim/bundle/ctrlp.vim/autoload/ctrlp/quickfix.vim b/vim/bundle/ctrlp.vim/autoload/ctrlp/quickfix.vim
new file mode 100644
index 0000000..03ab921
--- /dev/null
+++ b/vim/bundle/ctrlp.vim/autoload/ctrlp/quickfix.vim
@@ -0,0 +1,59 @@
+" =============================================================================
+" File: autoload/ctrlp/quickfix.vim
+" Description: Quickfix extension
+" Author: Kien Nguyen
+" =============================================================================
+
+" Init {{{1
+if exists('g:loaded_ctrlp_quickfix') && g:loaded_ctrlp_quickfix
+ fini
+en
+let g:loaded_ctrlp_quickfix = 1
+
+cal add(g:ctrlp_ext_vars, {
+ \ 'init': 'ctrlp#quickfix#init()',
+ \ 'accept': 'ctrlp#quickfix#accept',
+ \ 'lname': 'quickfix',
+ \ 'sname': 'qfx',
+ \ 'type': 'line',
+ \ 'sort': 0,
+ \ 'nolim': 1,
+ \ })
+
+let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
+
+fu! s:lineout(dict)
+ retu printf('%s|%d:%d| %s', bufname(a:dict['bufnr']), a:dict['lnum'],
+ \ a:dict['col'], matchstr(a:dict['text'], '\s*\zs.*\S'))
+endf
+" Utilities {{{1
+fu! s:syntax()
+ if !ctrlp#nosy()
+ cal ctrlp#hicheck('CtrlPqfLineCol', 'Search')
+ sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|'
+ en
+endf
+" Public {{{1
+fu! ctrlp#quickfix#init()
+ cal s:syntax()
+ retu map(getqflist(), 's:lineout(v:val)')
+endf
+
+fu! ctrlp#quickfix#accept(mode, str)
+ 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
+endf
+
+fu! ctrlp#quickfix#id()
+ retu s:id
+endf
+"}}}
+
+" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
diff --git a/vim/bundle/ctrlp.vim/autoload/ctrlp/rtscript.vim b/vim/bundle/ctrlp.vim/autoload/ctrlp/rtscript.vim
new file mode 100644
index 0000000..eed21c6
--- /dev/null
+++ b/vim/bundle/ctrlp.vim/autoload/ctrlp/rtscript.vim
@@ -0,0 +1,59 @@
+" =============================================================================
+" File: autoload/ctrlp/rtscript.vim
+" Description: Runtime scripts extension
+" Author: Kien Nguyen
+" =============================================================================
+
+" Init {{{1
+if exists('g:loaded_ctrlp_rtscript') && g:loaded_ctrlp_rtscript
+ fini
+en
+let [g:loaded_ctrlp_rtscript, g:ctrlp_newrts] = [1, 0]
+
+cal add(g:ctrlp_ext_vars, {
+ \ 'init': 'ctrlp#rtscript#init(s:caching)',
+ \ 'accept': 'ctrlp#acceptfile',
+ \ 'lname': 'runtime scripts',
+ \ 'sname': 'rts',
+ \ 'type': 'path',
+ \ 'opmul': 1,
+ \ })
+
+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(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(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
+ 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, s:cwd, entries, results], 0]
+ cal extend(s:filecounts, { s:cwd : len(results) })
+ retu results
+endf
+
+fu! ctrlp#rtscript#id()
+ retu s:id
+endf
+"}}}
+
+" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
diff --git a/vim/bundle/ctrlp.vim/autoload/ctrlp/tag.vim b/vim/bundle/ctrlp.vim/autoload/ctrlp/tag.vim
new file mode 100644
index 0000000..c229480
--- /dev/null
+++ b/vim/bundle/ctrlp.vim/autoload/ctrlp/tag.vim
@@ -0,0 +1,146 @@
+" =============================================================================
+" File: autoload/ctrlp/tag.vim
+" Description: Tag file extension
+" Author: Kien Nguyen
+" =============================================================================
+
+" Init {{{1
+if exists('g:loaded_ctrlp_tag') && g:loaded_ctrlp_tag
+ fini
+en
+let g:loaded_ctrlp_tag = 1
+
+cal add(g:ctrlp_ext_vars, {
+ \ 'init': 'ctrlp#tag#init()',
+ \ 'accept': 'ctrlp#tag#accept',
+ \ 'lname': 'tags',
+ \ 'sname': 'tag',
+ \ 'enter': 'ctrlp#tag#enter()',
+ \ 'type': 'tabs',
+ \ })
+
+let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
+" Utilities {{{1
+fu! s:findcount(str, tgaddr)
+ let [tg, ofname] = split(a:str, '\t\+\ze[^\t]\+$')
+ let tgs = taglist('^'.tg.'$')
+ if len(tgs) < 2
+ retu [0, 0, 0, 0]
+ en
+ let bname = fnamemodify(bufname('%'), ':p')
+ let fname = expand(fnamemodify(simplify(ofname), ':s?^[.\/]\+??:p:.'), 1)
+ let [fnd, cnt, pos, ctgs, otgs] = [0, 0, 0, [], []]
+ for tgi in tgs
+ let lst = bname == fnamemodify(tgi["filename"], ':p') ? 'ctgs' : 'otgs'
+ cal call('add', [{lst}, tgi])
+ endfo
+ let ntgs = ctgs + otgs
+ for tgi in ntgs
+ let cnt += 1
+ let fulname = fnamemodify(tgi["filename"], ':p')
+ if stridx(fulname, fname) >= 0
+ \ && strlen(fname) + stridx(fulname, fname) == strlen(fulname)
+ let fnd += 1
+ let pos = cnt
+ en
+ endfo
+ let cnt = 0
+ for tgi in ntgs
+ let cnt += 1
+ if tgi["filename"] == ofname
+ if a:tgaddr != ""
+ if a:tgaddr == tgi["cmd"]
+ let [fnd, pos] = [0, cnt]
+ en
+ else
+ let [fnd, pos] = [0, cnt]
+ en
+ en
+ endfo
+ retu [1, fnd, pos, len(ctgs)]
+endf
+
+fu! s:filter(tags)
+ let nr = 0
+ wh 0 < 1
+ if a:tags == [] | brea | en
+ if a:tags[nr] =~ '^!' && a:tags[nr] !~# '^!_TAG_'
+ let nr += 1
+ con
+ en
+ if a:tags[nr] =~# '^!_TAG_' && len(a:tags) > nr
+ cal remove(a:tags, nr)
+ el
+ brea
+ en
+ endw
+ retu a:tags
+endf
+
+fu! s:syntax()
+ if !ctrlp#nosy()
+ cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
+ sy match CtrlPTabExtra '\zs\t.*\ze$'
+ en
+endf
+" Public {{{1
+fu! ctrlp#tag#init()
+ if empty(s:tagfiles) | retu [] | en
+ let g:ctrlp_alltags = []
+ let tagfiles = sort(filter(s:tagfiles, 'count(s:tagfiles, v:val) == 1'))
+ for each in tagfiles
+ let alltags = s:filter(ctrlp#utils#readfile(each))
+ cal extend(g:ctrlp_alltags, alltags)
+ endfo
+ cal s:syntax()
+ retu g:ctrlp_alltags
+endf
+
+fu! ctrlp#tag#accept(mode, str)
+ cal ctrlp#exit()
+ let tgaddr = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\t\zs[^\t]\{-1,}\ze\%(;"\)\?\t')
+ let str = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\ze\t')
+ let [tg, fdcnt] = [split(str, '^[^\t]\+\zs\t')[0], s:findcount(str, tgaddr)]
+ let cmds = {
+ \ 't': ['tab sp', 'tab stj'],
+ \ 'h': ['sp', 'stj'],
+ \ 'v': ['vs', 'vert stj'],
+ \ 'e': ['', 'tj'],
+ \ }
+ let utg = fdcnt[3] < 2 && fdcnt[0] == 1 && fdcnt[1] == 1
+ let cmd = !fdcnt[0] || utg ? cmds[a:mode][0] : cmds[a:mode][1]
+ let cmd = a:mode == 'e' && ctrlp#modfilecond(!&aw)
+ \ ? ( cmd == 'tj' ? 'stj' : 'sp' ) : cmd
+ let cmd = a:mode == 't' ? ctrlp#tabcount().cmd : cmd
+ if !fdcnt[0] || utg
+ if cmd != ''
+ exe cmd
+ en
+ let save_cst = &cst
+ set cst&
+ cal feedkeys(":".( utg ? fdcnt[2] : "" )."ta ".tg."\r", 'nt')
+ let &cst = save_cst
+ el
+ let ext = ""
+ if fdcnt[1] < 2 && fdcnt[2]
+ let [sav_more, &more] = [&more, 0]
+ let ext = fdcnt[2]."\r".":let &more = ".sav_more."\r"
+ en
+ cal feedkeys(":".cmd." ".tg."\r".ext, 'nt')
+ en
+ cal feedkeys('zvzz', 'nt')
+ cal ctrlp#setlcdir()
+endf
+
+fu! ctrlp#tag#id()
+ retu s:id
+endf
+
+fu! ctrlp#tag#enter()
+ let tfs = get(g:, 'ctrlp_custom_tag_files', tagfiles())
+ let s:tagfiles = type(tfs) == 3 && tfs != [] ? filter(map(tfs, 'fnamemodify(v:val, ":p")'),
+ \ 'filereadable(v:val)') : []
+endf
+"}}}
+
+" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
diff --git a/vim/bundle/ctrlp.vim/autoload/ctrlp/undo.vim b/vim/bundle/ctrlp.vim/autoload/ctrlp/undo.vim
new file mode 100644
index 0000000..dee705e
--- /dev/null
+++ b/vim/bundle/ctrlp.vim/autoload/ctrlp/undo.vim
@@ -0,0 +1,154 @@
+" =============================================================================
+" File: autoload/ctrlp/undo.vim
+" Description: Undo extension
+" Author: Kien Nguyen
+" =============================================================================
+
+" Init {{{1
+if ( exists('g:loaded_ctrlp_undo') && g:loaded_ctrlp_undo )
+ fini
+en
+let g:loaded_ctrlp_undo = 1
+
+cal add(g:ctrlp_ext_vars, {
+ \ 'init': 'ctrlp#undo#init()',
+ \ 'accept': 'ctrlp#undo#accept',
+ \ 'lname': 'undo',
+ \ 'sname': 'udo',
+ \ 'enter': 'ctrlp#undo#enter()',
+ \ 'exit': 'ctrlp#undo#exit()',
+ \ 'type': 'line',
+ \ 'sort': 0,
+ \ 'nolim': 1,
+ \ })
+
+let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
+
+let s:text = map(['second', 'seconds', 'minutes', 'hours', 'days', 'weeks',
+ \ 'months', 'years'], '" ".v:val." ago"')
+" Utilities {{{1
+fu! s:getundo()
+ if exists('*undotree')
+ \ && ( v:version > 703 || ( v:version == 703 && has('patch005') ) )
+ retu [1, undotree()]
+ el
+ redi => result
+ sil! undol
+ redi END
+ retu [0, split(result, "\n")[1:]]
+ en
+endf
+
+fu! s:flatten(tree, cur)
+ let flatdict = {}
+ for each in a:tree
+ let saved = has_key(each, 'save') ? 'saved' : ''
+ let current = each['seq'] == a:cur ? 'current' : ''
+ cal extend(flatdict, { each['seq'] : [each['time'], saved, current] })
+ if has_key(each, 'alt')
+ cal extend(flatdict, s:flatten(each['alt'], a:cur))
+ en
+ endfo
+ retu flatdict
+endf
+
+fu! s:elapsed(nr)
+ let [text, time] = [s:text, localtime() - a:nr]
+ let mins = time / 60
+ let hrs = time / 3600
+ let days = time / 86400
+ let wks = time / 604800
+ let mons = time / 2592000
+ let yrs = time / 31536000
+ if yrs > 1
+ retu yrs.text[7]
+ elsei mons > 1
+ retu mons.text[6]
+ elsei wks > 1
+ retu wks.text[5]
+ elsei days > 1
+ retu days.text[4]
+ elsei hrs > 1
+ retu hrs.text[3]
+ elsei mins > 1
+ retu mins.text[2]
+ elsei time == 1
+ retu time.text[0]
+ elsei time < 120
+ retu time.text[1]
+ en
+endf
+
+fu! s:syntax()
+ if ctrlp#nosy() | retu | en
+ for [ke, va] in items({'T': 'Directory', 'Br': 'Comment', 'Nr': 'String',
+ \ 'Sv': 'Comment', 'Po': 'Title'})
+ cal ctrlp#hicheck('CtrlPUndo'.ke, va)
+ endfo
+ sy match CtrlPUndoT '\v\d+ \zs[^ ]+\ze|\d+:\d+:\d+'
+ sy match CtrlPUndoBr '\[\|\]'
+ sy match CtrlPUndoNr '\[\d\+\]' contains=CtrlPUndoBr
+ sy match CtrlPUndoSv 'saved'
+ sy match CtrlPUndoPo 'current'
+endf
+
+fu! s:dict2list(dict)
+ for ke in keys(a:dict)
+ let a:dict[ke][0] = s:elapsed(a:dict[ke][0])
+ endfo
+ retu map(keys(a:dict), 'eval(''[v:val, a:dict[v:val]]'')')
+endf
+
+fu! s:compval(...)
+ retu a:2[0] - a:1[0]
+endf
+
+fu! s:format(...)
+ let saved = !empty(a:1[1][1]) ? ' '.a:1[1][1] : ''
+ let current = !empty(a:1[1][2]) ? ' '.a:1[1][2] : ''
+ retu a:1[1][0].' ['.a:1[0].']'.saved.current
+endf
+
+fu! s:formatul(...)
+ let parts = matchlist(a:1,
+ \ '\v^\s+(\d+)\s+\d+\s+([^ ]+\s?[^ ]+|\d+\s\w+\s\w+)(\s*\d*)$')
+ retu parts == [] ? '----'
+ \ : parts[2].' ['.parts[1].']'.( parts[3] != '' ? ' saved' : '' )
+endf
+" Public {{{1
+fu! ctrlp#undo#init()
+ let entries = s:undos[0] ? s:undos[1]['entries'] : s:undos[1]
+ if empty(entries) | retu [] | en
+ if !exists('s:lines')
+ if s:undos[0]
+ let entries = s:dict2list(s:flatten(entries, s:undos[1]['seq_cur']))
+ let s:lines = map(sort(entries, 's:compval'), 's:format(v:val)')
+ el
+ let s:lines = map(reverse(entries), 's:formatul(v:val)')
+ en
+ en
+ cal s:syntax()
+ retu s:lines
+endf
+
+fu! ctrlp#undo#accept(mode, str)
+ let undon = matchstr(a:str, '\[\zs\d\+\ze\]')
+ if empty(undon) | retu | en
+ cal ctrlp#exit()
+ exe 'u' undon
+endf
+
+fu! ctrlp#undo#id()
+ retu s:id
+endf
+
+fu! ctrlp#undo#enter()
+ let s:undos = s:getundo()
+endf
+
+fu! ctrlp#undo#exit()
+ unl! s:lines
+endf
+"}}}
+
+" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
diff --git a/vim/bundle/ctrlp.vim/autoload/ctrlp/utils.vim b/vim/bundle/ctrlp.vim/autoload/ctrlp/utils.vim
new file mode 100644
index 0000000..91b9f24
--- /dev/null
+++ b/vim/bundle/ctrlp.vim/autoload/ctrlp/utils.vim
@@ -0,0 +1,110 @@
+" =============================================================================
+" File: autoload/ctrlp/utils.vim
+" Description: Utilities
+" Author: Kien Nguyen
+" =============================================================================
+
+" Static variables {{{1
+fu! ctrlp#utils#lash()
+ retu &ssl || !exists('+ssl') ? '/' : '\'
+endf
+
+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 cadir = isdirectory(usrhome.'.ctrlp_cache')
+ \ ? usrhome.'.ctrlp_cache' : cahome.s:lash(cahome).'ctrlp'
+ if exists('g:ctrlp_cache_dir')
+ 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
+endf
+
+fu! ctrlp#utils#cachefile(...)
+ let [tail, dir] = [a:0 == 1 ? '.'.a:1 : '', a:0 == 2 ? a:1 : getcwd()]
+ let cache_file = substitute(dir, '\([\/]\|^\a\zs:\)', '%', 'g').tail.'.txt'
+ retu a:0 == 1 ? cache_file : s:cache_dir.s:lash(s:cache_dir).cache_file
+endf
+
+fu! ctrlp#utils#readfile(file)
+ if filereadable(a:file)
+ let data = readfile(a:file)
+ if empty(data) || type(data) != 3
+ unl data
+ let data = []
+ en
+ retu data
+ en
+ retu []
+endf
+
+fu! ctrlp#utils#mkdir(dir)
+ if exists('*mkdir') && !isdirectory(a:dir)
+ sil! cal mkdir(a:dir, 'p')
+ en
+ retu a:dir
+endf
+
+fu! ctrlp#utils#writecache(lines, ...)
+ if isdirectory(ctrlp#utils#mkdir(a:0 ? a:1 : s:cache_dir))
+ sil! cal writefile(a:lines, a:0 >= 2 ? a:2 : ctrlp#utils#cachefile())
+ en
+endf
+
+fu! ctrlp#utils#glob(...)
+ 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
+"}}}
+
+" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
diff --git a/vim/bundle/ctrlp.vim/doc/ctrlp.cnx b/vim/bundle/ctrlp.vim/doc/ctrlp.cnx
new file mode 100644
index 0000000..d99c4c6
--- /dev/null
+++ b/vim/bundle/ctrlp.vim/doc/ctrlp.cnx
@@ -0,0 +1,1616 @@
+*ctrlp.txt* 支持模糊匹配的 文件, 缓冲区, 最近最多使用, 标签, ... 检索. v1.80
+*CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'*
+===============================================================================
+# #
+# :::::::: ::::::::::: ::::::::: ::: ::::::::: #
+# :+: :+: :+: :+: :+: :+: :+: :+: #
+# +:+ +:+ +:+ +:+ +:+ +:+ +:+ #
+# +#+ +#+ +#++:++#: +#+ +#++:++#+ #
+# +#+ +#+ +#+ +#+ +#+ +#+ #
+# #+# #+# #+# #+# #+# #+# #+# #
+# ######## ### ### ### ########## ### #
+# #
+===============================================================================
+名词对照(译注)
+
+ buffer:缓冲区 mapping:按键绑定
+ mru:最近最多使用 prompt:提示符面板
+ tag:标签 tab:页签
+ tab:制表符
+
+===============================================================================
+内容 *ctrlp-content*
+
+ 1. 介绍.............................................|ctrlp-intro|
+ 2. 选项.............................................|ctrlp-options|
+ 3. 命令.............................................|ctrlp-commands|
+ 4. 按键绑定.........................................|ctrlp-mappings|
+ 5. 输入格式.........................................|ctrlp-input-formats|
+ 6. 扩展.............................................|ctrlp-extensions|
+
+===============================================================================
+介绍 *ctrlp-intro*
+
+带有直观接口的全路径模糊文件, 缓冲区, 最近最多使用, 标签, ... 检索。
+使用纯净的Vimscript编写,可以运行在MacVim,gVim和版本号7.0以上的Vim中。
+全面支持Vim的正则表达式 |regexp| 作为搜索模式,内建最近最多使用文件监测,
+项目根目录定位和更多特性。
+
+开启可选的扩展(标记,目录,rtscript...),参考 |ctrlp-extensions| 。
+
+===============================================================================
+OPTIONS *ctrlp-options*
+
+总览:~
+
+ |loaded_ctrlp|................禁用插件。
+ |ctrlp_map|...................默认按键绑定。
+ |ctrlp_cmd|...................默认按键绑定调用的命令。
+ |ctrlp_by_filename|...........是否默认开启文件名模式。
+ |ctrlp_regexp|................是否默认开启正则表达式模式。
+ |ctrlp_match_window|..........匹配窗口的显示位置。
+ |ctrlp_switch_buffer|.........如果文件已在缓冲区中打开,跳转到该打开的缓冲区。
+ |ctrlp_reuse_window|..........重用特殊窗口(帮助、快速修复 |quickfix| ,等等)。
+ |ctrlp_tabpage_position|......新标签页出现的位置。
+ |ctrlp_working_path_mode|.....如何设置CtrlP的本地工作目录。
+ |ctrlp_root_markers|..........额外的,高优先级的根目录标识。
+ |ctrlp_use_caching|...........针对每个会话,设置是否开启缓存的。
+ |ctrlp_clear_cache_on_exit|...退出Vim后是否保留缓存。
+ |ctrlp_cache_dir|.............缓存目录的位置。
+ |ctrlp_show_hidden|...........是否显示隐藏文件和隐藏文件夹。
+ |ctrlp_custom_ignore|.........使用 |globpath()| 时自定义忽略的文件或目录。
+ |ctrlp_max_files|.............扫描文件的最大数目。
+ |ctrlp_max_depth|.............扫描目录的最大层数。
+ |ctrlp_user_command|..........使用外部的扫描工具。
+ |ctrlp_max_history|...........历史提示符面板中保留的最大条目数。
+ |ctrlp_open_new_file|.........由创建的文件的打开方式。
+ |ctrlp_open_multiple_files|...由选择的文件的打开方式。
+ |ctrlp_arg_map|...............是否拦截 和 命令。
+ |ctrlp_follow_symlinks|.......是否跟随链接。
+ |ctrlp_lazy_update|...........停止输入时才更新。
+ |ctrlp_default_input|.........为提示符面板提供一个初始字符串。
+ |ctrlp_abbrev|................输入缩写。
+ |ctrlp_key_loop|..............为多字节输入开启输入事件循环。
+ |ctrlp_prompt_mappings|.......改变提示符面板内部的按键绑定。
+ |ctrlp_line_prefix|...........ctrlp 窗口中为每一行添加前缀。
+ |ctrlp_open_single_match|.....当只有一个候选时自动接受。
+ |ctrlp_brief_prompt|..........提示符为空的时候使用退出 CtrlP。
+ |ctrlp_match_current_file|....在匹配条目中包含当前文件。
+ |ctrlp_types|.................內建类型的名称。
+
+ 最近最多使用模式:
+ |ctrlp_mruf_max|..............记录的最近最多使用的最大数据。
+ |ctrlp_mruf_exclude|..........需要被排除的文件。
+ |ctrlp_mruf_include|..........需要被记录的文件。
+ |ctrlp_mruf_relative|.........只显示在工作目录内的最近最多使用。
+ |ctrlp_tilde_homedir|.........保存 home 目录中的 MRU 的目录路径为波浪扩展的形式 ~/。
+ |ctrlp_mruf_default_order|....禁用排序。
+ |ctrlp_mruf_case_sensitive|...最近最多使用文件是否大小写敏感。
+ |ctrlp_mruf_save_on_update|...只要有一个新的条目添加,就保存到磁盘。
+
+ 缓冲模式:
+ |ctrlp_bufname_mod|...........文件名部分修饰符。
+ |ctrlp_bufpath_mod|...........文件路径部分修饰符。
+
+ 缓冲标签模式: (开启此模式,参考 |ctrlp-extensions| )
+ |g:ctrlp_buftag_ctags_bin|....兼容的ctags二进制程序的位置。
+ |g:ctrlp_buftag_systemenc|....ctags命令的编码。
+ |g:ctrlp_buftag_types|........添加新的文件类型和设置命令行参数。
+
+ 高级选项:
+ |ctrlp_open_func|.............使用自定义的打开文件的函数。
+ |ctrlp_status_func|...........改变CtrlP的两个状态栏
+ |ctrlp_buffer_func|...........在CtrlP的缓冲区内调用自定义的函数。
+ |ctrlp_match_func|............替换内建的匹配算法。
+
+-------------------------------------------------------------------------------
+详细描述和默认值:~
+
+ *'g:ctrlp_map'*
+使用该选项来改变普通模式 |Normal| 下调用CtrlP的按键绑定: >
+ let g:ctrlp_map = ''
+<
+
+ *'g:ctrlp_cmd'*
+
+设置当按下上面的按键绑定时,使用的默认打开命令: >
+ let g:ctrlp_cmd = 'CtrlP'
+<
+
+ *'g:loaded_ctrlp'*
+使用该选项完全禁用插件: >
+ let g:loaded_ctrlp = 1
+<
+
+ *'g:ctrlp_by_filename'*
+修改该选项为1,设置默认为按文件名搜索(否则为全路径): >
+ let g:ctrlp_by_filename = 0
+<
+在提示符面板内可以使用 来切换。
+
+ *'g:ctrlp_regexp'*
+修改该选项为1,设置默认为使用正则表达式匹配。: >
+ let g:ctrlp_regexp = 0
+<
+在提示符面板内可以使用 来切换。
+
+ *'g:ctrlp_match_window'*
+改变匹配窗口的位置,结果的排列顺序,最小和最大高度: >
+ let g:ctrlp_match_window = ''
+<
+例子: >
+ let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10,results:10'
+<
+位置: (默认:底部)
+ top - 在屏幕顶部显示匹配窗口。
+ bottom - 在屏幕底部显示匹配窗口。
+
+结果的排列顺序: (默认: btt)
+ order:ttb - 从顶部到底部。
+ order:btt - 从底部到顶部。
+
+最小和最大高度:
+ min:{n} - 最少显示 {n} 行 (默认: 1).
+ max:{n} - 最多显示 {n} 行 (默认: 10).
+
+结果集的最大数目:
+ results:{n} - 列出最多 {n} 条结果 (默认: 和最大高度同步).
+ 0代表没有限制。
+
+注意: 当一个设置项没有被设置时,将会使用默认值。
+
+ *'g:ctrlp_switch_buffer'*
+当尝试打开一个文件时,如果它已经在某个窗口被打开,CtrlP会尝试跳到那个窗口,而
+不是新打开一个实例。: >
+ let g:ctrlp_switch_buffer = 'Et'
+<
+ e - 当 被按下时跳转,但是只跳转到当前页签内的窗口内。
+ t - 当 被按下时跳转, 但是只跳转到其它标签的窗口内。
+ v - 类似 "e", 但是当 被按下时跳转。
+ h - 类似 "e", 但是当 被按下时跳转。
+ E, T, V, H - 行为类似 "e", "t", "v", and "h", 但是跳转到任何地方的窗口中。
+ 0 或者 - 禁用这项功能。
+
+ *'g:ctrlp_reuse_window'*
+当使用 打开新文件时,CtrlP避免在插件,帮助,快速修复创建的窗口中打开该文
+件。使用该选项来设置一些例外: >
+ let g:ctrlp_reuse_window = 'netrw'
+<
+接受的值可以为特殊缓冲区的名字的一部分,文件类型或者缓冲区类型使用正则表达式来
+指定匹配模式。
+例子: >
+ let g:ctrlp_reuse_window = 'netrw\|help\|quickfix'
+<
+
+ *'g:ctrlp_tabpage_position'*
+新打开页签的位置: >
+ let g:ctrlp_tabpage_position = 'ac'
+<
+ a - 后面。
+ b - 前面。
+ c - 当前页签。
+ l - 最后一个页签。
+ f - 第一个页签。
+
+ *'g:ctrlp_working_path_mode'*
+当启动时,CtrlP依据这个变量来设置它的工作目录: >
+ let g:ctrlp_working_path_mode = 'ra'
+<
+ c - 当前文件所在的目录。
+ a - 当前文件所在的目录,除非这个目录为当前工作目录的子目录
+ r - 包含下列文件或者目录的最近的祖先目录:
+ .git .hg .svn .bzr _darcs
+ w - 用来修饰r:使用当前工作目录而不是当前文件所在目录进行查找
+ 0 或者 - 禁用这项功能。
+
+注意 #1: 如果 "a" 或者 "c" 和 "r"一起被包含,当无法找到根目录时使用 "a" 或者
+"c" 的行为(作为备选)。
+
+注意 #2: 你可以在每个缓冲区内使用 |b:var| 来设置该选项。
+
+ *'g:ctrlp_root_markers'*
+使用该选项来设置自定义的根目录标记作为对默认标记(.hg, .svn, .bzr, and _darcs)
+的补充。自定义的标记具有优先权: >
+ let g:ctrlp_root_markers = ['']
+<
+注意: 你可以在每个缓冲区内使用 |b:var| 来设置该选项。
+
+ *'g:ctrlp_use_caching'*
+启用/禁用每个会话的缓存: >
+ let g:ctrlp_use_caching = 1
+<
+ 0 - 禁用缓存。
+ 1 - 启用缓存。
+ n - 当大于1时,禁用缓存,使用该数值作为重新启用缓存的限制条件。
+
+注意: 当在CtrlP中时你可以使用 来快速的清除缓存。
+
+ *'g:ctrlp_clear_cache_on_exit'*
+设置该选项为0通过退出Vim时不删除缓存文件来启用跨会话的缓存: >
+ let g:ctrlp_clear_cache_on_exit = 1
+<
+
+ *'g:ctrlp_cache_dir'*
+设置存储缓存文件的目录: >
+ let g:ctrlp_cache_dir = $HOME.'/.cache/ctrlp'
+<
+
+ *'g:ctrlp_show_hidden'*
+如果你想CtrlP扫描隐藏文件和目录,设置该选项为1: >
+ let g:ctrlp_show_hidden = 0
+<
+注意: 当命令使用 |g:ctrlp_user_command| 定义时该选项无效。
+
+ *'ctrlp-wildignore'*
+你可以使用Vim的 |'wildignore'| 来从结果集中排序文件或目录。
+例子: >
+ " 排除版本控制文件
+ set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " Linux/MacOSX
+ set wildignore+=*\\.git\\*,*\\.hg\\*,*\\.svn\\* " Windows ('noshellslash')
+<
+注意 #1: 每个目录设置前的字符 `*/` 是必须的。
+
+注意 #2: |wildignore| 影响 |expand()| , |globpath()| 和 |glob()| 的结果,这些函数被很
+多插件用来在系统中执行查找。(例如和版本控制系统有关的插件在查找.git/、.hg/等,
+一些其他插件用来在Windows上查找外部的*.exe工具),所以要修改 |wildignore| 时请先
+考虑清楚。
+
+ *'g:ctrlp_custom_ignore'*
+作为对 |'wildignore'| 和 |g:ctrlp_show_hidden| 的补充,用来设置你只是想在CtrlP中隐藏的文件和目录。使用正
+则表达式来指定匹配模式: >
+ let g:ctrlp_custom_ignore = ''
+<
+例子: >
+ let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
+ let g:ctrlp_custom_ignore = {
+ \ '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
+<
+注意: 当命令使用 |g:ctrlp_user_command| 定义时该选项无效。
+
+ *'g:ctrlp_max_depth'*
+目录树递归的最大层数: >
+ let g:ctrlp_max_depth = 40
+<
+注意: 当命令使用 |g:ctrlp_user_command| 定义时该选项无效。
+
+ *'g:ctrlp_user_command'*
+指定用来代替Vim的 |globpath()| 的外部工具来列出文件,使用 %s 代表目标目录: >
+ let g:ctrlp_user_command = ''
+<
+例子: >
+ let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux
+ let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows
+<
+你也可以使用 'grep', 'findstr' 或者其它东西来过滤结果集。
+例子: >
+ 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
+<
+在扫描一个大型项目时,在仓库目录中使用版本控制系统的列出命令会加快扫描速度: >
+ let g:ctrlp_user_command = [root_marker, listing_command, fallback_command]
+ let g:ctrlp_user_command = {
+ \ 'types': {
+ \ 1: [root_marker_1, listing_command_1],
+ \ n: [root_marker_n, listing_command_n],
+ \ },
+ \ 'fallback': fallback_command,
+ \ 'ignore': 0 or 1
+ \ }
+<
+一些例子: >
+ " 单个版本控制系统,列出命令不会列出没有被追踪的文件:
+ let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files']
+ let g:ctrlp_user_command = ['.hg', 'hg --cwd %s locate -I .']
+
+ " 多个版本控制系统:
+ let g:ctrlp_user_command = {
+ \ 'types': {
+ \ 1: ['.git', 'cd %s && git ls-files'],
+ \ 2: ['.hg', 'hg --cwd %s locate -I .'],
+ \ },
+ \ 'fallback': 'find %s -type f'
+ \ }
+
+ " 单个版本控制系统,列出命令列出没有被追踪的文件(较慢):
+ 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
+<
+注意 #1: 在 |Dictionary| 格式, 'fallback' 和 'ignore' 是可选的,在 |List| 格式,
+备选命令是可选的。
+
+注意 #2: 如果备选命令是空的或者属性 'fallback' 没有定义,当扫描仓库之外目录时,
+|globpath()| 会被使用。
+
+注意 #3: 除非使用了 |Dictionary| 格式并且 'ignore' 被定义并且设置为1,当这些自
+定义的命令被使用时 |wildignore| 和 |g:ctrlp_custom_ignore| 选项不会生效。没有出现
+时,'ignore' 被默认设置为0来保留使用外部命令的性能优势。
+
+注意 #4: 当改变了选项的变量类型时,记得先 |:unlet| ,或者重启Vim来避免这个错误:
+"E706: Variable type mismatch" 。
+
+注意 #5: 你可以在每个缓冲区内使用 |b:var| 来设置该选项。
+
+ *'g:ctrlp_max_history'*
+你希望CtrlP记录的用户输入历史的最大数目。默认值是Vim的全局选项 |'history'| : >
+ let g:ctrlp_max_history = &history
+<
+设置为0来禁用提示符面板的历史。使用 和 来浏览历史。
+
+ *'g:ctrlp_open_new_file'*
+使用该选项指定当使用 打开新建的文件时,文件的打开方式: >
+ let g:ctrlp_open_new_file = 'v'
+<
+ t - 在新页签中。
+ h - 在新的水平分割窗口。
+ v - 在新的竖直分割窗口。
+ r - 在当前窗口。
+
+ *'g:ctrlp_open_multiple_files'*
+如果非0, 会启用使用 和 打开多个文件: >
+ let g:ctrlp_open_multiple_files = 'v'
+<
+例子: >
+ let g:ctrlp_open_multiple_files = '2vjr'
+<
+对于数字:
+ - 如果指定,会被用来作为打开文件时创建的窗口或者页签的最大数量(剩余的会在隐
+ 藏的缓冲区中打开)。
+ - 如果没有指定, 会打开所有文件,每个在一个新的窗口或者页签中。
+
+对于字母:
+ t - 每个文件在一个新页签中。
+ h - 每个文件在一个新的水平分割窗口中。
+ v - 每个文件在一个新的竖直分割窗口中。
+ i - 所有的文件在隐藏的缓冲区中。
+ j - 打开以后,跳转到第一个打开的页签或者窗口。
+ r - 在当前窗口打开第一个文件,其他文件根据同时出现的"h","v"和"t"中的一个,
+ 在新的分割窗口或者页签中打开。
+
+ *'g:ctrlp_arg_map'*
+当设置为1时, 和 会接收一个额外的键值作为参数,来覆盖默认行为: >
+ let g:ctrlp_arg_map = 0
+<
+按下 或者 会提示一次按键。按键可以是:
+ t - 在新标签页中打开。
+ h - 每个文件在一个新的水平分割窗口中。
+ v - 每个文件在一个新的竖直分割窗口中。
+ i - 所有的文件在隐藏的缓冲区中(只有 生效)。
+ c - 清楚标记的文件(只有 生效)。
+ r - 在当前窗口中打开(只有 生效)。
+ , , - 取消并且回到提示符面板。
+ - 使用 |g:ctrlp_open_new_file| 和 |g:ctrlp_open_multiple_files| 指定的默
+ 认行为。
+
+
+ *'g:ctrlp_follow_symlinks'*
+如果非0,当列出文件时CtrlP会跟随链接: >
+ let g:ctrlp_follow_symlinks = 0
+<
+ 0 - 不要跟随链接。
+ 1 - 跟随但是忽略内部循环的链接,避免重复。
+ 2 - 无差别的跟随所有链接。
+
+注意: 当命令使用 |g:ctrlp_user_command| 定义时该选项无效。
+
+ *'g:ctrlp_lazy_update'*
+设置为1将开启延迟更新特性:只在输入停止一个确定的时间后才更新匹配窗口: >
+ let g:ctrlp_lazy_update = 0
+<
+如果设置为1,在250毫秒后更新。如果大于1,数字会被作为延迟时间使用。
+
+ *'g:ctrlp_default_input'*
+设置为1将为提示符面板提供当前文件的相对路径作为种子: >
+ let g:ctrlp_default_input = 0
+<
+如果不指定1或0,如果选项的值是字符串,会被用来作为默认输入: >
+ let g:ctrlp_default_input = 'anystring'
+<
+这个选项可以和 |g:ctrlp_open_single_match| 配合使用。
+
+
+ *'g:ctrlp_match_current_file'*
+在匹配条目中包含当前文件: >
+ let g:ctrlp_match_current_file = 1
+
+默认情况下,当前文件不包含在列表中。
+
+注意: 当使用 |g:ctrlp_match_func| 时不会应用这个选项。
+
+ *'g:ctrlp_types'*
+通过设置这个列表变量的值来定制核心类型: >
+ let g:ctrlp_types = ['mru', 'fil']
+
+类型默认为: >
+ let g:ctrlp_types = ['fil', 'buf', 'mru'].
+
+ *'g:ctrlp_abbrev'*
+定义可以在提示面包内被扩展(内部的或者可见的)的输入缩写: >
+ let g:ctrlp_abbrev = {}
+<
+例子: >
+ let g:ctrlp_abbrev = {
+ \ 'gmode': 'i',
+ \ 'abbrevs': [
+ \ {
+ \ 'pattern': '^cd b',
+ \ 'expanded': '@cd ~/.vim/bundle',
+ \ 'mode': 'pfrz',
+ \ },
+ \ {
+ \ 'pattern': '\(^@.\+\|\\\@ 创建新文件时(使用扩展后的字符串作为文件名)。
+ c - 当使用 自动补全目录名时(在自动补全之前立即扩展模式)。
+ 或者未定义 - 总是启用。
+
+注意: 缩写条目按顺序求值,后求值的条目会覆盖先求值的条目;当 'gmode' 为"t"时,
+包括他自己。
+
+ *'g:ctrlp_key_loop'*
+一个实验性的特性。设置该选项为1将为多字节字符开启输入事件循环: >
+ let g:ctrlp_key_loop = 0
+<
+注意 #1: 当设置时,该选项会重置 |g:ctrlp_lazy_update| 选项。
+
+注意 #2: 你可以在提示符面板使用自定义的按键绑定切换这个特性: >
+ let g:ctrlp_prompt_mappings = { 'ToggleKeyLoop()': [''] }
+<
+
+ *'g:ctrlp_prompt_mappings'*
+使用该选项来自定义CtrlP的提示窗口内的按键绑定为你喜欢的方式。你只需要保留你改
+变值(在[]内部)的行: >
+ let g:ctrlp_prompt_mappings = {
+ \ 'PrtBS()': ['', ''],
+ \ 'PrtDelete()': [''],
+ \ 'PrtDeleteWord()': [''],
+ \ 'PrtClear()': [''],
+ \ 'PrtSelectMove("j")': ['', ''],
+ \ 'PrtSelectMove("k")': ['', ''],
+ \ 'PrtSelectMove("t")': ['', ''],
+ \ 'PrtSelectMove("b")': ['', ''],
+ \ 'PrtSelectMove("u")': ['', ''],
+ \ 'PrtSelectMove("d")': ['', ''],
+ \ 'PrtHistory(-1)': [''],
+ \ 'PrtHistory(1)': [''],
+ \ 'AcceptSelection("e")': ['', '<2-LeftMouse>'],
+ \ 'AcceptSelection("h")': ['', '', ''],
+ \ 'AcceptSelection("t")': [''],
+ \ 'AcceptSelection("v")': ['', ''],
+ \ 'ToggleFocus()': [''],
+ \ 'ToggleRegex()': [''],
+ \ 'ToggleByFname()': [''],
+ \ 'ToggleType(1)': ['', ''],
+ \ 'ToggleType(-1)': ['', ''],
+ \ 'PrtExpandDir()': [''],
+ \ 'PrtInsert("c")': ['', ''],
+ \ 'PrtInsert()': [''],
+ \ 'PrtCurStart()': [''],
+ \ 'PrtCurEnd()': [''],
+ \ 'PrtCurLeft()': ['', '', ''],
+ \ 'PrtCurRight()': ['', ''],
+ \ 'PrtClearCache()': [''],
+ \ 'PrtDeleteEnt()': [''],
+ \ 'CreateNewFile()': [''],
+ \ 'MarkToOpen()': [''],
+ \ 'OpenMulti()': [''],
+ \ 'PrtExit()': ['', '', ''],
+ \ }
+<
+注意: 如果按 后光标向左移动一个字符而不是删除一个字符,在你的.vimrc中添加
+下面的设置来禁用插件默认的 绑定: >
+ let g:ctrlp_prompt_mappings = { 'PrtCurLeft()': ['', ''] }
+<
+
+ *'g:ctrlp_line_prefix'*
+这个前缀会被加到ctrlp的条目列表中每一行的前面。
+默认值: >
+ let g:ctrlp_line_prefix = '> '
+<
+
+ *'g:ctrlp_open_single_match'*
+当CtrlP处于列表中配置的模式中时,如果只有一个候选条目,CtrlP会直接接受该条目。
+例子: >
+ let g:ctrlp_open_single_match = ['buffer tags', 'buffer']
+<
+目前这个选项的作用是和 |g:ctrlp_default_input| 一起,使用类似下面的函数,在使用
+前设置,使用完后还原: >
+ fu! tagsUnderCursor()
+ try
+ let default_input_save = get(g:, 'ctrlp_default_input', '')
+ let g:ctrlp_default_input = expand('')
+ CtrlPBufTagAll
+ finally
+ if exists('default_input_save')
+ let g:ctrlp_default_input = default_input_save
+ endif
+ endtry
+ endfu
+>
+<
+----------------------------------------
+MRU mode options:~
+
+ *'g:ctrlp_mruf_max'*
+指定你希望CtrlP记录的最近打开的文件历史的数目: >
+ let g:ctrlp_mruf_max = 250
+<
+
+ *'g:ctrlp_mruf_exclude'*
+你不希望CtrlP记录的文件。使用正则表达式来指定模式: >
+ let g:ctrlp_mruf_exclude = ''
+<
+例子: >
+ let g:ctrlp_mruf_exclude = '/tmp/.*\|/temp/.*' " MacOSX/Linux
+ let g:ctrlp_mruf_exclude = '^C:\\dev\\tmp\\.*' " Windows
+<
+
+ *'g:ctrlp_mruf_include'*
+如果你想让CtrlP只记录某些文件,在这里指定: >
+ let g:ctrlp_mruf_include = ''
+<
+例子: >
+ let g:ctrlp_mruf_include = '\.py$\|\.rb$'
+<
+ *'g:ctrlp_tilde_homedir'*
+将这个选项设置为1来把所有的 MRU 文件路径中 $HOME 目录下的 $HOME/$filepath 保存
+为 ~/$filepath ,而不是 $HOME/$filepath : >
+ let g:ctrlp_tilde_homedir = 0
+<
+注意: 对所有通过 :CtrlPBookmarkDirAdd! 保存的也有效
+
+ *'g:ctrlp_mruf_relative'*
+设置该选项为1将只显示在当前工作目录内的最近最多使用文件: >
+ let g:ctrlp_mruf_relative = 0
+<
+注意: 你可以在提示符面板使用自定义的按键绑定切换这个特性: >
+ let g:ctrlp_prompt_mappings = { 'ToggleMRURelative()': [''] }
+<
+
+ *'g:ctrlp_mruf_default_order'*
+设置该选项为1将在最近最多使用模式搜索时禁用排序: >
+ let g:ctrlp_mruf_default_order = 0
+<
+
+ *'g:ctrlp_mruf_case_sensitive'*
+将该选项和你的文件系统大小写敏感性保持一致来避免重复的最近最多使用条目: >
+ let g:ctrlp_mruf_case_sensitive = 1
+<
+
+ *'g:ctrlp_mruf_save_on_update'*
+设置该选项为 0 禁止 CtrlP 每当有一个新条目增加就把最近最多使用列表保存到磁盘
+文件,而是在退出Vim时才保存: >
+ let g:ctrlp_mruf_save_on_update = 1
+<
+ *'g:ctrlp_bufname_mod'*
+根据修饰符修改文件名部分。参见 |filename-modifiers| 。 >
+ let g:ctrlp_bufname_mod = ':t'
+<
+ *'g:ctrlp_bufpath_mod'*
+根据修饰符修改文件路径部分。参见 |filename-modifiers| 。 >
+ let g:ctrlp_bufpath_mod = ':~:.:h'
+<
+----------------------------------------
+高级选项:~
+
+ *'g:ctrlp_open_func'*
+使用一个自定义函数来打开选定的文件: >
+ let g:ctrlp_open_func = {}
+<
+例子: >
+ let g:ctrlp_open_func = {
+ \ 'files' : 'Function_Name_1',
+ \ 'buffers' : 'Function_Name_2',
+ \ 'mru files' : 'Function_Name_3',
+ \ }
+<
+函数结构: >
+ function! Function_Name(action, line)
+ " 参数:
+ " |
+ " +- a:action : 打开的动作:
+ " | + 'e' : 用户按下 (默认)
+ " | + 'h' : 用户按下 (默认)
+ " | + 'v' : 用户按下 (默认)
+ " | + 't' : 用户按下 (默认)
+ " | + 'x' : 用户使用 终端对话框 (默认) 选择"e[x]ternal"。
+ " |
+ " +- a:line : 选择的文件。
+
+ endfunction
+<
+注意: 当使用 和 打开多个文件时无效。
+
+例子: 当 被按下时在默认浏览器中打开HTML文件,否则在Vim中打开 >
+ function! HTMLOpenFunc(action, line)
+ if a:action =~ '^[tx]$' && fnamemodify(a:line, ':e') =~? '^html\?$'
+
+ " 获取文件名
+ let filename = fnameescape(fnamemodify(a:line, ':p'))
+
+ " 关闭CtrlP
+ call ctrlp#exit()
+
+ " 打开文件
+ silent! execute '!xdg-open' filename
+
+ elseif a:action == 'x' && fnamemodify(a:line, ':e') !~? '^html\?$'
+
+ " 不是HTML文件,再次模拟 按键并且等待新的输入
+ call feedkeys("\")
+
+ else
+
+ " 使用CtrlP的默认的打开文件的函数
+ call call('ctrlp#acceptfile', [a:action, a:line])
+
+ endif
+ endfunction
+
+ let g:ctrlp_open_func = { 'files': 'HTMLOpenFunc' }
+<
+
+ *'g:ctrlp_status_func'*
+为CtrlP窗口使用自定义的状态栏: >
+ let g:ctrlp_status_func = {}
+<
+例子: >
+ let g:ctrlp_status_func = {
+ \ 'main': 'Function_Name_1',
+ \ 'prog': 'Function_Name_2',
+ \ }
+<
+函数结构: >
+ " 主状态栏
+ function! Function_Name_1(focus, byfname, regex, prev, item, next, marked)
+ " 参数:
+ " |
+ " +- a:focus : 提示符面板的焦点: "prt" 或者 "win"。
+ " |
+ " +- a:byfname : 在文件名模式还是全路径模式: "file" 或者 "path"。
+ " |
+ " +- a:regex : 是否在正则表达式模式: 1 or 0。
+ " |
+ " +- a:prev : 前一个搜索模式。
+ " |
+ " +- a:item : 当前的搜索模式。
+ " |
+ " +- a:next : 下一个搜索模式。
+ " |
+ " +- a:marked : 被标记文件的数目,或者一个逗号分隔的被标记的文件名列表。
+
+ return full_statusline
+ endfunction
+
+ " 状态栏进度条
+ function! Function_Name_2(str)
+ " a:str : 一个当前已扫描的文件数,或者一个当前扫描目录和用户命令的字符串。
+
+ return full_statusline
+ endfunction
+<
+一个可用的例子,参见 https://gist.github.com/1610859 。
+
+ *'g:ctrlp_buffer_func'*
+指定一个会在启动或者退出CtrlP缓冲区时被调用的函数: >
+ let g:ctrlp_buffer_func = {}
+<
+例子: >
+ let g:ctrlp_buffer_func = {
+ \ 'enter': 'Function_Name_1',
+ \ 'exit': 'Function_Name_2',
+ \ }
+<
+
+ *'g:ctrlp_match_func'*
+为CtrlP设置一个额外的模糊匹配函数: >
+ let g:ctrlp_match_func = {}
+<
+例子: >
+ let g:ctrlp_match_func = { 'match': 'Function_Name' }
+<
+函数结构: >
+ function! Function_Name(items, str, limit, mmode, ispath, crfile, regex)
+ " 参数:
+ " |
+ " +- a:items : 搜索条目的全列表。
+ " |
+ " +- a:str : 用户输入的字符串。
+ " |
+ " +- a:limit : 匹配窗口的最大高度。可以用来限制返回的条目数量。
+ " |
+ " +- a:mmode : 在匹配模式。可以是下列字符串之一:
+ " | + "full-line": 匹配整行。
+ " | + "filename-only": 只匹配文件名。
+ " | + "first-non-tab": 匹配到第一个制表符。
+ " | + "until-last-tab": 匹配到最后一个制表符。
+ " |
+ " +- a:ispath : 搜索文件,缓冲区,最近最多使用,混合,目录和rtscript模.
+ " | 式时为1。其它为0。
+ " |
+ " +- a:crfile : 当前窗口中的文件。当a:ispath为1时应该被搜索结果排除在外
+ " |
+ " +- a:regex : 是否在正则表达式模式: 1 or 0.
+
+ return list_of_matched_items
+ endfunction
+<
+
+注意: 你可以通过 { 'arg_type': 'dict' } 扩展上面的任何选项,这样就可以通过
+一个字典类型的参数来传递所有的函数参数。使用参数名作为字典的键值。
+
+例子: >
+ let g:ctrlp_status_func = {
+ \ 'arg_type' : 'dict',
+ \ 'enter': 'Function_Name_1',
+ \ 'exit': 'Function_Name_2',
+ \ }
+
+ function! Function_Name_1(dict)
+ " where dict == {
+ " \ 'focus': value,
+ " \ 'byfname': value,
+ " \ 'regex': value,
+ " \ ...
+ " }
+ endfunction
+<
+ *'g:ctrlp_brief_prompt'*
+当设置为 1 时, 提示符后为空时按 会退出 CtrlP 。
+
+ *ctrlp-default-value*
+另外,你可以使用下面的方式来改变默认值。
+例子: >
+ let g:ctrlp_path_nolim = 1
+
+这样可以让无限制模式匹配“路径”类型。
+===============================================================================
+命令 *ctrlp-commands*
+
+ *:CtrlP*
+:CtrlP [起始目录]
+ 用文件搜索模式打开CtrlP。
+
+ 如果没有给定参数,|g:ctrlp_working_path_mode| 会被用来决定起始目录。临时覆盖
+ 这个参数 的方法见 |:CtrlPCurFile| 和 |:CtrlPCurWD| 。
+
+ 在输入时你可以使用 自动补全[起始目录]。
+
+ *:CtrlPBuffer*
+:CtrlPBuffer
+ 用缓冲区搜索模式打开CtrlP。
+
+ *:CtrlPCurFile*
+:CtrlPCurFile
+ 行为类似变量 |g:ctrlp_working_path_mode| = '' 时执行 |:CtrlP| ,忽略这个变量
+ 现在的值。
+
+ *:CtrlPCurWD*
+:CtrlPCurWD
+ 行为类似变量 |g:ctrlp_working_path_mode| = '' 时执行 |:CtrlP| ,忽略这个变量
+ 现在的值。
+
+ *:CtrlPMRU*
+:CtrlPMRU
+ 用最近最多使用模式打开CtrlP。
+
+ *:CtrlPLastMode*
+:CtrlPLastMode [--dir]
+ 用上一次使用的模式打开CtrlP。当提供了"--dir"参数,也重用上一次的工作目录。
+
+ *:CtrlPRoot*
+:CtrlPRoot
+ 行为类似使用了 |g:ctrlp_working_path_mode| = 'r' 并且忽略了该变量的当前值的
+ |:CtrlP| 命令。
+
+ *:CtrlPClearCache*
+:CtrlPClearCache
+ 清除当前工作目录的缓存。和在CtrlP内按 效果一样。
+ 使用 |g:ctrlp_use_caching| 来启用或禁用缓存。
+
+ *:CtrlPClearAllCaches*
+:CtrlPClearAllCaches
+ 删除在 |g:ctrlp_cache_dir| 中定义的缓存目录中的所有缓存文件。
+
+-------------------------------------------------------------------------------
+由扩展提供的命令参见 |ctrlp-extensions| 。
+
+===============================================================================
+按键绑定 *ctrlp-mappings*
+
+ *'ctrlp-'*
+
+ 普通模式 |Normal| 下默认以文件搜索模式打开CtrlP提示符面板。
+
+----------------------------------------
+已经在提示符面板中:~
+
+
+ 在全路径搜索和文件名搜索间切换。
+ 注意: 在文件名搜索模式,提示符面板的提示符是'>d>',而不是'>>>'
+
+ *'ctrlp-fullregexp'*
+ 在字符串搜索模式和正则表达式模式之间切换。
+ 注意: 在全正则表达式模式,提示符面板的提示符是'r>>',而不是'>>>'
+
+ 详细参见: |input-formats| (指引)和 |g:ctrlp_regexp_search| 选项。
+
+ , 'forward' 前进
+
+ 切换到序列里面的 'next' 后一个搜索模式。
+
+ , 'backward' 后退
+
+ 切换到序列里面的 'previous' 前一个搜索模式。
+
+ *'ctrlp-autocompletion'*
+ 自动补全在提示符面板的当前工作路径中的目录名。
+
+
+ 在匹配窗口和提示符面板之间切换焦点。
+
+ ,
+ ,
+
+ 退出CtrlP。
+
+移动:~
+
+ ,
+
+ 向下移动。
+
+ ,
+
+ 向上移动。
+
+
+ 移动光标到提示符面板的 'start' 开头。
+
+
+ 移动光标到提示符面板的 'end' 末尾。
+
+ ,
+ ,
+
+ 向左 'left' 移动一个字符。
+
+ ,
+
+ 向右 'right' 移动一个字符。
+
+编辑:~
+
+ ,
+
+ 删除前一个字符。
+
+
+ 删除当前字符。
+
+
+ 删除前一个单词。
+
+
+ 清除输入。
+
+浏览输入历史:~
+
+
+ 提示符面板历史里的下一个字符串。
+
+
+ 提示符面板历史里的上一个字符串。
+
+打开/创建文件:~
+
+
+ 如果可能的话在 'current' 当前窗口打开选择的文件。
+
+
+ 在 'tab' 新标签打开选择的文件。
+ Open the selected file in a new 'tab'.
+
+
+ 在 'vertical' 竖直分割窗口打开选择的文件。
+
+ ,
+