├── .gitignore
├── README.md
├── autoload
└── pathogen.vim
├── bundle
├── ack.vim
│ ├── doc
│ │ ├── ack.txt
│ │ └── tags
│ └── plugin
│ │ └── ack.vim
├── ctrlp.vim
│ ├── .gitignore
│ ├── autoload
│ │ ├── ctrlp.vim
│ │ └── ctrlp
│ │ │ ├── bookmarkdir.vim
│ │ │ ├── buffertag.vim
│ │ │ ├── changes.vim
│ │ │ ├── dir.vim
│ │ │ ├── line.vim
│ │ │ ├── mixed.vim
│ │ │ ├── mrufiles.vim
│ │ │ ├── quickfix.vim
│ │ │ ├── rtscript.vim
│ │ │ ├── tag.vim
│ │ │ ├── undo.vim
│ │ │ └── utils.vim
│ ├── doc
│ │ └── ctrlp.txt
│ ├── plugin
│ │ └── ctrlp.vim
│ └── readme.md
├── delimitMate
│ ├── .gitignore
│ ├── Makefile
│ ├── README
│ ├── autoload
│ │ ├── delimitMate.vim
│ │ └── delimitMateTests.vim
│ ├── doc
│ │ └── delimitMate.txt
│ ├── plugin
│ │ └── delimitMate.vim
│ └── test
│ │ ├── README
│ │ ├── _setup.vim
│ │ ├── autoclose_matchpairs.txt
│ │ ├── autoclose_matchpairs.vim
│ │ ├── autoclose_quotes.txt
│ │ ├── autoclose_quotes.vim
│ │ ├── expand_cr.txt
│ │ ├── expand_cr.vim
│ │ ├── expand_space.txt
│ │ └── expand_space.vim
├── gnupg
│ └── plugin
│ │ └── gnupg.vim
├── matchit
│ ├── doc
│ │ └── matchit.txt
│ └── plugin
│ │ └── matchit.vim
├── snipmate
│ ├── README
│ ├── after
│ │ └── plugin
│ │ │ └── snipMate.vim
│ ├── autoload
│ │ └── snipMate.vim
│ ├── doc
│ │ ├── snipMate.txt
│ │ └── tags
│ ├── ftplugin
│ │ └── html_snip_helper.vim
│ ├── plugin
│ │ └── snipMate.vim
│ ├── snippets
│ │ ├── _.snippets
│ │ ├── autoit.snippets
│ │ ├── c.snippets
│ │ ├── cpp.snippets
│ │ ├── css.snippets
│ │ ├── eruby.snippets
│ │ ├── html.snippets
│ │ ├── java.snippets
│ │ ├── javascript.snippets
│ │ ├── mako.snippets
│ │ ├── objc.snippets
│ │ ├── perl.snippets
│ │ ├── php.snippets
│ │ ├── python.snippets
│ │ ├── ruby.snippets
│ │ ├── scss.snippets
│ │ ├── sh.snippets
│ │ ├── snippet.snippets
│ │ ├── tcl.snippets
│ │ ├── tex.snippets
│ │ ├── vim.snippets
│ │ └── zsh.snippets
│ └── syntax
│ │ └── snippet.vim
├── surround.vim
│ ├── doc
│ │ ├── surround.txt
│ │ └── tags
│ └── plugin
│ │ └── surround.vim
├── tComment
│ ├── README
│ ├── autoload
│ │ └── tcomment.vim
│ ├── doc
│ │ └── tcomment.txt
│ └── plugin
│ │ └── tcomment.vim
├── vim-auto-save
│ ├── README
│ ├── README.md
│ ├── doc
│ │ └── LICENSE.txt
│ └── plugin
│ │ └── AutoSave.vim
└── vim-rails
│ ├── .gitignore
│ ├── CONTRIBUTING.markdown
│ ├── README.markdown
│ ├── autoload
│ └── rails.vim
│ ├── doc
│ └── rails.txt
│ └── plugin
│ └── rails.vim
└── vimrc
/.gitignore:
--------------------------------------------------------------------------------
1 | tags
2 | *.netrwhist
3 | *.zip
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### Who will love this?
2 | If you do web dev a lot...yes
3 |
4 | ### Install
5 | 1. clone the repo
6 |
7 | git clone git://github.com/happypeter/peter-vim.git
8 |
9 | 1. rename it
10 |
11 | mv peter-vim ~/.vim
12 |
13 | 1. set up `~/.vimrc`, have a fake `.vimrc` in your `$HOME`
14 |
15 | ln -s ~/.vim/vimrc ~/.vimrc
16 |
17 | 1. you also need to install `Ctags`, `ack-grep`
18 |
19 | sudo apt-get install exuberant-ctags ack-grep # for ubuntu
20 |
21 | 1. vim 注意
22 |
23 | vim 中有 gpg.vim 插件,但是插件能使用的前题是系统上已经安装了 gpg ,也就是先要
24 |
25 | ```
26 | brew install gpg
27 | ```
28 |
29 | 然后再
30 |
31 | ```
32 | vim xxx.gpg
33 | ```
34 |
35 | 1. Video about how I manage my plugins
36 |
37 | - [vim plugin manage](https://www.bilibili.com/video/BV1JE411G7M3)
38 |
--------------------------------------------------------------------------------
/autoload/pathogen.vim:
--------------------------------------------------------------------------------
1 | " pathogen.vim - path option manipulation
2 | " Maintainer: Tim Pope
3 | " Version: 2.0
4 |
5 | " Install in ~/.vim/autoload (or ~\vimfiles\autoload).
6 | "
7 | " For management of individually installed plugins in ~/.vim/bundle (or
8 | " ~\vimfiles\bundle), adding `call pathogen#infect()` to your .vimrc
9 | " prior to `filetype plugin indent on` is the only other setup necessary.
10 | "
11 | " The API is documented inline below. For maximum ease of reading,
12 | " :set foldmethod=marker
13 |
14 | if exists("g:loaded_pathogen") || &cp
15 | finish
16 | endif
17 | let g:loaded_pathogen = 1
18 |
19 | " Point of entry for basic default usage. Give a directory name to invoke
20 | " pathogen#runtime_append_all_bundles() (defaults to "bundle"), or a full path
21 | " to invoke pathogen#runtime_prepend_subdirectories(). Afterwards,
22 | " pathogen#cycle_filetype() is invoked.
23 | function! pathogen#infect(...) abort " {{{1
24 | let source_path = a:0 ? a:1 : 'bundle'
25 | if source_path =~# '[\\/]'
26 | call pathogen#runtime_prepend_subdirectories(source_path)
27 | else
28 | call pathogen#runtime_append_all_bundles(source_path)
29 | endif
30 | call pathogen#cycle_filetype()
31 | endfunction " }}}1
32 |
33 | " Split a path into a list.
34 | function! pathogen#split(path) abort " {{{1
35 | if type(a:path) == type([]) | return a:path | endif
36 | let split = split(a:path,'\\\@"),'!isdirectory(v:val)')) && (!filereadable(dir.sep.'doc'.sep.'tags') || filewritable(dir.sep.'doc'.sep.'tags'))
170 | helptags `=dir.'/doc'`
171 | endif
172 | endfor
173 | endfunction " }}}1
174 |
175 | command! -bar Helptags :call pathogen#helptags()
176 |
177 | " Like findfile(), but hardcoded to use the runtimepath.
178 | function! pathogen#runtime_findfile(file,count) "{{{1
179 | let rtp = pathogen#join(1,pathogen#split(&rtp))
180 | return fnamemodify(findfile(a:file,rtp,a:count),':p')
181 | endfunction " }}}1
182 |
183 | " Backport of fnameescape().
184 | function! pathogen#fnameescape(string) " {{{1
185 | if exists('*fnameescape')
186 | return fnameescape(a:string)
187 | elseif a:string ==# '-'
188 | return '\-'
189 | else
190 | return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','')
191 | endif
192 | endfunction " }}}1
193 |
194 | function! s:find(count,cmd,file,lcd) " {{{1
195 | let rtp = pathogen#join(1,pathogen#split(&runtimepath))
196 | let file = pathogen#runtime_findfile(a:file,a:count)
197 | if file ==# ''
198 | return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'"
199 | elseif a:lcd
200 | let path = file[0:-strlen(a:file)-2]
201 | execute 'lcd `=path`'
202 | return a:cmd.' '.pathogen#fnameescape(a:file)
203 | else
204 | return a:cmd.' '.pathogen#fnameescape(file)
205 | endif
206 | endfunction " }}}1
207 |
208 | function! s:Findcomplete(A,L,P) " {{{1
209 | let sep = pathogen#separator()
210 | let cheats = {
211 | \'a': 'autoload',
212 | \'d': 'doc',
213 | \'f': 'ftplugin',
214 | \'i': 'indent',
215 | \'p': 'plugin',
216 | \'s': 'syntax'}
217 | if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0])
218 | let request = cheats[a:A[0]].a:A[1:-1]
219 | else
220 | let request = a:A
221 | endif
222 | let pattern = substitute(request,'\'.sep,'*'.sep,'g').'*'
223 | let found = {}
224 | for path in pathogen#split(&runtimepath)
225 | let path = expand(path, ':p')
226 | let matches = split(glob(path.sep.pattern),"\n")
227 | call map(matches,'isdirectory(v:val) ? v:val.sep : v:val')
228 | call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]')
229 | for match in matches
230 | let found[match] = 1
231 | endfor
232 | endfor
233 | return sort(keys(found))
234 | endfunction " }}}1
235 |
236 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(,'edit',,0)
237 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(,'edit',,0)
238 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(,'edit',,1)
239 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(,'split',,1)
240 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(,'vsplit',,1)
241 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(,'tabedit',,1)
242 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(,'pedit',,1)
243 | command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(,'read',,1)
244 |
245 | " vim:set ft=vim ts=8 sw=2 sts=2:
246 |
--------------------------------------------------------------------------------
/bundle/ack.vim/doc/ack.txt:
--------------------------------------------------------------------------------
1 | *ack.txt* Plugin that integrates ack with Vim
2 |
3 | ==============================================================================
4 | Author: Antoine Imbert *ack-author*
5 | License: Same terms as Vim itself (see |license|)
6 |
7 | ==============================================================================
8 | INTRODUCTION *ack*
9 |
10 | This plugin is a front for the Perl module App::Ack. Ack can be used as a
11 | replacement for grep. This plugin will allow you to run ack from vim, and
12 | shows the results in a split window.
13 |
14 | :Ack[!] [options] {pattern} [{directory}] *:Ack*
15 |
16 | Search recursively in {directory} (which defaults to the current
17 | directory) for the {pattern}. Behaves just like the |:grep| command, but
18 | will open the |Quickfix| window for you. If [!] is not given the first
19 | error is jumped to.
20 |
21 | :AckAdd [options] {pattern} [{directory}] *:AckAdd*
22 |
23 | Just like |:Ack|, but instead of making a new list, the matches are
24 | appended to the current |quickfix| list.
25 |
26 | :AckFromSearch [{directory}] *:AckFromSearch*
27 |
28 | Just like |:Ack| but the pattern is from previous search.
29 |
30 | :LAck [options] {pattern} [{directory}] *:LAck*
31 |
32 | Just like |:Ack| but instead of the |quickfix| list, matches are placed in
33 | the current |location-list|.
34 |
35 | :LAckAdd [options] {pattern} [{directory}] *:LAckAdd*
36 |
37 | Just like |:AckAdd| but instead of the |quickfix| list, matches are added
38 | to the current |location-list|
39 |
40 | :AckFile [options] {pattern} [{directory}] *:AckFile*
41 |
42 | Search recursively in {directory} (which defaults to the current
43 | directory) for filenames matching the {pattern}. Behaves just like the
44 | |:grep| command, but will open the |Quickfix| window for you.
45 |
46 | Files containing the search term will be listed in the split window, along
47 | with the line number of the occurrence, once for each occurrence. on
48 | a line in this window will open the file, and place the cursor on the matching
49 | line.
50 |
51 | See http://betterthangrep.com/ for more information.
52 |
53 | ==============================================================================
54 | MAPPINGS *ack-mappings*
55 |
56 | The following keyboard shortcuts are available in the quickfix window:
57 |
58 | o open file (same as enter).
59 |
60 | go preview file (open but maintain focus on ack.vim results).
61 |
62 | t open in a new tab.
63 |
64 | T open in new tab silently.
65 |
66 | v open in vertical split.
67 |
68 | gv open in vertical split silently.
69 |
70 | q close the quickfix window.
71 |
--------------------------------------------------------------------------------
/bundle/ack.vim/doc/tags:
--------------------------------------------------------------------------------
1 | :Ack ack.txt /*:Ack*
2 | :AckAdd ack.txt /*:AckAdd*
3 | :AckFile ack.txt /*:AckFile*
4 | :AckFromSearch ack.txt /*:AckFromSearch*
5 | :LAck ack.txt /*:LAck*
6 | :LAckAdd ack.txt /*:LAckAdd*
7 | ack ack.txt /*ack*
8 | ack-author ack.txt /*ack-author*
9 | ack-mappings ack.txt /*ack-mappings*
10 | ack.txt ack.txt /*ack.txt*
11 |
--------------------------------------------------------------------------------
/bundle/ack.vim/plugin/ack.vim:
--------------------------------------------------------------------------------
1 | " NOTE: You must, of course, install the ack script
2 | " in your path.
3 | " On Debian / Ubuntu:
4 | " sudo apt-get install ack-grep
5 | " On your vimrc:
6 | " let g:ackprg="ack-grep -H --nocolor --nogroup --column"
7 | "
8 | " With MacPorts:
9 | " sudo port install p5-app-ack
10 |
11 | " Location of the ack utility
12 | if !exists("g:ackprg")
13 | let g:ackprg="ack -H --nocolor --nogroup --column"
14 | endif
15 |
16 | function! s:Ack(cmd, args)
17 | redraw
18 | echo "Searching ..."
19 |
20 | " If no pattern is provided, search for the word under the cursor
21 | if empty(a:args)
22 | let l:grepargs = expand("")
23 | else
24 | let l:grepargs = a:args
25 | end
26 |
27 | " Format, used to manage column jump
28 | if a:cmd =~# '-g$'
29 | let g:ackformat="%f"
30 | else
31 | let g:ackformat="%f:%l:%c:%m"
32 | end
33 |
34 | let grepprg_bak=&grepprg
35 | let grepformat_bak=&grepformat
36 | try
37 | let &grepprg=g:ackprg
38 | let &grepformat=g:ackformat
39 | silent execute a:cmd . " " . l:grepargs
40 | finally
41 | let &grepprg=grepprg_bak
42 | let &grepformat=grepformat_bak
43 | endtry
44 |
45 | if a:cmd =~# '^l'
46 | botright lopen
47 | else
48 | botright copen
49 | endif
50 |
51 | exec "nnoremap q :ccl"
52 | exec "nnoremap t T"
53 | exec "nnoremap T TgT"
54 | exec "nnoremap o "
55 | exec "nnoremap go "
56 | exec "nnoremap v v"
57 | exec "nnoremap gv v"
58 |
59 | " If highlighting is on, highlight the search keyword.
60 | if exists("g:ackhighlight")
61 | let @/=a:args
62 | set hlsearch
63 | end
64 |
65 | redraw!
66 | endfunction
67 |
68 | function! s:AckFromSearch(cmd, args)
69 | let search = getreg('/')
70 | " translate vim regular expression to perl regular expression.
71 | let search = substitute(search,'\(\\<\|\\>\)','\\b','g')
72 | call s:Ack(a:cmd, '"' . search .'" '. a:args)
73 | endfunction
74 |
75 | command! -bang -nargs=* -complete=file Ack call s:Ack('grep',)
76 | command! -bang -nargs=* -complete=file AckAdd call s:Ack('grepadd', )
77 | command! -bang -nargs=* -complete=file AckFromSearch call s:AckFromSearch('grep', )
78 | command! -bang -nargs=* -complete=file LAck call s:Ack('lgrep', )
79 | command! -bang -nargs=* -complete=file LAckAdd call s:Ack('lgrepadd', )
80 | command! -bang -nargs=* -complete=file AckFile call s:Ack('grep -g', )
81 |
--------------------------------------------------------------------------------
/bundle/ctrlp.vim/.gitignore:
--------------------------------------------------------------------------------
1 | *.markdown
2 | *.zip
3 | note.txt
4 | tags
5 | .hg*
6 | tmp/*
7 |
--------------------------------------------------------------------------------
/bundle/ctrlp.vim/autoload/ctrlp/bookmarkdir.vim:
--------------------------------------------------------------------------------
1 | " =============================================================================
2 | " File: autoload/ctrlp/bookmarkdir.vim
3 | " Description: Bookmarked directories extension
4 | " Author: Kien Nguyen
5 | " =============================================================================
6 |
7 | " Init {{{1
8 | if exists('g:loaded_ctrlp_bookmarkdir') && g:loaded_ctrlp_bookmarkdir
9 | fini
10 | en
11 | let g:loaded_ctrlp_bookmarkdir = 1
12 |
13 | cal add(g:ctrlp_ext_vars, {
14 | \ 'init': 'ctrlp#bookmarkdir#init()',
15 | \ 'accept': 'ctrlp#bookmarkdir#accept',
16 | \ 'lname': 'bookmarked dirs',
17 | \ 'sname': 'bkd',
18 | \ 'type': 'tabs',
19 | \ 'opmul': 1,
20 | \ 'nolim': 1,
21 | \ 'wipe': 'ctrlp#bookmarkdir#remove',
22 | \ })
23 |
24 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
25 | " Utilities {{{1
26 | fu! s:getinput(str, ...)
27 | echoh Identifier
28 | cal inputsave()
29 | let input = call('input', a:0 ? [a:str] + a:000 : [a:str])
30 | cal inputrestore()
31 | echoh None
32 | retu input
33 | endf
34 |
35 | fu! s:cachefile()
36 | if !exists('s:cadir') || !exists('s:cafile')
37 | let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'bkd'
38 | let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt'
39 | en
40 | retu s:cafile
41 | endf
42 |
43 | fu! s:writecache(lines)
44 | cal ctrlp#utils#writecache(a:lines, s:cadir, s:cafile)
45 | endf
46 |
47 | fu! s:getbookmarks()
48 | retu ctrlp#utils#readfile(s:cachefile())
49 | endf
50 |
51 | fu! s:savebookmark(name, cwd)
52 | let cwds = exists('+ssl') ? [tr(a:cwd, '\', '/'), tr(a:cwd, '/', '\')] : [a:cwd]
53 | let entries = filter(s:getbookmarks(), 'index(cwds, s:parts(v:val)[1]) < 0')
54 | cal s:writecache(insert(entries, a:name.' '.a:cwd))
55 | endf
56 |
57 | fu! s:setentries()
58 | let time = getftime(s:cachefile())
59 | if !( exists('s:bookmarks') && time == s:bookmarks[0] )
60 | let s:bookmarks = [time, s:getbookmarks()]
61 | en
62 | endf
63 |
64 | fu! s:parts(str)
65 | let mlist = matchlist(a:str, '\v([^\t]+)\t(.*)$')
66 | retu mlist != [] ? mlist[1:2] : ['', '']
67 | endf
68 |
69 | fu! s:process(entries, type)
70 | retu map(a:entries, 's:modify(v:val, a:type)')
71 | endf
72 |
73 | fu! s:modify(entry, type)
74 | let [name, dir] = s:parts(a:entry)
75 | let dir = fnamemodify(dir, a:type)
76 | retu name.' '.( dir == '' ? '.' : dir )
77 | endf
78 |
79 | fu! s:msg(name, cwd)
80 | redr
81 | echoh Identifier | echon 'Bookmarked ' | echoh Constant
82 | echon a:name.' ' | echoh Directory | echon a:cwd
83 | echoh None
84 | endf
85 |
86 | fu! s:syntax()
87 | if !ctrlp#nosy()
88 | cal ctrlp#hicheck('CtrlPBookmark', 'Identifier')
89 | cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
90 | sy match CtrlPBookmark '^> [^\t]\+' contains=CtrlPLinePre
91 | sy match CtrlPTabExtra '\zs\t.*\ze$'
92 | en
93 | endf
94 | " Public {{{1
95 | fu! ctrlp#bookmarkdir#init()
96 | cal s:setentries()
97 | cal s:syntax()
98 | retu s:process(copy(s:bookmarks[1]), ':.')
99 | endf
100 |
101 | fu! ctrlp#bookmarkdir#accept(mode, str)
102 | let parts = s:parts(s:modify(a:str, ':p'))
103 | cal call('s:savebookmark', parts)
104 | if a:mode =~ 't\|v\|h'
105 | cal ctrlp#exit()
106 | en
107 | cal ctrlp#setdir(parts[1], a:mode =~ 't\|h' ? 'chd!' : 'lc!')
108 | if a:mode == 'e'
109 | cal ctrlp#switchtype(0)
110 | cal ctrlp#recordhist()
111 | cal ctrlp#prtclear()
112 | en
113 | endf
114 |
115 | fu! ctrlp#bookmarkdir#add(dir)
116 | let str = 'Directory to bookmark: '
117 | let cwd = a:dir != '' ? a:dir : s:getinput(str, getcwd(), 'dir')
118 | if cwd == '' | retu | en
119 | let cwd = fnamemodify(cwd, ':p')
120 | let name = s:getinput('Bookmark as: ', cwd)
121 | if name == '' | retu | en
122 | let name = tr(name, ' ', ' ')
123 | cal s:savebookmark(name, cwd)
124 | cal s:msg(name, cwd)
125 | endf
126 |
127 | fu! ctrlp#bookmarkdir#remove(entries)
128 | cal s:process(a:entries, ':p')
129 | cal s:writecache(a:entries == [] ? [] :
130 | \ filter(s:getbookmarks(), 'index(a:entries, v:val) < 0'))
131 | cal s:setentries()
132 | retu s:process(copy(s:bookmarks[1]), ':.')
133 | endf
134 |
135 | fu! ctrlp#bookmarkdir#id()
136 | retu s:id
137 | endf
138 | "}}}
139 |
140 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
141 |
--------------------------------------------------------------------------------
/bundle/ctrlp.vim/autoload/ctrlp/buffertag.vim:
--------------------------------------------------------------------------------
1 | " =============================================================================
2 | " File: autoload/ctrlp/buffertag.vim
3 | " Description: Buffer Tag extension
4 | " Maintainer: Kien Nguyen
5 | " Credits: Much of the code was taken from tagbar.vim by Jan Larres, plus
6 | " a few lines from taglist.vim by Yegappan Lakshmanan and from
7 | " buffertag.vim by Takeshi Nishida.
8 | " =============================================================================
9 |
10 | " Init {{{1
11 | if exists('g:loaded_ctrlp_buftag') && g:loaded_ctrlp_buftag
12 | fini
13 | en
14 | let g:loaded_ctrlp_buftag = 1
15 |
16 | cal add(g:ctrlp_ext_vars, {
17 | \ 'init': 'ctrlp#buffertag#init(s:crfile)',
18 | \ 'accept': 'ctrlp#buffertag#accept',
19 | \ 'lname': 'buffer tags',
20 | \ 'sname': 'bft',
21 | \ 'exit': 'ctrlp#buffertag#exit()',
22 | \ 'type': 'tabs',
23 | \ 'opts': 'ctrlp#buffertag#opts()',
24 | \ })
25 |
26 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
27 |
28 | let [s:pref, s:opts] = ['g:ctrlp_buftag_', {
29 | \ 'systemenc': ['s:enc', &enc],
30 | \ 'ctags_bin': ['s:bin', ''],
31 | \ 'types': ['s:usr_types', {}],
32 | \ }]
33 |
34 | let s:bins = [
35 | \ 'ctags-exuberant',
36 | \ 'exuberant-ctags',
37 | \ 'exctags',
38 | \ '/usr/local/bin/ctags',
39 | \ '/opt/local/bin/ctags',
40 | \ 'ctags',
41 | \ 'ctags.exe',
42 | \ 'tags',
43 | \ ]
44 |
45 | let s:types = {
46 | \ 'asm' : '%sasm%sasm%sdlmt',
47 | \ 'aspperl': '%sasp%sasp%sfsv',
48 | \ 'aspvbs' : '%sasp%sasp%sfsv',
49 | \ 'awk' : '%sawk%sawk%sf',
50 | \ 'beta' : '%sbeta%sbeta%sfsv',
51 | \ 'c' : '%sc%sc%sdgsutvf',
52 | \ 'cpp' : '%sc++%sc++%snvdtcgsuf',
53 | \ 'cs' : '%sc#%sc#%sdtncEgsipm',
54 | \ 'cobol' : '%scobol%scobol%sdfgpPs',
55 | \ 'eiffel' : '%seiffel%seiffel%scf',
56 | \ 'erlang' : '%serlang%serlang%sdrmf',
57 | \ 'expect' : '%stcl%stcl%scfp',
58 | \ 'fortran': '%sfortran%sfortran%spbceiklmntvfs',
59 | \ 'html' : '%shtml%shtml%saf',
60 | \ 'java' : '%sjava%sjava%spcifm',
61 | \ 'javascript': '%sjavascript%sjavascript%sf',
62 | \ 'lisp' : '%slisp%slisp%sf',
63 | \ 'lua' : '%slua%slua%sf',
64 | \ 'make' : '%smake%smake%sm',
65 | \ 'pascal' : '%spascal%spascal%sfp',
66 | \ 'perl' : '%sperl%sperl%sclps',
67 | \ 'php' : '%sphp%sphp%scdvf',
68 | \ 'python' : '%spython%spython%scmf',
69 | \ 'rexx' : '%srexx%srexx%ss',
70 | \ 'ruby' : '%sruby%sruby%scfFm',
71 | \ 'scheme' : '%sscheme%sscheme%ssf',
72 | \ 'sh' : '%ssh%ssh%sf',
73 | \ 'csh' : '%ssh%ssh%sf',
74 | \ 'zsh' : '%ssh%ssh%sf',
75 | \ 'slang' : '%sslang%sslang%snf',
76 | \ 'sml' : '%ssml%ssml%secsrtvf',
77 | \ 'sql' : '%ssql%ssql%scFPrstTvfp',
78 | \ 'tcl' : '%stcl%stcl%scfmp',
79 | \ 'vera' : '%svera%svera%scdefgmpPtTvx',
80 | \ 'verilog': '%sverilog%sverilog%smcPertwpvf',
81 | \ 'vim' : '%svim%svim%savf',
82 | \ 'yacc' : '%syacc%syacc%sl',
83 | \ }
84 |
85 | cal map(s:types, 'printf(v:val, "--language-force=", " --", "-types=")')
86 |
87 | if executable('jsctags')
88 | cal extend(s:types, { 'javascript': { 'args': '-f -', 'bin': 'jsctags' } })
89 | en
90 |
91 | fu! ctrlp#buffertag#opts()
92 | for [ke, va] in items(s:opts)
93 | let {va[0]} = exists(s:pref.ke) ? {s:pref.ke} : va[1]
94 | endfo
95 | " Ctags bin
96 | if empty(s:bin)
97 | for bin in s:bins | if executable(bin)
98 | let s:bin = bin
99 | brea
100 | en | endfo
101 | el
102 | let s:bin = expand(s:bin, 1)
103 | en
104 | " Types
105 | cal extend(s:types, s:usr_types)
106 | endf
107 | " Utilities {{{1
108 | fu! s:validfile(fname, ftype)
109 | if ( !empty(a:fname) || !empty(a:ftype) ) && filereadable(a:fname)
110 | \ && index(keys(s:types), a:ftype) >= 0 | retu 1 | en
111 | retu 0
112 | endf
113 |
114 | fu! s:exectags(cmd)
115 | if exists('+ssl')
116 | let [ssl, &ssl] = [&ssl, 0]
117 | en
118 | if &sh =~ 'cmd\.exe'
119 | let [sxq, &sxq, shcf, &shcf] = [&sxq, '"', &shcf, '/s /c']
120 | en
121 | let output = system(a:cmd)
122 | if &sh =~ 'cmd\.exe'
123 | let [&sxq, &shcf] = [sxq, shcf]
124 | en
125 | if exists('+ssl')
126 | let &ssl = ssl
127 | en
128 | retu output
129 | endf
130 |
131 | fu! s:exectagsonfile(fname, ftype)
132 | let [ags, ft] = ['-f - --sort=no --excmd=pattern --fields=nKs ', a:ftype]
133 | if type(s:types[ft]) == 1
134 | let ags .= s:types[ft]
135 | let bin = s:bin
136 | elsei type(s:types[ft]) == 4
137 | let ags = s:types[ft]['args']
138 | let bin = expand(s:types[ft]['bin'], 1)
139 | en
140 | if empty(bin) | retu '' | en
141 | let cmd = s:esctagscmd(bin, ags, a:fname)
142 | if empty(cmd) | retu '' | en
143 | let output = s:exectags(cmd)
144 | if v:shell_error || output =~ 'Warning: cannot open' | retu '' | en
145 | retu output
146 | endf
147 |
148 | fu! s:esctagscmd(bin, args, ...)
149 | if exists('+ssl')
150 | let [ssl, &ssl] = [&ssl, 0]
151 | en
152 | let fname = a:0 ? shellescape(a:1) : ''
153 | let cmd = shellescape(a:bin).' '.a:args.' '.fname
154 | if &sh =~ 'cmd\.exe'
155 | let cmd = substitute(cmd, '[&()@^<>|]', '^\0', 'g')
156 | en
157 | if exists('+ssl')
158 | let &ssl = ssl
159 | en
160 | if has('iconv')
161 | let last = s:enc != &enc ? s:enc : !empty( $LANG ) ? $LANG : &enc
162 | let cmd = iconv(cmd, &enc, last)
163 | en
164 | retu cmd
165 | endf
166 |
167 | fu! s:process(fname, ftype)
168 | if !s:validfile(a:fname, a:ftype) | retu [] | endif
169 | let ftime = getftime(a:fname)
170 | if has_key(g:ctrlp_buftags, a:fname)
171 | \ && g:ctrlp_buftags[a:fname]['time'] >= ftime
172 | let lines = g:ctrlp_buftags[a:fname]['lines']
173 | el
174 | let data = s:exectagsonfile(a:fname, a:ftype)
175 | let [raw, lines] = [split(data, '\n\+'), []]
176 | for line in raw
177 | if line !~# '^!_TAG_' && len(split(line, ';"')) == 2
178 | let parsed_line = s:parseline(line)
179 | if parsed_line != ''
180 | cal add(lines, parsed_line)
181 | en
182 | en
183 | endfo
184 | let cache = { a:fname : { 'time': ftime, 'lines': lines } }
185 | cal extend(g:ctrlp_buftags, cache)
186 | en
187 | retu lines
188 | endf
189 |
190 | fu! s:parseline(line)
191 | let vals = matchlist(a:line,
192 | \ '\v^([^\t]+)\t(.+)\t[?/]\^?(.{-1,})\$?[?/]\;\"\t(.+)\tline(no)?\:(\d+)')
193 | if vals == [] | retu '' | en
194 | let [bufnr, bufname] = [bufnr('^'.vals[2].'$'), fnamemodify(vals[2], ':p:t')]
195 | retu vals[1].' '.vals[4].'|'.bufnr.':'.bufname.'|'.vals[6].'| '.vals[3]
196 | endf
197 |
198 | fu! s:syntax()
199 | if !ctrlp#nosy()
200 | cal ctrlp#hicheck('CtrlPTagKind', 'Title')
201 | cal ctrlp#hicheck('CtrlPBufName', 'Directory')
202 | cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
203 | sy match CtrlPTagKind '\zs[^\t|]\+\ze|\d\+:[^|]\+|\d\+|'
204 | sy match CtrlPBufName '|\d\+:\zs[^|]\+\ze|\d\+|'
205 | sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName,CtrlPTagKind
206 | en
207 | endf
208 |
209 | fu! s:chknearby(pat)
210 | if match(getline('.'), a:pat) < 0
211 | let [int, forw, maxl] = [1, 1, line('$')]
212 | wh !search(a:pat, 'W'.( forw ? '' : 'b' ))
213 | if !forw
214 | if int > maxl | brea | en
215 | let int += int
216 | en
217 | let forw = !forw
218 | endw
219 | en
220 | endf
221 | " Public {{{1
222 | fu! ctrlp#buffertag#init(fname)
223 | let bufs = exists('s:btmode') && s:btmode
224 | \ ? filter(ctrlp#buffers(), 'filereadable(v:val)')
225 | \ : [exists('s:bufname') ? s:bufname : a:fname]
226 | let lines = []
227 | for each in bufs
228 | let bname = fnamemodify(each, ':p')
229 | let tftype = get(split(getbufvar('^'.bname.'$', '&ft'), '\.'), 0, '')
230 | cal extend(lines, s:process(bname, tftype))
231 | endfo
232 | cal s:syntax()
233 | retu lines
234 | endf
235 |
236 | fu! ctrlp#buffertag#accept(mode, str)
237 | let vals = matchlist(a:str,
238 | \ '\v^[^\t]+\t+[^\t|]+\|(\d+)\:[^\t|]+\|(\d+)\|\s(.+)$')
239 | let bufnr = str2nr(get(vals, 1))
240 | if bufnr
241 | cal ctrlp#acceptfile(a:mode, bufnr)
242 | exe 'norm!' str2nr(get(vals, 2, line('.'))).'G'
243 | cal s:chknearby('\V\C'.get(vals, 3, ''))
244 | sil! norm! zvzz
245 | en
246 | endf
247 |
248 | fu! ctrlp#buffertag#cmd(mode, ...)
249 | let s:btmode = a:mode
250 | if a:0 && !empty(a:1)
251 | let s:bufname = fnamemodify(a:1, ':p')
252 | en
253 | retu s:id
254 | endf
255 |
256 | fu! ctrlp#buffertag#exit()
257 | unl! s:btmode s:bufname
258 | endf
259 | "}}}
260 |
261 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
262 |
--------------------------------------------------------------------------------
/bundle/ctrlp.vim/autoload/ctrlp/changes.vim:
--------------------------------------------------------------------------------
1 | " =============================================================================
2 | " File: autoload/ctrlp/changes.vim
3 | " Description: Change list extension
4 | " Author: Kien Nguyen
5 | " =============================================================================
6 |
7 | " Init {{{1
8 | if exists('g:loaded_ctrlp_changes') && g:loaded_ctrlp_changes
9 | fini
10 | en
11 | let g:loaded_ctrlp_changes = 1
12 |
13 | cal add(g:ctrlp_ext_vars, {
14 | \ 'init': 'ctrlp#changes#init(s:bufnr, s:crbufnr)',
15 | \ 'accept': 'ctrlp#changes#accept',
16 | \ 'lname': 'changes',
17 | \ 'sname': 'chs',
18 | \ 'exit': 'ctrlp#changes#exit()',
19 | \ 'type': 'tabe',
20 | \ 'sort': 0,
21 | \ 'nolim': 1,
22 | \ })
23 |
24 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
25 | " Utilities {{{1
26 | fu! s:changelist(bufnr)
27 | sil! exe 'noa hid b' a:bufnr
28 | redi => result
29 | sil! changes
30 | redi END
31 | retu map(split(result, "\n")[1:], 'tr(v:val, " ", " ")')
32 | endf
33 |
34 | fu! s:process(clines, ...)
35 | let [clines, evas] = [[], []]
36 | for each in a:clines
37 | let parts = matchlist(each, '\v^.\s*\d+\s+(\d+)\s+(\d+)\s(.*)$')
38 | if !empty(parts)
39 | if parts[3] == '' | let parts[3] = ' ' | en
40 | cal add(clines, parts[3].' |'.a:1.':'.a:2.'|'.parts[1].':'.parts[2].'|')
41 | en
42 | endfo
43 | retu reverse(filter(clines, 'count(clines, v:val) == 1'))
44 | endf
45 |
46 | fu! s:syntax()
47 | if !ctrlp#nosy()
48 | cal ctrlp#hicheck('CtrlPBufName', 'Directory')
49 | cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
50 | sy match CtrlPBufName '\t|\d\+:\zs[^|]\+\ze|\d\+:\d\+|$'
51 | sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName
52 | en
53 | endf
54 | " Public {{{1
55 | fu! ctrlp#changes#init(original_bufnr, bufnr)
56 | let bufnr = exists('s:bufnr') ? s:bufnr : a:bufnr
57 | let bufs = exists('s:clmode') && s:clmode ? ctrlp#buffers('id') : [bufnr]
58 | cal filter(bufs, 'v:val > 0')
59 | let [swb, &swb] = [&swb, '']
60 | let lines = []
61 | for each in bufs
62 | let bname = bufname(each)
63 | let fnamet = fnamemodify(bname == '' ? '[No Name]' : bname, ':t')
64 | cal extend(lines, s:process(s:changelist(each), each, fnamet))
65 | endfo
66 | sil! exe 'noa hid b' a:original_bufnr
67 | let &swb = swb
68 | cal ctrlp#syntax()
69 | cal s:syntax()
70 | retu lines
71 | endf
72 |
73 | fu! ctrlp#changes#accept(mode, str)
74 | let info = matchlist(a:str, '\t|\(\d\+\):[^|]\+|\(\d\+\):\(\d\+\)|$')
75 | let bufnr = str2nr(get(info, 1))
76 | if bufnr
77 | cal ctrlp#acceptfile(a:mode, bufnr)
78 | cal cursor(get(info, 2), get(info, 3))
79 | sil! norm! zvzz
80 | en
81 | endf
82 |
83 | fu! ctrlp#changes#cmd(mode, ...)
84 | let s:clmode = a:mode
85 | if a:0 && !empty(a:1)
86 | let s:bufnr = bufnr('^'.fnamemodify(a:1, ':p').'$')
87 | en
88 | retu s:id
89 | endf
90 |
91 | fu! ctrlp#changes#exit()
92 | unl! s:clmode s:bufnr
93 | endf
94 | "}}}
95 |
96 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
97 |
--------------------------------------------------------------------------------
/bundle/ctrlp.vim/autoload/ctrlp/dir.vim:
--------------------------------------------------------------------------------
1 | " =============================================================================
2 | " File: autoload/ctrlp/dir.vim
3 | " Description: Directory extension
4 | " Author: Kien Nguyen
5 | " =============================================================================
6 |
7 | " Init {{{1
8 | if exists('g:loaded_ctrlp_dir') && g:loaded_ctrlp_dir
9 | fini
10 | en
11 | let [g:loaded_ctrlp_dir, g:ctrlp_newdir] = [1, 0]
12 |
13 | let s:ars = ['s:maxdepth', 's:maxfiles', 's:compare_lim', 's:glob', 's:caching']
14 |
15 | cal add(g:ctrlp_ext_vars, {
16 | \ 'init': 'ctrlp#dir#init('.join(s:ars, ', ').')',
17 | \ 'accept': 'ctrlp#dir#accept',
18 | \ 'lname': 'dirs',
19 | \ 'sname': 'dir',
20 | \ 'type': 'path',
21 | \ 'specinput': 1,
22 | \ })
23 |
24 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
25 |
26 | let s:dircounts = {}
27 | " Utilities {{{1
28 | fu! s:globdirs(dirs, depth)
29 | let entries = split(globpath(a:dirs, s:glob), "\n")
30 | let [dirs, depth] = [ctrlp#dirnfile(entries)[0], a:depth + 1]
31 | cal extend(g:ctrlp_alldirs, dirs)
32 | let nr = len(g:ctrlp_alldirs)
33 | if !empty(dirs) && !s:max(nr, s:maxfiles) && depth <= s:maxdepth
34 | sil! cal ctrlp#progress(nr)
35 | cal map(dirs, 'ctrlp#utils#fnesc(v:val, "g", ",")')
36 | cal s:globdirs(join(dirs, ','), depth)
37 | en
38 | endf
39 |
40 | fu! s:max(len, max)
41 | retu a:max && a:len > a:max
42 | endf
43 |
44 | fu! s:nocache()
45 | retu !s:caching || ( s:caching > 1 && get(s:dircounts, s:cwd) < s:caching )
46 | endf
47 | " Public {{{1
48 | fu! ctrlp#dir#init(...)
49 | let s:cwd = getcwd()
50 | for each in range(len(s:ars))
51 | let {s:ars[each]} = a:{each + 1}
52 | endfo
53 | let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'dir'
54 | let cafile = cadir.ctrlp#utils#lash().ctrlp#utils#cachefile('dir')
55 | if g:ctrlp_newdir || s:nocache() || !filereadable(cafile)
56 | let [s:initcwd, g:ctrlp_alldirs] = [s:cwd, []]
57 | if !ctrlp#igncwd(s:cwd)
58 | cal s:globdirs(ctrlp#utils#fnesc(s:cwd, 'g', ','), 0)
59 | en
60 | cal ctrlp#rmbasedir(g:ctrlp_alldirs)
61 | if len(g:ctrlp_alldirs) <= s:compare_lim
62 | cal sort(g:ctrlp_alldirs, 'ctrlp#complen')
63 | en
64 | cal ctrlp#utils#writecache(g:ctrlp_alldirs, cadir, cafile)
65 | let g:ctrlp_newdir = 0
66 | el
67 | if !( exists('s:initcwd') && s:initcwd == s:cwd )
68 | let s:initcwd = s:cwd
69 | let g:ctrlp_alldirs = ctrlp#utils#readfile(cafile)
70 | en
71 | en
72 | cal extend(s:dircounts, { s:cwd : len(g:ctrlp_alldirs) })
73 | retu g:ctrlp_alldirs
74 | endf
75 |
76 | fu! ctrlp#dir#accept(mode, str)
77 | let path = a:mode == 'h' ? getcwd() : s:cwd.ctrlp#utils#lash().a:str
78 | if a:mode =~ 't\|v\|h'
79 | cal ctrlp#exit()
80 | en
81 | cal ctrlp#setdir(path, a:mode =~ 't\|h' ? 'chd!' : 'lc!')
82 | if a:mode == 'e'
83 | sil! cal ctrlp#statusline()
84 | cal ctrlp#setlines(s:id)
85 | cal ctrlp#recordhist()
86 | cal ctrlp#prtclear()
87 | en
88 | endf
89 |
90 | fu! ctrlp#dir#id()
91 | retu s:id
92 | endf
93 | "}}}
94 |
95 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
96 |
--------------------------------------------------------------------------------
/bundle/ctrlp.vim/autoload/ctrlp/line.vim:
--------------------------------------------------------------------------------
1 | " =============================================================================
2 | " File: autoload/ctrlp/line.vim
3 | " Description: Line extension
4 | " Author: Kien Nguyen
5 | " =============================================================================
6 |
7 | " Init {{{1
8 | if exists('g:loaded_ctrlp_line') && g:loaded_ctrlp_line
9 | fini
10 | en
11 | let g:loaded_ctrlp_line = 1
12 |
13 | cal add(g:ctrlp_ext_vars, {
14 | \ 'init': 'ctrlp#line#init()',
15 | \ 'accept': 'ctrlp#line#accept',
16 | \ 'lname': 'lines',
17 | \ 'sname': 'lns',
18 | \ 'type': 'tabe',
19 | \ })
20 |
21 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
22 | " Utilities {{{1
23 | fu! s:syntax()
24 | if !ctrlp#nosy()
25 | cal ctrlp#hicheck('CtrlPBufName', 'Directory')
26 | cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
27 | sy match CtrlPBufName '\t|\zs[^|]\+\ze|\d\+:\d\+|$'
28 | sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName
29 | en
30 | endf
31 | " Public {{{1
32 | fu! ctrlp#line#init()
33 | let [bufs, lines] = [ctrlp#buffers('id'), []]
34 | for bufnr in bufs
35 | let [lfb, bufn] = [getbufline(bufnr, 1, '$'), bufname(bufnr)]
36 | if lfb == [] && bufn != ''
37 | let lfb = ctrlp#utils#readfile(fnamemodify(bufn, ':p'))
38 | en
39 | cal map(lfb, 'tr(v:val, '' '', '' '')')
40 | let [linenr, len_lfb] = [1, len(lfb)]
41 | let buft = bufn == '' ? '[No Name]' : fnamemodify(bufn, ':t')
42 | wh linenr <= len_lfb
43 | let lfb[linenr - 1] .= ' |'.buft.'|'.bufnr.':'.linenr.'|'
44 | let linenr += 1
45 | endw
46 | cal extend(lines, filter(lfb, 'v:val !~ ''^\s*\t|[^|]\+|\d\+:\d\+|$'''))
47 | endfo
48 | cal s:syntax()
49 | retu lines
50 | endf
51 |
52 | fu! ctrlp#line#accept(mode, str)
53 | let info = matchlist(a:str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$')
54 | let bufnr = str2nr(get(info, 1))
55 | if bufnr
56 | cal ctrlp#acceptfile(a:mode, bufnr, get(info, 2))
57 | en
58 | endf
59 |
60 | fu! ctrlp#line#id()
61 | retu s:id
62 | endf
63 | "}}}
64 |
65 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
66 |
--------------------------------------------------------------------------------
/bundle/ctrlp.vim/autoload/ctrlp/mixed.vim:
--------------------------------------------------------------------------------
1 | " =============================================================================
2 | " File: autoload/ctrlp/mixed.vim
3 | " Description: Mixing Files + MRU + Buffers
4 | " Author: Kien Nguyen
5 | " =============================================================================
6 |
7 | " Init {{{1
8 | if exists('g:loaded_ctrlp_mixed') && g:loaded_ctrlp_mixed
9 | fini
10 | en
11 | let [g:loaded_ctrlp_mixed, g:ctrlp_newmix] = [1, 0]
12 |
13 | cal add(g:ctrlp_ext_vars, {
14 | \ 'init': 'ctrlp#mixed#init(s:compare_lim)',
15 | \ 'accept': 'ctrlp#acceptfile',
16 | \ 'lname': 'fil + mru + buf',
17 | \ 'sname': 'mix',
18 | \ 'type': 'path',
19 | \ 'opmul': 1,
20 | \ 'specinput': 1,
21 | \ })
22 |
23 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
24 | " Utilities {{{1
25 | fu! s:newcache(cwd)
26 | if g:ctrlp_newmix || !has_key(g:ctrlp_allmixes, 'data') | retu 1 | en
27 | retu g:ctrlp_allmixes['cwd'] != a:cwd
28 | \ || g:ctrlp_allmixes['filtime'] < getftime(ctrlp#utils#cachefile())
29 | \ || g:ctrlp_allmixes['mrutime'] < getftime(ctrlp#mrufiles#cachefile())
30 | \ || g:ctrlp_allmixes['bufs'] < len(ctrlp#mrufiles#bufs())
31 | endf
32 |
33 | fu! s:getnewmix(cwd, clim)
34 | if g:ctrlp_newmix
35 | cal ctrlp#mrufiles#refresh('raw')
36 | let g:ctrlp_newcache = 1
37 | en
38 | let g:ctrlp_lines = copy(ctrlp#files())
39 | cal ctrlp#progress('Mixing...')
40 | let mrufs = copy(ctrlp#mrufiles#list('raw'))
41 | if exists('+ssl') && &ssl
42 | cal map(mrufs, 'tr(v:val, "\\", "/")')
43 | en
44 | let allbufs = map(ctrlp#buffers(), 'fnamemodify(v:val, ":p")')
45 | let [bufs, ubufs] = [[], []]
46 | for each in allbufs
47 | cal add(filereadable(each) ? bufs : ubufs, each)
48 | endfo
49 | let mrufs = bufs + filter(mrufs, 'index(bufs, v:val) < 0')
50 | if len(mrufs) > len(g:ctrlp_lines)
51 | cal filter(mrufs, 'stridx(v:val, a:cwd)')
52 | el
53 | let cwd_mrufs = filter(copy(mrufs), '!stridx(v:val, a:cwd)')
54 | let cwd_mrufs = ctrlp#rmbasedir(cwd_mrufs)
55 | for each in cwd_mrufs
56 | let id = index(g:ctrlp_lines, each)
57 | if id >= 0 | cal remove(g:ctrlp_lines, id) | en
58 | endfo
59 | en
60 | let mrufs += ubufs
61 | cal map(mrufs, 'fnamemodify(v:val, ":.")')
62 | let g:ctrlp_lines = len(mrufs) > len(g:ctrlp_lines)
63 | \ ? g:ctrlp_lines + mrufs : mrufs + g:ctrlp_lines
64 | if len(g:ctrlp_lines) <= a:clim
65 | cal sort(g:ctrlp_lines, 'ctrlp#complen')
66 | en
67 | let g:ctrlp_allmixes = { 'filtime': getftime(ctrlp#utils#cachefile()),
68 | \ 'mrutime': getftime(ctrlp#mrufiles#cachefile()), 'cwd': a:cwd,
69 | \ 'bufs': len(ctrlp#mrufiles#bufs()), 'data': g:ctrlp_lines }
70 | endf
71 | " Public {{{1
72 | fu! ctrlp#mixed#init(clim)
73 | let cwd = getcwd()
74 | if s:newcache(cwd)
75 | cal s:getnewmix(cwd, a:clim)
76 | el
77 | let g:ctrlp_lines = g:ctrlp_allmixes['data']
78 | en
79 | let g:ctrlp_newmix = 0
80 | retu g:ctrlp_lines
81 | endf
82 |
83 | fu! ctrlp#mixed#id()
84 | retu s:id
85 | endf
86 | "}}}
87 |
88 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
89 |
--------------------------------------------------------------------------------
/bundle/ctrlp.vim/autoload/ctrlp/mrufiles.vim:
--------------------------------------------------------------------------------
1 | " =============================================================================
2 | " File: autoload/ctrlp/mrufiles.vim
3 | " Description: Most Recently Used Files extension
4 | " Author: Kien Nguyen
5 | " =============================================================================
6 |
7 | " Static variables {{{1
8 | let [s:mrbs, s:mrufs] = [[], []]
9 |
10 | fu! ctrlp#mrufiles#opts()
11 | let [pref, opts] = ['g:ctrlp_mruf_', {
12 | \ 'max': ['s:max', 250],
13 | \ 'include': ['s:in', ''],
14 | \ 'exclude': ['s:ex', ''],
15 | \ 'case_sensitive': ['s:cseno', 1],
16 | \ 'relative': ['s:re', 0],
17 | \ 'save_on_update': ['s:soup', 1],
18 | \ }]
19 | for [ke, va] in items(opts)
20 | let [{va[0]}, {pref.ke}] = [pref.ke, exists(pref.ke) ? {pref.ke} : va[1]]
21 | endfo
22 | endf
23 | cal ctrlp#mrufiles#opts()
24 | " Utilities {{{1
25 | fu! s:excl(fn)
26 | retu !empty({s:ex}) && a:fn =~# {s:ex}
27 | endf
28 |
29 | fu! s:mergelists()
30 | let diskmrufs = ctrlp#utils#readfile(ctrlp#mrufiles#cachefile())
31 | cal filter(diskmrufs, 'index(s:mrufs, v:val) < 0')
32 | let mrufs = s:mrufs + diskmrufs
33 | retu s:chop(mrufs)
34 | endf
35 |
36 | fu! s:chop(mrufs)
37 | if len(a:mrufs) > {s:max} | cal remove(a:mrufs, {s:max}, -1) | en
38 | retu a:mrufs
39 | endf
40 |
41 | fu! s:reformat(mrufs, ...)
42 | let cwd = getcwd()
43 | let cwd .= cwd !~ '[\/]$' ? ctrlp#utils#lash() : ''
44 | if {s:re}
45 | let cwd = exists('+ssl') ? tr(cwd, '/', '\') : cwd
46 | cal filter(a:mrufs, '!stridx(v:val, cwd)')
47 | en
48 | if a:0 && a:1 == 'raw' | retu a:mrufs | en
49 | let idx = strlen(cwd)
50 | if exists('+ssl') && &ssl
51 | let cwd = tr(cwd, '\', '/')
52 | cal map(a:mrufs, 'tr(v:val, "\\", "/")')
53 | en
54 | retu map(a:mrufs, '!stridx(v:val, cwd) ? strpart(v:val, idx) : v:val')
55 | endf
56 |
57 | fu! s:record(bufnr)
58 | if s:locked | retu | en
59 | let bufnr = a:bufnr + 0
60 | let bufname = bufname(bufnr)
61 | if bufnr > 0 && !empty(bufname)
62 | cal filter(s:mrbs, 'v:val != bufnr')
63 | cal insert(s:mrbs, bufnr)
64 | cal s:addtomrufs(bufname)
65 | en
66 | endf
67 |
68 | fu! s:addtomrufs(fname)
69 | let fn = fnamemodify(a:fname, ':p')
70 | let fn = exists('+ssl') ? tr(fn, '/', '\') : fn
71 | if ( !empty({s:in}) && fn !~# {s:in} ) || ( !empty({s:ex}) && fn =~# {s:ex} )
72 | \ || !empty(getbufvar('^'.fn.'$', '&bt')) || !filereadable(fn) | retu
73 | en
74 | let idx = index(s:mrufs, fn, 0, !{s:cseno})
75 | if idx
76 | cal filter(s:mrufs, 'v:val !='.( {s:cseno} ? '#' : '?' ).' fn')
77 | cal insert(s:mrufs, fn)
78 | if {s:soup} && idx < 0
79 | cal s:savetofile(s:mergelists())
80 | en
81 | en
82 | endf
83 |
84 | fu! s:savetofile(mrufs)
85 | cal ctrlp#utils#writecache(a:mrufs, s:cadir, s:cafile)
86 | endf
87 | " Public {{{1
88 | fu! ctrlp#mrufiles#refresh(...)
89 | let mrufs = s:mergelists()
90 | cal filter(mrufs, '!empty(ctrlp#utils#glob(v:val, 1)) && !s:excl(v:val)')
91 | if exists('+ssl')
92 | cal map(mrufs, 'tr(v:val, "/", "\\")')
93 | cal map(s:mrufs, 'tr(v:val, "/", "\\")')
94 | let cond = 'count(mrufs, v:val, !{s:cseno}) == 1'
95 | cal filter(mrufs, cond)
96 | cal filter(s:mrufs, cond)
97 | en
98 | cal s:savetofile(mrufs)
99 | retu a:0 && a:1 == 'raw' ? [] : s:reformat(mrufs)
100 | endf
101 |
102 | fu! ctrlp#mrufiles#remove(files)
103 | let mrufs = []
104 | if a:files != []
105 | let mrufs = s:mergelists()
106 | let cond = 'index(a:files, v:val, 0, !{s:cseno}) < 0'
107 | cal filter(mrufs, cond)
108 | cal filter(s:mrufs, cond)
109 | en
110 | cal s:savetofile(mrufs)
111 | retu s:reformat(mrufs)
112 | endf
113 |
114 | fu! ctrlp#mrufiles#add(fn)
115 | if !empty(a:fn)
116 | cal s:addtomrufs(a:fn)
117 | en
118 | endf
119 |
120 | fu! ctrlp#mrufiles#list(...)
121 | retu a:0 ? a:1 == 'raw' ? s:reformat(s:mergelists(), a:1) : 0
122 | \ : s:reformat(s:mergelists())
123 | endf
124 |
125 | fu! ctrlp#mrufiles#bufs()
126 | retu s:mrbs
127 | endf
128 |
129 | fu! ctrlp#mrufiles#cachefile()
130 | if !exists('s:cadir') || !exists('s:cafile')
131 | let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru'
132 | let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt'
133 | en
134 | retu s:cafile
135 | endf
136 |
137 | fu! ctrlp#mrufiles#init()
138 | if !has('autocmd') | retu | en
139 | let s:locked = 0
140 | aug CtrlPMRUF
141 | au!
142 | au BufAdd,BufEnter,BufLeave,BufWritePost * cal s:record(expand('', 1))
143 | au QuickFixCmdPre *vimgrep* let s:locked = 1
144 | au QuickFixCmdPost *vimgrep* let s:locked = 0
145 | au VimLeavePre * cal s:savetofile(s:mergelists())
146 | aug END
147 | endf
148 | "}}}
149 |
150 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
151 |
--------------------------------------------------------------------------------
/bundle/ctrlp.vim/autoload/ctrlp/quickfix.vim:
--------------------------------------------------------------------------------
1 | " =============================================================================
2 | " File: autoload/ctrlp/quickfix.vim
3 | " Description: Quickfix extension
4 | " Author: Kien Nguyen
5 | " =============================================================================
6 |
7 | " Init {{{1
8 | if exists('g:loaded_ctrlp_quickfix') && g:loaded_ctrlp_quickfix
9 | fini
10 | en
11 | let g:loaded_ctrlp_quickfix = 1
12 |
13 | cal add(g:ctrlp_ext_vars, {
14 | \ 'init': 'ctrlp#quickfix#init()',
15 | \ 'accept': 'ctrlp#quickfix#accept',
16 | \ 'lname': 'quickfix',
17 | \ 'sname': 'qfx',
18 | \ 'type': 'line',
19 | \ 'sort': 0,
20 | \ 'nolim': 1,
21 | \ })
22 |
23 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
24 |
25 | fu! s:lineout(dict)
26 | retu printf('%s|%d:%d| %s', bufname(a:dict['bufnr']), a:dict['lnum'],
27 | \ a:dict['col'], matchstr(a:dict['text'], '\s*\zs.*\S'))
28 | endf
29 | " Utilities {{{1
30 | fu! s:syntax()
31 | if !ctrlp#nosy()
32 | cal ctrlp#hicheck('CtrlPqfLineCol', 'Search')
33 | sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|'
34 | en
35 | endf
36 | " Public {{{1
37 | fu! ctrlp#quickfix#init()
38 | cal s:syntax()
39 | retu map(getqflist(), 's:lineout(v:val)')
40 | endf
41 |
42 | fu! ctrlp#quickfix#accept(mode, str)
43 | let vals = matchlist(a:str, '^\([^|]\+\ze\)|\(\d\+\):\(\d\+\)|')
44 | if vals == [] || vals[1] == '' | retu | en
45 | cal ctrlp#acceptfile(a:mode, vals[1])
46 | let cur_pos = getpos('.')[1:2]
47 | if cur_pos != [1, 1] && cur_pos != map(vals[2:3], 'str2nr(v:val)')
48 | mark '
49 | en
50 | cal cursor(vals[2], vals[3])
51 | sil! norm! zvzz
52 | endf
53 |
54 | fu! ctrlp#quickfix#id()
55 | retu s:id
56 | endf
57 | "}}}
58 |
59 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
60 |
--------------------------------------------------------------------------------
/bundle/ctrlp.vim/autoload/ctrlp/rtscript.vim:
--------------------------------------------------------------------------------
1 | " =============================================================================
2 | " File: autoload/ctrlp/rtscript.vim
3 | " Description: Runtime scripts extension
4 | " Author: Kien Nguyen
5 | " =============================================================================
6 |
7 | " Init {{{1
8 | if exists('g:loaded_ctrlp_rtscript') && g:loaded_ctrlp_rtscript
9 | fini
10 | en
11 | let [g:loaded_ctrlp_rtscript, g:ctrlp_newrts] = [1, 0]
12 |
13 | cal add(g:ctrlp_ext_vars, {
14 | \ 'init': 'ctrlp#rtscript#init(s:caching)',
15 | \ 'accept': 'ctrlp#acceptfile',
16 | \ 'lname': 'runtime scripts',
17 | \ 'sname': 'rts',
18 | \ 'type': 'path',
19 | \ 'opmul': 1,
20 | \ })
21 |
22 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
23 |
24 | let s:filecounts = {}
25 | " Utilities {{{1
26 | fu! s:nocache()
27 | retu g:ctrlp_newrts ||
28 | \ !s:caching || ( s:caching > 1 && get(s:filecounts, s:cwd) < s:caching )
29 | endf
30 | " Public {{{1
31 | fu! ctrlp#rtscript#init(caching)
32 | let [s:caching, s:cwd] = [a:caching, getcwd()]
33 | if s:nocache() ||
34 | \ !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[0] == &rtp )
35 | sil! cal ctrlp#progress('Indexing...')
36 | let entries = split(globpath(ctrlp#utils#fnesc(&rtp, 'g'), '**/*.*'), "\n")
37 | cal filter(entries, 'count(entries, v:val) == 1')
38 | let [entries, echoed] = [ctrlp#dirnfile(entries)[1], 1]
39 | el
40 | let [entries, results] = g:ctrlp_rtscache[2:3]
41 | en
42 | if s:nocache() ||
43 | \ !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[:1] == [&rtp, s:cwd] )
44 | if !exists('echoed')
45 | sil! cal ctrlp#progress('Processing...')
46 | en
47 | let results = map(copy(entries), 'fnamemodify(v:val, '':.'')')
48 | en
49 | let [g:ctrlp_rtscache, g:ctrlp_newrts] = [[&rtp, s:cwd, entries, results], 0]
50 | cal extend(s:filecounts, { s:cwd : len(results) })
51 | retu results
52 | endf
53 |
54 | fu! ctrlp#rtscript#id()
55 | retu s:id
56 | endf
57 | "}}}
58 |
59 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
60 |
--------------------------------------------------------------------------------
/bundle/ctrlp.vim/autoload/ctrlp/tag.vim:
--------------------------------------------------------------------------------
1 | " =============================================================================
2 | " File: autoload/ctrlp/tag.vim
3 | " Description: Tag file extension
4 | " Author: Kien Nguyen
5 | " =============================================================================
6 |
7 | " Init {{{1
8 | if exists('g:loaded_ctrlp_tag') && g:loaded_ctrlp_tag
9 | fini
10 | en
11 | let g:loaded_ctrlp_tag = 1
12 |
13 | cal add(g:ctrlp_ext_vars, {
14 | \ 'init': 'ctrlp#tag#init()',
15 | \ 'accept': 'ctrlp#tag#accept',
16 | \ 'lname': 'tags',
17 | \ 'sname': 'tag',
18 | \ 'enter': 'ctrlp#tag#enter()',
19 | \ 'type': 'tabs',
20 | \ })
21 |
22 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
23 | " Utilities {{{1
24 | fu! s:findcount(str)
25 | let [tg, fname] = split(a:str, '\t\+\ze[^\t]\+$')
26 | let tgs = taglist('^'.tg.'$')
27 | if len(tgs) < 2
28 | retu [1, 1]
29 | en
30 | let bname = fnamemodify(bufname('%'), ':p')
31 | let fname = expand(fnamemodify(simplify(fname), ':s?^[.\/]\+??:p:.'), 1)
32 | let [fnd, ct, pos, idx] = [0, 0, 0, 0]
33 | wh idx < len(tgs)
34 | if bname == fnamemodify(tgs[idx]["filename"], ':p')
35 | cal insert(tgs, remove(tgs, idx))
36 | brea
37 | en
38 | let idx += 1
39 | endw
40 | for each in tgs
41 | let ct += 1
42 | let fulname = fnamemodify(each["filename"], ':p')
43 | if stridx(fulname, fname) >= 0
44 | \ && strlen(fname) + stridx(fulname, fname) == strlen(fulname)
45 | let fnd += 1
46 | let pos = ct
47 | en
48 | if fnd > 1 | brea | en
49 | endfo
50 | retu [fnd, pos]
51 | endf
52 |
53 | fu! s:filter(tags)
54 | let nr = 0
55 | wh 0 < 1
56 | if a:tags == [] | brea | en
57 | if a:tags[nr] =~ '^!' && a:tags[nr] !~# '^!_TAG_'
58 | let nr += 1
59 | con
60 | en
61 | if a:tags[nr] =~# '^!_TAG_' && len(a:tags) > nr
62 | cal remove(a:tags, nr)
63 | el
64 | brea
65 | en
66 | endw
67 | retu a:tags
68 | endf
69 |
70 | fu! s:syntax()
71 | if !ctrlp#nosy()
72 | cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
73 | sy match CtrlPTabExtra '\zs\t.*\ze$'
74 | en
75 | endf
76 | " Public {{{1
77 | fu! ctrlp#tag#init()
78 | if empty(s:tagfiles) | retu [] | en
79 | let g:ctrlp_alltags = []
80 | let tagfiles = sort(filter(s:tagfiles, 'count(s:tagfiles, v:val) == 1'))
81 | for each in tagfiles
82 | let alltags = s:filter(ctrlp#utils#readfile(each))
83 | cal extend(g:ctrlp_alltags, alltags)
84 | endfo
85 | cal s:syntax()
86 | retu g:ctrlp_alltags
87 | endf
88 |
89 | fu! ctrlp#tag#accept(mode, str)
90 | cal ctrlp#exit()
91 | let str = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\ze\t')
92 | let [tg, fnd] = [split(str, '^[^\t]\+\zs\t')[0], s:findcount(str)]
93 | let cmds = {
94 | \ 't': ['tab sp', 'tab stj'],
95 | \ 'h': ['sp', 'stj'],
96 | \ 'v': ['vs', 'vert stj'],
97 | \ 'e': ['', 'tj'],
98 | \ }
99 | let cmd = fnd[0] == 1 ? cmds[a:mode][0] : cmds[a:mode][1]
100 | let cmd = a:mode == 'e' && ctrlp#modfilecond(!&aw)
101 | \ ? ( cmd == 'tj' ? 'stj' : 'sp' ) : cmd
102 | let cmd = a:mode == 't' ? ctrlp#tabcount().cmd : cmd
103 | if fnd[0] == 1
104 | if cmd != ''
105 | exe cmd
106 | en
107 | let save_cst = &cst
108 | set cst&
109 | cal feedkeys(":".fnd[1]."ta ".tg."\r", 'nt')
110 | let &cst = save_cst
111 | el
112 | cal feedkeys(":".cmd." ".tg."\r", 'nt')
113 | en
114 | cal ctrlp#setlcdir()
115 | endf
116 |
117 | fu! ctrlp#tag#id()
118 | retu s:id
119 | endf
120 |
121 | fu! ctrlp#tag#enter()
122 | let tfs = tagfiles()
123 | let s:tagfiles = tfs != [] ? filter(map(tfs, 'fnamemodify(v:val, ":p")'),
124 | \ 'filereadable(v:val)') : []
125 | endf
126 | "}}}
127 |
128 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
129 |
--------------------------------------------------------------------------------
/bundle/ctrlp.vim/autoload/ctrlp/undo.vim:
--------------------------------------------------------------------------------
1 | " =============================================================================
2 | " File: autoload/ctrlp/undo.vim
3 | " Description: Undo extension
4 | " Author: Kien Nguyen
5 | " =============================================================================
6 |
7 | " Init {{{1
8 | if ( exists('g:loaded_ctrlp_undo') && g:loaded_ctrlp_undo )
9 | fini
10 | en
11 | let g:loaded_ctrlp_undo = 1
12 |
13 | cal add(g:ctrlp_ext_vars, {
14 | \ 'init': 'ctrlp#undo#init()',
15 | \ 'accept': 'ctrlp#undo#accept',
16 | \ 'lname': 'undo',
17 | \ 'sname': 'udo',
18 | \ 'enter': 'ctrlp#undo#enter()',
19 | \ 'exit': 'ctrlp#undo#exit()',
20 | \ 'type': 'line',
21 | \ 'sort': 0,
22 | \ 'nolim': 1,
23 | \ })
24 |
25 | let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
26 |
27 | let s:text = map(['second', 'seconds', 'minutes', 'hours', 'days', 'weeks',
28 | \ 'months', 'years'], '" ".v:val." ago"')
29 | " Utilities {{{1
30 | fu! s:getundo()
31 | if exists('*undotree')
32 | \ && ( v:version > 703 || ( v:version == 703 && has('patch005') ) )
33 | retu [1, undotree()]
34 | el
35 | redi => result
36 | sil! undol
37 | redi END
38 | retu [0, split(result, "\n")[1:]]
39 | en
40 | endf
41 |
42 | fu! s:flatten(tree, cur)
43 | let flatdict = {}
44 | for each in a:tree
45 | let saved = has_key(each, 'save') ? 'saved' : ''
46 | let current = each['seq'] == a:cur ? 'current' : ''
47 | cal extend(flatdict, { each['seq'] : [each['time'], saved, current] })
48 | if has_key(each, 'alt')
49 | cal extend(flatdict, s:flatten(each['alt'], a:cur))
50 | en
51 | endfo
52 | retu flatdict
53 | endf
54 |
55 | fu! s:elapsed(nr)
56 | let [text, time] = [s:text, localtime() - a:nr]
57 | let mins = time / 60
58 | let hrs = time / 3600
59 | let days = time / 86400
60 | let wks = time / 604800
61 | let mons = time / 2592000
62 | let yrs = time / 31536000
63 | if yrs > 1
64 | retu yrs.text[7]
65 | elsei mons > 1
66 | retu mons.text[6]
67 | elsei wks > 1
68 | retu wks.text[5]
69 | elsei days > 1
70 | retu days.text[4]
71 | elsei hrs > 1
72 | retu hrs.text[3]
73 | elsei mins > 1
74 | retu mins.text[2]
75 | elsei time == 1
76 | retu time.text[0]
77 | elsei time < 120
78 | retu time.text[1]
79 | en
80 | endf
81 |
82 | fu! s:syntax()
83 | if ctrlp#nosy() | retu | en
84 | for [ke, va] in items({'T': 'Directory', 'Br': 'Comment', 'Nr': 'String',
85 | \ 'Sv': 'Comment', 'Po': 'Title'})
86 | cal ctrlp#hicheck('CtrlPUndo'.ke, va)
87 | endfo
88 | sy match CtrlPUndoT '\v\d+ \zs[^ ]+\ze|\d+:\d+:\d+'
89 | sy match CtrlPUndoBr '\[\|\]'
90 | sy match CtrlPUndoNr '\[\d\+\]' contains=CtrlPUndoBr
91 | sy match CtrlPUndoSv 'saved'
92 | sy match CtrlPUndoPo 'current'
93 | endf
94 |
95 | fu! s:dict2list(dict)
96 | for ke in keys(a:dict)
97 | let a:dict[ke][0] = s:elapsed(a:dict[ke][0])
98 | endfo
99 | retu map(keys(a:dict), 'eval(''[v:val, a:dict[v:val]]'')')
100 | endf
101 |
102 | fu! s:compval(...)
103 | retu a:2[0] - a:1[0]
104 | endf
105 |
106 | fu! s:format(...)
107 | let saved = !empty(a:1[1][1]) ? ' '.a:1[1][1] : ''
108 | let current = !empty(a:1[1][2]) ? ' '.a:1[1][2] : ''
109 | retu a:1[1][0].' ['.a:1[0].']'.saved.current
110 | endf
111 |
112 | fu! s:formatul(...)
113 | let parts = matchlist(a:1,
114 | \ '\v^\s+(\d+)\s+\d+\s+([^ ]+\s?[^ ]+|\d+\s\w+\s\w+)(\s*\d*)$')
115 | retu parts == [] ? '----'
116 | \ : parts[2].' ['.parts[1].']'.( parts[3] != '' ? ' saved' : '' )
117 | endf
118 | " Public {{{1
119 | fu! ctrlp#undo#init()
120 | let entries = s:undos[0] ? s:undos[1]['entries'] : s:undos[1]
121 | if empty(entries) | retu [] | en
122 | if !exists('s:lines')
123 | if s:undos[0]
124 | let entries = s:dict2list(s:flatten(entries, s:undos[1]['seq_cur']))
125 | let s:lines = map(sort(entries, 's:compval'), 's:format(v:val)')
126 | el
127 | let s:lines = map(reverse(entries), 's:formatul(v:val)')
128 | en
129 | en
130 | cal s:syntax()
131 | retu s:lines
132 | endf
133 |
134 | fu! ctrlp#undo#accept(mode, str)
135 | let undon = matchstr(a:str, '\[\zs\d\+\ze\]')
136 | if empty(undon) | retu | en
137 | cal ctrlp#exit()
138 | exe 'u' undon
139 | endf
140 |
141 | fu! ctrlp#undo#id()
142 | retu s:id
143 | endf
144 |
145 | fu! ctrlp#undo#enter()
146 | let s:undos = s:getundo()
147 | endf
148 |
149 | fu! ctrlp#undo#exit()
150 | unl! s:lines
151 | endf
152 | "}}}
153 |
154 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
155 |
--------------------------------------------------------------------------------
/bundle/ctrlp.vim/autoload/ctrlp/utils.vim:
--------------------------------------------------------------------------------
1 | " =============================================================================
2 | " File: autoload/ctrlp/utils.vim
3 | " Description: Utilities
4 | " Author: Kien Nguyen
5 | " =============================================================================
6 |
7 | " Static variables {{{1
8 | fu! ctrlp#utils#lash()
9 | retu &ssl || !exists('+ssl') ? '/' : '\'
10 | endf
11 |
12 | fu! s:lash(...)
13 | retu ( a:0 ? a:1 : getcwd() ) !~ '[\/]$' ? s:lash : ''
14 | endf
15 |
16 | fu! ctrlp#utils#opts()
17 | let s:lash = ctrlp#utils#lash()
18 | let usrhome = $HOME . s:lash( $HOME )
19 | let cahome = exists('$XDG_CACHE_HOME') ? $XDG_CACHE_HOME : usrhome.'.cache'
20 | let cadir = isdirectory(usrhome.'.ctrlp_cache')
21 | \ ? usrhome.'.ctrlp_cache' : cahome.s:lash(cahome).'ctrlp'
22 | if exists('g:ctrlp_cache_dir')
23 | let cadir = expand(g:ctrlp_cache_dir, 1)
24 | if isdirectory(cadir.s:lash(cadir).'.ctrlp_cache')
25 | let cadir = cadir.s:lash(cadir).'.ctrlp_cache'
26 | en
27 | en
28 | let s:cache_dir = cadir
29 | endf
30 | cal ctrlp#utils#opts()
31 |
32 | let s:wig_cond = v:version > 702 || ( v:version == 702 && has('patch051') )
33 | " Files and Directories {{{1
34 | fu! ctrlp#utils#cachedir()
35 | retu s:cache_dir
36 | endf
37 |
38 | fu! ctrlp#utils#cachefile(...)
39 | let [tail, dir] = [a:0 == 1 ? '.'.a:1 : '', a:0 == 2 ? a:1 : getcwd()]
40 | let cache_file = substitute(dir, '\([\/]\|^\a\zs:\)', '%', 'g').tail.'.txt'
41 | retu a:0 == 1 ? cache_file : s:cache_dir.s:lash(s:cache_dir).cache_file
42 | endf
43 |
44 | fu! ctrlp#utils#readfile(file)
45 | if filereadable(a:file)
46 | let data = readfile(a:file)
47 | if empty(data) || type(data) != 3
48 | unl data
49 | let data = []
50 | en
51 | retu data
52 | en
53 | retu []
54 | endf
55 |
56 | fu! ctrlp#utils#mkdir(dir)
57 | if exists('*mkdir') && !isdirectory(a:dir)
58 | sil! cal mkdir(a:dir, 'p')
59 | en
60 | retu a:dir
61 | endf
62 |
63 | fu! ctrlp#utils#writecache(lines, ...)
64 | if isdirectory(ctrlp#utils#mkdir(a:0 ? a:1 : s:cache_dir))
65 | sil! cal writefile(a:lines, a:0 >= 2 ? a:2 : ctrlp#utils#cachefile())
66 | en
67 | endf
68 |
69 | fu! ctrlp#utils#glob(...)
70 | let path = ctrlp#utils#fnesc(a:1, 'g')
71 | retu s:wig_cond ? glob(path, a:2) : glob(path)
72 | endf
73 |
74 | fu! ctrlp#utils#globpath(...)
75 | retu call('globpath', s:wig_cond ? a:000 : a:000[:1])
76 | endf
77 |
78 | fu! ctrlp#utils#fnesc(path, type, ...)
79 | if exists('*fnameescape')
80 | if exists('+ssl')
81 | if a:type == 'c'
82 | let path = escape(a:path, '%#')
83 | elsei a:type == 'f'
84 | let path = fnameescape(a:path)
85 | elsei a:type == 'g'
86 | let path = escape(a:path, '?*')
87 | en
88 | let path = substitute(path, '[', '[[]', 'g')
89 | el
90 | let path = fnameescape(a:path)
91 | en
92 | el
93 | if exists('+ssl')
94 | if a:type == 'c'
95 | let path = escape(a:path, '%#')
96 | elsei a:type == 'f'
97 | let path = escape(a:path, " \t\n%#*?|<\"")
98 | elsei a:type == 'g'
99 | let path = escape(a:path, '?*')
100 | en
101 | let path = substitute(path, '[', '[[]', 'g')
102 | el
103 | let path = escape(a:path, " \t\n*?[{`$\\%#'\"|!<")
104 | en
105 | en
106 | retu a:0 ? escape(path, a:1) : path
107 | endf
108 | "}}}
109 |
110 | " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
111 |
--------------------------------------------------------------------------------
/bundle/ctrlp.vim/plugin/ctrlp.vim:
--------------------------------------------------------------------------------
1 | " =============================================================================
2 | " File: plugin/ctrlp.vim
3 | " Description: Fuzzy file, buffer, mru, tag, etc finder.
4 | " Author: Kien Nguyen
5 | " =============================================================================
6 | " GetLatestVimScripts: 3736 1 :AutoInstall: ctrlp.zip
7 |
8 | if ( exists('g:loaded_ctrlp') && g:loaded_ctrlp ) || v:version < 700 || &cp
9 | fini
10 | en
11 | let g:loaded_ctrlp = 1
12 |
13 | let [g:ctrlp_lines, g:ctrlp_allfiles, g:ctrlp_alltags, g:ctrlp_alldirs,
14 | \ g:ctrlp_allmixes, g:ctrlp_buftags, g:ctrlp_ext_vars, g:ctrlp_builtins]
15 | \ = [[], [], [], [], {}, {}, [], 2]
16 |
17 | if !exists('g:ctrlp_map') | let g:ctrlp_map = '' | en
18 | if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en
19 |
20 | com! -n=? -com=dir CtrlP cal ctrlp#init(0, { 'dir': })
21 | com! -n=? -com=dir CtrlPMRUFiles cal ctrlp#init(2, { 'dir': })
22 |
23 | com! -bar CtrlPBuffer cal ctrlp#init(1)
24 | com! -n=? CtrlPLastMode cal ctrlp#init(-1, { 'args': })
25 |
26 | com! -bar CtrlPClearCache cal ctrlp#clr()
27 | com! -bar CtrlPClearAllCaches cal ctrlp#clra()
28 |
29 | com! -bar ClearCtrlPCache cal ctrlp#clr()
30 | com! -bar ClearAllCtrlPCaches cal ctrlp#clra()
31 |
32 | com! -bar CtrlPCurWD cal ctrlp#init(0, { 'mode': '' })
33 | com! -bar CtrlPCurFile cal ctrlp#init(0, { 'mode': 'c' })
34 | com! -bar CtrlPRoot cal ctrlp#init(0, { 'mode': 'r' })
35 |
36 | if g:ctrlp_map != '' && !hasmapto(':'.g:ctrlp_cmd.'', 'n')
37 | exe 'nn ' g:ctrlp_map ':'.g:ctrlp_cmd.''
38 | en
39 |
40 | cal ctrlp#mrufiles#init()
41 |
42 | com! -bar CtrlPTag cal ctrlp#init(ctrlp#tag#id())
43 | com! -bar CtrlPQuickfix cal ctrlp#init(ctrlp#quickfix#id())
44 |
45 | com! -n=? -com=dir CtrlPDir
46 | \ cal ctrlp#init(ctrlp#dir#id(), { 'dir': })
47 |
48 | com! -n=? -com=buffer CtrlPBufTag
49 | \ cal ctrlp#init(ctrlp#buffertag#cmd(0, ))
50 |
51 | com! -bar CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1))
52 | com! -bar CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id())
53 | com! -bar CtrlPUndo cal ctrlp#init(ctrlp#undo#id())
54 | com! -bar CtrlPLine cal ctrlp#init(ctrlp#line#id())
55 |
56 | com! -n=? -com=buffer CtrlPChange
57 | \ cal ctrlp#init(ctrlp#changes#cmd(0, ))
58 |
59 | com! -bar CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1))
60 | com! -bar CtrlPMixed cal ctrlp#init(ctrlp#mixed#id())
61 | com! -bar CtrlPBookmarkDir cal ctrlp#init(ctrlp#bookmarkdir#id())
62 |
63 | com! -n=? -com=dir CtrlPBookmarkDirAdd
64 | \ cal ctrlp#call('ctrlp#bookmarkdir#add', )
65 |
66 | " vim:ts=2:sw=2:sts=2
67 |
--------------------------------------------------------------------------------
/bundle/ctrlp.vim/readme.md:
--------------------------------------------------------------------------------
1 | # ctrlp.vim
2 | Full path fuzzy __file__, __buffer__, __mru__, __tag__, __...__ finder for Vim.
3 |
4 | * Written in pure Vimscript for MacVim, gVim and Vim 7.0+.
5 | * Full support for Vim's regexp as search patterns.
6 | * Built-in Most Recently Used (MRU) files monitoring.
7 | * Built-in project's root finder.
8 | * Open multiple files at once.
9 | * Create new files and directories.
10 | * [Extensible][2].
11 |
12 | ![ctrlp][1]
13 |
14 | ## Basic Usage
15 | * Run `:CtrlP` or `:CtrlP [starting-directory]` to invoke CtrlP in find file mode.
16 | * Run `:CtrlPBuffer` or `:CtrlPMRU` to invoke CtrlP in find buffer or find MRU file mode.
17 | * Run `:CtrlPMixed` to search in Files, Buffers and MRU files at the same time.
18 |
19 | Check `:help ctrlp-commands` and `:help ctrlp-extensions` for other commands.
20 |
21 | ##### Once CtrlP is open:
22 | * Press `` to purge the cache for the current directory to get new files, remove deleted files and apply new ignore options.
23 | * Press `` and `` to cycle between modes.
24 | * Press `` to switch to filename only search instead of full path.
25 | * Press `` to switch to regexp mode.
26 | * Use ``, `` or the arrow keys to navigate the result list.
27 | * Use `` or ``, `` to open the selected entry in a new tab or in a new split.
28 | * Use ``, `` to select the next/previous string in the prompt's history.
29 | * Use `` to create a new file and its parent directories.
30 | * Use `` to mark/unmark multiple files and `` to open them.
31 |
32 | Run `:help ctrlp-mappings` or submit `?` in CtrlP for more mapping help.
33 |
34 | * Submit two or more dots `..` to go up the directory tree by one or multiple levels.
35 | * End the input string with a colon `:` followed by a command to execute it on the opening file(s):
36 | Use `:25` to jump to line 25.
37 | Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 files.
38 |
39 | ## Basic Options
40 | * Change the default mapping and the default command to invoke CtrlP:
41 |
42 | ```vim
43 | let g:ctrlp_map = ''
44 | let g:ctrlp_cmd = 'CtrlP'
45 | ```
46 |
47 | * When invoked, unless a starting directory is specified, CtrlP will set its local working directory according to this variable:
48 |
49 | ```vim
50 | let g:ctrlp_working_path_mode = 'ra'
51 | ```
52 |
53 | `'c'` - the directory of the current file.
54 | `'r'` - the nearest ancestor that contains one of these directories or files: `.git` `.hg` `.svn` `.bzr` `_darcs`
55 | `'a'` - like c, but only if the current working directory outside of CtrlP is not a direct ancestor of the directory of the current file.
56 | `0` or `''` (empty string) - disable this feature.
57 |
58 | Define additional root markers with the `g:ctrlp_root_markers` option.
59 |
60 | * Exclude files and directories using Vim's `wildignore` and CtrlP's own `g:ctrlp_custom_ignore`:
61 |
62 | ```vim
63 | set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
64 | set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows
65 |
66 | let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
67 | let g:ctrlp_custom_ignore = {
68 | \ 'dir': '\v[\/]\.(git|hg|svn)$',
69 | \ 'file': '\v\.(exe|so|dll)$',
70 | \ 'link': 'some_bad_symbolic_links',
71 | \ }
72 | ```
73 |
74 | * Use a custom file listing command:
75 |
76 | ```vim
77 | let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux
78 | let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows
79 | ```
80 |
81 | Check `:help ctrlp-options` for other options.
82 |
83 | ## Installation
84 | Use your favorite method or check the homepage for a [quick installation guide][3].
85 |
86 | [1]: http://i.imgur.com/yIynr.png
87 | [2]: https://github.com/kien/ctrlp.vim/tree/extensions
88 | [3]: http://kien.github.com/ctrlp.vim#installation
89 |
--------------------------------------------------------------------------------
/bundle/delimitMate/.gitignore:
--------------------------------------------------------------------------------
1 | *.sw?
2 | *.un?
3 | *.vba
4 | *.zip
5 | *.gz
6 | vimball.txt
7 | *.orig
8 | tags
9 |
--------------------------------------------------------------------------------
/bundle/delimitMate/Makefile:
--------------------------------------------------------------------------------
1 | PLUGIN=$(shell basename "$$PWD")
2 | SCRIPT=$(wildcard plugin/*.vim)
3 | #AUTOL=$(wildcard autoload/*.vim)
4 | AUTOL=autoload/$(PLUGIN).vim
5 | DOC=$(wildcard doc/*.txt)
6 | TESTS=$(wildcard autoload/*Tests.vim)
7 | VERSION=$(shell perl -ne 'if (/\*\sCurrent\srelease:/) {s/^\s+(\d+\.\S+)\s.*$$/\1/;print}' $(DOC))
8 | VIMFOLDER=~/.vim/
9 | VIM=/usr/bin/vim
10 |
11 | .PHONY: $(PLUGIN).vba README
12 |
13 | all: vimball README zip gzip
14 |
15 | vimball: $(PLUGIN).vba
16 |
17 | clean:
18 | @echo clean
19 | rm -f *.vba */*.orig *.~* .VimballRecord *.zip *.gz
20 |
21 | dist-clean: clean
22 |
23 | undo:
24 | for i in */*.orig; do mv -f "$$i" "$${i%.*}"; done
25 |
26 | README:
27 | @echo README
28 | cp -f $(DOC) README
29 |
30 | $(PLUGIN).vba:
31 | @echo $(PLUGIN).vba
32 | rm -f $(PLUGIN)-$(VERSION).vba
33 | $(VIM) -N -c 'ru! vimballPlugin.vim' -c ':call append("0", [ "$(SCRIPT)", "$(AUTOL)", "$(DOC)"])' -c '$$d' -c ":%MkVimball $(PLUGIN)-$(VERSION) ." -c':q!'
34 | ln -f $(PLUGIN)-$(VERSION).vba $(PLUGIN).vba
35 |
36 | zip:
37 | @echo zip
38 | rm -f *.zip
39 | zip -r $(PLUGIN).zip doc plugin autoload
40 | zip $(PLUGIN).zip -d \*.sw\? || echo 1
41 | zip $(PLUGIN).zip -d \*.un\? || echo 1
42 | zip $(PLUGIN).zip -d \*.orig || echo 1
43 | zip $(PLUGIN).zip -d \*tags || echo 1
44 | zip $(PLUGIN).zip -d $(TESTS)
45 | ln -f $(PLUGIN).zip $(PLUGIN)-$(VERSION).zip
46 |
47 | gzip: vimball
48 | @echo vimball
49 | gzip -f $(PLUGIN).vba
50 |
51 | release: version all
52 |
53 | version:
54 | @echo version: $(VERSION)
55 | perl -i.orig -pne 'if (/^"\sVersion:/) {s/(\d+\.\S+)/$(VERSION)/}' $(SCRIPT) $(AUTOL)
56 | perl -i.orig -pne 'if (/let\sdelimitMate_version/) {s/"(\d+\.\S+)"/"$(VERSION)"/}' $(SCRIPT)
57 | perl -i.orig -pne 'if (/beasts/) {s/(v\d+\.\S+)/v$(VERSION)/}' $(DOC)
58 | perl -i.orig -MPOSIX -pne 'if (/^"\sModified:/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/e}' $(SCRIPT) $(AUTOL)
59 | perl -i.orig -MPOSIX -pne 'if (/^\s+$(VERSION)\s+\d+-\d+-\d+\s+\*/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/}' $(DOC)
60 | @echo Version: $(VERSION)
61 |
62 | echo:
63 |
--------------------------------------------------------------------------------
/bundle/delimitMate/README:
--------------------------------------------------------------------------------
1 | This plug-in provides automatic closing of quotes, parenthesis, brackets, etc., besides some other related features that should make your time in insert mode a little bit easier, like syntax awareness (will not insert the closing delimiter in comments and other configurable regions), and expansions (off by default), and some more.
2 |
3 | Most of the features can be modified or disabled permanently, using global variables, or on a FileType basis, using :autocmd. With a couple of exceptions and limitations, these features don't break undo, redo or history.
4 |
--------------------------------------------------------------------------------
/bundle/delimitMate/autoload/delimitMateTests.vim:
--------------------------------------------------------------------------------
1 | function! delimitMateTests#Main()
2 | if !exists("g:delimitMate_testing")
3 | echoerr "delimitMateTests#Main(): If you really want to use me, you must set delimitMate_testing to any value."
4 | return
5 | elseif g:delimitMate_testing == "fork"
6 | !gvim -N -u NONE -U NONE -c "set runtimepath+=~/.vim/bundle/pathogen" -c "call pathogen\#runtime_append_all_bundles('bundle','symlinks')" -c "set backspace=eol,start" -c "set background=light" -c "syntax on" -c "let delimitMate_testing = 1" -c "ru autoload/delimitMate.vim" -c "ru autoload/delimitMateTests.vim" -c "ru plugin/delimitMate.vim" -c "call delimitMateTests\#Main()"
7 | return ""
8 | endif
9 | nmap :qall!
10 | let nomore = &more
11 | set nomore
12 | let b:test_results = {}
13 | let b:errors = 0
14 | let b:corrects = 0
15 | let b:ignores = 0
16 |
17 | function! SetOptions(list) " {{{
18 | let b:delimitMate_autoclose = 1
19 | let b:delimitMate_matchpairs = &matchpairs
20 | let b:delimitMate_quotes = "\" ' `"
21 | let b:delimitMate_excluded_regions = "Comment"
22 | let b:delimitMate_expand_space = 0
23 | let b:delimitMate_expand_cr = 0
24 | let b:delimitMate_smart_quotes = 1
25 | let b:delimitMate_apostrophes = ""
26 | let b:delimitMate_tab2exit = 1
27 | " Set current test options:
28 | for str in a:list
29 | "echom '1:'.str
30 | let op = strpart(str, 0, stridx(str,':'))
31 | "echom op
32 | let val = strpart(str, stridx(str, ':' ) + 1)
33 | "echom val
34 | exec "let b:delimitMate_" . op . " = " . val
35 | endfor
36 | DelimitMateReload
37 | endfunction " }}}
38 |
39 | function! Type(name, input, output, options, ...) " {{{
40 | if a:0 > 0
41 | let ignore = a:1
42 | else
43 | let ignore = 0
44 | endif
45 | if a:input != "\."
46 | " Set default options:
47 | call SetOptions(a:options)
48 | let CapR = ""
49 | normal ggVG"_d
50 | exec "normal i" . a:input . "|\"
51 | else
52 | let CapR = "_R"
53 | normal gg.
54 | endif
55 |
56 | exec "normal \"
57 | call setpos('.', [0, 1, 1, 0])
58 | let result = len(a:output) != line('$')
59 | for line in a:output
60 | if getline('.') != line || result == 1
61 | let result = 1
62 | break
63 | endif
64 | call setpos('.', [0, line('.') + 1, 1, 0])
65 | endfor
66 | let text = getline('.')
67 | let i = 2
68 | while i <= line('$')
69 | let text = text . "" . getline(i)
70 | let i += 1
71 | endwhile
72 | if ignore == 1
73 | let label = "Ignored"
74 | let result = "?="
75 | let b:ignores += 1
76 | elseif result == 0
77 | let label = "Passed"
78 | let result = "=="
79 | let b:corrects += 1
80 | else
81 | let label = "Failed"
82 | let result = "!="
83 | let b:errors += 1
84 | endif
85 | exec "let b:test_results['" .
86 | \ substitute(a:name, "[^a-zA-Z0-9_]", "_", "g") . CapR . "'] = '" .
87 | \ label . ": ' . a:input . ' => ' . text . ' " .
88 | \ result . " ' . join(a:output, '')"
89 | endfunction " }}}
90 |
91 | function! RepeatLast(name, output, ...) " {{{
92 | if a:0 > 0
93 | let arg1 = a:1
94 | else
95 | let arg1 = ''
96 | endif
97 | call Type(a:name, "\.", a:output, [], arg1)
98 | endfunction " }}}
99 |
100 | " Test's test {{{
101 | call Type("Test 1", "123", ["123|"], [])
102 | call RepeatLast("Test 1", ["123|123|"])
103 |
104 | " Auto-closing parens
105 | call Type("Autoclose parens", "(", ["(|)"], [])
106 | call RepeatLast("Autoclose_parens", ["(|)(|)"])
107 |
108 | " Auto-closing quotes
109 | call Type("Autoclose quotes", '"', ['"|"'], [])
110 | call RepeatLast("Autoclose_quotes", ['"|""|"'])
111 |
112 | " Deleting parens
113 | call Type("Delete empty parens", "(\", ["|"], [])
114 | call RepeatLast("Delete empty parens", ["||"])
115 |
116 | " Deleting quotes
117 | call Type("Delete emtpy quotes", "\"\", ['|'], [])
118 | call RepeatLast("Delete empty quotes", ["||"])
119 |
120 | " Manual closing parens
121 | call Type("Manual closing parens", "()", ["(|)"], ["autoclose:0"])
122 | call RepeatLast("Manual closing parens", ["(|)(|)"])
123 |
124 | " Manual closing quotes
125 | call Type("Manual closing quotes", "\"\"", ['"|"'], ["autoclose:0"])
126 | call RepeatLast("Manual closing quotes", ['"|""|"'])
127 |
128 | " Jump over paren
129 | call Type("Jump over paren", "()", ['()|'], [])
130 | call RepeatLast("Jump over paren", ['()|()|'])
131 |
132 | " Jump over quote
133 | call Type("Jump over quote", "\"\"", ['""|'], [])
134 | call RepeatLast("Jump over quote", ['""|""|'])
135 |
136 | " Apostrophe
137 | call Type("Apostrophe", "test'", ["test'|"], [])
138 | call RepeatLast("Apostrophe", ["test'|test'|"])
139 |
140 | " Close quote
141 | call Type("Close quote", "'\\a'", ["'|'"], [])
142 |
143 | " Closing paren
144 | call Type("Closing paren", "abcd)", ["abcd)|"], [])
145 |
146 | "
147 | call Type("S Tab", "(\", ["()|"], [])
148 | call RepeatLast("S Tab", ["()|()|"])
149 |
150 | " Space expansion
151 | call Type("Space expansion", "(\\", ['(|)'], ['expand_space:1'])
152 | call RepeatLast("BS with space expansion", ['(|)(|)'])
153 |
154 | " BS with space expansion
155 | call Type("BS with space expansion", "(\", ['( | )'], ['expand_space:1'])
156 | call RepeatLast("Space expansion", ['( | )( | )'])
157 |
158 | " Car return expansion
159 | call Type("CR expansion", "(\", ['(', '|', ')'], ['expand_cr:1'])
160 | call RepeatLast("CR expansion", ['(', '|', ')(', '|', ')'], 1)
161 |
162 | " BS with car return expansion
163 | call Type("BS with CR expansion", "(\\", ['(|)'], ['expand_cr:1'])
164 | call RepeatLast("BS with CR expansion", ['(|)(|)'], 1)
165 |
166 | " Smart quotes
167 | call Type("Smart quote alphanumeric", "a\"4", ['a"4|'], [])
168 | call RepeatLast("Smart quote alphanumeric", ['a"4|a"4|'])
169 |
170 | " Smart quotes
171 | call Type("Smart quote escaped", "esc\\\"", ['esc\"|'], [])
172 | call RepeatLast("Smart quote escaped", ['esc\"|esc\"|'])
173 |
174 | " Smart quotes
175 | call Type("Smart quote apostrophe", "I'm", ["I'm|"], ['smart_quotes:0'])
176 | call RepeatLast("Smart quote escaped", ["I'm|I'm|"])
177 |
178 | " Backspace inside space expansion
179 | call Type("Backspace inside space expansion", "(\\", ['(|)'], ['expand_space:1'])
180 | call RepeatLast("Backspace inside space expansion", ['(|)(|)'])
181 |
182 | " inserts text
183 | call Type(" inserts text", "(he\\th\\", ['(he) th|'], [])
184 |
185 | " Backspace inside CR expansion
186 | call Type("Backspace inside CR expansion", "(\\", ['(|)'], ['expand_cr:1'])
187 | call RepeatLast("Backspace inside CR expansion", ['(|)(|)'], 1)
188 |
189 | " FileType event
190 | let g:delimitMate_excluded_ft = "vim"
191 | set ft=vim
192 | call Type("FileType Autoclose parens", "(", ["(|"], [])
193 | unlet g:delimitMate_excluded_ft
194 | set ft=
195 |
196 | " Duplicated delimiter after CR
197 | call Type("Duplicated delimiter after CR", "(\", ['(', '|)'], [])
198 |
199 | " Deactivate on comments: The first call to a closing delimiter
200 | " will not work here as expected, but it does in real life tests.
201 | set ft=vim
202 | call Type("Deactivate on comments", "\"()``[]''\"\"", ["\"()``[]''\"\"|"], ["autoclose:0"], 1)
203 | set ft=
204 |
205 | " Deactivate parens on comments: The first call to a closing delimiter
206 | " will not work here as expected, but it does in real life tests.
207 | set ft=vim
208 | call Type("Deactivate parens on comments", "\"()[]", ["\"()[]|"], ["autoclose:0"], 1)
209 | set ft=
210 |
211 | " Deactivate quotes on comments: See previous note.
212 | set ft=vim
213 | call Type("Deactivate parens on comments", "\"(`", ["\"(``|"], [], 1)
214 | set ft=
215 |
216 | " Manual close at start of line
217 | call Type("Manual close at start of line", "m)\\)", [')|m)'], ["autoclose:0"])
218 |
219 | " Use | in quotes
220 | call Type("Use in quotes", "\bars", ['|bars|'], ["quotes:'|'"])
221 |
222 | " Use | in matchpairs
223 | call Type("Use in matchpairs", "\bars", ['|bars|$$'], ["matchpairs:'|:$'"])
224 |
225 | "}}}
226 |
227 | " Show results: {{{
228 | normal ggVG"_d
229 | call append(0, split(string(b:test_results)[1:-2], ', '))
230 | call append(0, "*TESTS REPORT: " . b:errors . " failed, " . b:corrects . " passed and " . b:ignores . " ignored.")
231 | normal "_ddgg
232 | let @/ = ".\\+Failed:.*!="
233 | 2,$sort /^.\+':/
234 | normal gg
235 | exec search('Ignored:','nW').",$sort! /^.\\+':/"
236 | set nohlsearch
237 | syn match lineIgnored ".*Ignored.*"
238 | syn match labelPassed "'\@<=.\+\(': 'Passed\)\@="
239 | syn match labelFailed "'\@<=.\+\(': 'Failed\)\@="
240 | syn match resultPassed "\('Passed: \)\@<=.\+\('$\)\@="
241 | syn match resultFailed "\('Failed: \)\@<=.\+\('$\)\@=" contains=resultInequal
242 | syn match resultIgnored "\('Ignored: \)\@<=.\+\('$\)\@="
243 | syn match resultInequal "!="
244 | syn match resultSummary "^\*.\+" contains=resultSummaryNumber
245 | syn match resultSummaryNumber "[1-9][0-9]* failed*" contained
246 |
247 | hi def link lineIgnored Ignore
248 | hi def link labelPassed Comment
249 | hi def link labelFailed Special
250 | hi def link resultPassed Ignore
251 | hi def link resultFailed Boolean
252 | hi def link resultInequal Error
253 | hi def link resultSummary SpecialComment
254 | hi def link resultSummaryNumber Error
255 | " }}}
256 |
257 | let &more = nomore
258 | endfunction
259 | " vim:foldmethod=marker:foldcolumn=4
260 |
261 |
--------------------------------------------------------------------------------
/bundle/delimitMate/test/README:
--------------------------------------------------------------------------------
1 | The plugins runVimTests (http://www.vim.org/scripts/script.php?script_id=2565)
2 | and VimTAP (http://www.vim.org/scripts/script.php?script_id=2213) are needed to
3 | run these tests.
4 |
5 | Besides the _setup.vim configuration file present in this repo you need to
6 | create a global one and place it in the same dir where the runVimTests
7 | executable is located. Assuming the executable is at '~/bin/runVimTests' this
8 | global configuration file should be '~/bin/runVimTestsSetup.vim' and should
9 | have something like the following lines inside of it:
10 |
11 | " Prepend tests repos to &rtp
12 | let &runtimepath = '/path/to/runVimTests_dir,' . &rtp
13 | let &runtimepath = '/path/to/vimTAP_dir,' . &rtp
14 |
--------------------------------------------------------------------------------
/bundle/delimitMate/test/_setup.vim:
--------------------------------------------------------------------------------
1 | let &rtp = expand(':p:h:h') . ',' . &rtp . ',' . expand(':p:h:h') . '/after'
2 | ru plugin/delimitMate.vim
3 |
--------------------------------------------------------------------------------
/bundle/delimitMate/test/autoclose_matchpairs.txt:
--------------------------------------------------------------------------------
1 | let g:delimitMate_autoclose = 1
2 | "(x" "(x)"
3 | "(\x" "x"
4 | "()x" "()x"
5 | "((\gx" "(())x"
6 | "(x\u" ""
7 | "@(x" "@(x)"
8 | "@#\(x" "@(x)#"
9 | "(\x" "()x"
10 | let g:delimitMate_autoclose = 0
11 | "(x" "(x"
12 | "()x" "(x)"
13 | "())x" "()x"
14 | "()\x" "x"
15 | "@()x" "@(x)"
16 | "@#\()x" "@(x)#"
17 | let g:delimitMate_expand_space = 1
18 | let g:delimitMate_autoclose = 1
19 | "(\x" "( x )"
20 | "(\\x" "(x)"
21 | let g:delimitMate_autoclose = 0
22 | "()\\x" "(x)"
23 | let g:delimitMate_autoclose = 1
24 | # Handle backspace gracefully.
25 | set backspace=
26 | "(\a\x" "(x)"
27 |
28 | # Add semicolon next to the closing paren. Issue #77.
29 | new
30 | let b:delimitMate_eol_marker = ';'
31 | "abc(x" "abc(x);"
32 | %d
33 | # BS should behave accordingly.
34 | "abc(\" "abc"
35 |
--------------------------------------------------------------------------------
/bundle/delimitMate/test/autoclose_matchpairs.vim:
--------------------------------------------------------------------------------
1 | let g:delimitMate_matchpairs = '(:),{:},[:],<:>,¿:?,¡:!'
2 | let lines = readfile(expand(':t:r').'.txt')
3 | call vimtest#StartTap()
4 | let testsnumber = len(filter(copy(lines), 'v:val =~ ''^"'''))
5 | let itemsnumber = len(split(g:delimitMate_matchpairs, ','))
6 | call vimtap#Plan(testsnumber * itemsnumber)
7 | let tcount = 1
8 | let reload = 1
9 | for item in lines
10 | if item =~ '^#\|^\s*$'
11 | " A comment or empty line.
12 | continue
13 | endif
14 | if item !~ '^"'
15 | " A command.
16 | exec item
17 | call vimtap#Diag(item)
18 | let reload = 1
19 | continue
20 | endif
21 | if reload
22 | DelimitMateReload
23 | call vimtap#Diag('DelimitMateReload')
24 | let reload = 0
25 | endif
26 | let [input, output] = split(item, '"\%(\\.\|[^\\"]\)*"\zs\s*\ze"\%(\\.\|[^\\"]\)*"')
27 | for [s:l,s:r] in map(split(g:delimitMate_matchpairs, ','), 'split(v:val, ":")')
28 | let input2 = substitute(input, '(', s:l, 'g')
29 | let input2 = substitute(input2, ')', s:r, 'g')
30 | let output2 = substitute(output, '(', s:l, 'g')
31 | let output2 = substitute(output2, ')', s:r, 'g')
32 | %d
33 | exec 'normal i'.eval(input2)."\"
34 | let line = getline('.')
35 | let passed = line == eval(output2)
36 | call vimtap#Ok(passed, input2 . ' => ' . string(line) .
37 | \ (passed ? ' =' : ' !') . '= ' . string(eval(output2)))
38 | let tcount += 1
39 | endfor
40 | endfor
41 | call vimtest#Quit()
42 |
--------------------------------------------------------------------------------
/bundle/delimitMate/test/autoclose_quotes.txt:
--------------------------------------------------------------------------------
1 | let g:delimitMate_autoclose = 1
2 | "'x" "'x'"
3 | "'x\u" ""
4 | "''x" "''x"
5 | "'\x" "x"
6 | "'\gx" "''x"
7 | "'\"x" "'\"x\"'"
8 | "@'x" "@'x'"
9 | "@#\'x" "@'x'#"
10 | "'\x" "''x"
11 | "abc'" "abc'"
12 | "abc\\'x" "abc\\'x"
13 | "u'Привет'" "u'Привет'"
14 | "u'string'" "u'string'"
15 | let g:delimitMate_autoclose = 0
16 | "'x" "'x"
17 | "''x" "'x'"
18 | "'''x" "''x"
19 | "''\x" "x"
20 | "@''x" "@'x'"
21 | "@#\''x" "@'x'#"
22 | let g:delimitMate_expand_space = 1
23 | let g:delimitMate_autoclose = 1
24 | "'\x" "' x '"
25 | "'\\x" "'x'"
26 | "abc\\''\x" "abc\\' x'"
27 | let g:delimitMate_autoclose = 0
28 | "''\\x" "'x'"
29 | let g:delimitMate_autoclose = 1
30 | # Handle backspace gracefully.
31 | set backspace=
32 | "'\a\x" "'x'"
33 | set cpo=ces$
34 | "'x" "'x'"
35 | # Make sure smart quote works beyond first column.
36 | " 'x" " 'x'"
37 | # Make sure we jump over a quote on the right. #89.
38 | "('test'x" "('test'x)"
39 |
--------------------------------------------------------------------------------
/bundle/delimitMate/test/autoclose_quotes.vim:
--------------------------------------------------------------------------------
1 | let g:delimitMate_quotes = '" '' ` ” « |'
2 | let lines = readfile(expand(':t:r').'.txt')
3 | call vimtest#StartTap()
4 | let testsnumber = len(filter(copy(lines), 'v:val =~ ''^"'''))
5 | let itemsnumber = len(split(g:delimitMate_quotes, ' '))
6 | call vimtap#Plan(testsnumber * itemsnumber)
7 | let reload = 1
8 | let tcount = 1
9 | for item in lines
10 | if item =~ '^#\|^\s*$'
11 | " A comment or empty line.
12 | continue
13 | endif
14 | if item !~ '^"'
15 | " A command.
16 | exec item
17 | call vimtap#Diag(item)
18 | let reload = 1
19 | continue
20 | endif
21 | if reload
22 | DelimitMateReload
23 | call vimtap#Diag('DelimitMateReload')
24 | let reload = 0
25 | endif
26 | let [input, output] = split(item, '"\%(\\.\|[^\\"]\)*"\zs\s*\ze"\%(\\.\|[^\\"]\)*"')
27 | let quotes = split(g:delimitMate_quotes, '\s')
28 | for quote in quotes
29 | let input_q = substitute(input,"'" , escape(escape(quote, '"'), '\'), 'g')
30 | let output_q = substitute(output,"'" , escape(escape(quote, '"'), '\'), 'g')
31 | %d
32 | exec 'normal i'.eval(input_q)."\"
33 | let line = getline('.')
34 | let passed = line == eval(output_q)
35 | if quote == '”' || tcount == 31
36 | call vimtap#Todo(1)
37 | endif
38 | if 1 "!vimtap#Skip(1, tcount != 21, 'Test 21')
39 | call vimtap#Ok(passed, eval(substitute(input_q, '\\<', '<','g')) . ' => ' . line .
40 | \ (passed ? ' =' : ' !') . '= ' . eval(output_q))
41 | endif
42 | let tcount += 1
43 | endfor
44 | endfor
45 | call vimtest#Quit()
46 |
--------------------------------------------------------------------------------
/bundle/delimitMate/test/expand_cr.txt:
--------------------------------------------------------------------------------
1 | #
2 | %d
3 | filetype indent on
4 | set bs=2 et sts=4 sw=4 ft=javascript
5 | call setline(1, '$(document).ready(function() {})')
6 | DelimitMateReload
7 | exec "normal 31|i\x\"
8 | ================================================================================
9 | $(document).ready(function() {
10 | x
11 | })
12 | --------------------------------------------------------------------------------
13 | # Issue #95
14 | new
15 | exec "normal i(\test)x"
16 | ================================================================================
17 | (
18 | test
19 | )x
20 | --------------------------------------------------------------------------------
21 | # Remove CR expansion on BS
22 | %d
23 | exec "normal i(\\x"
24 | ================================================================================
25 | (x)
26 | --------------------------------------------------------------------------------
27 | # Consider indentation with BS inside an empty CR expansion.
28 | %d
29 | exec "normal i( \\\x"
30 | ================================================================================
31 | (x)
32 | --------------------------------------------------------------------------------
33 | # Conflict with indentation settings (cindent). Issue #95
34 | se cindent
35 | call setline(1, ['sub foo {',' while (1) {', ' ', ' }', '}'])
36 | call cursor(3, 8)
37 | normal a}x
38 | ================================================================================
39 | sub foo {
40 | while (1) {
41 |
42 | }x
43 | }
44 | --------------------------------------------------------------------------------
45 | %d
46 | call setline(1, "\"{bracketed}")
47 | normal A"x
48 | ================================================================================
49 | "{bracketed""x
50 | --------------------------------------------------------------------------------
51 | # Syntax folding enabled by autocmd breaks expansion. But ti can't be tested
52 | # with :normal
53 | new
54 | autocmd InsertEnter * let w:fdm=&foldmethod | setl foldmethod=manual
55 | autocmd InsertLeave * let &foldmethod = w:fdm
56 | set foldmethod=marker
57 | set foldmarker={,}
58 | set foldlevel=0
59 | set backspace=2
60 | exec "normal iabc {\x"
61 | ================================================================================
62 | abc {
63 | x
64 | }
65 | --------------------------------------------------------------------------------
66 |
--------------------------------------------------------------------------------
/bundle/delimitMate/test/expand_cr.vim:
--------------------------------------------------------------------------------
1 | let g:delimitMate_expand_cr = 1
2 | "DelimitMateReload
3 | let lines = readfile(expand(':t:r').'.txt')
4 | call vimtest#StartTap()
5 | let testsnumber = len(filter(copy(lines), 'v:val =~ ''^=\{80}$'''))
6 | call vimtap#Plan(testsnumber)
7 | let tcount = 1
8 | let expect = 0
9 | let evaluate = 0
10 | for item in lines
11 | if item =~ '^=\{80}$'
12 | let expect = 1
13 | let expected = []
14 | continue
15 | endif
16 |
17 | if item =~ '^#\|^\s*$' && expect == 0
18 | " A comment or empty line.
19 | continue
20 | endif
21 | if ! expect
22 | " A command.
23 | exec item
24 | call vimtap#Diag(item)
25 | continue
26 | endif
27 | if item =~ '^-\{80}$'
28 | let expect = 0
29 | endif
30 | if expect
31 | call add(expected, item)
32 | continue
33 | endif
34 | let lines = getline(1, line('$'))
35 | let passed = lines == expected
36 | echom string(lines)
37 | echom string(expected)
38 | call vimtap#Ok(passed, string(expected) .
39 | \ (passed ? ' =' : ' !') . '= ' . string(lines))
40 | let tcount += 1
41 | endfor
42 | call vimtest#Quit()
43 |
--------------------------------------------------------------------------------
/bundle/delimitMate/test/expand_space.txt:
--------------------------------------------------------------------------------
1 | # Issue #95
2 | new
3 | exec "normal i( test)x"
4 | ================================================================================
5 | ( test )x
6 | --------------------------------------------------------------------------------
7 |
--------------------------------------------------------------------------------
/bundle/delimitMate/test/expand_space.vim:
--------------------------------------------------------------------------------
1 | let g:delimitMate_expand_space = 1
2 | "DelimitMateReload
3 | let lines = readfile(expand(':t:r').'.txt')
4 | call vimtest#StartTap()
5 | let testsnumber = len(filter(copy(lines), 'v:val =~ ''^=\{80}$'''))
6 | call vimtap#Plan(testsnumber)
7 | let tcount = 1
8 | let expect = 0
9 | let evaluate = 0
10 | for item in lines
11 | if item =~ '^=\{80}$'
12 | let expect = 1
13 | let expected = []
14 | continue
15 | endif
16 |
17 | if item =~ '^#\|^\s*$' && expect == 0
18 | " A comment or empty line.
19 | continue
20 | endif
21 | if ! expect
22 | " A command.
23 | exec item
24 | call vimtap#Diag(item)
25 | continue
26 | endif
27 | if item =~ '^-\{80}$'
28 | let expect = 0
29 | endif
30 | if expect
31 | call add(expected, item)
32 | continue
33 | endif
34 | let lines = getline(1, line('$'))
35 | let passed = lines == expected
36 | echom string(lines)
37 | echom string(expected)
38 | call vimtap#Ok(passed, string(expected) .
39 | \ (passed ? ' =' : ' !') . '= ' . string(lines))
40 | let tcount += 1
41 | endfor
42 | call vimtest#Quit()
43 |
--------------------------------------------------------------------------------
/bundle/snipmate/README:
--------------------------------------------------------------------------------
1 | This is a mirror of http://www.vim.org/scripts/script.php?script_id=2540
2 |
3 | snipMate.vim aims to be an unobtrusive, concise vim script that implements some of TextMate's snippets features in Vim. A snippet is a piece of often-typed text that you can insert into your document using a trigger word followed by a .
4 |
5 | For instance, in a C file using the default installation of snipMate.vim, if you type "for" in insert mode, it will expand a typical for loop in C:
6 |
7 | for (i = 0; i < count; i++) {
8 |
9 | }
10 |
11 | To go to the next item in the loop, simply over to it; if there is repeated code, such as the "i" variable in this example, you can simply start typing once it's highlighted and all the matches specified in the snippet will be updated.
12 |
13 | Requires Vim 7 or higher.
14 | For a quick introduction, see this screencast: http://vimeo.com/3535418
15 | For more help see the documentation that comes with snipMate in ~/.vim/doc/snipMate.txt.
16 |
17 | snipMate.vim has the following features among others:
18 | - The syntax of snippets is very similar to TextMate's, allowing easy conversion.
19 | - The position of the snippet is kept transparently (i.e., it does not use marks/placeholders inserted into the buffer), allowing you to escape out of an incomplete snippet, something particularly useful in Vim.
20 | - Variables in snippets are updated as-you-type.
21 | - Snippets can have multiple matches.
22 | - Snippets can be out of order. For instance, in a do...while loop, the condition can be added before the code.
23 |
24 | Bug reports, feature requests, etc. are welcome and can be emailed to me or submitted on the issue tracker: http://code.google.com/p/snipmate/issues/list
25 |
26 | If you would like to watch the development of this plugin, you can also follow it on github: http://github.com/msanders/snipmate.vim
27 |
28 | Enjoy!
29 |
--------------------------------------------------------------------------------
/bundle/snipmate/after/plugin/snipMate.vim:
--------------------------------------------------------------------------------
1 | " These are the mappings for snipMate.vim. Putting it here ensures that it
2 | " will be mapped after other plugins such as supertab.vim.
3 | if !exists('loaded_snips') || exists('s:did_snips_mappings')
4 | finish
5 | endif
6 | let s:did_snips_mappings = 1
7 |
8 | ino =TriggerSnippet()
9 | snor i=TriggerSnippet()
10 | ino =BackwardsSnippet()
11 | snor i=BackwardsSnippet()
12 | ino =ShowAvailableSnips()
13 |
14 | " The default mappings for these are annoying & sometimes break snipMate.
15 | " You can change them back if you want, I've put them here for convenience.
16 | snor b
17 | snor a
18 | snor bi
19 | snor ' b'
20 | snor ` b`
21 | snor % b%
22 | snor U bU
23 | snor ^ b^
24 | snor \ b\
25 | snor b
26 |
27 | " By default load snippets in snippets_dir
28 | if empty(snippets_dir)
29 | finish
30 | endif
31 |
32 | call GetSnippets(snippets_dir, '_') " Get global snippets
33 |
34 | au FileType * if &ft != 'help' | call GetSnippets(snippets_dir, &ft) | endif
35 | " vim:noet:sw=4:ts=4:ft=vim
36 |
--------------------------------------------------------------------------------
/bundle/snipmate/autoload/snipMate.vim:
--------------------------------------------------------------------------------
1 | fun! Filename(...)
2 | let filename = expand('%:t:r')
3 | if filename == '' | return a:0 == 2 ? a:2 : '' | endif
4 | return !a:0 || a:1 == '' ? filename : substitute(a:1, '$1', filename, 'g')
5 | endf
6 |
7 | fun s:RemoveSnippet()
8 | unl! g:snipPos s:curPos s:snipLen s:endCol s:endLine s:prevLen
9 | \ s:lastBuf s:oldWord
10 | if exists('s:update')
11 | unl s:startCol s:origWordLen s:update
12 | if exists('s:oldVars') | unl s:oldVars s:oldEndCol | endif
13 | endif
14 | aug! snipMateAutocmds
15 | endf
16 |
17 | fun snipMate#expandSnip(snip, col)
18 | let lnum = line('.') | let col = a:col
19 |
20 | let snippet = s:ProcessSnippet(a:snip)
21 | " Avoid error if eval evaluates to nothing
22 | if snippet == '' | return '' | endif
23 |
24 | " Expand snippet onto current position with the tab stops removed
25 | let snipLines = split(substitute(snippet, '$\d\+\|${\d\+.\{-}}', '', 'g'), "\n", 1)
26 |
27 | let line = getline(lnum)
28 | let afterCursor = strpart(line, col - 1)
29 | " Keep text after the cursor
30 | if afterCursor != "\t" && afterCursor != ' '
31 | let line = strpart(line, 0, col - 1)
32 | let snipLines[-1] .= afterCursor
33 | else
34 | let afterCursor = ''
35 | " For some reason the cursor needs to move one right after this
36 | if line != '' && col == 1 && &ve != 'all' && &ve != 'onemore'
37 | let col += 1
38 | endif
39 | endif
40 |
41 | call setline(lnum, line.snipLines[0])
42 |
43 | " Autoindent snippet according to previous indentation
44 | let indent = matchend(line, '^.\{-}\ze\(\S\|$\)') + 1
45 | call append(lnum, map(snipLines[1:], "'".strpart(line, 0, indent - 1)."'.v:val"))
46 |
47 | " Open any folds snippet expands into
48 | if &fen | sil! exe lnum.','.(lnum + len(snipLines) - 1).'foldopen' | endif
49 |
50 | let [g:snipPos, s:snipLen] = s:BuildTabStops(snippet, lnum, col - indent, indent)
51 |
52 | if s:snipLen
53 | aug snipMateAutocmds
54 | au CursorMovedI * call s:UpdateChangedSnip(0)
55 | au InsertEnter * call s:UpdateChangedSnip(1)
56 | aug END
57 | let s:lastBuf = bufnr(0) " Only expand snippet while in current buffer
58 | let s:curPos = 0
59 | let s:endCol = g:snipPos[s:curPos][1]
60 | let s:endLine = g:snipPos[s:curPos][0]
61 |
62 | call cursor(g:snipPos[s:curPos][0], g:snipPos[s:curPos][1])
63 | let s:prevLen = [line('$'), col('$')]
64 | if g:snipPos[s:curPos][2] != -1 | return s:SelectWord() | endif
65 | else
66 | unl g:snipPos s:snipLen
67 | " Place cursor at end of snippet if no tab stop is given
68 | let newlines = len(snipLines) - 1
69 | call cursor(lnum + newlines, indent + len(snipLines[-1]) - len(afterCursor)
70 | \ + (newlines ? 0: col - 1))
71 | endif
72 | return ''
73 | endf
74 |
75 | " Prepare snippet to be processed by s:BuildTabStops
76 | fun s:ProcessSnippet(snip)
77 | let snippet = a:snip
78 | " Evaluate eval (`...`) expressions.
79 | " Using a loop here instead of a regex fixes a bug with nested "\=".
80 | if stridx(snippet, '`') != -1
81 | while match(snippet, '`.\{-}`') != -1
82 | let snippet = substitute(snippet, '`.\{-}`',
83 | \ substitute(eval(matchstr(snippet, '`\zs.\{-}\ze`')),
84 | \ "\n\\%$", '', ''), '')
85 | endw
86 | let snippet = substitute(snippet, "\r", "\n", 'g')
87 | endif
88 |
89 | " Place all text after a colon in a tab stop after the tab stop
90 | " (e.g. "${#:foo}" becomes "${:foo}foo").
91 | " This helps tell the position of the tab stops later.
92 | let snippet = substitute(snippet, '${\d\+:\(.\{-}\)}', '&\1', 'g')
93 |
94 | " Update the a:snip so that all the $# become the text after
95 | " the colon in their associated ${#}.
96 | " (e.g. "${1:foo}" turns all "$1"'s into "foo")
97 | let i = 1
98 | while stridx(snippet, '${'.i) != -1
99 | let s = matchstr(snippet, '${'.i.':\zs.\{-}\ze}')
100 | if s != ''
101 | let snippet = substitute(snippet, '$'.i, s.'&', 'g')
102 | endif
103 | let i += 1
104 | endw
105 |
106 | if &et " Expand tabs to spaces if 'expandtab' is set.
107 | return substitute(snippet, '\t', repeat(' ', &sts ? &sts : &sw), 'g')
108 | endif
109 | return snippet
110 | endf
111 |
112 | " Counts occurences of haystack in needle
113 | fun s:Count(haystack, needle)
114 | let counter = 0
115 | let index = stridx(a:haystack, a:needle)
116 | while index != -1
117 | let index = stridx(a:haystack, a:needle, index+1)
118 | let counter += 1
119 | endw
120 | return counter
121 | endf
122 |
123 | " Builds a list of a list of each tab stop in the snippet containing:
124 | " 1.) The tab stop's line number.
125 | " 2.) The tab stop's column number
126 | " (by getting the length of the string between the last "\n" and the
127 | " tab stop).
128 | " 3.) The length of the text after the colon for the current tab stop
129 | " (e.g. "${1:foo}" would return 3). If there is no text, -1 is returned.
130 | " 4.) If the "${#:}" construct is given, another list containing all
131 | " the matches of "$#", to be replaced with the placeholder. This list is
132 | " composed the same way as the parent; the first item is the line number,
133 | " and the second is the column.
134 | fun s:BuildTabStops(snip, lnum, col, indent)
135 | let snipPos = []
136 | let i = 1
137 | let withoutVars = substitute(a:snip, '$\d\+', '', 'g')
138 | while stridx(a:snip, '${'.i) != -1
139 | let beforeTabStop = matchstr(withoutVars, '^.*\ze${'.i.'\D')
140 | let withoutOthers = substitute(withoutVars, '${\('.i.'\D\)\@!\d\+.\{-}}', '', 'g')
141 |
142 | let j = i - 1
143 | call add(snipPos, [0, 0, -1])
144 | let snipPos[j][0] = a:lnum + s:Count(beforeTabStop, "\n")
145 | let snipPos[j][1] = a:indent + len(matchstr(withoutOthers, '.*\(\n\|^\)\zs.*\ze${'.i.'\D'))
146 | if snipPos[j][0] == a:lnum | let snipPos[j][1] += a:col | endif
147 |
148 | " Get all $# matches in another list, if ${#:name} is given
149 | if stridx(withoutVars, '${'.i.':') != -1
150 | let snipPos[j][2] = len(matchstr(withoutVars, '${'.i.':\zs.\{-}\ze}'))
151 | let dots = repeat('.', snipPos[j][2])
152 | call add(snipPos[j], [])
153 | let withoutOthers = substitute(a:snip, '${\d\+.\{-}}\|$'.i.'\@!\d\+', '', 'g')
154 | while match(withoutOthers, '$'.i.'\(\D\|$\)') != -1
155 | let beforeMark = matchstr(withoutOthers, '^.\{-}\ze'.dots.'$'.i.'\(\D\|$\)')
156 | call add(snipPos[j][3], [0, 0])
157 | let snipPos[j][3][-1][0] = a:lnum + s:Count(beforeMark, "\n")
158 | let snipPos[j][3][-1][1] = a:indent + (snipPos[j][3][-1][0] > a:lnum
159 | \ ? len(matchstr(beforeMark, '.*\n\zs.*'))
160 | \ : a:col + len(beforeMark))
161 | let withoutOthers = substitute(withoutOthers, '$'.i.'\ze\(\D\|$\)', '', '')
162 | endw
163 | endif
164 | let i += 1
165 | endw
166 | return [snipPos, i - 1]
167 | endf
168 |
169 | fun snipMate#jumpTabStop(backwards)
170 | let leftPlaceholder = exists('s:origWordLen')
171 | \ && s:origWordLen != g:snipPos[s:curPos][2]
172 | if leftPlaceholder && exists('s:oldEndCol')
173 | let startPlaceholder = s:oldEndCol + 1
174 | endif
175 |
176 | if exists('s:update')
177 | call s:UpdatePlaceholderTabStops()
178 | else
179 | call s:UpdateTabStops()
180 | endif
181 |
182 | " Don't reselect placeholder if it has been modified
183 | if leftPlaceholder && g:snipPos[s:curPos][2] != -1
184 | if exists('startPlaceholder')
185 | let g:snipPos[s:curPos][1] = startPlaceholder
186 | else
187 | let g:snipPos[s:curPos][1] = col('.')
188 | let g:snipPos[s:curPos][2] = 0
189 | endif
190 | endif
191 |
192 | let s:curPos += a:backwards ? -1 : 1
193 | " Loop over the snippet when going backwards from the beginning
194 | if s:curPos < 0 | let s:curPos = s:snipLen - 1 | endif
195 |
196 | if s:curPos == s:snipLen
197 | let sMode = s:endCol == g:snipPos[s:curPos-1][1]+g:snipPos[s:curPos-1][2]
198 | call s:RemoveSnippet()
199 | return sMode ? "\