diff --git a/bashrc b/bashrc
index 1d46448..9546680 100644
--- a/bashrc
+++ b/bashrc
@@ -32,7 +32,7 @@ ec2-info() {
}
export EDITOR=vim
export GOPATH=$HOME/code/go
-export PATH=$HOME/bin:/usr/local/go/bin:$HOME/perl5/bin:/usr/sbin/:$GOPATH/bin:$HOME/bin/vim/vim-8.0.1481/bin/bin/:$HOME/Library/Python/2.7/bin:$PATH
+export PATH=$HOME/bin:$HOME/bin/fzf/bin/:$HOME/gobin/go/bin/:/usr/local/go/bin:$HOME/perl5/bin:/usr/sbin/:$GOPATH/bin:$HOME/Library/Python/2.7/bin:$HOME/bin/vim/vim-8.0.1481/bin/bin/:$PATH
[ -f $HOME/perl5/lib/perl5/Devel/Local.pm ] && source `which devel-local.sh`
function github() {
git clone git@github.com:SocialFlowDev/$1.git
diff --git a/install.sh b/install.sh
index d8d4469..9ed1ce9 100755
--- a/install.sh
+++ b/install.sh
@@ -8,13 +8,7 @@ DIR="$(pwd)"
ln -sf "$DIR/jsbeautifyrc" "$HOME/.jsbeautifyrc"
ln -sf "$DIR/jshintrc" "$HOME/.jshintrc"
mkdir -p "$HOME/.vim/colors"
- mkdir -p "$HOME/.vim/plugin"
- mkdir -p "$HOME/.vim/autoload"
mkdir -p "$HOME/.ssh"
ln -sf "$DIR/ssh-config" "$HOME/.ssh/config"
ln -sf "$DIR/vim-colors/molokaimod.vim" "$HOME/.vim/colors/molokaimod.vim"
- ln -sf "$DIR/vim-plugin/ack.vim" "$HOME/.vim/plugin/ack.vim"
- ln -sf "$DIR/vim-plugin/openssl.vim" "$HOME/.vim/plugin/openssl.vim"
- ln -sf "$DIR/vim-plugin/gnupg.vim" "$HOME/.vim/plugin/gnupg.vim"
- ln -sf "$DIR/vim-autoload/pathogen.vim" "$HOME/.vim/autoload/pathogen.vim"
- ln -sf "$DIR/vim-bundle" "$HOME/.vim/bundle"
+ ln -sf "$DIR/vim-autoload" "$HOME/.vim/autoload"
diff --git a/ssh-config b/ssh-config
index dc17e3f..fc94065 100644
--- a/ssh-config
+++ b/ssh-config
@@ -17,7 +17,7 @@ Host *.mars.sfsrv.net
Host *.saturn.sfsrv.net
User appuser
ConnectTimeout 30
- #ProxyCommand docker exec -i saturnvpn nc -q0 %h %p 2>/dev/null
+ ProxyCommand docker exec -i saturnvpn nc -q0 %h %p 2>/dev/null
StrictHostKeyChecking false
KbdInteractiveAuthentication false
diff --git a/tmux.conf b/tmux.conf
index 137dac8..0d9d5f6 100644
--- a/tmux.conf
+++ b/tmux.conf
@@ -97,5 +97,5 @@ bind k next-window
unbind @
bind @ command-prompt -p "join pane to:" "join-pane -t '%%'"
-set-option -g default-command "reattach-to-user-namespace -l bash"
+if-shell "uname | grep -q Darwin" "set-option -g default-command \"reattach-to-user-namespace -l bash\""
diff --git a/vim-autoload/pathogen.vim b/vim-autoload/pathogen.vim
deleted file mode 100644
index a13ae08..0000000
--- a/vim-autoload/pathogen.vim
+++ /dev/null
@@ -1,347 +0,0 @@
-" pathogen.vim - path option manipulation
-" Maintainer: Tim Pope
-" Version: 2.3
-
-" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
-"
-" For management of individually installed plugins in ~/.vim/bundle (or
-" ~\vimfiles\bundle), adding `execute pathogen#infect()` to the top of your
-" .vimrc is the only other setup necessary.
-"
-" The API is documented inline below.
-
-if exists("g:loaded_pathogen") || &cp
- finish
-endif
-let g:loaded_pathogen = 1
-
-" Point of entry for basic default usage. Give a relative path to invoke
-" pathogen#interpose() (defaults to "bundle/{}"), or an absolute path to invoke
-" pathogen#surround(). Curly braces are expanded with pathogen#expand():
-" "bundle/{}" finds all subdirectories inside "bundle" inside all directories
-" in the runtime path.
-function! pathogen#infect(...) abort
- for path in a:0 ? filter(reverse(copy(a:000)), 'type(v:val) == type("")') : ['bundle/{}']
- if path =~# '^\%({\=[$~\\/]\|{\=\w:[\\/]\).*[{}*]'
- call pathogen#surround(path)
- elseif path =~# '^\%([$~\\/]\|\w:[\\/]\)'
- call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')')
- call pathogen#surround(path . '/{}')
- elseif path =~# '[{}*]'
- call pathogen#interpose(path)
- else
- call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')')
- call pathogen#interpose(path . '/{}')
- endif
- endfor
- call pathogen#cycle_filetype()
- if pathogen#is_disabled($MYVIMRC)
- return 'finish'
- endif
- return ''
-endfunction
-
-" Split a path into a list.
-function! pathogen#split(path) abort
- if type(a:path) == type([]) | return a:path | endif
- if empty(a:path) | return [] | endif
- let split = split(a:path,'\\\@]','\\&','')
- endif
-endfunction
-
-" Like findfile(), but hardcoded to use the runtimepath.
-function! pathogen#runtime_findfile(file,count) abort "{{{1
- let rtp = pathogen#join(1,pathogen#split(&rtp))
- let file = findfile(a:file,rtp,a:count)
- if file ==# ''
- return ''
- else
- return fnamemodify(file,':p')
- endif
-endfunction
-
-" Section: Deprecated
-
-function! s:warn(msg) abort
- echohl WarningMsg
- echomsg a:msg
- echohl NONE
-endfunction
-
-" Prepend all subdirectories of path to the rtp, and append all 'after'
-" directories in those subdirectories. Deprecated.
-function! pathogen#runtime_prepend_subdirectories(path) abort
- call s:warn('Change pathogen#runtime_prepend_subdirectories('.string(a:path).') to pathogen#infect('.string(a:path.'/{}').')')
- return pathogen#surround(a:path . pathogen#slash() . '{}')
-endfunction
-
-function! pathogen#incubate(...) abort
- let name = a:0 ? a:1 : 'bundle/{}'
- call s:warn('Change pathogen#incubate('.(a:0 ? string(a:1) : '').') to pathogen#infect('.string(name).')')
- return pathogen#interpose(name)
-endfunction
-
-" Deprecated alias for pathogen#interpose().
-function! pathogen#runtime_append_all_bundles(...) abort
- if a:0
- call s:warn('Change pathogen#runtime_append_all_bundles('.string(a:1).') to pathogen#infect('.string(a:1.'/{}').')')
- else
- call s:warn('Change pathogen#runtime_append_all_bundles() to pathogen#infect()')
- endif
- return pathogen#interpose(a:0 ? a:1 . '/{}' : 'bundle/{}')
-endfunction
-
-if exists(':Vedit')
- finish
-endif
-
-let s:vopen_warning = 0
-
-function! s:find(count,cmd,file,lcd)
- let rtp = pathogen#join(1,pathogen#split(&runtimepath))
- let file = pathogen#runtime_findfile(a:file,a:count)
- if file ==# ''
- return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'"
- endif
- if !s:vopen_warning
- let s:vopen_warning = 1
- let warning = '|echohl WarningMsg|echo "Install scriptease.vim to continue using :V'.a:cmd.'"|echohl NONE'
- else
- let warning = ''
- endif
- if a:lcd
- let path = file[0:-strlen(a:file)-2]
- execute 'lcd `=path`'
- return a:cmd.' '.pathogen#fnameescape(a:file) . warning
- else
- return a:cmd.' '.pathogen#fnameescape(file) . warning
- endif
-endfunction
-
-function! s:Findcomplete(A,L,P)
- let sep = pathogen#slash()
- let cheats = {
- \'a': 'autoload',
- \'d': 'doc',
- \'f': 'ftplugin',
- \'i': 'indent',
- \'p': 'plugin',
- \'s': 'syntax'}
- if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0])
- let request = cheats[a:A[0]].a:A[1:-1]
- else
- let request = a:A
- endif
- let pattern = substitute(request,'/\|\'.sep,'*'.sep,'g').'*'
- let found = {}
- for path in pathogen#split(&runtimepath)
- let path = expand(path, ':p')
- let matches = split(glob(path.sep.pattern),"\n")
- call map(matches,'isdirectory(v:val) ? v:val.sep : v:val')
- call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]')
- for match in matches
- let found[match] = 1
- endfor
- endfor
- return sort(keys(found))
-endfunction
-
-command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(,'edit',,0)
-command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(,'edit',,0)
-command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(,'edit',,1)
-command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(,'split',,1)
-command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(,'vsplit',,1)
-command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(,'tabedit',,1)
-command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(,'pedit',,1)
-command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(,'read',,1)
-
-" vim:set et sw=2 foldmethod=expr foldexpr=getline(v\:lnum)=~'^\"\ Section\:'?'>1'\:getline(v\:lnum)=~#'^fu'?'a1'\:getline(v\:lnum)=~#'^endf'?'s1'\:'=':
diff --git a/vim-autoload/plug.vim b/vim-autoload/plug.vim
new file mode 100644
index 0000000..9dd02c0
--- /dev/null
+++ b/vim-autoload/plug.vim
@@ -0,0 +1,2504 @@
+" vim-plug: Vim plugin manager
+" ============================
+"
+" Download plug.vim and put it in ~/.vim/autoload
+"
+" curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
+" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
+"
+" Edit your .vimrc
+"
+" call plug#begin('~/.vim/plugged')
+"
+" " Make sure you use single quotes
+"
+" " Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
+" Plug 'junegunn/vim-easy-align'
+"
+" " Any valid git URL is allowed
+" Plug 'https://github.com/junegunn/vim-github-dashboard.git'
+"
+" " Multiple Plug commands can be written in a single line using | separators
+" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
+"
+" " On-demand loading
+" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
+" Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
+"
+" " Using a non-master branch
+" Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
+"
+" " Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
+" Plug 'fatih/vim-go', { 'tag': '*' }
+"
+" " Plugin options
+" Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
+"
+" " Plugin outside ~/.vim/plugged with post-update hook
+" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
+"
+" " Unmanaged plugin (manually installed and updated)
+" Plug '~/my-prototype-plugin'
+"
+" " Initialize plugin system
+" call plug#end()
+"
+" Then reload .vimrc and :PlugInstall to install plugins.
+"
+" Plug options:
+"
+"| Option | Description |
+"| ----------------------- | ------------------------------------------------ |
+"| `branch`/`tag`/`commit` | Branch/tag/commit of the repository to use |
+"| `rtp` | Subdirectory that contains Vim plugin |
+"| `dir` | Custom directory for the plugin |
+"| `as` | Use different name for the plugin |
+"| `do` | Post-update hook (string or funcref) |
+"| `on` | On-demand loading: Commands or ``-mappings |
+"| `for` | On-demand loading: File types |
+"| `frozen` | Do not update unless explicitly specified |
+"
+" More information: https://github.com/junegunn/vim-plug
+"
+"
+" Copyright (c) 2017 Junegunn Choi
+"
+" MIT License
+"
+" Permission is hereby granted, free of charge, to any person obtaining
+" a copy of this software and associated documentation files (the
+" "Software"), to deal in the Software without restriction, including
+" without limitation the rights to use, copy, modify, merge, publish,
+" distribute, sublicense, and/or sell copies of the Software, and to
+" permit persons to whom the Software is furnished to do so, subject to
+" the following conditions:
+"
+" The above copyright notice and this permission notice shall be
+" included in all copies or substantial portions of the Software.
+"
+" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+if exists('g:loaded_plug')
+ finish
+endif
+let g:loaded_plug = 1
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+let s:plug_src = 'https://github.com/junegunn/vim-plug.git'
+let s:plug_tab = get(s:, 'plug_tab', -1)
+let s:plug_buf = get(s:, 'plug_buf', -1)
+let s:mac_gui = has('gui_macvim') && has('gui_running')
+let s:is_win = has('win32') || has('win64')
+let s:nvim = has('nvim-0.2') || (has('nvim') && exists('*jobwait') && !s:is_win)
+let s:vim8 = has('patch-8.0.0039') && exists('*job_start')
+let s:me = resolve(expand(':p'))
+let s:base_spec = { 'branch': 'master', 'frozen': 0 }
+let s:TYPE = {
+\ 'string': type(''),
+\ 'list': type([]),
+\ 'dict': type({}),
+\ 'funcref': type(function('call'))
+\ }
+let s:loaded = get(s:, 'loaded', {})
+let s:triggers = get(s:, 'triggers', {})
+
+function! plug#begin(...)
+ if a:0 > 0
+ let s:plug_home_org = a:1
+ let home = s:path(fnamemodify(expand(a:1), ':p'))
+ elseif exists('g:plug_home')
+ let home = s:path(g:plug_home)
+ elseif !empty(&rtp)
+ let home = s:path(split(&rtp, ',')[0]) . '/plugged'
+ else
+ return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.')
+ endif
+ if fnamemodify(home, ':t') ==# 'plugin' && fnamemodify(home, ':h') ==# s:first_rtp
+ return s:err('Invalid plug home. '.home.' is a standard Vim runtime path and is not allowed.')
+ endif
+
+ let g:plug_home = home
+ let g:plugs = {}
+ let g:plugs_order = []
+ let s:triggers = {}
+
+ call s:define_commands()
+ return 1
+endfunction
+
+function! s:define_commands()
+ command! -nargs=+ -bar Plug call plug#()
+ if !executable('git')
+ return s:err('`git` executable not found. Most commands will not be available. To suppress this message, prepend `silent!` to `call plug#begin(...)`.')
+ endif
+ command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install(0, [])
+ command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate call s:update(0, [])
+ command! -nargs=0 -bar -bang PlugClean call s:clean(0)
+ command! -nargs=0 -bar PlugUpgrade if s:upgrade() | execute 'source' s:esc(s:me) | endif
+ command! -nargs=0 -bar PlugStatus call s:status()
+ command! -nargs=0 -bar PlugDiff call s:diff()
+ command! -nargs=? -bar -bang -complete=file PlugSnapshot call s:snapshot(0, )
+endfunction
+
+function! s:to_a(v)
+ return type(a:v) == s:TYPE.list ? a:v : [a:v]
+endfunction
+
+function! s:to_s(v)
+ return type(a:v) == s:TYPE.string ? a:v : join(a:v, "\n") . "\n"
+endfunction
+
+function! s:glob(from, pattern)
+ return s:lines(globpath(a:from, a:pattern))
+endfunction
+
+function! s:source(from, ...)
+ let found = 0
+ for pattern in a:000
+ for vim in s:glob(a:from, pattern)
+ execute 'source' s:esc(vim)
+ let found = 1
+ endfor
+ endfor
+ return found
+endfunction
+
+function! s:assoc(dict, key, val)
+ let a:dict[a:key] = add(get(a:dict, a:key, []), a:val)
+endfunction
+
+function! s:ask(message, ...)
+ call inputsave()
+ echohl WarningMsg
+ let answer = input(a:message.(a:0 ? ' (y/N/a) ' : ' (y/N) '))
+ echohl None
+ call inputrestore()
+ echo "\r"
+ return (a:0 && answer =~? '^a') ? 2 : (answer =~? '^y') ? 1 : 0
+endfunction
+
+function! s:ask_no_interrupt(...)
+ try
+ return call('s:ask', a:000)
+ catch
+ return 0
+ endtry
+endfunction
+
+function! plug#end()
+ if !exists('g:plugs')
+ return s:err('Call plug#begin() first')
+ endif
+
+ if exists('#PlugLOD')
+ augroup PlugLOD
+ autocmd!
+ augroup END
+ augroup! PlugLOD
+ endif
+ let lod = { 'ft': {}, 'map': {}, 'cmd': {} }
+
+ if exists('g:did_load_filetypes')
+ filetype off
+ endif
+ for name in g:plugs_order
+ if !has_key(g:plugs, name)
+ continue
+ endif
+ let plug = g:plugs[name]
+ if get(s:loaded, name, 0) || !has_key(plug, 'on') && !has_key(plug, 'for')
+ let s:loaded[name] = 1
+ continue
+ endif
+
+ if has_key(plug, 'on')
+ let s:triggers[name] = { 'map': [], 'cmd': [] }
+ for cmd in s:to_a(plug.on)
+ if cmd =~? '^.\+'
+ if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i'))
+ call s:assoc(lod.map, cmd, name)
+ endif
+ call add(s:triggers[name].map, cmd)
+ elseif cmd =~# '^[A-Z]'
+ let cmd = substitute(cmd, '!*$', '', '')
+ if exists(':'.cmd) != 2
+ call s:assoc(lod.cmd, cmd, name)
+ endif
+ call add(s:triggers[name].cmd, cmd)
+ else
+ call s:err('Invalid `on` option: '.cmd.
+ \ '. Should start with an uppercase letter or ``.')
+ endif
+ endfor
+ endif
+
+ if has_key(plug, 'for')
+ let types = s:to_a(plug.for)
+ if !empty(types)
+ augroup filetypedetect
+ call s:source(s:rtp(plug), 'ftdetect/**/*.vim', 'after/ftdetect/**/*.vim')
+ augroup END
+ endif
+ for type in types
+ call s:assoc(lod.ft, type, name)
+ endfor
+ endif
+ endfor
+
+ for [cmd, names] in items(lod.cmd)
+ execute printf(
+ \ 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "", , , , %s)',
+ \ cmd, string(cmd), string(names))
+ endfor
+
+ for [map, names] in items(lod.map)
+ for [mode, map_prefix, key_prefix] in
+ \ [['i', '', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']]
+ execute printf(
+ \ '%snoremap %s %s:call lod_map(%s, %s, %s, "%s")',
+ \ mode, map, map_prefix, string(map), string(names), mode != 'i', key_prefix)
+ endfor
+ endfor
+
+ for [ft, names] in items(lod.ft)
+ augroup PlugLOD
+ execute printf('autocmd FileType %s call lod_ft(%s, %s)',
+ \ ft, string(ft), string(names))
+ augroup END
+ endfor
+
+ call s:reorg_rtp()
+ filetype plugin indent on
+ if has('vim_starting')
+ if has('syntax') && !exists('g:syntax_on')
+ syntax enable
+ end
+ else
+ call s:reload_plugins()
+ endif
+endfunction
+
+function! s:loaded_names()
+ return filter(copy(g:plugs_order), 'get(s:loaded, v:val, 0)')
+endfunction
+
+function! s:load_plugin(spec)
+ call s:source(s:rtp(a:spec), 'plugin/**/*.vim', 'after/plugin/**/*.vim')
+endfunction
+
+function! s:reload_plugins()
+ for name in s:loaded_names()
+ call s:load_plugin(g:plugs[name])
+ endfor
+endfunction
+
+function! s:trim(str)
+ return substitute(a:str, '[\/]\+$', '', '')
+endfunction
+
+function! s:version_requirement(val, min)
+ for idx in range(0, len(a:min) - 1)
+ let v = get(a:val, idx, 0)
+ if v < a:min[idx] | return 0
+ elseif v > a:min[idx] | return 1
+ endif
+ endfor
+ return 1
+endfunction
+
+function! s:git_version_requirement(...)
+ if !exists('s:git_version')
+ let s:git_version = map(split(split(s:system('git --version'))[2], '\.'), 'str2nr(v:val)')
+ endif
+ return s:version_requirement(s:git_version, a:000)
+endfunction
+
+function! s:progress_opt(base)
+ return a:base && !s:is_win &&
+ \ s:git_version_requirement(1, 7, 1) ? '--progress' : ''
+endfunction
+
+if s:is_win
+ function! s:rtp(spec)
+ return s:path(a:spec.dir . get(a:spec, 'rtp', ''))
+ endfunction
+
+ function! s:path(path)
+ return s:trim(substitute(a:path, '/', '\', 'g'))
+ endfunction
+
+ function! s:dirpath(path)
+ return s:path(a:path) . '\'
+ endfunction
+
+ function! s:is_local_plug(repo)
+ return a:repo =~? '^[a-z]:\|^[%~]'
+ endfunction
+else
+ function! s:rtp(spec)
+ return s:dirpath(a:spec.dir . get(a:spec, 'rtp', ''))
+ endfunction
+
+ function! s:path(path)
+ return s:trim(a:path)
+ endfunction
+
+ function! s:dirpath(path)
+ return substitute(a:path, '[/\\]*$', '/', '')
+ endfunction
+
+ function! s:is_local_plug(repo)
+ return a:repo[0] =~ '[/$~]'
+ endfunction
+endif
+
+function! s:err(msg)
+ echohl ErrorMsg
+ echom '[vim-plug] '.a:msg
+ echohl None
+endfunction
+
+function! s:warn(cmd, msg)
+ echohl WarningMsg
+ execute a:cmd 'a:msg'
+ echohl None
+endfunction
+
+function! s:esc(path)
+ return escape(a:path, ' ')
+endfunction
+
+function! s:escrtp(path)
+ return escape(a:path, ' ,')
+endfunction
+
+function! s:remove_rtp()
+ for name in s:loaded_names()
+ let rtp = s:rtp(g:plugs[name])
+ execute 'set rtp-='.s:escrtp(rtp)
+ let after = globpath(rtp, 'after')
+ if isdirectory(after)
+ execute 'set rtp-='.s:escrtp(after)
+ endif
+ endfor
+endfunction
+
+function! s:reorg_rtp()
+ if !empty(s:first_rtp)
+ execute 'set rtp-='.s:first_rtp
+ execute 'set rtp-='.s:last_rtp
+ endif
+
+ " &rtp is modified from outside
+ if exists('s:prtp') && s:prtp !=# &rtp
+ call s:remove_rtp()
+ unlet! s:middle
+ endif
+
+ let s:middle = get(s:, 'middle', &rtp)
+ let rtps = map(s:loaded_names(), 's:rtp(g:plugs[v:val])')
+ let afters = filter(map(copy(rtps), 'globpath(v:val, "after")'), '!empty(v:val)')
+ let rtp = join(map(rtps, 'escape(v:val, ",")'), ',')
+ \ . ','.s:middle.','
+ \ . join(map(afters, 'escape(v:val, ",")'), ',')
+ let &rtp = substitute(substitute(rtp, ',,*', ',', 'g'), '^,\|,$', '', 'g')
+ let s:prtp = &rtp
+
+ if !empty(s:first_rtp)
+ execute 'set rtp^='.s:first_rtp
+ execute 'set rtp+='.s:last_rtp
+ endif
+endfunction
+
+function! s:doautocmd(...)
+ if exists('#'.join(a:000, '#'))
+ execute 'doautocmd' ((v:version > 703 || has('patch442')) ? '' : '') join(a:000)
+ endif
+endfunction
+
+function! s:dobufread(names)
+ for name in a:names
+ let path = s:rtp(g:plugs[name]).'/**'
+ for dir in ['ftdetect', 'ftplugin']
+ if len(finddir(dir, path))
+ if exists('#BufRead')
+ doautocmd BufRead
+ endif
+ return
+ endif
+ endfor
+ endfor
+endfunction
+
+function! plug#load(...)
+ if a:0 == 0
+ return s:err('Argument missing: plugin name(s) required')
+ endif
+ if !exists('g:plugs')
+ return s:err('plug#begin was not called')
+ endif
+ let names = a:0 == 1 && type(a:1) == s:TYPE.list ? a:1 : a:000
+ let unknowns = filter(copy(names), '!has_key(g:plugs, v:val)')
+ if !empty(unknowns)
+ let s = len(unknowns) > 1 ? 's' : ''
+ return s:err(printf('Unknown plugin%s: %s', s, join(unknowns, ', ')))
+ end
+ let unloaded = filter(copy(names), '!get(s:loaded, v:val, 0)')
+ if !empty(unloaded)
+ for name in unloaded
+ call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
+ endfor
+ call s:dobufread(unloaded)
+ return 1
+ end
+ return 0
+endfunction
+
+function! s:remove_triggers(name)
+ if !has_key(s:triggers, a:name)
+ return
+ endif
+ for cmd in s:triggers[a:name].cmd
+ execute 'silent! delc' cmd
+ endfor
+ for map in s:triggers[a:name].map
+ execute 'silent! unmap' map
+ execute 'silent! iunmap' map
+ endfor
+ call remove(s:triggers, a:name)
+endfunction
+
+function! s:lod(names, types, ...)
+ for name in a:names
+ call s:remove_triggers(name)
+ let s:loaded[name] = 1
+ endfor
+ call s:reorg_rtp()
+
+ for name in a:names
+ let rtp = s:rtp(g:plugs[name])
+ for dir in a:types
+ call s:source(rtp, dir.'/**/*.vim')
+ endfor
+ if a:0
+ if !s:source(rtp, a:1) && !empty(s:glob(rtp, a:2))
+ execute 'runtime' a:1
+ endif
+ call s:source(rtp, a:2)
+ endif
+ call s:doautocmd('User', name)
+ endfor
+endfunction
+
+function! s:lod_ft(pat, names)
+ let syn = 'syntax/'.a:pat.'.vim'
+ call s:lod(a:names, ['plugin', 'after/plugin'], syn, 'after/'.syn)
+ execute 'autocmd! PlugLOD FileType' a:pat
+ call s:doautocmd('filetypeplugin', 'FileType')
+ call s:doautocmd('filetypeindent', 'FileType')
+endfunction
+
+function! s:lod_cmd(cmd, bang, l1, l2, args, names)
+ call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
+ call s:dobufread(a:names)
+ execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
+endfunction
+
+function! s:lod_map(map, names, with_prefix, prefix)
+ call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
+ call s:dobufread(a:names)
+ let extra = ''
+ while 1
+ let c = getchar(0)
+ if c == 0
+ break
+ endif
+ let extra .= nr2char(c)
+ endwhile
+
+ if a:with_prefix
+ let prefix = v:count ? v:count : ''
+ let prefix .= '"'.v:register.a:prefix
+ if mode(1) == 'no'
+ if v:operator == 'c'
+ let prefix = "\" . prefix
+ endif
+ let prefix .= v:operator
+ endif
+ call feedkeys(prefix, 'n')
+ endif
+ call feedkeys(substitute(a:map, '^', "\", '') . extra)
+endfunction
+
+function! plug#(repo, ...)
+ if a:0 > 1
+ return s:err('Invalid number of arguments (1..2)')
+ endif
+
+ try
+ let repo = s:trim(a:repo)
+ let opts = a:0 == 1 ? s:parse_options(a:1) : s:base_spec
+ let name = get(opts, 'as', fnamemodify(repo, ':t:s?\.git$??'))
+ let spec = extend(s:infer_properties(name, repo), opts)
+ if !has_key(g:plugs, name)
+ call add(g:plugs_order, name)
+ endif
+ let g:plugs[name] = spec
+ let s:loaded[name] = get(s:loaded, name, 0)
+ catch
+ return s:err(v:exception)
+ endtry
+endfunction
+
+function! s:parse_options(arg)
+ let opts = copy(s:base_spec)
+ let type = type(a:arg)
+ if type == s:TYPE.string
+ let opts.tag = a:arg
+ elseif type == s:TYPE.dict
+ call extend(opts, a:arg)
+ if has_key(opts, 'dir')
+ let opts.dir = s:dirpath(expand(opts.dir))
+ endif
+ else
+ throw 'Invalid argument type (expected: string or dictionary)'
+ endif
+ return opts
+endfunction
+
+function! s:infer_properties(name, repo)
+ let repo = a:repo
+ if s:is_local_plug(repo)
+ return { 'dir': s:dirpath(expand(repo)) }
+ else
+ if repo =~ ':'
+ let uri = repo
+ else
+ if repo !~ '/'
+ throw printf('Invalid argument: %s (implicit `vim-scripts'' expansion is deprecated)', repo)
+ endif
+ let fmt = get(g:, 'plug_url_format', 'https://git::@github.com/%s.git')
+ let uri = printf(fmt, repo)
+ endif
+ return { 'dir': s:dirpath(g:plug_home.'/'.a:name), 'uri': uri }
+ endif
+endfunction
+
+function! s:install(force, names)
+ call s:update_impl(0, a:force, a:names)
+endfunction
+
+function! s:update(force, names)
+ call s:update_impl(1, a:force, a:names)
+endfunction
+
+function! plug#helptags()
+ if !exists('g:plugs')
+ return s:err('plug#begin was not called')
+ endif
+ for spec in values(g:plugs)
+ let docd = join([s:rtp(spec), 'doc'], '/')
+ if isdirectory(docd)
+ silent! execute 'helptags' s:esc(docd)
+ endif
+ endfor
+ return 1
+endfunction
+
+function! s:syntax()
+ syntax clear
+ syntax region plug1 start=/\%1l/ end=/\%2l/ contains=plugNumber
+ syntax region plug2 start=/\%2l/ end=/\%3l/ contains=plugBracket,plugX
+ syn match plugNumber /[0-9]\+[0-9.]*/ contained
+ syn match plugBracket /[[\]]/ contained
+ syn match plugX /x/ contained
+ syn match plugDash /^-/
+ syn match plugPlus /^+/
+ syn match plugStar /^*/
+ syn match plugMessage /\(^- \)\@<=.*/
+ syn match plugName /\(^- \)\@<=[^ ]*:/
+ syn match plugSha /\%(: \)\@<=[0-9a-f]\{4,}$/
+ syn match plugTag /(tag: [^)]\+)/
+ syn match plugInstall /\(^+ \)\@<=[^:]*/
+ syn match plugUpdate /\(^* \)\@<=[^:]*/
+ syn match plugCommit /^ \X*[0-9a-f]\{7,9} .*/ contains=plugRelDate,plugEdge,plugTag
+ syn match plugEdge /^ \X\+$/
+ syn match plugEdge /^ \X*/ contained nextgroup=plugSha
+ syn match plugSha /[0-9a-f]\{7,9}/ contained
+ syn match plugRelDate /([^)]*)$/ contained
+ syn match plugNotLoaded /(not loaded)$/
+ syn match plugError /^x.*/
+ syn region plugDeleted start=/^\~ .*/ end=/^\ze\S/
+ syn match plugH2 /^.*:\n-\+$/
+ syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean
+ hi def link plug1 Title
+ hi def link plug2 Repeat
+ hi def link plugH2 Type
+ hi def link plugX Exception
+ hi def link plugBracket Structure
+ hi def link plugNumber Number
+
+ hi def link plugDash Special
+ hi def link plugPlus Constant
+ hi def link plugStar Boolean
+
+ hi def link plugMessage Function
+ hi def link plugName Label
+ hi def link plugInstall Function
+ hi def link plugUpdate Type
+
+ hi def link plugError Error
+ hi def link plugDeleted Ignore
+ hi def link plugRelDate Comment
+ hi def link plugEdge PreProc
+ hi def link plugSha Identifier
+ hi def link plugTag Constant
+
+ hi def link plugNotLoaded Comment
+endfunction
+
+function! s:lpad(str, len)
+ return a:str . repeat(' ', a:len - len(a:str))
+endfunction
+
+function! s:lines(msg)
+ return split(a:msg, "[\r\n]")
+endfunction
+
+function! s:lastline(msg)
+ return get(s:lines(a:msg), -1, '')
+endfunction
+
+function! s:new_window()
+ execute get(g:, 'plug_window', 'vertical topleft new')
+endfunction
+
+function! s:plug_window_exists()
+ let buflist = tabpagebuflist(s:plug_tab)
+ return !empty(buflist) && index(buflist, s:plug_buf) >= 0
+endfunction
+
+function! s:switch_in()
+ if !s:plug_window_exists()
+ return 0
+ endif
+
+ if winbufnr(0) != s:plug_buf
+ let s:pos = [tabpagenr(), winnr(), winsaveview()]
+ execute 'normal!' s:plug_tab.'gt'
+ let winnr = bufwinnr(s:plug_buf)
+ execute winnr.'wincmd w'
+ call add(s:pos, winsaveview())
+ else
+ let s:pos = [winsaveview()]
+ endif
+
+ setlocal modifiable
+ return 1
+endfunction
+
+function! s:switch_out(...)
+ call winrestview(s:pos[-1])
+ setlocal nomodifiable
+ if a:0 > 0
+ execute a:1
+ endif
+
+ if len(s:pos) > 1
+ execute 'normal!' s:pos[0].'gt'
+ execute s:pos[1] 'wincmd w'
+ call winrestview(s:pos[2])
+ endif
+endfunction
+
+function! s:finish_bindings()
+ nnoremap R :call retry()
+ nnoremap D :PlugDiff
+ nnoremap S :PlugStatus
+ nnoremap U :call status_update()
+ xnoremap U :call status_update()
+ nnoremap ]] :silent! call section('')
+ nnoremap [[ :silent! call section('b')
+endfunction
+
+function! s:prepare(...)
+ if empty(getcwd())
+ throw 'Invalid current working directory. Cannot proceed.'
+ endif
+
+ for evar in ['$GIT_DIR', '$GIT_WORK_TREE']
+ if exists(evar)
+ throw evar.' detected. Cannot proceed.'
+ endif
+ endfor
+
+ call s:job_abort()
+ if s:switch_in()
+ if b:plug_preview == 1
+ pc
+ endif
+ enew
+ else
+ call s:new_window()
+ endif
+
+ nnoremap q :if b:plug_preview==1pcendifbd
+ if a:0 == 0
+ call s:finish_bindings()
+ endif
+ let b:plug_preview = -1
+ let s:plug_tab = tabpagenr()
+ let s:plug_buf = winbufnr(0)
+ call s:assign_name()
+
+ for k in ['', 'L', 'o', 'X', 'd', 'dd']
+ execute 'silent! unmap ' k
+ endfor
+ setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline modifiable nospell
+ setf vim-plug
+ if exists('g:syntax_on')
+ call s:syntax()
+ endif
+endfunction
+
+function! s:assign_name()
+ " Assign buffer name
+ let prefix = '[Plugins]'
+ let name = prefix
+ let idx = 2
+ while bufexists(name)
+ let name = printf('%s (%s)', prefix, idx)
+ let idx = idx + 1
+ endwhile
+ silent! execute 'f' fnameescape(name)
+endfunction
+
+function! s:chsh(swap)
+ let prev = [&shell, &shellcmdflag, &shellredir]
+ if s:is_win
+ set shell=cmd.exe shellcmdflag=/c shellredir=>%s\ 2>&1
+ elseif a:swap
+ set shell=sh shellredir=>%s\ 2>&1
+ endif
+ return prev
+endfunction
+
+function! s:bang(cmd, ...)
+ try
+ let [sh, shellcmdflag, shrd] = s:chsh(a:0)
+ " FIXME: Escaping is incomplete. We could use shellescape with eval,
+ " but it won't work on Windows.
+ let cmd = a:0 ? s:with_cd(a:cmd, a:1) : a:cmd
+ if s:is_win
+ let batchfile = tempname().'.bat'
+ call writefile(["@echo off\r", cmd . "\r"], batchfile)
+ let cmd = batchfile
+ endif
+ let g:_plug_bang = (s:is_win && has('gui_running') ? 'silent ' : '').'!'.escape(cmd, '#!%')
+ execute "normal! :execute g:_plug_bang\\"
+ finally
+ unlet g:_plug_bang
+ let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
+ if s:is_win
+ call delete(batchfile)
+ endif
+ endtry
+ return v:shell_error ? 'Exit status: ' . v:shell_error : ''
+endfunction
+
+function! s:regress_bar()
+ let bar = substitute(getline(2)[1:-2], '.*\zs=', 'x', '')
+ call s:progress_bar(2, bar, len(bar))
+endfunction
+
+function! s:is_updated(dir)
+ return !empty(s:system_chomp('git log --pretty=format:"%h" "HEAD...HEAD@{1}"', a:dir))
+endfunction
+
+function! s:do(pull, force, todo)
+ for [name, spec] in items(a:todo)
+ if !isdirectory(spec.dir)
+ continue
+ endif
+ let installed = has_key(s:update.new, name)
+ let updated = installed ? 0 :
+ \ (a:pull && index(s:update.errors, name) < 0 && s:is_updated(spec.dir))
+ if a:force || installed || updated
+ execute 'cd' s:esc(spec.dir)
+ call append(3, '- Post-update hook for '. name .' ... ')
+ let error = ''
+ let type = type(spec.do)
+ if type == s:TYPE.string
+ if spec.do[0] == ':'
+ if !get(s:loaded, name, 0)
+ let s:loaded[name] = 1
+ call s:reorg_rtp()
+ endif
+ call s:load_plugin(spec)
+ try
+ execute spec.do[1:]
+ catch
+ let error = v:exception
+ endtry
+ if !s:plug_window_exists()
+ cd -
+ throw 'Warning: vim-plug was terminated by the post-update hook of '.name
+ endif
+ else
+ let error = s:bang(spec.do)
+ endif
+ elseif type == s:TYPE.funcref
+ try
+ let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged')
+ call spec.do({ 'name': name, 'status': status, 'force': a:force })
+ catch
+ let error = v:exception
+ endtry
+ else
+ let error = 'Invalid hook type'
+ endif
+ call s:switch_in()
+ call setline(4, empty(error) ? (getline(4) . 'OK')
+ \ : ('x' . getline(4)[1:] . error))
+ if !empty(error)
+ call add(s:update.errors, name)
+ call s:regress_bar()
+ endif
+ cd -
+ endif
+ endfor
+endfunction
+
+function! s:hash_match(a, b)
+ return stridx(a:a, a:b) == 0 || stridx(a:b, a:a) == 0
+endfunction
+
+function! s:checkout(spec)
+ let sha = a:spec.commit
+ let output = s:system('git rev-parse HEAD', a:spec.dir)
+ if !v:shell_error && !s:hash_match(sha, s:lines(output)[0])
+ let output = s:system(
+ \ 'git fetch --depth 999999 && git checkout '.s:esc(sha).' --', a:spec.dir)
+ endif
+ return output
+endfunction
+
+function! s:finish(pull)
+ let new_frozen = len(filter(keys(s:update.new), 'g:plugs[v:val].frozen'))
+ if new_frozen
+ let s = new_frozen > 1 ? 's' : ''
+ call append(3, printf('- Installed %d frozen plugin%s', new_frozen, s))
+ endif
+ call append(3, '- Finishing ... ') | 4
+ redraw
+ call plug#helptags()
+ call plug#end()
+ call setline(4, getline(4) . 'Done!')
+ redraw
+ let msgs = []
+ if !empty(s:update.errors)
+ call add(msgs, "Press 'R' to retry.")
+ endif
+ if a:pull && len(s:update.new) < len(filter(getline(5, '$'),
+ \ "v:val =~ '^- ' && v:val !~# 'Already up.to.date'"))
+ call add(msgs, "Press 'D' to see the updated changes.")
+ endif
+ echo join(msgs, ' ')
+ call s:finish_bindings()
+endfunction
+
+function! s:retry()
+ if empty(s:update.errors)
+ return
+ endif
+ echo
+ call s:update_impl(s:update.pull, s:update.force,
+ \ extend(copy(s:update.errors), [s:update.threads]))
+endfunction
+
+function! s:is_managed(name)
+ return has_key(g:plugs[a:name], 'uri')
+endfunction
+
+function! s:names(...)
+ return sort(filter(keys(g:plugs), 'stridx(v:val, a:1) == 0 && s:is_managed(v:val)'))
+endfunction
+
+function! s:check_ruby()
+ silent! ruby require 'thread'; VIM::command("let g:plug_ruby = '#{RUBY_VERSION}'")
+ if !exists('g:plug_ruby')
+ redraw!
+ return s:warn('echom', 'Warning: Ruby interface is broken')
+ endif
+ let ruby_version = split(g:plug_ruby, '\.')
+ unlet g:plug_ruby
+ return s:version_requirement(ruby_version, [1, 8, 7])
+endfunction
+
+function! s:update_impl(pull, force, args) abort
+ let sync = index(a:args, '--sync') >= 0 || has('vim_starting')
+ let args = filter(copy(a:args), 'v:val != "--sync"')
+ let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ?
+ \ remove(args, -1) : get(g:, 'plug_threads', 16)
+
+ let managed = filter(copy(g:plugs), 's:is_managed(v:key)')
+ let todo = empty(args) ? filter(managed, '!v:val.frozen || !isdirectory(v:val.dir)') :
+ \ filter(managed, 'index(args, v:key) >= 0')
+
+ if empty(todo)
+ return s:warn('echo', 'No plugin to '. (a:pull ? 'update' : 'install'))
+ endif
+
+ if !s:is_win && s:git_version_requirement(2, 3)
+ let s:git_terminal_prompt = exists('$GIT_TERMINAL_PROMPT') ? $GIT_TERMINAL_PROMPT : ''
+ let $GIT_TERMINAL_PROMPT = 0
+ for plug in values(todo)
+ let plug.uri = substitute(plug.uri,
+ \ '^https://git::@github\.com', 'https://github.com', '')
+ endfor
+ endif
+
+ if !isdirectory(g:plug_home)
+ try
+ call mkdir(g:plug_home, 'p')
+ catch
+ return s:err(printf('Invalid plug directory: %s. '.
+ \ 'Try to call plug#begin with a valid directory', g:plug_home))
+ endtry
+ endif
+
+ if has('nvim') && !exists('*jobwait') && threads > 1
+ call s:warn('echom', '[vim-plug] Update Neovim for parallel installer')
+ endif
+
+ let use_job = s:nvim || s:vim8
+ let python = (has('python') || has('python3')) && !use_job
+ let ruby = has('ruby') && !use_job && (v:version >= 703 || v:version == 702 && has('patch374')) && !(s:is_win && has('gui_running')) && threads > 1 && s:check_ruby()
+
+ let s:update = {
+ \ 'start': reltime(),
+ \ 'all': todo,
+ \ 'todo': copy(todo),
+ \ 'errors': [],
+ \ 'pull': a:pull,
+ \ 'force': a:force,
+ \ 'new': {},
+ \ 'threads': (python || ruby || use_job) ? min([len(todo), threads]) : 1,
+ \ 'bar': '',
+ \ 'fin': 0
+ \ }
+
+ call s:prepare(1)
+ call append(0, ['', ''])
+ normal! 2G
+ silent! redraw
+
+ let s:clone_opt = get(g:, 'plug_shallow', 1) ?
+ \ '--depth 1' . (s:git_version_requirement(1, 7, 10) ? ' --no-single-branch' : '') : ''
+
+ if has('win32unix')
+ let s:clone_opt .= ' -c core.eol=lf -c core.autocrlf=input'
+ endif
+
+ " Python version requirement (>= 2.7)
+ if python && !has('python3') && !ruby && !use_job && s:update.threads > 1
+ redir => pyv
+ silent python import platform; print platform.python_version()
+ redir END
+ let python = s:version_requirement(
+ \ map(split(split(pyv)[0], '\.'), 'str2nr(v:val)'), [2, 6])
+ endif
+
+ if (python || ruby) && s:update.threads > 1
+ try
+ let imd = &imd
+ if s:mac_gui
+ set noimd
+ endif
+ if ruby
+ call s:update_ruby()
+ else
+ call s:update_python()
+ endif
+ catch
+ let lines = getline(4, '$')
+ let printed = {}
+ silent! 4,$d _
+ for line in lines
+ let name = s:extract_name(line, '.', '')
+ if empty(name) || !has_key(printed, name)
+ call append('$', line)
+ if !empty(name)
+ let printed[name] = 1
+ if line[0] == 'x' && index(s:update.errors, name) < 0
+ call add(s:update.errors, name)
+ end
+ endif
+ endif
+ endfor
+ finally
+ let &imd = imd
+ call s:update_finish()
+ endtry
+ else
+ call s:update_vim()
+ while use_job && sync
+ sleep 100m
+ if s:update.fin
+ break
+ endif
+ endwhile
+ endif
+endfunction
+
+function! s:log4(name, msg)
+ call setline(4, printf('- %s (%s)', a:msg, a:name))
+ redraw
+endfunction
+
+function! s:update_finish()
+ if exists('s:git_terminal_prompt')
+ let $GIT_TERMINAL_PROMPT = s:git_terminal_prompt
+ endif
+ if s:switch_in()
+ call append(3, '- Updating ...') | 4
+ for [name, spec] in items(filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && (s:update.force || s:update.pull || has_key(s:update.new, v:key))'))
+ let [pos, _] = s:logpos(name)
+ if !pos
+ continue
+ endif
+ if has_key(spec, 'commit')
+ call s:log4(name, 'Checking out '.spec.commit)
+ let out = s:checkout(spec)
+ elseif has_key(spec, 'tag')
+ let tag = spec.tag
+ if tag =~ '\*'
+ let tags = s:lines(s:system('git tag --list '.s:shellesc(tag).' --sort -version:refname 2>&1', spec.dir))
+ if !v:shell_error && !empty(tags)
+ let tag = tags[0]
+ call s:log4(name, printf('Latest tag for %s -> %s', spec.tag, tag))
+ call append(3, '')
+ endif
+ endif
+ call s:log4(name, 'Checking out '.tag)
+ let out = s:system('git checkout -q '.s:esc(tag).' -- 2>&1', spec.dir)
+ else
+ let branch = s:esc(get(spec, 'branch', 'master'))
+ call s:log4(name, 'Merging origin/'.branch)
+ let out = s:system('git checkout -q '.branch.' -- 2>&1'
+ \. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only origin/'.branch.' 2>&1')), spec.dir)
+ endif
+ if !v:shell_error && filereadable(spec.dir.'/.gitmodules') &&
+ \ (s:update.force || has_key(s:update.new, name) || s:is_updated(spec.dir))
+ call s:log4(name, 'Updating submodules. This may take a while.')
+ let out .= s:bang('git submodule update --init --recursive 2>&1', spec.dir)
+ endif
+ let msg = s:format_message(v:shell_error ? 'x': '-', name, out)
+ if v:shell_error
+ call add(s:update.errors, name)
+ call s:regress_bar()
+ silent execute pos 'd _'
+ call append(4, msg) | 4
+ elseif !empty(out)
+ call setline(pos, msg[0])
+ endif
+ redraw
+ endfor
+ silent 4 d _
+ try
+ call s:do(s:update.pull, s:update.force, filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && has_key(v:val, "do")'))
+ catch
+ call s:warn('echom', v:exception)
+ call s:warn('echo', '')
+ return
+ endtry
+ call s:finish(s:update.pull)
+ call setline(1, 'Updated. Elapsed time: ' . split(reltimestr(reltime(s:update.start)))[0] . ' sec.')
+ call s:switch_out('normal! gg')
+ endif
+endfunction
+
+function! s:job_abort()
+ if (!s:nvim && !s:vim8) || !exists('s:jobs')
+ return
+ endif
+
+ for [name, j] in items(s:jobs)
+ if s:nvim
+ silent! call jobstop(j.jobid)
+ elseif s:vim8
+ silent! call job_stop(j.jobid)
+ endif
+ if j.new
+ call s:system('rm -rf ' . s:shellesc(g:plugs[name].dir))
+ endif
+ endfor
+ let s:jobs = {}
+endfunction
+
+function! s:last_non_empty_line(lines)
+ let len = len(a:lines)
+ for idx in range(len)
+ let line = a:lines[len-idx-1]
+ if !empty(line)
+ return line
+ endif
+ endfor
+ return ''
+endfunction
+
+function! s:job_out_cb(self, data) abort
+ let self = a:self
+ let data = remove(self.lines, -1) . a:data
+ let lines = map(split(data, "\n", 1), 'split(v:val, "\r", 1)[-1]')
+ call extend(self.lines, lines)
+ " To reduce the number of buffer updates
+ let self.tick = get(self, 'tick', -1) + 1
+ if !self.running || self.tick % len(s:jobs) == 0
+ let bullet = self.running ? (self.new ? '+' : '*') : (self.error ? 'x' : '-')
+ let result = self.error ? join(self.lines, "\n") : s:last_non_empty_line(self.lines)
+ call s:log(bullet, self.name, result)
+ endif
+endfunction
+
+function! s:job_exit_cb(self, data) abort
+ let a:self.running = 0
+ let a:self.error = a:data != 0
+ call s:reap(a:self.name)
+ call s:tick()
+endfunction
+
+function! s:job_cb(fn, job, ch, data)
+ if !s:plug_window_exists() " plug window closed
+ return s:job_abort()
+ endif
+ call call(a:fn, [a:job, a:data])
+endfunction
+
+function! s:nvim_cb(job_id, data, event) dict abort
+ return a:event == 'stdout' ?
+ \ s:job_cb('s:job_out_cb', self, 0, join(a:data, "\n")) :
+ \ s:job_cb('s:job_exit_cb', self, 0, a:data)
+endfunction
+
+function! s:spawn(name, cmd, opts)
+ let job = { 'name': a:name, 'running': 1, 'error': 0, 'lines': [''],
+ \ 'batchfile': (s:is_win && (s:nvim || s:vim8)) ? tempname().'.bat' : '',
+ \ 'new': get(a:opts, 'new', 0) }
+ let s:jobs[a:name] = job
+ let cmd = has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd
+ if !empty(job.batchfile)
+ call writefile(["@echo off\r", cmd . "\r"], job.batchfile)
+ let cmd = job.batchfile
+ endif
+ let argv = add(s:is_win ? ['cmd', '/c'] : ['sh', '-c'], cmd)
+
+ if s:nvim
+ call extend(job, {
+ \ 'on_stdout': function('s:nvim_cb'),
+ \ 'on_exit': function('s:nvim_cb'),
+ \ })
+ let jid = jobstart(argv, job)
+ if jid > 0
+ let job.jobid = jid
+ else
+ let job.running = 0
+ let job.error = 1
+ let job.lines = [jid < 0 ? argv[0].' is not executable' :
+ \ 'Invalid arguments (or job table is full)']
+ endif
+ elseif s:vim8
+ let jid = job_start(s:is_win ? join(argv, ' ') : argv, {
+ \ 'out_cb': function('s:job_cb', ['s:job_out_cb', job]),
+ \ 'exit_cb': function('s:job_cb', ['s:job_exit_cb', job]),
+ \ 'out_mode': 'raw'
+ \})
+ if job_status(jid) == 'run'
+ let job.jobid = jid
+ else
+ let job.running = 0
+ let job.error = 1
+ let job.lines = ['Failed to start job']
+ endif
+ else
+ let job.lines = s:lines(call('s:system', [cmd]))
+ let job.error = v:shell_error != 0
+ let job.running = 0
+ endif
+endfunction
+
+function! s:reap(name)
+ let job = s:jobs[a:name]
+ if job.error
+ call add(s:update.errors, a:name)
+ elseif get(job, 'new', 0)
+ let s:update.new[a:name] = 1
+ endif
+ let s:update.bar .= job.error ? 'x' : '='
+
+ let bullet = job.error ? 'x' : '-'
+ let result = job.error ? join(job.lines, "\n") : s:last_non_empty_line(job.lines)
+ call s:log(bullet, a:name, empty(result) ? 'OK' : result)
+ call s:bar()
+
+ if has_key(job, 'batchfile') && !empty(job.batchfile)
+ call delete(job.batchfile)
+ endif
+ call remove(s:jobs, a:name)
+endfunction
+
+function! s:bar()
+ if s:switch_in()
+ let total = len(s:update.all)
+ call setline(1, (s:update.pull ? 'Updating' : 'Installing').
+ \ ' plugins ('.len(s:update.bar).'/'.total.')')
+ call s:progress_bar(2, s:update.bar, total)
+ call s:switch_out()
+ endif
+endfunction
+
+function! s:logpos(name)
+ for i in range(4, line('$'))
+ if getline(i) =~# '^[-+x*] '.a:name.':'
+ for j in range(i + 1, line('$'))
+ if getline(j) !~ '^ '
+ return [i, j - 1]
+ endif
+ endfor
+ return [i, i]
+ endif
+ endfor
+ return [0, 0]
+endfunction
+
+function! s:log(bullet, name, lines)
+ if s:switch_in()
+ let [b, e] = s:logpos(a:name)
+ if b > 0
+ silent execute printf('%d,%d d _', b, e)
+ if b > winheight('.')
+ let b = 4
+ endif
+ else
+ let b = 4
+ endif
+ " FIXME For some reason, nomodifiable is set after :d in vim8
+ setlocal modifiable
+ call append(b - 1, s:format_message(a:bullet, a:name, a:lines))
+ call s:switch_out()
+ endif
+endfunction
+
+function! s:update_vim()
+ let s:jobs = {}
+
+ call s:bar()
+ call s:tick()
+endfunction
+
+function! s:tick()
+ let pull = s:update.pull
+ let prog = s:progress_opt(s:nvim || s:vim8)
+while 1 " Without TCO, Vim stack is bound to explode
+ if empty(s:update.todo)
+ if empty(s:jobs) && !s:update.fin
+ call s:update_finish()
+ let s:update.fin = 1
+ endif
+ return
+ endif
+
+ let name = keys(s:update.todo)[0]
+ let spec = remove(s:update.todo, name)
+ let new = !isdirectory(spec.dir)
+
+ call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...')
+ redraw
+
+ let has_tag = has_key(spec, 'tag')
+ if !new
+ let [error, _] = s:git_validate(spec, 0)
+ if empty(error)
+ if pull
+ let fetch_opt = (has_tag && !empty(globpath(spec.dir, '.git/shallow'))) ? '--depth 99999999' : ''
+ call s:spawn(name, printf('git fetch %s %s 2>&1', fetch_opt, prog), { 'dir': spec.dir })
+ else
+ let s:jobs[name] = { 'running': 0, 'lines': ['Already installed'], 'error': 0 }
+ endif
+ else
+ let s:jobs[name] = { 'running': 0, 'lines': s:lines(error), 'error': 1 }
+ endif
+ else
+ call s:spawn(name,
+ \ printf('git clone %s %s %s %s 2>&1',
+ \ has_tag ? '' : s:clone_opt,
+ \ prog,
+ \ s:shellesc(spec.uri),
+ \ s:shellesc(s:trim(spec.dir))), { 'new': 1 })
+ endif
+
+ if !s:jobs[name].running
+ call s:reap(name)
+ endif
+ if len(s:jobs) >= s:update.threads
+ break
+ endif
+endwhile
+endfunction
+
+function! s:update_python()
+let py_exe = has('python') ? 'python' : 'python3'
+execute py_exe "<< EOF"
+import datetime
+import functools
+import os
+try:
+ import queue
+except ImportError:
+ import Queue as queue
+import random
+import re
+import shutil
+import signal
+import subprocess
+import tempfile
+import threading as thr
+import time
+import traceback
+import vim
+
+G_NVIM = vim.eval("has('nvim')") == '1'
+G_PULL = vim.eval('s:update.pull') == '1'
+G_RETRIES = int(vim.eval('get(g:, "plug_retries", 2)')) + 1
+G_TIMEOUT = int(vim.eval('get(g:, "plug_timeout", 60)'))
+G_CLONE_OPT = vim.eval('s:clone_opt')
+G_PROGRESS = vim.eval('s:progress_opt(1)')
+G_LOG_PROB = 1.0 / int(vim.eval('s:update.threads'))
+G_STOP = thr.Event()
+G_IS_WIN = vim.eval('s:is_win') == '1'
+
+class PlugError(Exception):
+ def __init__(self, msg):
+ self.msg = msg
+class CmdTimedOut(PlugError):
+ pass
+class CmdFailed(PlugError):
+ pass
+class InvalidURI(PlugError):
+ pass
+class Action(object):
+ INSTALL, UPDATE, ERROR, DONE = ['+', '*', 'x', '-']
+
+class Buffer(object):
+ def __init__(self, lock, num_plugs, is_pull):
+ self.bar = ''
+ self.event = 'Updating' if is_pull else 'Installing'
+ self.lock = lock
+ self.maxy = int(vim.eval('winheight(".")'))
+ self.num_plugs = num_plugs
+
+ def __where(self, name):
+ """ Find first line with name in current buffer. Return line num. """
+ found, lnum = False, 0
+ matcher = re.compile('^[-+x*] {0}:'.format(name))
+ for line in vim.current.buffer:
+ if matcher.search(line) is not None:
+ found = True
+ break
+ lnum += 1
+
+ if not found:
+ lnum = -1
+ return lnum
+
+ def header(self):
+ curbuf = vim.current.buffer
+ curbuf[0] = self.event + ' plugins ({0}/{1})'.format(len(self.bar), self.num_plugs)
+
+ num_spaces = self.num_plugs - len(self.bar)
+ curbuf[1] = '[{0}{1}]'.format(self.bar, num_spaces * ' ')
+
+ with self.lock:
+ vim.command('normal! 2G')
+ vim.command('redraw')
+
+ def write(self, action, name, lines):
+ first, rest = lines[0], lines[1:]
+ msg = ['{0} {1}{2}{3}'.format(action, name, ': ' if first else '', first)]
+ msg.extend([' ' + line for line in rest])
+
+ try:
+ if action == Action.ERROR:
+ self.bar += 'x'
+ vim.command("call add(s:update.errors, '{0}')".format(name))
+ elif action == Action.DONE:
+ self.bar += '='
+
+ curbuf = vim.current.buffer
+ lnum = self.__where(name)
+ if lnum != -1: # Found matching line num
+ del curbuf[lnum]
+ if lnum > self.maxy and action in set([Action.INSTALL, Action.UPDATE]):
+ lnum = 3
+ else:
+ lnum = 3
+ curbuf.append(msg, lnum)
+
+ self.header()
+ except vim.error:
+ pass
+
+class Command(object):
+ CD = 'cd /d' if G_IS_WIN else 'cd'
+
+ def __init__(self, cmd, cmd_dir=None, timeout=60, cb=None, clean=None):
+ self.cmd = cmd
+ if cmd_dir:
+ self.cmd = '{0} {1} && {2}'.format(Command.CD, cmd_dir, self.cmd)
+ self.timeout = timeout
+ self.callback = cb if cb else (lambda msg: None)
+ self.clean = clean if clean else (lambda: None)
+ self.proc = None
+
+ @property
+ def alive(self):
+ """ Returns true only if command still running. """
+ return self.proc and self.proc.poll() is None
+
+ def execute(self, ntries=3):
+ """ Execute the command with ntries if CmdTimedOut.
+ Returns the output of the command if no Exception.
+ """
+ attempt, finished, limit = 0, False, self.timeout
+
+ while not finished:
+ try:
+ attempt += 1
+ result = self.try_command()
+ finished = True
+ return result
+ except CmdTimedOut:
+ if attempt != ntries:
+ self.notify_retry()
+ self.timeout += limit
+ else:
+ raise
+
+ def notify_retry(self):
+ """ Retry required for command, notify user. """
+ for count in range(3, 0, -1):
+ if G_STOP.is_set():
+ raise KeyboardInterrupt
+ msg = 'Timeout. Will retry in {0} second{1} ...'.format(
+ count, 's' if count != 1 else '')
+ self.callback([msg])
+ time.sleep(1)
+ self.callback(['Retrying ...'])
+
+ def try_command(self):
+ """ Execute a cmd & poll for callback. Returns list of output.
+ Raises CmdFailed -> return code for Popen isn't 0
+ Raises CmdTimedOut -> command exceeded timeout without new output
+ """
+ first_line = True
+
+ try:
+ tfile = tempfile.NamedTemporaryFile(mode='w+b')
+ preexec_fn = not G_IS_WIN and os.setsid or None
+ self.proc = subprocess.Popen(self.cmd, stdout=tfile,
+ stderr=subprocess.STDOUT,
+ stdin=subprocess.PIPE, shell=True,
+ preexec_fn=preexec_fn)
+ thrd = thr.Thread(target=(lambda proc: proc.wait()), args=(self.proc,))
+ thrd.start()
+
+ thread_not_started = True
+ while thread_not_started:
+ try:
+ thrd.join(0.1)
+ thread_not_started = False
+ except RuntimeError:
+ pass
+
+ while self.alive:
+ if G_STOP.is_set():
+ raise KeyboardInterrupt
+
+ if first_line or random.random() < G_LOG_PROB:
+ first_line = False
+ line = '' if G_IS_WIN else nonblock_read(tfile.name)
+ if line:
+ self.callback([line])
+
+ time_diff = time.time() - os.path.getmtime(tfile.name)
+ if time_diff > self.timeout:
+ raise CmdTimedOut(['Timeout!'])
+
+ thrd.join(0.5)
+
+ tfile.seek(0)
+ result = [line.decode('utf-8', 'replace').rstrip() for line in tfile]
+
+ if self.proc.returncode != 0:
+ raise CmdFailed([''] + result)
+
+ return result
+ except:
+ self.terminate()
+ raise
+
+ def terminate(self):
+ """ Terminate process and cleanup. """
+ if self.alive:
+ if G_IS_WIN:
+ os.kill(self.proc.pid, signal.SIGINT)
+ else:
+ os.killpg(self.proc.pid, signal.SIGTERM)
+ self.clean()
+
+class Plugin(object):
+ def __init__(self, name, args, buf_q, lock):
+ self.name = name
+ self.args = args
+ self.buf_q = buf_q
+ self.lock = lock
+ self.tag = args.get('tag', 0)
+
+ def manage(self):
+ try:
+ if os.path.exists(self.args['dir']):
+ self.update()
+ else:
+ self.install()
+ with self.lock:
+ thread_vim_command("let s:update.new['{0}'] = 1".format(self.name))
+ except PlugError as exc:
+ self.write(Action.ERROR, self.name, exc.msg)
+ except KeyboardInterrupt:
+ G_STOP.set()
+ self.write(Action.ERROR, self.name, ['Interrupted!'])
+ except:
+ # Any exception except those above print stack trace
+ msg = 'Trace:\n{0}'.format(traceback.format_exc().rstrip())
+ self.write(Action.ERROR, self.name, msg.split('\n'))
+ raise
+
+ def install(self):
+ target = self.args['dir']
+ if target[-1] == '\\':
+ target = target[0:-1]
+
+ def clean(target):
+ def _clean():
+ try:
+ shutil.rmtree(target)
+ except OSError:
+ pass
+ return _clean
+
+ self.write(Action.INSTALL, self.name, ['Installing ...'])
+ callback = functools.partial(self.write, Action.INSTALL, self.name)
+ cmd = 'git clone {0} {1} {2} {3} 2>&1'.format(
+ '' if self.tag else G_CLONE_OPT, G_PROGRESS, self.args['uri'],
+ esc(target))
+ com = Command(cmd, None, G_TIMEOUT, callback, clean(target))
+ result = com.execute(G_RETRIES)
+ self.write(Action.DONE, self.name, result[-1:])
+
+ def repo_uri(self):
+ cmd = 'git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url'
+ command = Command(cmd, self.args['dir'], G_TIMEOUT,)
+ result = command.execute(G_RETRIES)
+ return result[-1]
+
+ def update(self):
+ actual_uri = self.repo_uri()
+ expect_uri = self.args['uri']
+ regex = re.compile(r'^(?:\w+://)?(?:[^@/]*@)?([^:/]*(?::[0-9]*)?)[:/](.*?)(?:\.git)?/?$')
+ ma = regex.match(actual_uri)
+ mb = regex.match(expect_uri)
+ if ma is None or mb is None or ma.groups() != mb.groups():
+ msg = ['',
+ 'Invalid URI: {0}'.format(actual_uri),
+ 'Expected {0}'.format(expect_uri),
+ 'PlugClean required.']
+ raise InvalidURI(msg)
+
+ if G_PULL:
+ self.write(Action.UPDATE, self.name, ['Updating ...'])
+ callback = functools.partial(self.write, Action.UPDATE, self.name)
+ fetch_opt = '--depth 99999999' if self.tag and os.path.isfile(os.path.join(self.args['dir'], '.git/shallow')) else ''
+ cmd = 'git fetch {0} {1} 2>&1'.format(fetch_opt, G_PROGRESS)
+ com = Command(cmd, self.args['dir'], G_TIMEOUT, callback)
+ result = com.execute(G_RETRIES)
+ self.write(Action.DONE, self.name, result[-1:])
+ else:
+ self.write(Action.DONE, self.name, ['Already installed'])
+
+ def write(self, action, name, msg):
+ self.buf_q.put((action, name, msg))
+
+class PlugThread(thr.Thread):
+ def __init__(self, tname, args):
+ super(PlugThread, self).__init__()
+ self.tname = tname
+ self.args = args
+
+ def run(self):
+ thr.current_thread().name = self.tname
+ buf_q, work_q, lock = self.args
+
+ try:
+ while not G_STOP.is_set():
+ name, args = work_q.get_nowait()
+ plug = Plugin(name, args, buf_q, lock)
+ plug.manage()
+ work_q.task_done()
+ except queue.Empty:
+ pass
+
+class RefreshThread(thr.Thread):
+ def __init__(self, lock):
+ super(RefreshThread, self).__init__()
+ self.lock = lock
+ self.running = True
+
+ def run(self):
+ while self.running:
+ with self.lock:
+ thread_vim_command('noautocmd normal! a')
+ time.sleep(0.33)
+
+ def stop(self):
+ self.running = False
+
+if G_NVIM:
+ def thread_vim_command(cmd):
+ vim.session.threadsafe_call(lambda: vim.command(cmd))
+else:
+ def thread_vim_command(cmd):
+ vim.command(cmd)
+
+def esc(name):
+ return '"' + name.replace('"', '\"') + '"'
+
+def nonblock_read(fname):
+ """ Read a file with nonblock flag. Return the last line. """
+ fread = os.open(fname, os.O_RDONLY | os.O_NONBLOCK)
+ buf = os.read(fread, 100000).decode('utf-8', 'replace')
+ os.close(fread)
+
+ line = buf.rstrip('\r\n')
+ left = max(line.rfind('\r'), line.rfind('\n'))
+ if left != -1:
+ left += 1
+ line = line[left:]
+
+ return line
+
+def main():
+ thr.current_thread().name = 'main'
+ nthreads = int(vim.eval('s:update.threads'))
+ plugs = vim.eval('s:update.todo')
+ mac_gui = vim.eval('s:mac_gui') == '1'
+
+ lock = thr.Lock()
+ buf = Buffer(lock, len(plugs), G_PULL)
+ buf_q, work_q = queue.Queue(), queue.Queue()
+ for work in plugs.items():
+ work_q.put(work)
+
+ start_cnt = thr.active_count()
+ for num in range(nthreads):
+ tname = 'PlugT-{0:02}'.format(num)
+ thread = PlugThread(tname, (buf_q, work_q, lock))
+ thread.start()
+ if mac_gui:
+ rthread = RefreshThread(lock)
+ rthread.start()
+
+ while not buf_q.empty() or thr.active_count() != start_cnt:
+ try:
+ action, name, msg = buf_q.get(True, 0.25)
+ buf.write(action, name, ['OK'] if not msg else msg)
+ buf_q.task_done()
+ except queue.Empty:
+ pass
+ except KeyboardInterrupt:
+ G_STOP.set()
+
+ if mac_gui:
+ rthread.stop()
+ rthread.join()
+
+main()
+EOF
+endfunction
+
+function! s:update_ruby()
+ ruby << EOF
+ module PlugStream
+ SEP = ["\r", "\n", nil]
+ def get_line
+ buffer = ''
+ loop do
+ char = readchar rescue return
+ if SEP.include? char.chr
+ buffer << $/
+ break
+ else
+ buffer << char
+ end
+ end
+ buffer
+ end
+ end unless defined?(PlugStream)
+
+ def esc arg
+ %["#{arg.gsub('"', '\"')}"]
+ end
+
+ def killall pid
+ pids = [pid]
+ if /mswin|mingw|bccwin/ =~ RUBY_PLATFORM
+ pids.each { |pid| Process.kill 'INT', pid.to_i rescue nil }
+ else
+ unless `which pgrep 2> /dev/null`.empty?
+ children = pids
+ until children.empty?
+ children = children.map { |pid|
+ `pgrep -P #{pid}`.lines.map { |l| l.chomp }
+ }.flatten
+ pids += children
+ end
+ end
+ pids.each { |pid| Process.kill 'TERM', pid.to_i rescue nil }
+ end
+ end
+
+ def compare_git_uri a, b
+ regex = %r{^(?:\w+://)?(?:[^@/]*@)?([^:/]*(?::[0-9]*)?)[:/](.*?)(?:\.git)?/?$}
+ regex.match(a).to_a.drop(1) == regex.match(b).to_a.drop(1)
+ end
+
+ require 'thread'
+ require 'fileutils'
+ require 'timeout'
+ running = true
+ iswin = VIM::evaluate('s:is_win').to_i == 1
+ pull = VIM::evaluate('s:update.pull').to_i == 1
+ base = VIM::evaluate('g:plug_home')
+ all = VIM::evaluate('s:update.todo')
+ limit = VIM::evaluate('get(g:, "plug_timeout", 60)')
+ tries = VIM::evaluate('get(g:, "plug_retries", 2)') + 1
+ nthr = VIM::evaluate('s:update.threads').to_i
+ maxy = VIM::evaluate('winheight(".")').to_i
+ vim7 = VIM::evaluate('v:version').to_i <= 703 && RUBY_PLATFORM =~ /darwin/
+ cd = iswin ? 'cd /d' : 'cd'
+ tot = VIM::evaluate('len(s:update.todo)') || 0
+ bar = ''
+ skip = 'Already installed'
+ mtx = Mutex.new
+ take1 = proc { mtx.synchronize { running && all.shift } }
+ logh = proc {
+ cnt = bar.length
+ $curbuf[1] = "#{pull ? 'Updating' : 'Installing'} plugins (#{cnt}/#{tot})"
+ $curbuf[2] = '[' + bar.ljust(tot) + ']'
+ VIM::command('normal! 2G')
+ VIM::command('redraw')
+ }
+ where = proc { |name| (1..($curbuf.length)).find { |l| $curbuf[l] =~ /^[-+x*] #{name}:/ } }
+ log = proc { |name, result, type|
+ mtx.synchronize do
+ ing = ![true, false].include?(type)
+ bar += type ? '=' : 'x' unless ing
+ b = case type
+ when :install then '+' when :update then '*'
+ when true, nil then '-' else
+ VIM::command("call add(s:update.errors, '#{name}')")
+ 'x'
+ end
+ result =
+ if type || type.nil?
+ ["#{b} #{name}: #{result.lines.to_a.last || 'OK'}"]
+ elsif result =~ /^Interrupted|^Timeout/
+ ["#{b} #{name}: #{result}"]
+ else
+ ["#{b} #{name}"] + result.lines.map { |l| " " << l }
+ end
+ if lnum = where.call(name)
+ $curbuf.delete lnum
+ lnum = 4 if ing && lnum > maxy
+ end
+ result.each_with_index do |line, offset|
+ $curbuf.append((lnum || 4) - 1 + offset, line.gsub(/\e\[./, '').chomp)
+ end
+ logh.call
+ end
+ }
+ bt = proc { |cmd, name, type, cleanup|
+ tried = timeout = 0
+ begin
+ tried += 1
+ timeout += limit
+ fd = nil
+ data = ''
+ if iswin
+ Timeout::timeout(timeout) do
+ tmp = VIM::evaluate('tempname()')
+ system("(#{cmd}) > #{tmp}")
+ data = File.read(tmp).chomp
+ File.unlink tmp rescue nil
+ end
+ else
+ fd = IO.popen(cmd).extend(PlugStream)
+ first_line = true
+ log_prob = 1.0 / nthr
+ while line = Timeout::timeout(timeout) { fd.get_line }
+ data << line
+ log.call name, line.chomp, type if name && (first_line || rand < log_prob)
+ first_line = false
+ end
+ fd.close
+ end
+ [$? == 0, data.chomp]
+ rescue Timeout::Error, Interrupt => e
+ if fd && !fd.closed?
+ killall fd.pid
+ fd.close
+ end
+ cleanup.call if cleanup
+ if e.is_a?(Timeout::Error) && tried < tries
+ 3.downto(1) do |countdown|
+ s = countdown > 1 ? 's' : ''
+ log.call name, "Timeout. Will retry in #{countdown} second#{s} ...", type
+ sleep 1
+ end
+ log.call name, 'Retrying ...', type
+ retry
+ end
+ [false, e.is_a?(Interrupt) ? "Interrupted!" : "Timeout!"]
+ end
+ }
+ main = Thread.current
+ threads = []
+ watcher = Thread.new {
+ if vim7
+ while VIM::evaluate('getchar(1)')
+ sleep 0.1
+ end
+ else
+ require 'io/console' # >= Ruby 1.9
+ nil until IO.console.getch == 3.chr
+ end
+ mtx.synchronize do
+ running = false
+ threads.each { |t| t.raise Interrupt } unless vim7
+ end
+ threads.each { |t| t.join rescue nil }
+ main.kill
+ }
+ refresh = Thread.new {
+ while true
+ mtx.synchronize do
+ break unless running
+ VIM::command('noautocmd normal! a')
+ end
+ sleep 0.2
+ end
+ } if VIM::evaluate('s:mac_gui') == 1
+
+ clone_opt = VIM::evaluate('s:clone_opt')
+ progress = VIM::evaluate('s:progress_opt(1)')
+ nthr.times do
+ mtx.synchronize do
+ threads << Thread.new {
+ while pair = take1.call
+ name = pair.first
+ dir, uri, tag = pair.last.values_at *%w[dir uri tag]
+ exists = File.directory? dir
+ ok, result =
+ if exists
+ chdir = "#{cd} #{iswin ? dir : esc(dir)}"
+ ret, data = bt.call "#{chdir} && git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url", nil, nil, nil
+ current_uri = data.lines.to_a.last
+ if !ret
+ if data =~ /^Interrupted|^Timeout/
+ [false, data]
+ else
+ [false, [data.chomp, "PlugClean required."].join($/)]
+ end
+ elsif !compare_git_uri(current_uri, uri)
+ [false, ["Invalid URI: #{current_uri}",
+ "Expected: #{uri}",
+ "PlugClean required."].join($/)]
+ else
+ if pull
+ log.call name, 'Updating ...', :update
+ fetch_opt = (tag && File.exist?(File.join(dir, '.git/shallow'))) ? '--depth 99999999' : ''
+ bt.call "#{chdir} && git fetch #{fetch_opt} #{progress} 2>&1", name, :update, nil
+ else
+ [true, skip]
+ end
+ end
+ else
+ d = esc dir.sub(%r{[\\/]+$}, '')
+ log.call name, 'Installing ...', :install
+ bt.call "git clone #{clone_opt unless tag} #{progress} #{uri} #{d} 2>&1", name, :install, proc {
+ FileUtils.rm_rf dir
+ }
+ end
+ mtx.synchronize { VIM::command("let s:update.new['#{name}'] = 1") } if !exists && ok
+ log.call name, result, ok
+ end
+ } if running
+ end
+ end
+ threads.each { |t| t.join rescue nil }
+ logh.call
+ refresh.kill if refresh
+ watcher.kill
+EOF
+endfunction
+
+function! s:shellesc_cmd(arg)
+ let escaped = substitute(a:arg, '[&|<>()@^]', '^&', 'g')
+ let escaped = substitute(escaped, '%', '%%', 'g')
+ let escaped = substitute(escaped, '"', '\\^&', 'g')
+ let escaped = substitute(escaped, '\(\\\+\)\(\\^\)', '\1\1\2', 'g')
+ return '^"'.substitute(escaped, '\(\\\+\)$', '\1\1', '').'^"'
+endfunction
+
+function! s:shellesc(arg)
+ if &shell =~# 'cmd.exe$'
+ return s:shellesc_cmd(a:arg)
+ endif
+ return shellescape(a:arg)
+endfunction
+
+function! s:glob_dir(path)
+ return map(filter(s:glob(a:path, '**'), 'isdirectory(v:val)'), 's:dirpath(v:val)')
+endfunction
+
+function! s:progress_bar(line, bar, total)
+ call setline(a:line, '[' . s:lpad(a:bar, a:total) . ']')
+endfunction
+
+function! s:compare_git_uri(a, b)
+ " See `git help clone'
+ " https:// [user@] github.com[:port] / junegunn/vim-plug [.git]
+ " [git@] github.com[:port] : junegunn/vim-plug [.git]
+ " file:// / junegunn/vim-plug [/]
+ " / junegunn/vim-plug [/]
+ let pat = '^\%(\w\+://\)\='.'\%([^@/]*@\)\='.'\([^:/]*\%(:[0-9]*\)\=\)'.'[:/]'.'\(.\{-}\)'.'\%(\.git\)\=/\?$'
+ let ma = matchlist(a:a, pat)
+ let mb = matchlist(a:b, pat)
+ return ma[1:2] ==# mb[1:2]
+endfunction
+
+function! s:format_message(bullet, name, message)
+ if a:bullet != 'x'
+ return [printf('%s %s: %s', a:bullet, a:name, s:lastline(a:message))]
+ else
+ let lines = map(s:lines(a:message), '" ".v:val')
+ return extend([printf('x %s:', a:name)], lines)
+ endif
+endfunction
+
+function! s:with_cd(cmd, dir)
+ return printf('cd%s %s && %s', s:is_win ? ' /d' : '', s:shellesc(a:dir), a:cmd)
+endfunction
+
+function! s:system(cmd, ...)
+ try
+ let [sh, shellcmdflag, shrd] = s:chsh(1)
+ let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
+ if s:is_win
+ let batchfile = tempname().'.bat'
+ call writefile(["@echo off\r", cmd . "\r"], batchfile)
+ let cmd = batchfile
+ endif
+ return system(s:is_win ? '('.cmd.')' : cmd)
+ finally
+ let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
+ if s:is_win
+ call delete(batchfile)
+ endif
+ endtry
+endfunction
+
+function! s:system_chomp(...)
+ let ret = call('s:system', a:000)
+ return v:shell_error ? '' : substitute(ret, '\n$', '', '')
+endfunction
+
+function! s:git_validate(spec, check_branch)
+ let err = ''
+ if isdirectory(a:spec.dir)
+ let result = s:lines(s:system('git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url', a:spec.dir))
+ let remote = result[-1]
+ if v:shell_error
+ let err = join([remote, 'PlugClean required.'], "\n")
+ elseif !s:compare_git_uri(remote, a:spec.uri)
+ let err = join(['Invalid URI: '.remote,
+ \ 'Expected: '.a:spec.uri,
+ \ 'PlugClean required.'], "\n")
+ elseif a:check_branch && has_key(a:spec, 'commit')
+ let result = s:lines(s:system('git rev-parse HEAD 2>&1', a:spec.dir))
+ let sha = result[-1]
+ if v:shell_error
+ let err = join(add(result, 'PlugClean required.'), "\n")
+ elseif !s:hash_match(sha, a:spec.commit)
+ let err = join([printf('Invalid HEAD (expected: %s, actual: %s)',
+ \ a:spec.commit[:6], sha[:6]),
+ \ 'PlugUpdate required.'], "\n")
+ endif
+ elseif a:check_branch
+ let branch = result[0]
+ " Check tag
+ if has_key(a:spec, 'tag')
+ let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1', a:spec.dir)
+ if a:spec.tag !=# tag && a:spec.tag !~ '\*'
+ let err = printf('Invalid tag: %s (expected: %s). Try PlugUpdate.',
+ \ (empty(tag) ? 'N/A' : tag), a:spec.tag)
+ endif
+ " Check branch
+ elseif a:spec.branch !=# branch
+ let err = printf('Invalid branch: %s (expected: %s). Try PlugUpdate.',
+ \ branch, a:spec.branch)
+ endif
+ if empty(err)
+ let [ahead, behind] = split(s:lastline(s:system(printf(
+ \ 'git rev-list --count --left-right HEAD...origin/%s',
+ \ a:spec.branch), a:spec.dir)), '\t')
+ if !v:shell_error && ahead
+ if behind
+ " Only mention PlugClean if diverged, otherwise it's likely to be
+ " pushable (and probably not that messed up).
+ let err = printf(
+ \ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n"
+ \ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', a:spec.branch, ahead, behind)
+ else
+ let err = printf("Ahead of origin/%s by %d commit(s).\n"
+ \ .'Cannot update until local changes are pushed.',
+ \ a:spec.branch, ahead)
+ endif
+ endif
+ endif
+ endif
+ else
+ let err = 'Not found'
+ endif
+ return [err, err =~# 'PlugClean']
+endfunction
+
+function! s:rm_rf(dir)
+ if isdirectory(a:dir)
+ call s:system((s:is_win ? 'rmdir /S /Q ' : 'rm -rf ') . s:shellesc(a:dir))
+ endif
+endfunction
+
+function! s:clean(force)
+ call s:prepare()
+ call append(0, 'Searching for invalid plugins in '.g:plug_home)
+ call append(1, '')
+
+ " List of valid directories
+ let dirs = []
+ let errs = {}
+ let [cnt, total] = [0, len(g:plugs)]
+ for [name, spec] in items(g:plugs)
+ if !s:is_managed(name)
+ call add(dirs, spec.dir)
+ else
+ let [err, clean] = s:git_validate(spec, 1)
+ if clean
+ let errs[spec.dir] = s:lines(err)[0]
+ else
+ call add(dirs, spec.dir)
+ endif
+ endif
+ let cnt += 1
+ call s:progress_bar(2, repeat('=', cnt), total)
+ normal! 2G
+ redraw
+ endfor
+
+ let allowed = {}
+ for dir in dirs
+ let allowed[s:dirpath(fnamemodify(dir, ':h:h'))] = 1
+ let allowed[dir] = 1
+ for child in s:glob_dir(dir)
+ let allowed[child] = 1
+ endfor
+ endfor
+
+ let todo = []
+ let found = sort(s:glob_dir(g:plug_home))
+ while !empty(found)
+ let f = remove(found, 0)
+ if !has_key(allowed, f) && isdirectory(f)
+ call add(todo, f)
+ call append(line('$'), '- ' . f)
+ if has_key(errs, f)
+ call append(line('$'), ' ' . errs[f])
+ endif
+ let found = filter(found, 'stridx(v:val, f) != 0')
+ end
+ endwhile
+
+ 4
+ redraw
+ if empty(todo)
+ call append(line('$'), 'Already clean.')
+ else
+ let s:clean_count = 0
+ call append(3, ['Directories to delete:', ''])
+ redraw!
+ if a:force || s:ask_no_interrupt('Delete all directories?')
+ call s:delete([6, line('$')], 1)
+ else
+ call setline(4, 'Cancelled.')
+ nnoremap d :set opfunc=delete_opg@
+ nmap dd d_
+ xnoremap d :call delete_op(visualmode(), 1)
+ echo 'Delete the lines (d{motion}) to delete the corresponding directories'
+ endif
+ endif
+ 4
+ setlocal nomodifiable
+endfunction
+
+function! s:delete_op(type, ...)
+ call s:delete(a:0 ? [line("'<"), line("'>")] : [line("'["), line("']")], 0)
+endfunction
+
+function! s:delete(range, force)
+ let [l1, l2] = a:range
+ let force = a:force
+ while l1 <= l2
+ let line = getline(l1)
+ if line =~ '^- ' && isdirectory(line[2:])
+ execute l1
+ redraw!
+ let answer = force ? 1 : s:ask('Delete '.line[2:].'?', 1)
+ let force = force || answer > 1
+ if answer
+ call s:rm_rf(line[2:])
+ setlocal modifiable
+ call setline(l1, '~'.line[1:])
+ let s:clean_count += 1
+ call setline(4, printf('Removed %d directories.', s:clean_count))
+ setlocal nomodifiable
+ endif
+ endif
+ let l1 += 1
+ endwhile
+endfunction
+
+function! s:upgrade()
+ echo 'Downloading the latest version of vim-plug'
+ redraw
+ let tmp = tempname()
+ let new = tmp . '/plug.vim'
+
+ try
+ let out = s:system(printf('git clone --depth 1 %s %s', s:plug_src, tmp))
+ if v:shell_error
+ return s:err('Error upgrading vim-plug: '. out)
+ endif
+
+ if readfile(s:me) ==# readfile(new)
+ echo 'vim-plug is already up-to-date'
+ return 0
+ else
+ call rename(s:me, s:me . '.old')
+ call rename(new, s:me)
+ unlet g:loaded_plug
+ echo 'vim-plug has been upgraded'
+ return 1
+ endif
+ finally
+ silent! call s:rm_rf(tmp)
+ endtry
+endfunction
+
+function! s:upgrade_specs()
+ for spec in values(g:plugs)
+ let spec.frozen = get(spec, 'frozen', 0)
+ endfor
+endfunction
+
+function! s:status()
+ call s:prepare()
+ call append(0, 'Checking plugins')
+ call append(1, '')
+
+ let ecnt = 0
+ let unloaded = 0
+ let [cnt, total] = [0, len(g:plugs)]
+ for [name, spec] in items(g:plugs)
+ let is_dir = isdirectory(spec.dir)
+ if has_key(spec, 'uri')
+ if is_dir
+ let [err, _] = s:git_validate(spec, 1)
+ let [valid, msg] = [empty(err), empty(err) ? 'OK' : err]
+ else
+ let [valid, msg] = [0, 'Not found. Try PlugInstall.']
+ endif
+ else
+ if is_dir
+ let [valid, msg] = [1, 'OK']
+ else
+ let [valid, msg] = [0, 'Not found.']
+ endif
+ endif
+ let cnt += 1
+ let ecnt += !valid
+ " `s:loaded` entry can be missing if PlugUpgraded
+ if is_dir && get(s:loaded, name, -1) == 0
+ let unloaded = 1
+ let msg .= ' (not loaded)'
+ endif
+ call s:progress_bar(2, repeat('=', cnt), total)
+ call append(3, s:format_message(valid ? '-' : 'x', name, msg))
+ normal! 2G
+ redraw
+ endfor
+ call setline(1, 'Finished. '.ecnt.' error(s).')
+ normal! gg
+ setlocal nomodifiable
+ if unloaded
+ echo "Press 'L' on each line to load plugin, or 'U' to update"
+ nnoremap L :call status_load(line('.'))
+ xnoremap L :call status_load(line('.'))
+ end
+endfunction
+
+function! s:extract_name(str, prefix, suffix)
+ return matchstr(a:str, '^'.a:prefix.' \zs[^:]\+\ze:.*'.a:suffix.'$')
+endfunction
+
+function! s:status_load(lnum)
+ let line = getline(a:lnum)
+ let name = s:extract_name(line, '-', '(not loaded)')
+ if !empty(name)
+ call plug#load(name)
+ setlocal modifiable
+ call setline(a:lnum, substitute(line, ' (not loaded)$', '', ''))
+ setlocal nomodifiable
+ endif
+endfunction
+
+function! s:status_update() range
+ let lines = getline(a:firstline, a:lastline)
+ let names = filter(map(lines, 's:extract_name(v:val, "[x-]", "")'), '!empty(v:val)')
+ if !empty(names)
+ echo
+ execute 'PlugUpdate' join(names)
+ endif
+endfunction
+
+function! s:is_preview_window_open()
+ silent! wincmd P
+ if &previewwindow
+ wincmd p
+ return 1
+ endif
+endfunction
+
+function! s:find_name(lnum)
+ for lnum in reverse(range(1, a:lnum))
+ let line = getline(lnum)
+ if empty(line)
+ return ''
+ endif
+ let name = s:extract_name(line, '-', '')
+ if !empty(name)
+ return name
+ endif
+ endfor
+ return ''
+endfunction
+
+function! s:preview_commit()
+ if b:plug_preview < 0
+ let b:plug_preview = !s:is_preview_window_open()
+ endif
+
+ let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}')
+ if empty(sha)
+ return
+ endif
+
+ let name = s:find_name(line('.'))
+ if empty(name) || !has_key(g:plugs, name) || !isdirectory(g:plugs[name].dir)
+ return
+ endif
+
+ if exists('g:plug_pwindow') && !s:is_preview_window_open()
+ execute g:plug_pwindow
+ execute 'e' sha
+ else
+ execute 'pedit' sha
+ wincmd P
+ endif
+ setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable
+ try
+ let [sh, shellcmdflag, shrd] = s:chsh(1)
+ let cmd = 'cd '.s:shellesc(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha
+ if s:is_win
+ let batchfile = tempname().'.bat'
+ call writefile(["@echo off\r", cmd . "\r"], batchfile)
+ let cmd = batchfile
+ endif
+ execute 'silent %!' cmd
+ finally
+ let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
+ if s:is_win
+ call delete(batchfile)
+ endif
+ endtry
+ setlocal nomodifiable
+ nnoremap q :q
+ wincmd p
+endfunction
+
+function! s:section(flags)
+ call search('\(^[x-] \)\@<=[^:]\+:', a:flags)
+endfunction
+
+function! s:format_git_log(line)
+ let indent = ' '
+ let tokens = split(a:line, nr2char(1))
+ if len(tokens) != 5
+ return indent.substitute(a:line, '\s*$', '', '')
+ endif
+ let [graph, sha, refs, subject, date] = tokens
+ let tag = matchstr(refs, 'tag: [^,)]\+')
+ let tag = empty(tag) ? ' ' : ' ('.tag.') '
+ return printf('%s%s%s%s%s (%s)', indent, graph, sha, tag, subject, date)
+endfunction
+
+function! s:append_ul(lnum, text)
+ call append(a:lnum, ['', a:text, repeat('-', len(a:text))])
+endfunction
+
+function! s:diff()
+ call s:prepare()
+ call append(0, ['Collecting changes ...', ''])
+ let cnts = [0, 0]
+ let bar = ''
+ let total = filter(copy(g:plugs), 's:is_managed(v:key) && isdirectory(v:val.dir)')
+ call s:progress_bar(2, bar, len(total))
+ for origin in [1, 0]
+ let plugs = reverse(sort(items(filter(copy(total), (origin ? '' : '!').'(has_key(v:val, "commit") || has_key(v:val, "tag"))'))))
+ if empty(plugs)
+ continue
+ endif
+ call s:append_ul(2, origin ? 'Pending updates:' : 'Last update:')
+ for [k, v] in plugs
+ let range = origin ? '..origin/'.v.branch : 'HEAD@{1}..'
+ let diff = s:system_chomp('git log --graph --color=never '.join(map(['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range], 's:shellesc(v:val)')), v.dir)
+ if !empty(diff)
+ let ref = has_key(v, 'tag') ? (' (tag: '.v.tag.')') : has_key(v, 'commit') ? (' '.v.commit) : ''
+ call append(5, extend(['', '- '.k.':'.ref], map(s:lines(diff), 's:format_git_log(v:val)')))
+ let cnts[origin] += 1
+ endif
+ let bar .= '='
+ call s:progress_bar(2, bar, len(total))
+ normal! 2G
+ redraw
+ endfor
+ if !cnts[origin]
+ call append(5, ['', 'N/A'])
+ endif
+ endfor
+ call setline(1, printf('%d plugin(s) updated.', cnts[0])
+ \ . (cnts[1] ? printf(' %d plugin(s) have pending updates.', cnts[1]) : ''))
+
+ if cnts[0] || cnts[1]
+ nnoremap :silent! call preview_commit()
+ nnoremap o :silent! call preview_commit()
+ endif
+ if cnts[0]
+ nnoremap X :call revert()
+ echo "Press 'X' on each block to revert the update"
+ endif
+ normal! gg
+ setlocal nomodifiable
+endfunction
+
+function! s:revert()
+ if search('^Pending updates', 'bnW')
+ return
+ endif
+
+ let name = s:find_name(line('.'))
+ if empty(name) || !has_key(g:plugs, name) ||
+ \ input(printf('Revert the update of %s? (y/N) ', name)) !~? '^y'
+ return
+ endif
+
+ call s:system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch).' --', g:plugs[name].dir)
+ setlocal modifiable
+ normal! "_dap
+ setlocal nomodifiable
+ echo 'Reverted'
+endfunction
+
+function! s:snapshot(force, ...) abort
+ call s:prepare()
+ setf vim
+ call append(0, ['" Generated by vim-plug',
+ \ '" '.strftime("%c"),
+ \ '" :source this file in vim to restore the snapshot',
+ \ '" or execute: vim -S snapshot.vim',
+ \ '', '', 'PlugUpdate!'])
+ 1
+ let anchor = line('$') - 3
+ let names = sort(keys(filter(copy(g:plugs),
+ \'has_key(v:val, "uri") && !has_key(v:val, "commit") && isdirectory(v:val.dir)')))
+ for name in reverse(names)
+ let sha = s:system_chomp('git rev-parse --short HEAD', g:plugs[name].dir)
+ if !empty(sha)
+ call append(anchor, printf("silent! let g:plugs['%s'].commit = '%s'", name, sha))
+ redraw
+ endif
+ endfor
+
+ if a:0 > 0
+ let fn = expand(a:1)
+ if filereadable(fn) && !(a:force || s:ask(a:1.' already exists. Overwrite?'))
+ return
+ endif
+ call writefile(getline(1, '$'), fn)
+ echo 'Saved as '.a:1
+ silent execute 'e' s:esc(fn)
+ setf vim
+ endif
+endfunction
+
+function! s:split_rtp()
+ return split(&rtp, '\\\@
-" Version: 1.79
-" =============================================================================
-
-" ** 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],
- \ 'use_migemo': ['s:migemo', 0],
- \ 'user_command': ['s:usrcmd', ''],
- \ 'working_path_mode': ['s:pathmode', 'ra'],
- \ }, {
- \ '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()': [''],
- \ 'PrtExit()': ['', '', ''],
- \ }]
-
-if !has('gui_running')
- cal add(s:prtmaps['PrtBS()'], remove(s:prtmaps['PrtCurLeft()'], 0))
-en
-
-let s:compare_lim = 3000
-
-let s:ficounts = {}
-
-let s:ccex = s:pref.'clear_cache_on_exit'
-
-" Regexp
-let s:fpats = {
- \ '^\(\\|\)\|\(\\|\)$': '\\|',
- \ '^\\\(zs\|ze\|<\|>\)': '^\\\(zs\|ze\|<\|>\)',
- \ '^\S\*$': '\*',
- \ '^\S\\?$': '\\?',
- \ }
-
-" 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',
- \ }
-" 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_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])
- let s:mw_res = max([s:mw_res, 1])
-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=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:cline 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:GlobPath(s:fnesc(s:dyncwd, 'g', ','), 0)
- 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: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! 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
- let [ssl, &ssl, path] = [&ssl, 0, tr(path, '/', '\')]
- en
- if has('win32') || has('win64')
- let lscmd = substitute(lscmd, '\v(^|\&\&\s*)\zscd (/d)@!', 'cd /d ', '')
- en
- let path = exists('*shellescape') ? shellescape(path) : path
- let g:ctrlp_allfiles = split(system(printf(lscmd, path)), "\n")
- 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! ctrlp#buffers(...)
- let ids = sort(filter(range(1, bufnr('$')), 'empty(getbufvar(v:val, "&bt"))'
- \ .' && 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
- if s:matcher != {}
- let argms =
- \ has_key(s:matcher, 'arg_type') && s: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(s:matcher['match'], argms, s: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
- if s:migemo && s:regexp && len(str) > 0 && executable('cmigemo')
- let str = s:migemo(str)
- en
- 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
- 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]
- if s:nolim != 1 | let s:cline = line('.') | en
- if line('$') > winheight(0) | cal s:BuildPrompt(0) | en
-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'
- if s:nolim != 1 | let s:cline = line('.') | en
- if line('$') > winheight(0) | cal s:BuildPrompt(0) | en
- en
-endf
-" Misc {{{2
-fu! s:PrtFocusMap(char)
- cal call(( s:focus ? 's:PrtAdd' : 's:PrtSelectJump' ), [a:char])
-endf
-
-fu! s:PrtClearCache()
- if s:itemtype == 0
- cal ctrlp#clr()
- elsei s:itemtype > 2
- cal ctrlp#clr(s:statypes[s:itemtype][1])
- en
- if s:itemtype == 2
- 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()
- if s:itemtype == 2
- cal s:PrtDeleteMRU()
- elsei type(s:getextvar('wipe')) == 1
- cal s:delent(s:getextvar('wipe'))
- en
-endf
-
-fu! s:PrtDeleteMRU()
- if s:itemtype == 2
- cal s:delent('ctrlp#mrufiles#remove')
- en
-endf
-
-fu! s:PrtExit()
- if bufnr('%') == s:bufnr && bufname('%') == 'ControlP'
- noa cal s:Close()
- noa winc p
- 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()
- wh exists('s:init') && s:keyloop
- redr
- let nr = getchar()
- let chr = !type(nr) ? nr2char(nr) : nr
- if nr >=# 0x20
- cal s:PrtFocusMap(chr)
- el
- let cmd = matchstr(maparg(chr), ':\zs.\+\ze$')
- exe ( cmd != '' ? cmd : 'norm '.chr )
- en
- endw
-endf
-" * Toggling {{{1
-fu! s: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) + 2
- let next = s:walker(max, s:itemtype, a:dir)
- cal ctrlp#syntax()
- cal ctrlp#setlines(next)
- 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 pmode = has_key(a:args, 'mode') ? a:args['mode'] : s:pathmode
- let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()]
- if s:crfile =~ '^.\+://' | retu | en
- if pmode =~ 'c' || ( pmode =~ 'a' && stridx(s:crfpath, s:cwd) < 0 )
- \ || ( !type(pmode) && pmode )
- if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en
- cal ctrlp#setdir(s:crfpath)
- en
- if pmode =~ 'r' || pmode == 2
- let markers = ['.git', '.hg', '.svn', '.bzr', '_darcs']
- let spath = pmode =~ 'd' ? s:dyncwd : pmode =~ 'w' ? s:cwd : s:crfpath
- if type(s:rmarkers) == 3 && !empty(s:rmarkers)
- if s:findroot(spath, s:rmarkers, 0, 0) != [] | retu | en
- cal filter(markers, 'index(s:rmarkers, v:val) < 0')
- en
- cal s:findroot(spath, markers, 0, 0)
- en
-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 filpath = fnamemodify(line, ':p')
- if s:nonamecond(line, filpath)
- let bufnr = str2nr(matchstr(line, '[\/]\?\[\zs\d\+\ze\*No Name\]$'))
- let [filpath, useb] = [bufnr, 1]
- el
- let bufnr = bufnr('^'.filpath.'$')
- en
- en
- cal s:PrtExit()
- let tail = s:tail()
- let j2l = atl != '' ? atl : matchstr(tail, '^ +\zs\d\+$')
- if ( s:jmptobuf =~ md || ( s:jmptobuf && md =~ '[et]' ) ) && bufnr > 0
- \ && !( md == 'e' && bufnr == bufnr('%') )
- let [jmpb, bufwinnr] = [1, bufwinnr(bufnr)]
- let buftab = ( s:jmptobuf =~# '[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:itemtype && 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 < 3
- 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 }]
- \ : [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()
- if s:bufnr <= 0 || s:opmul == '0'
- \ || ( s:itemtype > 2 && s:getextvar('opmul') != 1 )
- retu
- en
- let line = ctrlp#getcline()
- if empty(line) | retu | en
- let filpath = s:ispath ? fnamemodify(line, ':p') : line
- if exists('s:marked') && s:dictindex(s:marked, filpath) > 0
- " 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 > 2 && s:getextvar('opmul') != 1 )
- retu -1
- en
- " Get the options
- let [nr, md] = [matchstr(s:opmul, '\d\+'), matchstr(s:opmul, '[thvi]')]
- let [ur, jf] = [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: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)]
- retu id1 == id2 ? 0 : 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(...)
- if s:itemtype == 1
- 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 s:itemtype !~ '^[12]$' | let ms += [s:comptime(a:1, a:2)] | en
- if !s:itemtype | let ms += [s:comparent(a:1, a:2)] | en
- en
- if s:itemtype =~ '^[12]$'
- 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 = [
- \ ['files', 'fil'],
- \ ['buffers', 'buf'],
- \ ['mru files', 'mru'],
- \ ]
- 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
- if s:itemtype == 1
- let filpath = fnamemodify(str, ':p')
- let bufnr = s:nonamecond(str, filpath)
- \ ? str2nr(matchstr(str, '[\/]\?\[\zs\d\+\ze\*No Name\]$'))
- \ : bufnr('^'.filpath.'$')
- let idc = ( bufnr == bufnr('#') ? '#' : '' )
- \ . ( getbufvar(bufnr, '&ma') ? '' : '-' )
- \ . ( getbufvar(bufnr, '&ro') ? '=' : '' )
- \ . ( getbufvar(bufnr, '&mod') ? '+' : '' )
- let str .= idc != '' ? ' '.idc : ''
- en
- let cond = s:ispath && ( s:winw - 4 ) < s:strwidth(str)
- retu '> '.( 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 < 3 || ( s:itemtype > 2 && 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)
- retu s:igntype == 1 ? a:item =~ s:usrign
- \ : s:igntype == 4 && has_key(s:usrign, a:type) && s:usrign[a:type] != ''
- \ ? a:item =~ s:usrign[a:type] : 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)
- let cwd = s:dyncwd.s:lash()
- if a:items != [] && !stridx(a:items[0], 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#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
- if synIDattr(synIDtrans(hlID('Normal')), 'bg') !~ '^-1$\|^$'
- sil! exe 'hi CtrlPLinePre '.( has("gui_running") ? 'gui' : 'cterm' ).'fg=bg'
- en
- sy match CtrlPNoEntries '^ == NO ENTRIES ==$'
- if hlexists('CtrlPLinePre')
- sy match CtrlPLinePre '^>'
- en
-endf
-
-fu! s:highlight(pat, grp)
- if s:matcher != {} | retu | en
- cal clearmatches()
- if !empty(a:pat) && s:ispath
- let pat = s:regexp ? substitute(a:pat, '\\\@ \\zs', 'g') : a:pat
- if s:byfname
- let pat = substitute(pat, '\[\^\(.\{-}\)\]\\{-}', '[^\\/\1]\\{-}', 'g')
- let pat = substitute(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:nonamecond(str, filpath)
- retu a:str =~ '[\/]\?\[\d\+\*No Name\]$' && !filereadable(a:filpath)
- \ && bufnr('^'.a:filpath.'$') < 1
-endf
-
-fu! ctrlp#normcmd(cmd, ...)
- if a:0 < 2 && s:nosplit() | retu a:cmd | en
- let norwins = filter(range(1, winnr('$')),
- \ 'empty(getbufvar(winbufnr(v:val), "&bt"))')
- for each in norwins
- let bufnr = winbufnr(each)
- if empty(bufname(bufnr)) && empty(getbufvar(bufnr, '&ft'))
- let fstemp = each | brea
- 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
-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
- 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()
- retu s:matcher != {} || s:nolim == 1 || ( s:itemtype == 2 && s:mrudef )
- \ || ( s:itemtype =~ '\v^(1|2)$' && s:prompt == ['', '', ''] ) || !s:dosort
-endf
-
-fu! s:byfname()
- retu 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:migemo(str)
- let [str, rtp] = [a:str, s:fnesc(&rtp, 'g')]
- let dict = s:glbpath(rtp, printf("dict/%s/migemo-dict", &enc), 1)
- if !len(dict)
- let dict = s:glbpath(rtp, "dict/migemo-dict", 1)
- en
- if len(dict)
- let [tokens, str, cmd] = [split(str, '\s'), '', 'cmigemo -v -w %s -d %s']
- for token in tokens
- let rtn = system(printf(cmd, shellescape(token), shellescape(dict)))
- let str .= !v:shell_error && strlen(rtn) > 0 ? '.*'.rtn : token
- endfo
- en
- retu str
-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
-" 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
- en
-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]
- for item in range(1, len(a:lst) - 1)
- let pat .= '[^'.a:lst[item - 1].']\{-}'.a:lst[item]
- endfo
- retu pat
-endf
-
-fu! s:mfunc()
- let mfunc = 'match'
- if s:byfname()
- let mfunc = 's:matchfname'
- elsei s:itemtype > 2
- 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: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 > 2 ? 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 > 2
- let vars = g:ctrlp_ext_vars[s:itemtype - 3]
- retu has_key(vars, a:key) ? vars[a:key] : -1
- en
- retu -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#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 types = ['ctrlp#files()', 'ctrlp#buffers()', 'ctrlp#mrufiles#list()']
- 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
-
-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()
- cal ctrlp#syntax()
- cal ctrlp#setlines(s:settype(a:type))
- cal s:SetDefTxt()
- cal s:BuildPrompt(1)
- if s:keyloop | cal s:KeyLoop() | en
-endf
-" - Autocmds {{{1
-if has('autocmd')
- 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/bookmarkdir.vim b/vim-bundle/ctrlp.vim/autoload/ctrlp/bookmarkdir.vim
deleted file mode 100644
index 89bda89..0000000
--- a/vim-bundle/ctrlp.vim/autoload/ctrlp/bookmarkdir.vim
+++ /dev/null
@@ -1,140 +0,0 @@
-" =============================================================================
-" 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(dir, ...)
- let str = 'Directory to bookmark: '
- let cwd = a:dir != '' ? a:dir : s:getinput(str, getcwd(), 'dir')
- if cwd == '' | retu | en
- let cwd = fnamemodify(cwd, ':p')
- let name = a:0 && a:1 != '' ? a:1 : s:getinput('Bookmark as: ', cwd)
- if name == '' | retu | 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
deleted file mode 100644
index a38cad5..0000000
--- a/vim-bundle/ctrlp.vim/autoload/ctrlp/buffertag.vim
+++ /dev/null
@@ -1,264 +0,0 @@
-" =============================================================================
-" 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 = {
- \ 'asm' : '%sasm%sasm%sdlmt',
- \ 'aspperl': '%sasp%sasp%sfsv',
- \ 'aspvbs' : '%sasp%sasp%sfsv',
- \ 'awk' : '%sawk%sawk%sf',
- \ 'beta' : '%sbeta%sbeta%sfsv',
- \ 'c' : '%sc%sc%sdgsutvf',
- \ 'cpp' : '%sc++%sc++%snvdtcgsuf',
- \ 'cs' : '%sc#%sc#%sdtncEgsipm',
- \ 'cobol' : '%scobol%scobol%sdfgpPs',
- \ 'eiffel' : '%seiffel%seiffel%scf',
- \ 'erlang' : '%serlang%serlang%sdrmf',
- \ 'expect' : '%stcl%stcl%scfp',
- \ 'fortran': '%sfortran%sfortran%spbceiklmntvfs',
- \ 'html' : '%shtml%shtml%saf',
- \ 'java' : '%sjava%sjava%spcifm',
- \ 'javascript': '%sjavascript%sjavascript%sf',
- \ 'lisp' : '%slisp%slisp%sf',
- \ 'lua' : '%slua%slua%sf',
- \ 'make' : '%smake%smake%sm',
- \ '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',
- \ 'scheme' : '%sscheme%sscheme%ssf',
- \ 'sh' : '%ssh%ssh%sf',
- \ 'csh' : '%ssh%ssh%sf',
- \ 'zsh' : '%ssh%ssh%sf',
- \ 'slang' : '%sslang%sslang%snf',
- \ 'sml' : '%ssml%ssml%secsrtvf',
- \ 'sql' : '%ssql%ssql%scFPrstTvfp',
- \ 'tcl' : '%stcl%stcl%scfmp',
- \ 'vera' : '%svera%svera%scdefgmpPtTvx',
- \ 'verilog': '%sverilog%sverilog%smcPertwpvf',
- \ 'vim' : '%svim%svim%savf',
- \ 'yacc' : '%syacc%syacc%sl',
- \ }
-
-cal map(s:types, 'printf(v:val, "--language-force=", " --", "-types=")')
-
-if executable('jsctags')
- cal extend(s:types, { 'javascript': { 'args': '-f -', 'bin': 'jsctags' } })
-en
-
-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 ', 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) : ''
- let cmd = shellescape(a:bin).' '.a:args.' '.fname
- if &sh =~ 'cmd\.exe'
- let cmd = substitute(cmd, '[&()@^<>|]', '^\0', 'g')
- en
- if exists('+ssl')
- let &ssl = ssl
- en
- 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
deleted file mode 100644
index 313d8c2..0000000
--- a/vim-bundle/ctrlp.vim/autoload/ctrlp/changes.vim
+++ /dev/null
@@ -1,98 +0,0 @@
-" =============================================================================
-" 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
deleted file mode 100644
index 4e6d4ad..0000000
--- a/vim-bundle/ctrlp.vim/autoload/ctrlp/dir.vim
+++ /dev/null
@@ -1,95 +0,0 @@
-" =============================================================================
-" 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
deleted file mode 100644
index 5bec47e..0000000
--- a/vim-bundle/ctrlp.vim/autoload/ctrlp/line.vim
+++ /dev/null
@@ -1,72 +0,0 @@
-" =============================================================================
-" 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',
- \ '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') && 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(mode, str)
- let info = matchlist(a:str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$')
- let bufnr = str2nr(get(info, 1))
- if bufnr
- cal ctrlp#acceptfile(a:mode, bufnr, get(info, 2))
- 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
deleted file mode 100644
index 74d904d..0000000
--- a/vim-bundle/ctrlp.vim/autoload/ctrlp/mixed.vim
+++ /dev/null
@@ -1,88 +0,0 @@
-" =============================================================================
-" 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
deleted file mode 100644
index a182111..0000000
--- a/vim-bundle/ctrlp.vim/autoload/ctrlp/mrufiles.vim
+++ /dev/null
@@ -1,154 +0,0 @@
-" =============================================================================
-" File: autoload/ctrlp/mrufiles.vim
-" Description: Most Recently Used Files extension
-" Author: Kien Nguyen
-" =============================================================================
-
-" Static variables {{{1
-let [s:mrbs, s:mrufs] = [[], []]
-
-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],
- \ }]
- 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, '!stridx(v:val, cwd) ? strpart(v:val, idx) : v:val')
-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, ':p')
- let fn = exists('+ssl') ? tr(fn, '/', '\') : fn
- if ( !empty({s:in}) && fn !~# {s:in} ) || ( !empty({s:ex}) && fn =~# {s:ex} )
- \ || !empty(getbufvar('^'.fn.'$', '&bt')) || !filereadable(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 BufAdd,BufEnter,BufLeave,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
deleted file mode 100644
index 03ab921..0000000
--- a/vim-bundle/ctrlp.vim/autoload/ctrlp/quickfix.vim
+++ /dev/null
@@ -1,59 +0,0 @@
-" =============================================================================
-" 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
deleted file mode 100644
index eed21c6..0000000
--- a/vim-bundle/ctrlp.vim/autoload/ctrlp/rtscript.vim
+++ /dev/null
@@ -1,59 +0,0 @@
-" =============================================================================
-" 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
deleted file mode 100644
index 626363a..0000000
--- a/vim-bundle/ctrlp.vim/autoload/ctrlp/tag.vim
+++ /dev/null
@@ -1,138 +0,0 @@
-" =============================================================================
-" 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)
- 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
- let [fnd, pos] = [0, cnt]
- 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 str = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\ze\t')
- let [tg, fdcnt] = [split(str, '^[^\t]\+\zs\t')[0], s:findcount(str)]
- let cmds = {
- \ 't': ['tab sp', 'tab stj'],
- \ 'h': ['sp', 'stj'],
- \ 'v': ['vs', 'vert stj'],
- \ 'e': ['', 'tj'],
- \ }
- let 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 ctrlp#setlcdir()
-endf
-
-fu! ctrlp#tag#id()
- retu s:id
-endf
-
-fu! ctrlp#tag#enter()
- let tfs = tagfiles()
- let s:tagfiles = 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
deleted file mode 100644
index dee705e..0000000
--- a/vim-bundle/ctrlp.vim/autoload/ctrlp/undo.vim
+++ /dev/null
@@ -1,154 +0,0 @@
-" =============================================================================
-" 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
deleted file mode 100644
index 91b9f24..0000000
--- a/vim-bundle/ctrlp.vim/autoload/ctrlp/utils.vim
+++ /dev/null
@@ -1,110 +0,0 @@
-" =============================================================================
-" 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.txt b/vim-bundle/ctrlp.vim/doc/ctrlp.txt
deleted file mode 100644
index e697b93..0000000
--- a/vim-bundle/ctrlp.vim/doc/ctrlp.txt
+++ /dev/null
@@ -1,1451 +0,0 @@
-*ctrlp.txt* Fuzzy file, buffer, mru, tag, ... finder. v1.79
-*CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'*
-===============================================================================
-# #
-# :::::::: ::::::::::: ::::::::: ::: ::::::::: #
-# :+: :+: :+: :+: :+: :+: :+: :+: #
-# +:+ +:+ +:+ +:+ +:+ +:+ +:+ #
-# +#+ +#+ +#++:++#: +#+ +#++:++#+ #
-# +#+ +#+ +#+ +#+ +#+ +#+ #
-# #+# #+# #+# #+# #+# #+# #+# #
-# ######## ### ### ### ########## ### #
-# #
-===============================================================================
-CONTENTS *ctrlp-contents*
-
- 1. Intro........................................|ctrlp-intro|
- 2. Options......................................|ctrlp-options|
- 3. Commands.....................................|ctrlp-commands|
- 4. Mappings.....................................|ctrlp-mappings|
- 5. Input Formats................................|ctrlp-input-formats|
- 6. Extensions...................................|ctrlp-extensions|
-
-===============================================================================
-INTRO *ctrlp-intro*
-
-Full path fuzzy file, buffer, mru, tag, ... finder with an intuitive interface.
-Written in pure Vimscript for MacVim, gVim and Vim version 7.0+. Has full
-support for Vim's |regexp| as search pattern, built-in MRU files monitoring,
-project's root finder, and more.
-
-To enable optional extensions (tag, dir, rtscript...), see |ctrlp-extensions|.
-
-===============================================================================
-OPTIONS *ctrlp-options*
-
-Overview:~
-
- |loaded_ctrlp|................Disable the plugin.
- |ctrlp_map|...................Default mapping.
- |ctrlp_cmd|...................Default command used for the default mapping.
- |ctrlp_by_filename|...........Default to filename mode or not.
- |ctrlp_regexp|................Default to regexp mode or not.
- |ctrlp_match_window|..........Order, height and position of the match window.
- |ctrlp_switch_buffer|.........Jump to an open buffer if already opened.
- |ctrlp_reuse_window|..........Reuse special windows (help, quickfix, etc).
- |ctrlp_tabpage_position|......Where to put the new tab page.
- |ctrlp_working_path_mode|.....How to set CtrlP's local working directory.
- |ctrlp_root_markers|..........Additional, high priority root markers.
- |ctrlp_use_caching|...........Use per-session caching or not.
- |ctrlp_clear_cache_on_exit|...Keep cache after exiting Vim or not.
- |ctrlp_cache_dir|.............Location of the cache directory.
- |ctrlp_show_hidden|...........Ignore dotfiles and dotdirs or not.
- |ctrlp_custom_ignore|.........Hide stuff when using |globpath()|.
- |ctrlp_max_files|.............Number of files to scan initially.
- |ctrlp_max_depth|.............Directory depth to recurse into when scanning.
- |ctrlp_user_command|..........Use an external scanner.
- |ctrlp_max_history|...........Number of entries saved in the prompt history.
- |ctrlp_open_new_file|.........How to open a file created by .
- |ctrlp_open_multiple_files|...How to open files selected by .
- |ctrlp_arg_map|...............Intercept and or not.
- |ctrlp_follow_symlinks|.......Follow symbolic links or not.
- |ctrlp_lazy_update|...........Only update when typing has stopped.
- |ctrlp_default_input|.........Seed the prompt with an initial string.
- |ctrlp_abbrev|................Input abbreviations.
- |ctrlp_key_loop|..............Use input looping for multi-byte input.
- |ctrlp_use_migemo|............Use Migemo patterns for Japanese filenames.
- |ctrlp_prompt_mappings|.......Change the mappings inside the prompt.
-
- MRU mode:
- |ctrlp_mruf_max|..............Max MRU entries to remember.
- |ctrlp_mruf_exclude|..........Files that shouldn't be remembered.
- |ctrlp_mruf_include|..........Files to be remembered.
- |ctrlp_mruf_relative|.........Show only MRU files in the working directory.
- |ctrlp_mruf_default_order|....Disable sorting.
- |ctrlp_mruf_case_sensitive|...MRU files are case sensitive or not.
- |ctrlp_mruf_save_on_update|...Save to disk whenever a new entry is added.
-
- BufferTag mode: (to enable, see |ctrlp-extensions|)
- |g:ctrlp_buftag_ctags_bin|....The location of the ctags-compatible binary.
- |g:ctrlp_buftag_systemenc|....The encoding used for the ctags command.
- |g:ctrlp_buftag_types|........Add new filetypes and set the cmd arguments.
-
- Advanced options:
- |ctrlp_open_func|.............Use custom file opening functions.
- |ctrlp_status_func|...........Change CtrlP's two statuslines.
- |ctrlp_buffer_func|...........Call custom functions in the CtrlP buffer.
- |ctrlp_match_func|............Replace the built-in matching algorithm.
-
--------------------------------------------------------------------------------
-Detailed descriptions and default values:~
-
- *'g:ctrlp_map'*
-Use this option to change the mapping to invoke CtrlP in |Normal| mode: >
- let g:ctrlp_map = ''
-<
-
- *'g:ctrlp_cmd'*
-Set the default opening command to use when pressing the above mapping: >
- let g:ctrlp_cmd = 'CtrlP'
-<
-
- *'g:loaded_ctrlp'*
-Use this to disable the plugin completely: >
- let g:loaded_ctrlp = 1
-<
-
- *'g:ctrlp_by_filename'*
-Set this to 1 to set searching by filename (as opposed to full path) as the
-default: >
- let g:ctrlp_by_filename = 0
-<
-Can be toggled on/off by pressing inside the prompt.
-
- *'g:ctrlp_regexp'*
-Set this to 1 to set regexp search as the default: >
- let g:ctrlp_regexp = 0
-<
-Can be toggled on/off by pressing inside the prompt.
-
- *'g:ctrlp_match_window'*
-Change the postion, the listing order of results, the minimum and the maximum
-heights of the match window: >
- let g:ctrlp_match_window = ''
-<
-Example: >
- let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10,results:10'
-<
-The position: (default: bottom)
- top - show the match window at the top of the screen.
- bottom - show the match window at the bottom of the screen.
-
-The listing order of results: (default: btt)
- order:ttb - from top to bottom.
- order:btt - from bottom to top.
-
-The minimum and maximum heights:
- min:{n} - show minimum {n} lines (default: 1).
- max:{n} - show maximum {n} lines (default: 10).
-
-The maximum number of results:
- results:{n} - list maximum {n} results (default: sync with max height).
-
-Note: When a setting isn't set, its default value will be used.
-
- *'g:ctrlp_switch_buffer'*
-When opening a file, if it's already open in a window somewhere, CtrlP will try
-to jump to it instead of opening a new instance: >
- let g:ctrlp_switch_buffer = 'Et'
-<
- e - jump when is pressed, but only to windows in the current tab.
- t - jump when is pressed, but only to windows in another tab.
- v - like "e", but jump when is pressed.
- h - like "e", but jump when is pressed.
- E, T, V, H - like "e", "t", "v", and "h", but jump to windows anywhere.
- 0 or - disable this feature.
-
- *'g:ctrlp_reuse_window'*
-When opening a file with , CtrlP avoids opening it in windows created by
-plugins, help and quickfix. Use this to setup some exceptions: >
- let g:ctrlp_reuse_window = 'netrw'
-<
-Acceptable values are partial name, filetype or buftype of the special buffers.
-Use regexp to specify the pattern.
-Example: >
- let g:ctrlp_reuse_window = 'netrw\|help\|quickfix'
-<
-
- *'g:ctrlp_tabpage_position'*
-Where to put the new tab page when opening one: >
- let g:ctrlp_tabpage_position = 'ac'
-<
- a - after.
- b - before.
- c - the current tab page.
- l - the last tab page.
- f - the first tab page.
-
- *'g:ctrlp_working_path_mode'*
-When starting up, CtrlP sets its local working directory according to this
-variable: >
- let g:ctrlp_working_path_mode = 'ra'
-<
- c - the directory of the current file.
- a - like "c", but only applies when the current working directory outside of
- CtrlP isn't a direct ancestor of the directory of the current file.
- r - the nearest ancestor that contains one of these directories or files:
- .git .hg .svn .bzr _darcs
- w - begin finding a root from the current working directory outside of CtrlP
- instead of from the directory of the current file (default). Only applies
- when "r" is also present.
- 0 or - disable this feature.
-
-Note #1: if "a" or "c" is included with "r", use the behavior of "a" or "c" (as
-a fallback) when a root can't be found.
-
-Note #2: you can use a |b:var| to set this option on a per buffer basis.
-
- *'g:ctrlp_root_markers'*
-Use this to set your own root markers in addition to the default ones (.git,
-.hg, .svn, .bzr, and _darcs). Your markers will take precedence: >
- let g:ctrlp_root_markers = ['']
-<
-Note: you can use a |b:var| to set this option on a per buffer basis.
-
- *'g:ctrlp_use_caching'*
-Enable/Disable per-session caching: >
- let g:ctrlp_use_caching = 1
-<
- 0 - Disable caching.
- 1 - Enable caching.
- n - When bigger than 1, disable caching and use the number as the limit to
- enable caching again.
-
-Note: you can quickly purge the cache by pressing while inside CtrlP.
-
- *'g:ctrlp_clear_cache_on_exit'*
-Set this to 0 to enable cross-session caching by not deleting the cache files
-upon exiting Vim: >
- let g:ctrlp_clear_cache_on_exit = 1
-<
-
- *'g:ctrlp_cache_dir'*
-Set the directory to store the cache files: >
- let g:ctrlp_cache_dir = $HOME.'/.cache/ctrlp'
-<
-
- *'g:ctrlp_show_hidden'*
-Set this to 1 if you want CtrlP to scan for dotfiles and dotdirs: >
- let g:ctrlp_show_hidden = 0
-<
-Note: does not apply when a command defined with |g:ctrlp_user_command| is
-being used.
-
- *'ctrlp-wildignore'*
-You can use Vim's |'wildignore'| to exclude files and directories from the
-results.
-Examples: >
- " Excluding version control directories
- set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " Linux/MacOSX
- set wildignore+=*\\.git\\*,*\\.hg\\*,*\\.svn\\* " Windows ('noshellslash')
-<
-Note #1: the `*/` in front of each directory glob is required.
-
-Note #2: |wildignore| influences the result of |expand()|, |globpath()| and
-|glob()| which many plugins use to find stuff on the system (e.g. VCS related
-plugins look for .git/, .hg/,... some other plugins look for external *.exe
-tools on Windows). So be a little mindful of what you put in your |wildignore|.
-
- *'g:ctrlp_custom_ignore'*
-In addition to |'wildignore'|, use this for files and directories you want only
-CtrlP to not show. Use regexp to specify the patterns: >
- let g:ctrlp_custom_ignore = ''
-<
-Examples: >
- 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
-<
-Note: does not apply when a command defined with |g:ctrlp_user_command| is
-being used.
-
- *'g:ctrlp_max_depth'*
-The maximum depth of a directory tree to recurse into: >
- let g:ctrlp_max_depth = 40
-<
-Note: does not apply when a command defined with |g:ctrlp_user_command| is
-being used.
-
- *'g:ctrlp_user_command'*
-Specify an external tool to use for listing files instead of using Vim's
-|globpath()|. Use %s in place of the target directory: >
- let g:ctrlp_user_command = ''
-<
-Examples: >
- let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux
- let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows
-<
-You can also use 'grep', 'findstr' or something else to filter the results.
-Examples: >
- let g:ctrlp_user_command =
- \ 'find %s -type f | grep -v -P "\.jpg$|/tmp/"' " MacOSX/Linux
- let g:ctrlp_user_command =
- \ 'dir %s /-n /b /s /a-d | findstr /v /l ".jpg \\tmp\\"' " Windows
-<
-Use a version control listing command when inside a repository, this is faster
-when scanning large projects: >
- 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
- \ }
-<
-Some examples: >
- " Single VCS, listing command does not list untracked files:
- let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files']
- let g:ctrlp_user_command = ['.hg', 'hg --cwd %s locate -I .']
-
- " Multiple VCS's:
- let g:ctrlp_user_command = {
- \ 'types': {
- \ 1: ['.git', 'cd %s && git ls-files'],
- \ 2: ['.hg', 'hg --cwd %s locate -I .'],
- \ },
- \ 'fallback': 'find %s -type f'
- \ }
-
- " Single VCS, listing command lists untracked files (slower):
- let g:ctrlp_user_command =
- \ ['.git', 'cd %s && git ls-files . -co --exclude-standard']
-
- let g:ctrlp_user_command =
- \ ['.hg', 'hg --cwd %s status -numac -I . $(hg root)'] " MacOSX/Linux
-
- let g:ctrlp_user_command = ['.hg', 'for /f "tokens=1" %%a in (''hg root'') '
- \ . 'do hg --cwd %s status -numac -I . %%a'] " Windows
-<
-Note #1: in the |Dictionary| format, 'fallback' and 'ignore' are optional. In
-the |List| format, fallback_command is optional.
-
-Note #2: if the fallback_command is empty or the 'fallback' key is not defined,
-|globpath()| will then be used when scanning outside of a repository.
-
-Note #3: unless the |Dictionary| format is used and 'ignore' is defined and set
-to 1, the |wildignore| and |g:ctrlp_custom_ignore| options do not apply when
-these custom commands are being used. When not present, 'ignore' is set to 0 by
-default to retain the performance advantage of using external commands.
-
-Note #4: when changing the option's variable type, remember to |:unlet| it
-first or restart Vim to avoid the "E706: Variable type mismatch" error.
-
-Note #5: you can use a |b:var| to set this option on a per buffer basis.
-
- *'g:ctrlp_max_history'*
-The maximum number of input strings you want CtrlP to remember. The default
-value mirrors Vim's global |'history'| option: >
- let g:ctrlp_max_history = &history
-<
-Set to 0 to disable prompt's history. Browse the history with and .
-
- *'g:ctrlp_open_new_file'*
-Use this option to specify how the newly created file is to be opened when
-pressing : >
- let g:ctrlp_open_new_file = 'v'
-<
- t - in a new tab.
- h - in a new horizontal split.
- v - in a new vertical split.
- r - in the current window.
-
- *'g:ctrlp_open_multiple_files'*
-If non-zero, this will enable opening multiple files with and : >
- let g:ctrlp_open_multiple_files = 'v'
-<
-Example: >
- let g:ctrlp_open_multiple_files = '2vjr'
-<
-For the number:
- - If given, it'll be used as the maximum number of windows or tabs to create
- when opening the files (the rest will be opened as hidden buffers).
- - If not given, will open all files, each in a new window or new tab.
-
-For the letters:
- t - each file in a new tab.
- h - each file in a new horizontal split.
- v - each file in a new vertical split.
- i - all files as hidden buffers.
- j - after opening, jump to the first opened tab or window.
- r - open the first file in the current window, then the remaining files in
- new splits or new tabs depending on which of "h", "v" and "t" is also
- present.
-
- *'g:ctrlp_arg_map'*
-When this is set to 1, the and mappings will accept one extra key
-as an argument to override their default behavior: >
- let g:ctrlp_arg_map = 0
-<
-Pressing or will then prompt for a keypress. The key can be:
- t - open in tab(s)
- h - open in horizontal split(s)
- v - open in vertical split(s)
- i - open as hidden buffers (for only)
- c - clear the marked files (for only)
- r - open in the current window (for