New repo fix

This commit is contained in:
2015-03-04 12:22:32 -06:00
parent 43e3ec9f7c
commit 6c77529845
63 changed files with 21389 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,140 @@
" =============================================================================
" File: autoload/ctrlp/bookmarkdir.vim
" Description: Bookmarked directories extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Init {{{1
if exists('g:loaded_ctrlp_bookmarkdir') && g:loaded_ctrlp_bookmarkdir
fini
en
let g:loaded_ctrlp_bookmarkdir = 1
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#bookmarkdir#init()',
\ 'accept': 'ctrlp#bookmarkdir#accept',
\ 'lname': 'bookmarked dirs',
\ 'sname': 'bkd',
\ 'type': 'tabs',
\ 'opmul': 1,
\ 'nolim': 1,
\ 'wipe': 'ctrlp#bookmarkdir#remove',
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
" Utilities {{{1
fu! s:getinput(str, ...)
echoh Identifier
cal inputsave()
let input = call('input', a:0 ? [a:str] + a:000 : [a:str])
cal inputrestore()
echoh None
retu input
endf
fu! s:cachefile()
if !exists('s:cadir') || !exists('s:cafile')
let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'bkd'
let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt'
en
retu s:cafile
endf
fu! s:writecache(lines)
cal ctrlp#utils#writecache(a:lines, s:cadir, s:cafile)
endf
fu! s:getbookmarks()
retu ctrlp#utils#readfile(s:cachefile())
endf
fu! s:savebookmark(name, cwd)
let cwds = exists('+ssl') ? [tr(a:cwd, '\', '/'), tr(a:cwd, '/', '\')] : [a:cwd]
let entries = filter(s:getbookmarks(), 'index(cwds, s:parts(v:val)[1]) < 0')
cal s:writecache(insert(entries, a:name.' '.a:cwd))
endf
fu! s:setentries()
let time = getftime(s:cachefile())
if !( exists('s:bookmarks') && time == s:bookmarks[0] )
let s:bookmarks = [time, s:getbookmarks()]
en
endf
fu! s:parts(str)
let mlist = matchlist(a:str, '\v([^\t]+)\t(.*)$')
retu mlist != [] ? mlist[1:2] : ['', '']
endf
fu! s:process(entries, type)
retu map(a:entries, 's:modify(v:val, a:type)')
endf
fu! s:modify(entry, type)
let [name, dir] = s:parts(a:entry)
let dir = fnamemodify(dir, a:type)
retu name.' '.( dir == '' ? '.' : dir )
endf
fu! s:msg(name, cwd)
redr
echoh Identifier | echon 'Bookmarked ' | echoh Constant
echon a:name.' ' | echoh Directory | echon a:cwd
echoh None
endf
fu! s:syntax()
if !ctrlp#nosy()
cal ctrlp#hicheck('CtrlPBookmark', 'Identifier')
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
sy match CtrlPBookmark '^> [^\t]\+' contains=CtrlPLinePre
sy match CtrlPTabExtra '\zs\t.*\ze$'
en
endf
" Public {{{1
fu! ctrlp#bookmarkdir#init()
cal s:setentries()
cal s:syntax()
retu s:process(copy(s:bookmarks[1]), ':.')
endf
fu! ctrlp#bookmarkdir#accept(mode, str)
let parts = s:parts(s:modify(a:str, ':p'))
cal call('s:savebookmark', parts)
if a:mode =~ 't\|v\|h'
cal ctrlp#exit()
en
cal ctrlp#setdir(parts[1], a:mode =~ 't\|h' ? 'chd!' : 'lc!')
if a:mode == 'e'
cal ctrlp#switchtype(0)
cal ctrlp#recordhist()
cal ctrlp#prtclear()
en
endf
fu! ctrlp#bookmarkdir#add(dir, ...)
let str = 'Directory to bookmark: '
let cwd = a:dir != '' ? a:dir : s:getinput(str, getcwd(), 'dir')
if cwd == '' | retu | en
let cwd = fnamemodify(cwd, ':p')
let name = a:0 && a:1 != '' ? a:1 : s:getinput('Bookmark as: ', cwd)
if name == '' | retu | en
let name = tr(name, ' ', ' ')
cal s:savebookmark(name, cwd)
cal s:msg(name, cwd)
endf
fu! ctrlp#bookmarkdir#remove(entries)
cal s:process(a:entries, ':p')
cal s:writecache(a:entries == [] ? [] :
\ filter(s:getbookmarks(), 'index(a:entries, v:val) < 0'))
cal s:setentries()
retu s:process(copy(s:bookmarks[1]), ':.')
endf
fu! ctrlp#bookmarkdir#id()
retu s:id
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@@ -0,0 +1,264 @@
" =============================================================================
" File: autoload/ctrlp/buffertag.vim
" Description: Buffer Tag extension
" Maintainer: Kien Nguyen <github.com/kien>
" Credits: Much of the code was taken from tagbar.vim by Jan Larres, plus
" a few lines from taglist.vim by Yegappan Lakshmanan and from
" buffertag.vim by Takeshi Nishida.
" =============================================================================
" Init {{{1
if exists('g:loaded_ctrlp_buftag') && g:loaded_ctrlp_buftag
fini
en
let g:loaded_ctrlp_buftag = 1
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#buffertag#init(s:crfile)',
\ 'accept': 'ctrlp#buffertag#accept',
\ 'lname': 'buffer tags',
\ 'sname': 'bft',
\ 'exit': 'ctrlp#buffertag#exit()',
\ 'type': 'tabs',
\ 'opts': 'ctrlp#buffertag#opts()',
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
let [s:pref, s:opts] = ['g:ctrlp_buftag_', {
\ 'systemenc': ['s:enc', &enc],
\ 'ctags_bin': ['s:bin', ''],
\ 'types': ['s:usr_types', {}],
\ }]
let s:bins = [
\ 'ctags-exuberant',
\ 'exuberant-ctags',
\ 'exctags',
\ '/usr/local/bin/ctags',
\ '/opt/local/bin/ctags',
\ 'ctags',
\ 'ctags.exe',
\ 'tags',
\ ]
let s:types = {
\ 'asm' : '%sasm%sasm%sdlmt',
\ 'aspperl': '%sasp%sasp%sfsv',
\ 'aspvbs' : '%sasp%sasp%sfsv',
\ 'awk' : '%sawk%sawk%sf',
\ 'beta' : '%sbeta%sbeta%sfsv',
\ 'c' : '%sc%sc%sdgsutvf',
\ 'cpp' : '%sc++%sc++%snvdtcgsuf',
\ 'cs' : '%sc#%sc#%sdtncEgsipm',
\ 'cobol' : '%scobol%scobol%sdfgpPs',
\ 'eiffel' : '%seiffel%seiffel%scf',
\ 'erlang' : '%serlang%serlang%sdrmf',
\ 'expect' : '%stcl%stcl%scfp',
\ 'fortran': '%sfortran%sfortran%spbceiklmntvfs',
\ 'html' : '%shtml%shtml%saf',
\ 'java' : '%sjava%sjava%spcifm',
\ 'javascript': '%sjavascript%sjavascript%sf',
\ 'lisp' : '%slisp%slisp%sf',
\ 'lua' : '%slua%slua%sf',
\ 'make' : '%smake%smake%sm',
\ 'ocaml' : '%socaml%socaml%scmMvtfCre',
\ 'pascal' : '%spascal%spascal%sfp',
\ 'perl' : '%sperl%sperl%sclps',
\ 'php' : '%sphp%sphp%scdvf',
\ 'python' : '%spython%spython%scmf',
\ 'rexx' : '%srexx%srexx%ss',
\ 'ruby' : '%sruby%sruby%scfFm',
\ 'scheme' : '%sscheme%sscheme%ssf',
\ 'sh' : '%ssh%ssh%sf',
\ 'csh' : '%ssh%ssh%sf',
\ 'zsh' : '%ssh%ssh%sf',
\ 'slang' : '%sslang%sslang%snf',
\ 'sml' : '%ssml%ssml%secsrtvf',
\ 'sql' : '%ssql%ssql%scFPrstTvfp',
\ 'tcl' : '%stcl%stcl%scfmp',
\ 'vera' : '%svera%svera%scdefgmpPtTvx',
\ 'verilog': '%sverilog%sverilog%smcPertwpvf',
\ 'vim' : '%svim%svim%savf',
\ 'yacc' : '%syacc%syacc%sl',
\ }
cal map(s:types, 'printf(v:val, "--language-force=", " --", "-types=")')
if executable('jsctags')
cal extend(s:types, { 'javascript': { 'args': '-f -', 'bin': 'jsctags' } })
en
fu! ctrlp#buffertag#opts()
for [ke, va] in items(s:opts)
let {va[0]} = exists(s:pref.ke) ? {s:pref.ke} : va[1]
endfo
" Ctags bin
if empty(s:bin)
for bin in s:bins | if executable(bin)
let s:bin = bin
brea
en | endfo
el
let s:bin = expand(s:bin, 1)
en
" Types
cal extend(s:types, s:usr_types)
endf
" Utilities {{{1
fu! s:validfile(fname, ftype)
if ( !empty(a:fname) || !empty(a:ftype) ) && filereadable(a:fname)
\ && index(keys(s:types), a:ftype) >= 0 | retu 1 | en
retu 0
endf
fu! s:exectags(cmd)
if exists('+ssl')
let [ssl, &ssl] = [&ssl, 0]
en
if &sh =~ 'cmd\.exe'
let [sxq, &sxq, shcf, &shcf] = [&sxq, '"', &shcf, '/s /c']
en
let output = system(a:cmd)
if &sh =~ 'cmd\.exe'
let [&sxq, &shcf] = [sxq, shcf]
en
if exists('+ssl')
let &ssl = ssl
en
retu output
endf
fu! s:exectagsonfile(fname, ftype)
let [ags, ft] = ['-f - --sort=no --excmd=pattern --fields=nKs ', a:ftype]
if type(s:types[ft]) == 1
let ags .= s:types[ft]
let bin = s:bin
elsei type(s:types[ft]) == 4
let ags = s:types[ft]['args']
let bin = expand(s:types[ft]['bin'], 1)
en
if empty(bin) | retu '' | en
let cmd = s:esctagscmd(bin, ags, a:fname)
if empty(cmd) | retu '' | en
let output = s:exectags(cmd)
if v:shell_error || output =~ 'Warning: cannot open' | retu '' | en
retu output
endf
fu! s:esctagscmd(bin, args, ...)
if exists('+ssl')
let [ssl, &ssl] = [&ssl, 0]
en
let fname = a:0 ? shellescape(a:1) : ''
let cmd = shellescape(a:bin).' '.a:args.' '.fname
if &sh =~ 'cmd\.exe'
let cmd = substitute(cmd, '[&()@^<>|]', '^\0', 'g')
en
if exists('+ssl')
let &ssl = ssl
en
if has('iconv')
let last = s:enc != &enc ? s:enc : !empty( $LANG ) ? $LANG : &enc
let cmd = iconv(cmd, &enc, last)
en
retu cmd
endf
fu! s:process(fname, ftype)
if !s:validfile(a:fname, a:ftype) | retu [] | endif
let ftime = getftime(a:fname)
if has_key(g:ctrlp_buftags, a:fname)
\ && g:ctrlp_buftags[a:fname]['time'] >= ftime
let lines = g:ctrlp_buftags[a:fname]['lines']
el
let data = s:exectagsonfile(a:fname, a:ftype)
let [raw, lines] = [split(data, '\n\+'), []]
for line in raw
if line !~# '^!_TAG_' && len(split(line, ';"')) == 2
let parsed_line = s:parseline(line)
if parsed_line != ''
cal add(lines, parsed_line)
en
en
endfo
let cache = { a:fname : { 'time': ftime, 'lines': lines } }
cal extend(g:ctrlp_buftags, cache)
en
retu lines
endf
fu! s:parseline(line)
let vals = matchlist(a:line,
\ '\v^([^\t]+)\t(.+)\t[?/]\^?(.{-1,})\$?[?/]\;\"\t(.+)\tline(no)?\:(\d+)')
if vals == [] | retu '' | en
let [bufnr, bufname] = [bufnr('^'.vals[2].'$'), fnamemodify(vals[2], ':p:t')]
retu vals[1].' '.vals[4].'|'.bufnr.':'.bufname.'|'.vals[6].'| '.vals[3]
endf
fu! s:syntax()
if !ctrlp#nosy()
cal ctrlp#hicheck('CtrlPTagKind', 'Title')
cal ctrlp#hicheck('CtrlPBufName', 'Directory')
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
sy match CtrlPTagKind '\zs[^\t|]\+\ze|\d\+:[^|]\+|\d\+|'
sy match CtrlPBufName '|\d\+:\zs[^|]\+\ze|\d\+|'
sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName,CtrlPTagKind
en
endf
fu! s:chknearby(pat)
if match(getline('.'), a:pat) < 0
let [int, forw, maxl] = [1, 1, line('$')]
wh !search(a:pat, 'W'.( forw ? '' : 'b' ))
if !forw
if int > maxl | brea | en
let int += int
en
let forw = !forw
endw
en
endf
" Public {{{1
fu! ctrlp#buffertag#init(fname)
let bufs = exists('s:btmode') && s:btmode
\ ? filter(ctrlp#buffers(), 'filereadable(v:val)')
\ : [exists('s:bufname') ? s:bufname : a:fname]
let lines = []
for each in bufs
let bname = fnamemodify(each, ':p')
let tftype = get(split(getbufvar('^'.bname.'$', '&ft'), '\.'), 0, '')
cal extend(lines, s:process(bname, tftype))
endfo
cal s:syntax()
retu lines
endf
fu! ctrlp#buffertag#accept(mode, str)
let vals = matchlist(a:str,
\ '\v^[^\t]+\t+[^\t|]+\|(\d+)\:[^\t|]+\|(\d+)\|\s(.+)$')
let bufnr = str2nr(get(vals, 1))
if bufnr
cal ctrlp#acceptfile(a:mode, bufnr)
exe 'norm!' str2nr(get(vals, 2, line('.'))).'G'
cal s:chknearby('\V\C'.get(vals, 3, ''))
sil! norm! zvzz
en
endf
fu! ctrlp#buffertag#cmd(mode, ...)
let s:btmode = a:mode
if a:0 && !empty(a:1)
let s:btmode = 0
let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1
let s:bufname = fnamemodify(bname, ':p')
en
retu s:id
endf
fu! ctrlp#buffertag#exit()
unl! s:btmode s:bufname
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@@ -0,0 +1,98 @@
" =============================================================================
" File: autoload/ctrlp/changes.vim
" Description: Change list extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Init {{{1
if exists('g:loaded_ctrlp_changes') && g:loaded_ctrlp_changes
fini
en
let g:loaded_ctrlp_changes = 1
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#changes#init(s:bufnr, s:crbufnr)',
\ 'accept': 'ctrlp#changes#accept',
\ 'lname': 'changes',
\ 'sname': 'chs',
\ 'exit': 'ctrlp#changes#exit()',
\ 'type': 'tabe',
\ 'sort': 0,
\ 'nolim': 1,
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
" Utilities {{{1
fu! s:changelist(bufnr)
sil! exe 'noa hid b' a:bufnr
redi => result
sil! changes
redi END
retu map(split(result, "\n")[1:], 'tr(v:val, " ", " ")')
endf
fu! s:process(clines, ...)
let [clines, evas] = [[], []]
for each in a:clines
let parts = matchlist(each, '\v^.\s*\d+\s+(\d+)\s+(\d+)\s(.*)$')
if !empty(parts)
if parts[3] == '' | let parts[3] = ' ' | en
cal add(clines, parts[3].' |'.a:1.':'.a:2.'|'.parts[1].':'.parts[2].'|')
en
endfo
retu reverse(filter(clines, 'count(clines, v:val) == 1'))
endf
fu! s:syntax()
if !ctrlp#nosy()
cal ctrlp#hicheck('CtrlPBufName', 'Directory')
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
sy match CtrlPBufName '\t|\d\+:\zs[^|]\+\ze|\d\+:\d\+|$'
sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName
en
endf
" Public {{{1
fu! ctrlp#changes#init(original_bufnr, bufnr)
let bufnr = exists('s:bufnr') ? s:bufnr : a:bufnr
let bufs = exists('s:clmode') && s:clmode ? ctrlp#buffers('id') : [bufnr]
cal filter(bufs, 'v:val > 0')
let [swb, &swb] = [&swb, '']
let lines = []
for each in bufs
let bname = bufname(each)
let fnamet = fnamemodify(bname == '' ? '[No Name]' : bname, ':t')
cal extend(lines, s:process(s:changelist(each), each, fnamet))
endfo
sil! exe 'noa hid b' a:original_bufnr
let &swb = swb
cal ctrlp#syntax()
cal s:syntax()
retu lines
endf
fu! ctrlp#changes#accept(mode, str)
let info = matchlist(a:str, '\t|\(\d\+\):[^|]\+|\(\d\+\):\(\d\+\)|$')
let bufnr = str2nr(get(info, 1))
if bufnr
cal ctrlp#acceptfile(a:mode, bufnr)
cal cursor(get(info, 2), get(info, 3))
sil! norm! zvzz
en
endf
fu! ctrlp#changes#cmd(mode, ...)
let s:clmode = a:mode
if a:0 && !empty(a:1)
let s:clmode = 0
let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1
let s:bufnr = bufnr('^'.fnamemodify(bname, ':p').'$')
en
retu s:id
endf
fu! ctrlp#changes#exit()
unl! s:clmode s:bufnr
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@@ -0,0 +1,95 @@
" =============================================================================
" File: autoload/ctrlp/dir.vim
" Description: Directory extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Init {{{1
if exists('g:loaded_ctrlp_dir') && g:loaded_ctrlp_dir
fini
en
let [g:loaded_ctrlp_dir, g:ctrlp_newdir] = [1, 0]
let s:ars = ['s:maxdepth', 's:maxfiles', 's:compare_lim', 's:glob', 's:caching']
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#dir#init('.join(s:ars, ', ').')',
\ 'accept': 'ctrlp#dir#accept',
\ 'lname': 'dirs',
\ 'sname': 'dir',
\ 'type': 'path',
\ 'specinput': 1,
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
let s:dircounts = {}
" Utilities {{{1
fu! s:globdirs(dirs, depth)
let entries = split(globpath(a:dirs, s:glob), "\n")
let [dirs, depth] = [ctrlp#dirnfile(entries)[0], a:depth + 1]
cal extend(g:ctrlp_alldirs, dirs)
let nr = len(g:ctrlp_alldirs)
if !empty(dirs) && !s:max(nr, s:maxfiles) && depth <= s:maxdepth
sil! cal ctrlp#progress(nr)
cal map(dirs, 'ctrlp#utils#fnesc(v:val, "g", ",")')
cal s:globdirs(join(dirs, ','), depth)
en
endf
fu! s:max(len, max)
retu a:max && a:len > a:max
endf
fu! s:nocache()
retu !s:caching || ( s:caching > 1 && get(s:dircounts, s:cwd) < s:caching )
endf
" Public {{{1
fu! ctrlp#dir#init(...)
let s:cwd = getcwd()
for each in range(len(s:ars))
let {s:ars[each]} = a:{each + 1}
endfo
let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'dir'
let cafile = cadir.ctrlp#utils#lash().ctrlp#utils#cachefile('dir')
if g:ctrlp_newdir || s:nocache() || !filereadable(cafile)
let [s:initcwd, g:ctrlp_alldirs] = [s:cwd, []]
if !ctrlp#igncwd(s:cwd)
cal s:globdirs(ctrlp#utils#fnesc(s:cwd, 'g', ','), 0)
en
cal ctrlp#rmbasedir(g:ctrlp_alldirs)
if len(g:ctrlp_alldirs) <= s:compare_lim
cal sort(g:ctrlp_alldirs, 'ctrlp#complen')
en
cal ctrlp#utils#writecache(g:ctrlp_alldirs, cadir, cafile)
let g:ctrlp_newdir = 0
el
if !( exists('s:initcwd') && s:initcwd == s:cwd )
let s:initcwd = s:cwd
let g:ctrlp_alldirs = ctrlp#utils#readfile(cafile)
en
en
cal extend(s:dircounts, { s:cwd : len(g:ctrlp_alldirs) })
retu g:ctrlp_alldirs
endf
fu! ctrlp#dir#accept(mode, str)
let path = a:mode == 'h' ? getcwd() : s:cwd.ctrlp#call('s:lash', s:cwd).a:str
if a:mode =~ 't\|v\|h'
cal ctrlp#exit()
en
cal ctrlp#setdir(path, a:mode =~ 't\|h' ? 'chd!' : 'lc!')
if a:mode == 'e'
sil! cal ctrlp#statusline()
cal ctrlp#setlines(s:id)
cal ctrlp#recordhist()
cal ctrlp#prtclear()
en
endf
fu! ctrlp#dir#id()
retu s:id
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@@ -0,0 +1,72 @@
" =============================================================================
" File: autoload/ctrlp/line.vim
" Description: Line extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Init {{{1
if exists('g:loaded_ctrlp_line') && g:loaded_ctrlp_line
fini
en
let g:loaded_ctrlp_line = 1
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#line#init(s:crbufnr)',
\ 'accept': 'ctrlp#line#accept',
\ 'lname': 'lines',
\ 'sname': 'lns',
\ 'type': 'tabe',
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
" Utilities {{{1
fu! s:syntax()
if !ctrlp#nosy()
cal ctrlp#hicheck('CtrlPBufName', 'Directory')
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
sy match CtrlPBufName '\t|\zs[^|]\+\ze|\d\+:\d\+|$'
sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName
en
endf
" Public {{{1
fu! ctrlp#line#init(bufnr)
let [lines, bufnr] = [[], exists('s:bufnr') ? s:bufnr : a:bufnr]
let bufs = exists('s:lnmode') && s:lnmode ? ctrlp#buffers('id') : [bufnr]
for bufnr in bufs
let [lfb, bufn] = [getbufline(bufnr, 1, '$'), bufname(bufnr)]
if lfb == [] && bufn != ''
let lfb = ctrlp#utils#readfile(fnamemodify(bufn, ':p'))
en
cal map(lfb, 'tr(v:val, '' '', '' '')')
let [linenr, len_lfb] = [1, len(lfb)]
let buft = bufn == '' ? '[No Name]' : fnamemodify(bufn, ':t')
wh linenr <= len_lfb
let lfb[linenr - 1] .= ' |'.buft.'|'.bufnr.':'.linenr.'|'
let linenr += 1
endw
cal extend(lines, filter(lfb, 'v:val !~ ''^\s*\t|[^|]\+|\d\+:\d\+|$'''))
endfo
cal s:syntax()
retu lines
endf
fu! ctrlp#line#accept(mode, str)
let info = matchlist(a:str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$')
let bufnr = str2nr(get(info, 1))
if bufnr
cal ctrlp#acceptfile(a:mode, bufnr, get(info, 2))
en
endf
fu! ctrlp#line#cmd(mode, ...)
let s:lnmode = a:mode
if a:0 && !empty(a:1)
let s:lnmode = 0
let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1
let s:bufnr = bufnr('^'.fnamemodify(bname, ':p').'$')
en
retu s:id
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@@ -0,0 +1,88 @@
" =============================================================================
" File: autoload/ctrlp/mixed.vim
" Description: Mixing Files + MRU + Buffers
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Init {{{1
if exists('g:loaded_ctrlp_mixed') && g:loaded_ctrlp_mixed
fini
en
let [g:loaded_ctrlp_mixed, g:ctrlp_newmix] = [1, 0]
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#mixed#init(s:compare_lim)',
\ 'accept': 'ctrlp#acceptfile',
\ 'lname': 'fil + mru + buf',
\ 'sname': 'mix',
\ 'type': 'path',
\ 'opmul': 1,
\ 'specinput': 1,
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
" Utilities {{{1
fu! s:newcache(cwd)
if g:ctrlp_newmix || !has_key(g:ctrlp_allmixes, 'data') | retu 1 | en
retu g:ctrlp_allmixes['cwd'] != a:cwd
\ || g:ctrlp_allmixes['filtime'] < getftime(ctrlp#utils#cachefile())
\ || g:ctrlp_allmixes['mrutime'] < getftime(ctrlp#mrufiles#cachefile())
\ || g:ctrlp_allmixes['bufs'] < len(ctrlp#mrufiles#bufs())
endf
fu! s:getnewmix(cwd, clim)
if g:ctrlp_newmix
cal ctrlp#mrufiles#refresh('raw')
let g:ctrlp_newcache = 1
en
let g:ctrlp_lines = copy(ctrlp#files())
cal ctrlp#progress('Mixing...')
let mrufs = copy(ctrlp#mrufiles#list('raw'))
if exists('+ssl') && &ssl
cal map(mrufs, 'tr(v:val, "\\", "/")')
en
let allbufs = map(ctrlp#buffers(), 'fnamemodify(v:val, ":p")')
let [bufs, ubufs] = [[], []]
for each in allbufs
cal add(filereadable(each) ? bufs : ubufs, each)
endfo
let mrufs = bufs + filter(mrufs, 'index(bufs, v:val) < 0')
if len(mrufs) > len(g:ctrlp_lines)
cal filter(mrufs, 'stridx(v:val, a:cwd)')
el
let cwd_mrufs = filter(copy(mrufs), '!stridx(v:val, a:cwd)')
let cwd_mrufs = ctrlp#rmbasedir(cwd_mrufs)
for each in cwd_mrufs
let id = index(g:ctrlp_lines, each)
if id >= 0 | cal remove(g:ctrlp_lines, id) | en
endfo
en
let mrufs += ubufs
cal map(mrufs, 'fnamemodify(v:val, ":.")')
let g:ctrlp_lines = len(mrufs) > len(g:ctrlp_lines)
\ ? g:ctrlp_lines + mrufs : mrufs + g:ctrlp_lines
if len(g:ctrlp_lines) <= a:clim
cal sort(g:ctrlp_lines, 'ctrlp#complen')
en
let g:ctrlp_allmixes = { 'filtime': getftime(ctrlp#utils#cachefile()),
\ 'mrutime': getftime(ctrlp#mrufiles#cachefile()), 'cwd': a:cwd,
\ 'bufs': len(ctrlp#mrufiles#bufs()), 'data': g:ctrlp_lines }
endf
" Public {{{1
fu! ctrlp#mixed#init(clim)
let cwd = getcwd()
if s:newcache(cwd)
cal s:getnewmix(cwd, a:clim)
el
let g:ctrlp_lines = g:ctrlp_allmixes['data']
en
let g:ctrlp_newmix = 0
retu g:ctrlp_lines
endf
fu! ctrlp#mixed#id()
retu s:id
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@@ -0,0 +1,154 @@
" =============================================================================
" File: autoload/ctrlp/mrufiles.vim
" Description: Most Recently Used Files extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Static variables {{{1
let [s:mrbs, s:mrufs] = [[], []]
fu! ctrlp#mrufiles#opts()
let [pref, opts] = ['g:ctrlp_mruf_', {
\ 'max': ['s:max', 250],
\ 'include': ['s:in', ''],
\ 'exclude': ['s:ex', ''],
\ 'case_sensitive': ['s:cseno', 1],
\ 'relative': ['s:re', 0],
\ 'save_on_update': ['s:soup', 1],
\ }]
for [ke, va] in items(opts)
let [{va[0]}, {pref.ke}] = [pref.ke, exists(pref.ke) ? {pref.ke} : va[1]]
endfo
endf
cal ctrlp#mrufiles#opts()
" Utilities {{{1
fu! s:excl(fn)
retu !empty({s:ex}) && a:fn =~# {s:ex}
endf
fu! s:mergelists()
let diskmrufs = ctrlp#utils#readfile(ctrlp#mrufiles#cachefile())
cal filter(diskmrufs, 'index(s:mrufs, v:val) < 0')
let mrufs = s:mrufs + diskmrufs
retu s:chop(mrufs)
endf
fu! s:chop(mrufs)
if len(a:mrufs) > {s:max} | cal remove(a:mrufs, {s:max}, -1) | en
retu a:mrufs
endf
fu! s:reformat(mrufs, ...)
let cwd = getcwd()
let cwd .= cwd !~ '[\/]$' ? ctrlp#utils#lash() : ''
if {s:re}
let cwd = exists('+ssl') ? tr(cwd, '/', '\') : cwd
cal filter(a:mrufs, '!stridx(v:val, cwd)')
en
if a:0 && a:1 == 'raw' | retu a:mrufs | en
let idx = strlen(cwd)
if exists('+ssl') && &ssl
let cwd = tr(cwd, '\', '/')
cal map(a:mrufs, 'tr(v:val, "\\", "/")')
en
retu map(a:mrufs, '!stridx(v:val, cwd) ? strpart(v:val, idx) : v:val')
endf
fu! s:record(bufnr)
if s:locked | retu | en
let bufnr = a:bufnr + 0
let bufname = bufname(bufnr)
if bufnr > 0 && !empty(bufname)
cal filter(s:mrbs, 'v:val != bufnr')
cal insert(s:mrbs, bufnr)
cal s:addtomrufs(bufname)
en
endf
fu! s:addtomrufs(fname)
let fn = fnamemodify(a:fname, ':p')
let fn = exists('+ssl') ? tr(fn, '/', '\') : fn
if ( !empty({s:in}) && fn !~# {s:in} ) || ( !empty({s:ex}) && fn =~# {s:ex} )
\ || !empty(getbufvar('^'.fn.'$', '&bt')) || !filereadable(fn) | retu
en
let idx = index(s:mrufs, fn, 0, !{s:cseno})
if idx
cal filter(s:mrufs, 'v:val !='.( {s:cseno} ? '#' : '?' ).' fn')
cal insert(s:mrufs, fn)
if {s:soup} && idx < 0
cal s:savetofile(s:mergelists())
en
en
endf
fu! s:savetofile(mrufs)
cal ctrlp#utils#writecache(a:mrufs, s:cadir, s:cafile)
endf
" Public {{{1
fu! ctrlp#mrufiles#refresh(...)
let mrufs = s:mergelists()
cal filter(mrufs, '!empty(ctrlp#utils#glob(v:val, 1)) && !s:excl(v:val)')
if exists('+ssl')
cal map(mrufs, 'tr(v:val, "/", "\\")')
cal map(s:mrufs, 'tr(v:val, "/", "\\")')
let cond = 'count(mrufs, v:val, !{s:cseno}) == 1'
cal filter(mrufs, cond)
cal filter(s:mrufs, cond)
en
cal s:savetofile(mrufs)
retu a:0 && a:1 == 'raw' ? [] : s:reformat(mrufs)
endf
fu! ctrlp#mrufiles#remove(files)
let mrufs = []
if a:files != []
let mrufs = s:mergelists()
let cond = 'index(a:files, v:val, 0, !{s:cseno}) < 0'
cal filter(mrufs, cond)
cal filter(s:mrufs, cond)
en
cal s:savetofile(mrufs)
retu s:reformat(mrufs)
endf
fu! ctrlp#mrufiles#add(fn)
if !empty(a:fn)
cal s:addtomrufs(a:fn)
en
endf
fu! ctrlp#mrufiles#list(...)
retu a:0 ? a:1 == 'raw' ? s:reformat(s:mergelists(), a:1) : 0
\ : s:reformat(s:mergelists())
endf
fu! ctrlp#mrufiles#bufs()
retu s:mrbs
endf
fu! ctrlp#mrufiles#tgrel()
let {s:re} = !{s:re}
endf
fu! ctrlp#mrufiles#cachefile()
if !exists('s:cadir') || !exists('s:cafile')
let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru'
let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt'
en
retu s:cafile
endf
fu! ctrlp#mrufiles#init()
if !has('autocmd') | retu | en
let s:locked = 0
aug CtrlPMRUF
au!
au BufAdd,BufEnter,BufLeave,BufWritePost * cal s:record(expand('<abuf>', 1))
au QuickFixCmdPre *vimgrep* let s:locked = 1
au QuickFixCmdPost *vimgrep* let s:locked = 0
au VimLeavePre * cal s:savetofile(s:mergelists())
aug END
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@@ -0,0 +1,59 @@
" =============================================================================
" File: autoload/ctrlp/quickfix.vim
" Description: Quickfix extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Init {{{1
if exists('g:loaded_ctrlp_quickfix') && g:loaded_ctrlp_quickfix
fini
en
let g:loaded_ctrlp_quickfix = 1
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#quickfix#init()',
\ 'accept': 'ctrlp#quickfix#accept',
\ 'lname': 'quickfix',
\ 'sname': 'qfx',
\ 'type': 'line',
\ 'sort': 0,
\ 'nolim': 1,
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
fu! s:lineout(dict)
retu printf('%s|%d:%d| %s', bufname(a:dict['bufnr']), a:dict['lnum'],
\ a:dict['col'], matchstr(a:dict['text'], '\s*\zs.*\S'))
endf
" Utilities {{{1
fu! s:syntax()
if !ctrlp#nosy()
cal ctrlp#hicheck('CtrlPqfLineCol', 'Search')
sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|'
en
endf
" Public {{{1
fu! ctrlp#quickfix#init()
cal s:syntax()
retu map(getqflist(), 's:lineout(v:val)')
endf
fu! ctrlp#quickfix#accept(mode, str)
let vals = matchlist(a:str, '^\([^|]\+\ze\)|\(\d\+\):\(\d\+\)|')
if vals == [] || vals[1] == '' | retu | en
cal ctrlp#acceptfile(a:mode, vals[1])
let cur_pos = getpos('.')[1:2]
if cur_pos != [1, 1] && cur_pos != map(vals[2:3], 'str2nr(v:val)')
mark '
en
cal cursor(vals[2], vals[3])
sil! norm! zvzz
endf
fu! ctrlp#quickfix#id()
retu s:id
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@@ -0,0 +1,59 @@
" =============================================================================
" File: autoload/ctrlp/rtscript.vim
" Description: Runtime scripts extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Init {{{1
if exists('g:loaded_ctrlp_rtscript') && g:loaded_ctrlp_rtscript
fini
en
let [g:loaded_ctrlp_rtscript, g:ctrlp_newrts] = [1, 0]
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#rtscript#init(s:caching)',
\ 'accept': 'ctrlp#acceptfile',
\ 'lname': 'runtime scripts',
\ 'sname': 'rts',
\ 'type': 'path',
\ 'opmul': 1,
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
let s:filecounts = {}
" Utilities {{{1
fu! s:nocache()
retu g:ctrlp_newrts ||
\ !s:caching || ( s:caching > 1 && get(s:filecounts, s:cwd) < s:caching )
endf
" Public {{{1
fu! ctrlp#rtscript#init(caching)
let [s:caching, s:cwd] = [a:caching, getcwd()]
if s:nocache() ||
\ !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[0] == &rtp )
sil! cal ctrlp#progress('Indexing...')
let entries = split(globpath(ctrlp#utils#fnesc(&rtp, 'g'), '**/*.*'), "\n")
cal filter(entries, 'count(entries, v:val) == 1')
let [entries, echoed] = [ctrlp#dirnfile(entries)[1], 1]
el
let [entries, results] = g:ctrlp_rtscache[2:3]
en
if s:nocache() ||
\ !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[:1] == [&rtp, s:cwd] )
if !exists('echoed')
sil! cal ctrlp#progress('Processing...')
en
let results = map(copy(entries), 'fnamemodify(v:val, '':.'')')
en
let [g:ctrlp_rtscache, g:ctrlp_newrts] = [[&rtp, s:cwd, entries, results], 0]
cal extend(s:filecounts, { s:cwd : len(results) })
retu results
endf
fu! ctrlp#rtscript#id()
retu s:id
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@@ -0,0 +1,138 @@
" =============================================================================
" File: autoload/ctrlp/tag.vim
" Description: Tag file extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Init {{{1
if exists('g:loaded_ctrlp_tag') && g:loaded_ctrlp_tag
fini
en
let g:loaded_ctrlp_tag = 1
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#tag#init()',
\ 'accept': 'ctrlp#tag#accept',
\ 'lname': 'tags',
\ 'sname': 'tag',
\ 'enter': 'ctrlp#tag#enter()',
\ 'type': 'tabs',
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
" Utilities {{{1
fu! s:findcount(str)
let [tg, ofname] = split(a:str, '\t\+\ze[^\t]\+$')
let tgs = taglist('^'.tg.'$')
if len(tgs) < 2
retu [0, 0, 0, 0]
en
let bname = fnamemodify(bufname('%'), ':p')
let fname = expand(fnamemodify(simplify(ofname), ':s?^[.\/]\+??:p:.'), 1)
let [fnd, cnt, pos, ctgs, otgs] = [0, 0, 0, [], []]
for tgi in tgs
let lst = bname == fnamemodify(tgi["filename"], ':p') ? 'ctgs' : 'otgs'
cal call('add', [{lst}, tgi])
endfo
let ntgs = ctgs + otgs
for tgi in ntgs
let cnt += 1
let fulname = fnamemodify(tgi["filename"], ':p')
if stridx(fulname, fname) >= 0
\ && strlen(fname) + stridx(fulname, fname) == strlen(fulname)
let fnd += 1
let pos = cnt
en
endfo
let cnt = 0
for tgi in ntgs
let cnt += 1
if tgi["filename"] == ofname
let [fnd, pos] = [0, cnt]
en
endfo
retu [1, fnd, pos, len(ctgs)]
endf
fu! s:filter(tags)
let nr = 0
wh 0 < 1
if a:tags == [] | brea | en
if a:tags[nr] =~ '^!' && a:tags[nr] !~# '^!_TAG_'
let nr += 1
con
en
if a:tags[nr] =~# '^!_TAG_' && len(a:tags) > nr
cal remove(a:tags, nr)
el
brea
en
endw
retu a:tags
endf
fu! s:syntax()
if !ctrlp#nosy()
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
sy match CtrlPTabExtra '\zs\t.*\ze$'
en
endf
" Public {{{1
fu! ctrlp#tag#init()
if empty(s:tagfiles) | retu [] | en
let g:ctrlp_alltags = []
let tagfiles = sort(filter(s:tagfiles, 'count(s:tagfiles, v:val) == 1'))
for each in tagfiles
let alltags = s:filter(ctrlp#utils#readfile(each))
cal extend(g:ctrlp_alltags, alltags)
endfo
cal s:syntax()
retu g:ctrlp_alltags
endf
fu! ctrlp#tag#accept(mode, str)
cal ctrlp#exit()
let str = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\ze\t')
let [tg, fdcnt] = [split(str, '^[^\t]\+\zs\t')[0], s:findcount(str)]
let cmds = {
\ 't': ['tab sp', 'tab stj'],
\ 'h': ['sp', 'stj'],
\ 'v': ['vs', 'vert stj'],
\ 'e': ['', 'tj'],
\ }
let utg = fdcnt[3] < 2 && fdcnt[0] == 1 && fdcnt[1] == 1
let cmd = !fdcnt[0] || utg ? cmds[a:mode][0] : cmds[a:mode][1]
let cmd = a:mode == 'e' && ctrlp#modfilecond(!&aw)
\ ? ( cmd == 'tj' ? 'stj' : 'sp' ) : cmd
let cmd = a:mode == 't' ? ctrlp#tabcount().cmd : cmd
if !fdcnt[0] || utg
if cmd != ''
exe cmd
en
let save_cst = &cst
set cst&
cal feedkeys(":".( utg ? fdcnt[2] : "" )."ta ".tg."\r", 'nt')
let &cst = save_cst
el
let ext = ""
if fdcnt[1] < 2 && fdcnt[2]
let [sav_more, &more] = [&more, 0]
let ext = fdcnt[2]."\r".":let &more = ".sav_more."\r"
en
cal feedkeys(":".cmd." ".tg."\r".ext, 'nt')
en
cal ctrlp#setlcdir()
endf
fu! ctrlp#tag#id()
retu s:id
endf
fu! ctrlp#tag#enter()
let tfs = tagfiles()
let s:tagfiles = tfs != [] ? filter(map(tfs, 'fnamemodify(v:val, ":p")'),
\ 'filereadable(v:val)') : []
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@@ -0,0 +1,154 @@
" =============================================================================
" File: autoload/ctrlp/undo.vim
" Description: Undo extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Init {{{1
if ( exists('g:loaded_ctrlp_undo') && g:loaded_ctrlp_undo )
fini
en
let g:loaded_ctrlp_undo = 1
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#undo#init()',
\ 'accept': 'ctrlp#undo#accept',
\ 'lname': 'undo',
\ 'sname': 'udo',
\ 'enter': 'ctrlp#undo#enter()',
\ 'exit': 'ctrlp#undo#exit()',
\ 'type': 'line',
\ 'sort': 0,
\ 'nolim': 1,
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
let s:text = map(['second', 'seconds', 'minutes', 'hours', 'days', 'weeks',
\ 'months', 'years'], '" ".v:val." ago"')
" Utilities {{{1
fu! s:getundo()
if exists('*undotree')
\ && ( v:version > 703 || ( v:version == 703 && has('patch005') ) )
retu [1, undotree()]
el
redi => result
sil! undol
redi END
retu [0, split(result, "\n")[1:]]
en
endf
fu! s:flatten(tree, cur)
let flatdict = {}
for each in a:tree
let saved = has_key(each, 'save') ? 'saved' : ''
let current = each['seq'] == a:cur ? 'current' : ''
cal extend(flatdict, { each['seq'] : [each['time'], saved, current] })
if has_key(each, 'alt')
cal extend(flatdict, s:flatten(each['alt'], a:cur))
en
endfo
retu flatdict
endf
fu! s:elapsed(nr)
let [text, time] = [s:text, localtime() - a:nr]
let mins = time / 60
let hrs = time / 3600
let days = time / 86400
let wks = time / 604800
let mons = time / 2592000
let yrs = time / 31536000
if yrs > 1
retu yrs.text[7]
elsei mons > 1
retu mons.text[6]
elsei wks > 1
retu wks.text[5]
elsei days > 1
retu days.text[4]
elsei hrs > 1
retu hrs.text[3]
elsei mins > 1
retu mins.text[2]
elsei time == 1
retu time.text[0]
elsei time < 120
retu time.text[1]
en
endf
fu! s:syntax()
if ctrlp#nosy() | retu | en
for [ke, va] in items({'T': 'Directory', 'Br': 'Comment', 'Nr': 'String',
\ 'Sv': 'Comment', 'Po': 'Title'})
cal ctrlp#hicheck('CtrlPUndo'.ke, va)
endfo
sy match CtrlPUndoT '\v\d+ \zs[^ ]+\ze|\d+:\d+:\d+'
sy match CtrlPUndoBr '\[\|\]'
sy match CtrlPUndoNr '\[\d\+\]' contains=CtrlPUndoBr
sy match CtrlPUndoSv 'saved'
sy match CtrlPUndoPo 'current'
endf
fu! s:dict2list(dict)
for ke in keys(a:dict)
let a:dict[ke][0] = s:elapsed(a:dict[ke][0])
endfo
retu map(keys(a:dict), 'eval(''[v:val, a:dict[v:val]]'')')
endf
fu! s:compval(...)
retu a:2[0] - a:1[0]
endf
fu! s:format(...)
let saved = !empty(a:1[1][1]) ? ' '.a:1[1][1] : ''
let current = !empty(a:1[1][2]) ? ' '.a:1[1][2] : ''
retu a:1[1][0].' ['.a:1[0].']'.saved.current
endf
fu! s:formatul(...)
let parts = matchlist(a:1,
\ '\v^\s+(\d+)\s+\d+\s+([^ ]+\s?[^ ]+|\d+\s\w+\s\w+)(\s*\d*)$')
retu parts == [] ? '----'
\ : parts[2].' ['.parts[1].']'.( parts[3] != '' ? ' saved' : '' )
endf
" Public {{{1
fu! ctrlp#undo#init()
let entries = s:undos[0] ? s:undos[1]['entries'] : s:undos[1]
if empty(entries) | retu [] | en
if !exists('s:lines')
if s:undos[0]
let entries = s:dict2list(s:flatten(entries, s:undos[1]['seq_cur']))
let s:lines = map(sort(entries, 's:compval'), 's:format(v:val)')
el
let s:lines = map(reverse(entries), 's:formatul(v:val)')
en
en
cal s:syntax()
retu s:lines
endf
fu! ctrlp#undo#accept(mode, str)
let undon = matchstr(a:str, '\[\zs\d\+\ze\]')
if empty(undon) | retu | en
cal ctrlp#exit()
exe 'u' undon
endf
fu! ctrlp#undo#id()
retu s:id
endf
fu! ctrlp#undo#enter()
let s:undos = s:getundo()
endf
fu! ctrlp#undo#exit()
unl! s:lines
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@@ -0,0 +1,110 @@
" =============================================================================
" File: autoload/ctrlp/utils.vim
" Description: Utilities
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Static variables {{{1
fu! ctrlp#utils#lash()
retu &ssl || !exists('+ssl') ? '/' : '\'
endf
fu! s:lash(...)
retu ( a:0 ? a:1 : getcwd() ) !~ '[\/]$' ? s:lash : ''
endf
fu! ctrlp#utils#opts()
let s:lash = ctrlp#utils#lash()
let usrhome = $HOME . s:lash( $HOME )
let cahome = exists('$XDG_CACHE_HOME') ? $XDG_CACHE_HOME : usrhome.'.cache'
let cadir = isdirectory(usrhome.'.ctrlp_cache')
\ ? usrhome.'.ctrlp_cache' : cahome.s:lash(cahome).'ctrlp'
if exists('g:ctrlp_cache_dir')
let cadir = expand(g:ctrlp_cache_dir, 1)
if isdirectory(cadir.s:lash(cadir).'.ctrlp_cache')
let cadir = cadir.s:lash(cadir).'.ctrlp_cache'
en
en
let s:cache_dir = cadir
endf
cal ctrlp#utils#opts()
let s:wig_cond = v:version > 702 || ( v:version == 702 && has('patch051') )
" Files and Directories {{{1
fu! ctrlp#utils#cachedir()
retu s:cache_dir
endf
fu! ctrlp#utils#cachefile(...)
let [tail, dir] = [a:0 == 1 ? '.'.a:1 : '', a:0 == 2 ? a:1 : getcwd()]
let cache_file = substitute(dir, '\([\/]\|^\a\zs:\)', '%', 'g').tail.'.txt'
retu a:0 == 1 ? cache_file : s:cache_dir.s:lash(s:cache_dir).cache_file
endf
fu! ctrlp#utils#readfile(file)
if filereadable(a:file)
let data = readfile(a:file)
if empty(data) || type(data) != 3
unl data
let data = []
en
retu data
en
retu []
endf
fu! ctrlp#utils#mkdir(dir)
if exists('*mkdir') && !isdirectory(a:dir)
sil! cal mkdir(a:dir, 'p')
en
retu a:dir
endf
fu! ctrlp#utils#writecache(lines, ...)
if isdirectory(ctrlp#utils#mkdir(a:0 ? a:1 : s:cache_dir))
sil! cal writefile(a:lines, a:0 >= 2 ? a:2 : ctrlp#utils#cachefile())
en
endf
fu! ctrlp#utils#glob(...)
let path = ctrlp#utils#fnesc(a:1, 'g')
retu s:wig_cond ? glob(path, a:2) : glob(path)
endf
fu! ctrlp#utils#globpath(...)
retu call('globpath', s:wig_cond ? a:000 : a:000[:1])
endf
fu! ctrlp#utils#fnesc(path, type, ...)
if exists('*fnameescape')
if exists('+ssl')
if a:type == 'c'
let path = escape(a:path, '%#')
elsei a:type == 'f'
let path = fnameescape(a:path)
elsei a:type == 'g'
let path = escape(a:path, '?*')
en
let path = substitute(path, '[', '[[]', 'g')
el
let path = fnameescape(a:path)
en
el
if exists('+ssl')
if a:type == 'c'
let path = escape(a:path, '%#')
elsei a:type == 'f'
let path = escape(a:path, " \t\n%#*?|<\"")
elsei a:type == 'g'
let path = escape(a:path, '?*')
en
let path = substitute(path, '[', '[[]', 'g')
el
let path = escape(a:path, " \t\n*?[{`$\\%#'\"|!<")
en
en
retu a:0 ? escape(path, a:1) : path
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

File diff suppressed because it is too large Load Diff

100
bundle/ctrlp.vim/doc/tags Normal file
View File

@@ -0,0 +1,100 @@
'ctrl-p' ctrlp.txt /*'ctrl-p'*
'ctrlp' ctrlp.txt /*'ctrlp'*
'ctrlp-<c-p>' ctrlp.txt /*'ctrlp-<c-p>'*
'ctrlp-autocompletion' ctrlp.txt /*'ctrlp-autocompletion'*
'ctrlp-fullregexp' ctrlp.txt /*'ctrlp-fullregexp'*
'ctrlp-pasting' ctrlp.txt /*'ctrlp-pasting'*
'ctrlp-wildignore' ctrlp.txt /*'ctrlp-wildignore'*
'g:ctrlp_abbrev' ctrlp.txt /*'g:ctrlp_abbrev'*
'g:ctrlp_arg_map' ctrlp.txt /*'g:ctrlp_arg_map'*
'g:ctrlp_buffer_func' ctrlp.txt /*'g:ctrlp_buffer_func'*
'g:ctrlp_buftag_ctags_bin' ctrlp.txt /*'g:ctrlp_buftag_ctags_bin'*
'g:ctrlp_buftag_systemenc' ctrlp.txt /*'g:ctrlp_buftag_systemenc'*
'g:ctrlp_buftag_types' ctrlp.txt /*'g:ctrlp_buftag_types'*
'g:ctrlp_by_filename' ctrlp.txt /*'g:ctrlp_by_filename'*
'g:ctrlp_cache_dir' ctrlp.txt /*'g:ctrlp_cache_dir'*
'g:ctrlp_clear_cache_on_exit' ctrlp.txt /*'g:ctrlp_clear_cache_on_exit'*
'g:ctrlp_cmd' ctrlp.txt /*'g:ctrlp_cmd'*
'g:ctrlp_custom_ignore' ctrlp.txt /*'g:ctrlp_custom_ignore'*
'g:ctrlp_default_input' ctrlp.txt /*'g:ctrlp_default_input'*
'g:ctrlp_follow_symlinks' ctrlp.txt /*'g:ctrlp_follow_symlinks'*
'g:ctrlp_key_loop' ctrlp.txt /*'g:ctrlp_key_loop'*
'g:ctrlp_lazy_update' ctrlp.txt /*'g:ctrlp_lazy_update'*
'g:ctrlp_map' ctrlp.txt /*'g:ctrlp_map'*
'g:ctrlp_match_func' ctrlp.txt /*'g:ctrlp_match_func'*
'g:ctrlp_match_window' ctrlp.txt /*'g:ctrlp_match_window'*
'g:ctrlp_max_depth' ctrlp.txt /*'g:ctrlp_max_depth'*
'g:ctrlp_max_files' ctrlp.txt /*'g:ctrlp_max_files'*
'g:ctrlp_max_history' ctrlp.txt /*'g:ctrlp_max_history'*
'g:ctrlp_mruf_case_sensitive' ctrlp.txt /*'g:ctrlp_mruf_case_sensitive'*
'g:ctrlp_mruf_default_order' ctrlp.txt /*'g:ctrlp_mruf_default_order'*
'g:ctrlp_mruf_exclude' ctrlp.txt /*'g:ctrlp_mruf_exclude'*
'g:ctrlp_mruf_include' ctrlp.txt /*'g:ctrlp_mruf_include'*
'g:ctrlp_mruf_max' ctrlp.txt /*'g:ctrlp_mruf_max'*
'g:ctrlp_mruf_relative' ctrlp.txt /*'g:ctrlp_mruf_relative'*
'g:ctrlp_mruf_save_on_update' ctrlp.txt /*'g:ctrlp_mruf_save_on_update'*
'g:ctrlp_open_func' ctrlp.txt /*'g:ctrlp_open_func'*
'g:ctrlp_open_multiple_files' ctrlp.txt /*'g:ctrlp_open_multiple_files'*
'g:ctrlp_open_new_file' ctrlp.txt /*'g:ctrlp_open_new_file'*
'g:ctrlp_prompt_mappings' ctrlp.txt /*'g:ctrlp_prompt_mappings'*
'g:ctrlp_regexp' ctrlp.txt /*'g:ctrlp_regexp'*
'g:ctrlp_reuse_window' ctrlp.txt /*'g:ctrlp_reuse_window'*
'g:ctrlp_root_markers' ctrlp.txt /*'g:ctrlp_root_markers'*
'g:ctrlp_show_hidden' ctrlp.txt /*'g:ctrlp_show_hidden'*
'g:ctrlp_status_func' ctrlp.txt /*'g:ctrlp_status_func'*
'g:ctrlp_switch_buffer' ctrlp.txt /*'g:ctrlp_switch_buffer'*
'g:ctrlp_tabpage_position' ctrlp.txt /*'g:ctrlp_tabpage_position'*
'g:ctrlp_use_caching' ctrlp.txt /*'g:ctrlp_use_caching'*
'g:ctrlp_use_migemo' ctrlp.txt /*'g:ctrlp_use_migemo'*
'g:ctrlp_user_command' ctrlp.txt /*'g:ctrlp_user_command'*
'g:ctrlp_working_path_mode' ctrlp.txt /*'g:ctrlp_working_path_mode'*
'g:loaded_ctrlp' ctrlp.txt /*'g:loaded_ctrlp'*
:CtrlP ctrlp.txt /*:CtrlP*
:CtrlPBookmarkDir ctrlp.txt /*:CtrlPBookmarkDir*
:CtrlPBookmarkDirAdd ctrlp.txt /*:CtrlPBookmarkDirAdd*
:CtrlPBufTag ctrlp.txt /*:CtrlPBufTag*
:CtrlPBufTagAll ctrlp.txt /*:CtrlPBufTagAll*
:CtrlPBuffer ctrlp.txt /*:CtrlPBuffer*
:CtrlPChange ctrlp.txt /*:CtrlPChange*
:CtrlPChangeAll ctrlp.txt /*:CtrlPChangeAll*
:CtrlPClearAllCaches ctrlp.txt /*:CtrlPClearAllCaches*
:CtrlPClearCache ctrlp.txt /*:CtrlPClearCache*
:CtrlPDir ctrlp.txt /*:CtrlPDir*
:CtrlPLastMode ctrlp.txt /*:CtrlPLastMode*
:CtrlPLine ctrlp.txt /*:CtrlPLine*
:CtrlPMRU ctrlp.txt /*:CtrlPMRU*
:CtrlPMixed ctrlp.txt /*:CtrlPMixed*
:CtrlPQuickfix ctrlp.txt /*:CtrlPQuickfix*
:CtrlPRTS ctrlp.txt /*:CtrlPRTS*
:CtrlPRoot ctrlp.txt /*:CtrlPRoot*
:CtrlPTag ctrlp.txt /*:CtrlPTag*
:CtrlPUndo ctrlp.txt /*:CtrlPUndo*
ClearAllCtrlPCaches ctrlp.txt /*ClearAllCtrlPCaches*
ClearCtrlPCache ctrlp.txt /*ClearCtrlPCache*
ControlP ctrlp.txt /*ControlP*
CtrlP ctrlp.txt /*CtrlP*
ResetCtrlP ctrlp.txt /*ResetCtrlP*
ctrlp-changelog ctrlp.txt /*ctrlp-changelog*
ctrlp-commands ctrlp.txt /*ctrlp-commands*
ctrlp-contents ctrlp.txt /*ctrlp-contents*
ctrlp-credits ctrlp.txt /*ctrlp-credits*
ctrlp-customization ctrlp.txt /*ctrlp-customization*
ctrlp-extensions ctrlp.txt /*ctrlp-extensions*
ctrlp-input-formats ctrlp.txt /*ctrlp-input-formats*
ctrlp-intro ctrlp.txt /*ctrlp-intro*
ctrlp-mappings ctrlp.txt /*ctrlp-mappings*
ctrlp-miscellaneous-configs ctrlp.txt /*ctrlp-miscellaneous-configs*
ctrlp-options ctrlp.txt /*ctrlp-options*
ctrlp.txt ctrlp.txt /*ctrlp.txt*
g:ctrlp_dont_split ctrlp.txt /*g:ctrlp_dont_split*
g:ctrlp_dotfiles ctrlp.txt /*g:ctrlp_dotfiles*
g:ctrlp_highlight_match ctrlp.txt /*g:ctrlp_highlight_match*
g:ctrlp_jump_to_buffer ctrlp.txt /*g:ctrlp_jump_to_buffer*
g:ctrlp_live_update ctrlp.txt /*g:ctrlp_live_update*
g:ctrlp_match_window_bottom ctrlp.txt /*g:ctrlp_match_window_bottom*
g:ctrlp_match_window_reversed ctrlp.txt /*g:ctrlp_match_window_reversed*
g:ctrlp_max_height ctrlp.txt /*g:ctrlp_max_height*
g:ctrlp_mru_files ctrlp.txt /*g:ctrlp_mru_files*
g:ctrlp_open_multi ctrlp.txt /*g:ctrlp_open_multi*
g:ctrlp_persistent_input ctrlp.txt /*g:ctrlp_persistent_input*
g:ctrlp_regexp_search ctrlp.txt /*g:ctrlp_regexp_search*

View File

@@ -0,0 +1,68 @@
" =============================================================================
" File: plugin/ctrlp.vim
" Description: Fuzzy file, buffer, mru, tag, etc finder.
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" GetLatestVimScripts: 3736 1 :AutoInstall: ctrlp.zip
if ( exists('g:loaded_ctrlp') && g:loaded_ctrlp ) || v:version < 700 || &cp
fini
en
let g:loaded_ctrlp = 1
let [g:ctrlp_lines, g:ctrlp_allfiles, g:ctrlp_alltags, g:ctrlp_alldirs,
\ g:ctrlp_allmixes, g:ctrlp_buftags, g:ctrlp_ext_vars, g:ctrlp_builtins]
\ = [[], [], [], [], {}, {}, [], 2]
if !exists('g:ctrlp_map') | let g:ctrlp_map = '<c-p>' | en
if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en
com! -n=? -com=dir CtrlP cal ctrlp#init(0, { 'dir': <q-args> })
com! -n=? -com=dir CtrlPMRUFiles cal ctrlp#init(2, { 'dir': <q-args> })
com! -bar CtrlPBuffer cal ctrlp#init(1)
com! -n=? CtrlPLastMode cal ctrlp#init(-1, { 'args': <q-args> })
com! -bar CtrlPClearCache cal ctrlp#clr()
com! -bar CtrlPClearAllCaches cal ctrlp#clra()
com! -bar ClearCtrlPCache cal ctrlp#clr()
com! -bar ClearAllCtrlPCaches cal ctrlp#clra()
com! -bar CtrlPCurWD cal ctrlp#init(0, { 'mode': '' })
com! -bar CtrlPCurFile cal ctrlp#init(0, { 'mode': 'c' })
com! -bar CtrlPRoot cal ctrlp#init(0, { 'mode': 'r' })
if g:ctrlp_map != '' && !hasmapto(':<c-u>'.g:ctrlp_cmd.'<cr>', 'n')
exe 'nn <silent>' g:ctrlp_map ':<c-u>'.g:ctrlp_cmd.'<cr>'
en
cal ctrlp#mrufiles#init()
com! -bar CtrlPTag cal ctrlp#init(ctrlp#tag#id())
com! -bar CtrlPQuickfix cal ctrlp#init(ctrlp#quickfix#id())
com! -n=? -com=dir CtrlPDir
\ cal ctrlp#init(ctrlp#dir#id(), { 'dir': <q-args> })
com! -n=? -com=buffer CtrlPBufTag
\ cal ctrlp#init(ctrlp#buffertag#cmd(0, <q-args>))
com! -bar CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1))
com! -bar CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id())
com! -bar CtrlPUndo cal ctrlp#init(ctrlp#undo#id())
com! -n=? -com=buffer CtrlPLine
\ cal ctrlp#init(ctrlp#line#cmd(1, <q-args>))
com! -n=? -com=buffer CtrlPChange
\ cal ctrlp#init(ctrlp#changes#cmd(0, <q-args>))
com! -bar CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1))
com! -bar CtrlPMixed cal ctrlp#init(ctrlp#mixed#id())
com! -bar CtrlPBookmarkDir cal ctrlp#init(ctrlp#bookmarkdir#id())
com! -n=? -com=dir CtrlPBookmarkDirAdd
\ cal ctrlp#call('ctrlp#bookmarkdir#add', <q-args>)
" vim:ts=2:sw=2:sts=2

View File

@@ -0,0 +1,88 @@
# ctrlp.vim
Full path fuzzy __file__, __buffer__, __mru__, __tag__, __...__ finder for Vim.
* Written in pure Vimscript for MacVim, gVim and Vim 7.0+.
* Full support for Vim's regexp as search patterns.
* Built-in Most Recently Used (MRU) files monitoring.
* Built-in project's root finder.
* Open multiple files at once.
* Create new files and directories.
* [Extensible][2].
![ctrlp][1]
## Basic Usage
* Run `:CtrlP` or `:CtrlP [starting-directory]` to invoke CtrlP in find file mode.
* Run `:CtrlPBuffer` or `:CtrlPMRU` to invoke CtrlP in find buffer or find MRU file mode.
* Run `:CtrlPMixed` to search in Files, Buffers and MRU files at the same time.
Check `:help ctrlp-commands` and `:help ctrlp-extensions` for other commands.
##### Once CtrlP is open:
* Press `<F5>` to purge the cache for the current directory to get new files, remove deleted files and apply new ignore options.
* Press `<c-f>` and `<c-b>` to cycle between modes.
* Press `<c-d>` to switch to filename only search instead of full path.
* Press `<c-r>` to switch to regexp mode.
* Use `<c-j>`, `<c-k>` or the arrow keys to navigate the result list.
* Use `<c-t>` or `<c-v>`, `<c-x>` to open the selected entry in a new tab or in a new split.
* Use `<c-n>`, `<c-p>` to select the next/previous string in the prompt's history.
* Use `<c-y>` to create a new file and its parent directories.
* Use `<c-z>` to mark/unmark multiple files and `<c-o>` to open them.
Run `:help ctrlp-mappings` or submit `?` in CtrlP for more mapping help.
* Submit two or more dots `..` to go up the directory tree by one or multiple levels.
* End the input string with a colon `:` followed by a command to execute it on the opening file(s):
Use `:25` to jump to line 25.
Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 files.
## Basic Options
* Change the default mapping and the default command to invoke CtrlP:
```vim
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
```
* When invoked, unless a starting directory is specified, CtrlP will set its local working directory according to this variable:
```vim
let g:ctrlp_working_path_mode = 'ra'
```
`'c'` - the directory of the current file.
`'r'` - the nearest ancestor that contains one of these directories or files: `.git` `.hg` `.svn` `.bzr` `_darcs`
`'a'` - like c, but only if the current working directory outside of CtrlP is not a direct ancestor of the directory of the current file.
`0` or `''` (empty string) - disable this feature.
Define additional root markers with the `g:ctrlp_root_markers` option.
* Exclude files and directories using Vim's `wildignore` and CtrlP's own `g:ctrlp_custom_ignore`:
```vim
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\v\.(exe|so|dll)$',
\ 'link': 'some_bad_symbolic_links',
\ }
```
* Use a custom file listing command:
```vim
let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux
let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows
```
Check `:help ctrlp-options` for other options.
## Installation
Use your favorite method or check the homepage for a [quick installation guide][3].
[1]: http://i.imgur.com/yIynr.png
[2]: https://github.com/kien/ctrlp.vim/tree/extensions
[3]: http://kien.github.com/ctrlp.vim#installation

View File

@@ -0,0 +1,27 @@
# vim-blade #
Vim syntax highlighting for Blade templates (Laravel 4+).
Installation
------------
Using pathogen
[pathogen.vim](https://github.com/tpope/vim-pathogen).
cd ~/.vim/bundle
git clone git://github.com/xsbeats/vim-blade.git
Using vundle
[Vundle.vim](https://github.com/gmarik/Vundle.vim).
Plugin 'xsbeats/vim-blade'
Using neobundle
[Neobundle.vim](https://github.com/Shougo/neobundle.vim)
NeoBundle 'xsbeats/vim-blade'
Todo
----
Indentation (currently nonexistent)

View File

@@ -0,0 +1 @@
au BufNewFile,BufRead *.blade.php set filetype=blade

View File

@@ -0,0 +1,41 @@
" Language: Blade
" Maintainer: Jason Walton <jwalton512@gmail.com>
" URL: https://github.com/xsbeats/vim-blade
" License: DBAD
" Check if our syntax is already loaded
if exists('b:current_syntax') && b:current_syntax == 'blade'
finish
endif
" Include PHP
runtime! syntax/php.vim
silent! unlet b:current_syntax
" Echos
syn region bladeUnescapedEcho matchgroup=bladeEchoDelim start=/@\@<!\s*{!!/ end=/!!}\s*/ oneline contains=@phpClTop containedin=ALLBUT,bladeComment
syn region bladeEscapedEcho matchgroup=bladeEchoDelim start=/@\@<!\s*{{{\@!/ end=/}}\s*/ oneline contains=@phpClTop containedin=ALLBUT,bladeComment
syn region bladeEscapedEcho matchgroup=bladeEchoDelim start=/@\@<!\s*{{{{\@!/ end=/}}}/ oneline contains=@phpClTop containedin=ALLBUT,bladeComment
" Structures
syn match bladeStructure /\s*@\(else\|empty\|endfor\|endforeach\|endforelse\|endif\|endpush\|endsection\|endunless\|endwhile\|overwrite\|show\|stop\)\>/
syn match bladeStructure /\s*@\(append\|choice\|each\|elseif\|extends\|for\|foreach\|forelse\|if\|include\|lang\|push\|section\|stack\|unless\|while\|yield\|\)\>\s*/ nextgroup=bladeParens
syn region bladeParens matchgroup=bladeParen start=/(/ end=/)/ contained contains=@bladeAll,@phpClTop
" Comments
syn region bladeComments start=/\s*{{--/ end=/--}}/ contains=bladeComment keepend
syn match bladeComment /.*/ contained containedin=bladeComments
" Clusters
syn cluster bladeAll contains=bladeStructure,bladeParens
" Highlighting
hi def link bladeComment Comment
hi def link bladeEchoDelim Delimiter
hi def link bladeParen Delimiter
hi def link bladeStructure Keyword
if !exists('b:current_syntax')
let b:current_syntax = 'blade'
endif

View File

@@ -0,0 +1,166 @@
/* Regular PHP */
echo('foo') // shouldn't be highlighted
<?php if ($bar->foo == $foo) return false; ?>
/* Regular HTML */
<html>
</html>
/* Echos */
{!! $name !!}
{{ $name }}
{{{ $name }}}
@{!! $name !!} // should be treated as regular php
/* Structures */
@else
@empty
@endfor
@endforeach
@endif
@endpush
@endsection
@endunless
@endwhile
@overwrite
@show
@stop
/* Structures (with conditions) */
@append('foo')
@choice('language.line', 1)
@each(['foo', 'bar'])
@if ($bar == ($foo*2))
{{ $bar }}
@elseif ($bar == ($foo*3))
{{ $bar * 2 }}
@else
'foo'
@endif
@extends('layouts.default')
@for($i = 0; $i < 10; $i++)
the value is {{ $i }}
@endforeach
@forelse($users as $user)
<li>{{ $user->name }}</li>
@empty
<p>No users</p>
@endforelse
@include('something')
@lang('language.line')
@push('foo')
<h1>{{ $foo }}</h1>
@endpush
@section('nav')
<h1>Home</h1>
@endsection
@stack('content')
@unless(1 == 2)
{{ $foo }}
@endunless
@while(true == false)
{{ $foo }}
@endwhile
@yield('content')
/* Comments */
{{-- comments on one line --}}
{{-- comments
on
many
lines --}}
{{-- structures shouldn't escape @if($insideComments == true) --}}
@yield('section') {{-- comments after structure are valid --}}
{{ $comments->finished() }}
/* Edge Cases */
// try a multiline include
@include('admin.misc.sort-header', [
'column' => 'name',
])
// inside html
<div>
@if ($foo == $bar)
{{ $foo }}
@endif
</div>
// keywords inside of comments
{{--
List from http://www.php.net/manual/en/reserved.keywords.php
__halt_compiler()
abstract
and
array()
as
break
callable
case
catch
class
clone
const
continue
declare
default
die()
do
echo
else
elseif
empty()
enddeclare
endfor
endforeach
endif
endswitch
endwhile
eval()
exit()
extends
final
finally
for
foreach
function
global
goto
if
implements
include
include_once
instanceof
insteadof
interface
isset()
list()
namespace
new
or
print
private
protected
public
require
require_once
return
static
switch
throw
trait
try
unset()
use
var
while
xor
yield
__DIR__
__FILE__
__FUNCTION__
__LINE__
__METHOD__
__NAMESPACE__
__TRAIT__
--}

View File

@@ -0,0 +1,109 @@
# vim-nerdtree-tabs changelog
## v1.4.6
* Add NERDTreeTabsFind function.
## v1.4.5
* Add NERDTreeFocusToggle function. (Thanks orthez.)
* More general refactoring and cleanup. (Thanks techlivezheng.)
## v1.4.4
* Option to always focus file window after startup. (Thanks rr-.)
## v1.4.3
* Partial fix for #32. When directory is given as an argument, two nerdtrees
are open, but both now point into the correct directory. (Thanks szajbus.)
## v1.4.2
* Friendlier when using together with MiniBufExplorer. (Thanks techlivezheng.)
* Do not open NERDTree by default when starting Vim in diff mode. (Thanks
techlivezheng.)
## v1.4.1
* Fix "cd into" feature for paths that include spaces. (Thanks nybblr.)
## v1.4.0
* When synchronizing NERDTree scroll and cursor position, synchronize also
NERDTree window width. (Thanks EinfachToll.)
* When Vim is given a directory as a parameter, `:cd` into it. (Thanks DAddYE.)
* New commands `NERDTreeTabsOpen`, `NERDTreeTabsClose` and
`NERDTreeMirrorOpen`. They are not a new functionality, just externalize
stuff that was previously accessible only inside the plugin.
* New commands `NERDTreeSteppedOpen` and `NERDTreeSteppedClose` for combined
opening/closing of a NERDTree and focus switching. Works locally for a tab.
(Thanks ereOn.)
* Fixed an error when restoring a session caused by accessing an undefined
variable. (Thanks ereOn.)
* Fixed opening two NERDTrees when `NERDTreeHijackNetrw = 1` and launching
with a directory name as a parameter.
## v1.3.0
* Focus synchronization - ability to have focus on NERDTree after tab switch
if and only if it was focused before tab switch. Switched on by default.
## v1.2.1
* Smart startup focus fixed.
## v1.2.0
* Loading process refactoring (should fix some glitches and hopefully not
break anything else). Directory structure has changed in this release,
a new pull of the repository is required for the plugin to work properly.
## v1.1.2
* Smart focus - on startup, focus NERDTree if opening a directory, focus the
file when opening a file.
## v1.1.1
* About 50% speedup when toggling NERDTree on across all tabs.
## v1.1.0
* Meaningful tab names feature doesn't collide with opening new tabs silently.
To accomplish that, tab switching now preserves window focus. The original
behavior that always kept focus in the window with file being edited can be
restored by `let g:nerdtree_tabs_focus_on_files = 1`.
* Removed glitches when sourcing the plugin more than once.
## v1.0.1
* Plugin is usable with vundle.
## v1.0.0
* NERDTree view synchronization (cursor position and scroll) across tabs
* Fix: focus is now on NERDTree when opening it in all tabs.
* If you create more NERDTree instances, nerdtree-tabs now tries hard to sync
all tabs to the last opened one.
## v0.2.0
* Better solution for opening NERDTree on tab creation (fixes wrong behavior in
improbable situations)
* Global variables for configuration
* Tab autoclose
* Option to open NERDTree on console vim startup, stays false by default
* Readme
## v0.1.0
* New mappings and a command, otherwise original functionality preserved while making it namespaced

View File

@@ -0,0 +1,175 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

View File

@@ -0,0 +1,144 @@
# NERDTree and tabs together in Vim, painlessly
## Features
This plugin aims at making NERDTree feel like a true panel, independent of tabs.
* **Just one NERDTree**, always and ever. It will always look the same in
all tabs, including expanded/collapsed nodes, scroll position etc.
* Open in all tabs / close in all tabs. Do this via `:NERDTreeTabsToggle`
* Meaningful tab captions for inactive tabs. No more captions like 'NERD_tree_1'.
* When you close a file, the tab closes with it. No NERDTree hanging open.
* Autoopen NERDTree on GVim / MacVim startup.
Many of these features can be switched off. See section Configuration.
## Installation
1. If you haven't already, install NERDTree (see https://github.com/scrooloose/nerdtree)
2. Install the plugin **through Pathogen**:
cd ~/.vim/bundle
git clone https://github.com/jistr/vim-nerdtree-tabs.git
Or **through Vundle**:
Bundle 'jistr/vim-nerdtree-tabs'
Or **through Janus**:
cd ~/.janus
git clone https://github.com/jistr/vim-nerdtree-tabs.git
3. Map :NERDTreeTabsToggle command to some combo so you don't have to type it.
Alternatively, you can use plug-mapping instead of a command, like this:
map <Leader>n <plug>NERDTreeTabsToggle<CR>
4. Celebrate.
## Commands and Mappings
Vim-nerdtree-tabs provides these commands:
* `:NERDTreeTabsOpen` switches NERDTree on for all tabs.
* `:NERDTreeTabsClose` switches NERDTree off for all tabs.
* `:NERDTreeTabsToggle` toggles NERDTree on/off for all tabs.
* `:NERDTreeTabsFind` find currently opened file and select it
* `:NERDTreeMirrorOpen` acts as `:NERDTreeMirror`, but smarter: When opening,
it first tries to use an existing tree (i.e. previously closed in this tab or
perform a mirror of another tab's tree). If all this fails, a new tree is
created. It is recommended that you use this command instead of
`:NERDTreeMirror`.
* `:NERDTreeMirrorToggle` toggles NERDTree on/off in current tab, using
the same behavior as `:NERDTreeMirrorOpen`.
* `:NERDTreeSteppedOpen` focuses the NERDTree, opening one first if none is present.
* `:NERDTreeSteppedClose` unfocuses the NERDTree, or closes/hides it if it was
not focused.
* `:NERDTreeFocusToggle` focus the NERDTree or create it if focus is
on a file, unfocus NERDTree if focus is on NERDTree
There are also plug-mappings available with the same functionality:
* `<plug>NERDTreeTabsOpen`
* `<plug>NERDTreeTabsClose`
* `<plug>NERDTreeTabsToggle`
* `<plug>NERDTreeTabsFind`
* `<plug>NERDTreeMirrorOpen`
* `<plug>NERDTreeMirrorToggle`
* `<plug>NERDTreeSteppedOpen`
* `<plug>NERDTreeSteppedClose`
## Configuration
You can switch on/off some features of the plugin by setting global vars to 1
(for on) or 0 (for off) in your vimrc. Here are the options and their default
values:
* `g:nerdtree_tabs_open_on_gui_startup` (default: `1`)
Open NERDTree on gvim/macvim startup
* `g:nerdtree_tabs_open_on_console_startup` (default: `0`)
Open NERDTree on console vim startup
* `g:nerdtree_tabs_no_startup_for_diff` (default: `1`)
Do not open NERDTree if vim starts in diff mode
* `g:nerdtree_tabs_smart_startup_focus` (default: `1`)
On startup, focus NERDTree if opening a directory, focus file if opening
a file. (When set to `2`, always focus file window after startup).
* `g:nerdtree_tabs_open_on_new_tab` (default: `1`)
Open NERDTree on new tab creation (if NERDTree was globally opened by
:NERDTreeTabsToggle)
* `g:nerdtree_tabs_meaningful_tab_names` (default: `1`)
Unfocus NERDTree when leaving a tab for descriptive tab names
* `g:nerdtree_tabs_autoclose` (default: `1`)
Close current tab if there is only one window in it and it's NERDTree
* `g:nerdtree_tabs_synchronize_view` (default: `1`)
Synchronize view of all NERDTree windows (scroll and cursor position)
* `g:nerdtree_tabs_synchronize_focus` (default: `1`)
Synchronize focus when switching windows (focus NERDTree after tab switch
if and only if it was focused before tab switch)
* `g:nerdtree_tabs_focus_on_files` (default: `0`)
When switching into a tab, make sure that focus is on the file window,
not in the NERDTree window. (Note that this can get annoying if you use
NERDTree's feature "open in new tab silently", as you will lose focus on the
NERDTree.)
* `g:nerdtree_tabs_startup_cd` (default: `1`)
When given a directory name as a command line parameter when launching Vim,
`:cd` into it.
* `g:nerdtree_tabs_autofind` (default: `0`)
Automatically find and select currently opened file in NERDTree.
### Example
To run NERDTreeTabs on console vim startup, put into your .vimrc:
let g:nerdtree_tabs_open_on_console_startup=1
## Credits
The tab autoclose feature is stolen from Carl Lerche & Yehuda Katz's
[Janus](https://github.com/carlhuda/janus). Thanks, guys!

View File

@@ -0,0 +1,4 @@
:NERDTreeMirrorToggle vim-nerdtree-tabs.txt /*:NERDTreeMirrorToggle*
:NERDTreeTabsToggle vim-nerdtree-tabs.txt /*:NERDTreeTabsToggle*
nerdtree-tabs vim-nerdtree-tabs.txt /*nerdtree-tabs*
vim-nerdtree-tabs vim-nerdtree-tabs.txt /*vim-nerdtree-tabs*

View File

@@ -0,0 +1,123 @@
# NERDTree and tabs together in Vim, painlessly *vim-nerdtree-tabs*
*nerdtree-tabs*
## Installation
1. Copy the plugin to your vim config dir (via pathogen or any way you want).
2. Map :NERDTreeTabsToggle command to some combo so you don't have to type it.
Alternatively, you can use plug-mapping instead of a command, like this:
map <Leader>n <plug>NERDTreeTabsToggle<CR>
3. Celebrate.
## Features
In short, this vim plugin aims at making **NERDTree feel like a true panel**,
independent of tabs. That is done by keeping NERDTree synchronized between
tabs as much as possible. Read on for details.
### One command, open everywhere, close everywhere
You'll get a new command: `:NERDTreeTabsToggle`
For the needs of most of us, this will be the only command needed to operate
NERDTree. Press it once, NERDTree opens in all tabs (even in new tabs created
from now on); press it again, NERDTree closes in all tabs.
### Just one NERDTree
Tired of having a fully collapsed NERDTree every time you open a new tab?
Vim-nerdtree-tabs will keep them all synchronized. You will get just one
NERDTree buffer for all your tabs.
### Sync to the max
All NERDTree windows will always have the same scroll and cursor position.
### Meaningful tab captions
You know the feeling when you want to switch to *that file* and you have 8 tabs
open and they are all named 'NERD_tree_1'? Won't happen again. When leaving
a tab, vim-nerdtree-tabs moves focus out of NERDTree so that the tab caption is
the name of the file you are editing.
### Close the file = close the tab
A tab with NERDTree and a file won't hang open when you close the file window.
NERDTree will close automatically and so will the tab.
### Autoopen on startup
NERDTree will open automatically on GVim/MacVim startup. You can configure it
to open on console Vim as well, but this is disabled by default.
## Commands and mappings
Vim-nerdtree-tabs defines two commands:
*:NERDTreeTabsToggle*
* `:NERDTreeTabsToggle` switches NERDTree on/off for all tabs.
*:NERDTreeMirrorToggle*
* `:NERDTreeMirrorToggle` acts as `:NERDTreeToggle`, but smarter: When opening,
it first tries to use an existing tree (i.e. previously closed in this tab or
perform a mirror of another tab's tree). If all this fails, a new tree is
created. **It is recommended that you always use this command instead of
`:NERDTreeToggle`.**
There are also plug-mappings available with the same functionality:
* `<plug>NERDTreeTabsToggle`
* `<plug>NERDTreeMirrorToggle`
## Configuration
You can switch on/off some features of the plugin by setting global vars to 1
(for on) or 0 (for off) in your vimrc. Here are the options and their default
values:
* `let g:nerdtree_tabs_open_on_gui_startup = 1`
Open NERDTree on gvim/macvim startup
* `let g:nerdtree_tabs_open_on_console_startup = 0`
Open NERDTree on console vim startup
* `let g:nerdtree_tabs_no_startup_for_diff = 1`
Do not open NERDTree if vim starts in diff mode
* `let g:nerdtree_tabs_smart_startup_focus = 1`
On startup - focus NERDTree when opening a directory, focus the file if
editing a specified file. When set to `2`, always focus file after startup.
* `let g:nerdtree_tabs_open_on_new_tab = 1`
Open NERDTree on new tab creation (if NERDTree was globally opened by
:NERDTreeTabsToggle)
* `let g:nerdtree_tabs_meaningful_tab_names = 1`
Unfocus NERDTree when leaving a tab for descriptive tab names
* `let g:nerdtree_tabs_autoclose = 1`
Close current tab if there is only one window in it and it's NERDTree
* `let g:nerdtree_tabs_synchronize_view = 1`
Synchronize view of all NERDTree windows (scroll and cursor position)
* `let g:nerdtree_tabs_synchronize_focus = 1`
Synchronize focus when switching tabs (focus NERDTree after tab switch
if and only if it was focused before tab switch)
* `let g:nerdtree_tabs_focus_on_files = 0`
When switching into a tab, make sure that focus is on the file window,
not in the NERDTree window. (Note that this can get annoying if you use
NERDTree's feature "open in new tab silently", as you will lose focus on the
NERDTree.)
* `g:nerdtree_tabs_startup_cd = 1`
When starting up with a directory name as a parameter, cd into it
## Credits
* The tab autoclose feature is stolen from Carl Lerche & Yehuda Katz's
[Janus](https://github.com/carlhuda/janus). Thanks, guys!

View File

@@ -0,0 +1,607 @@
" === plugin configuration variables === {{{
"
" open NERDTree on gvim/macvim startup
if !exists('g:nerdtree_tabs_open_on_gui_startup')
let g:nerdtree_tabs_open_on_gui_startup = 1
endif
" open NERDTree on console vim startup (off by default)
if !exists('g:nerdtree_tabs_open_on_console_startup')
let g:nerdtree_tabs_open_on_console_startup = 0
endif
" do not open NERDTree if vim starts in diff mode
if !exists('g:nerdtree_tabs_no_startup_for_diff')
let g:nerdtree_tabs_no_startup_for_diff = 1
endif
" On startup - focus NERDTree when opening a directory, focus the file if
" editing a specified file. When set to `2`, always focus file after startup.
if !exists('g:nerdtree_tabs_smart_startup_focus')
let g:nerdtree_tabs_smart_startup_focus = 1
endif
" Open NERDTree on new tab creation if NERDTree was globally opened
" by :NERDTreeTabsToggle
if !exists('g:nerdtree_tabs_open_on_new_tab')
let g:nerdtree_tabs_open_on_new_tab = 1
endif
" unfocus NERDTree when leaving a tab so that you have descriptive tab names
" and not names like 'NERD_tree_1'
if !exists('g:nerdtree_tabs_meaningful_tab_names')
let g:nerdtree_tabs_meaningful_tab_names = 1
endif
" close current tab if there is only one window in it and it's NERDTree
if !exists('g:nerdtree_tabs_autoclose')
let g:nerdtree_tabs_autoclose = 1
endif
" synchronize view of all NERDTree windows (scroll and cursor position)
if !exists('g:nerdtree_tabs_synchronize_view')
let g:nerdtree_tabs_synchronize_view = 1
endif
" synchronize focus when switching tabs (focus NERDTree after tab switch
" if and only if it was focused before tab switch)
if !exists('g:nerdtree_tabs_synchronize_focus')
let g:nerdtree_tabs_synchronize_focus = 1
endif
" when switching into a tab, make sure that focus will always be in file
" editing window, not in NERDTree window (off by default)
if !exists('g:nerdtree_tabs_focus_on_files')
let g:nerdtree_tabs_focus_on_files = 0
endif
" when starting up with a directory name as a parameter, cd into it
if !exists('g:nerdtree_tabs_startup_cd')
let g:nerdtree_tabs_startup_cd = 1
endif
" automatically find and select currently opened file
if !exists('g:nerdtree_tabs_autofind')
let g:nerdtree_tabs_autofind = 0
endif
"
" }}}
" === plugin mappings === {{{
"
noremap <silent> <script> <Plug>NERDTreeTabsOpen :call <SID>NERDTreeOpenAllTabs()
noremap <silent> <script> <Plug>NERDTreeTabsClose :call <SID>NERDTreeCloseAllTabs()
noremap <silent> <script> <Plug>NERDTreeTabsToggle :call <SID>NERDTreeToggleAllTabs()
noremap <silent> <script> <Plug>NERDTreeTabsFind :call <SID>NERDTreeFindFile()
noremap <silent> <script> <Plug>NERDTreeMirrorOpen :call <SID>NERDTreeMirrorOrCreate()
noremap <silent> <script> <Plug>NERDTreeMirrorToggle :call <SID>NERDTreeMirrorToggle()
noremap <silent> <script> <Plug>NERDTreeSteppedOpen :call <SID>NERDTreeSteppedOpen()
noremap <silent> <script> <Plug>NERDTreeSteppedClose :call <SID>NERDTreeSteppedClose()
noremap <silent> <script> <Plug>NERDTreeFocusToggle :call <SID>NERDTreeFocusToggle()
"
" }}}
" === plugin commands === {{{
"
command! NERDTreeTabsOpen call <SID>NERDTreeOpenAllTabs()
command! NERDTreeTabsClose call <SID>NERDTreeCloseAllTabs()
command! NERDTreeTabsToggle call <SID>NERDTreeToggleAllTabs()
command! NERDTreeTabsFind call <SID>NERDTreeFindFile()
command! NERDTreeMirrorOpen call <SID>NERDTreeMirrorOrCreate()
command! NERDTreeMirrorToggle call <SID>NERDTreeMirrorToggle()
command! NERDTreeSteppedOpen call <SID>NERDTreeSteppedOpen()
command! NERDTreeSteppedClose call <SID>NERDTreeSteppedClose()
command! NERDTreeFocusToggle call <SID>NERDTreeFocusToggle()
"
" }}}
" === plugin functions === {{{
"
" === NERDTree manipulation (opening, closing etc.) === {{{
"
" s:NERDTreeMirrorOrCreate() {{{
"
" switch NERDTree on for current tab -- mirror it if possible, otherwise create it
fun! s:NERDTreeMirrorOrCreate()
let l:nerdtree_open = s:IsNERDTreeOpenInCurrentTab()
" if NERDTree is not active in the current tab, try to mirror it
if !l:nerdtree_open
let l:previous_winnr = winnr("$")
silent NERDTreeMirror
" if the window count of current tab didn't increase after NERDTreeMirror,
" it means NERDTreeMirror was unsuccessful and a new NERDTree has to be created
if l:previous_winnr == winnr("$")
silent NERDTreeToggle
endif
endif
endfun
" }}}
" s:NERDTreeMirrorToggle() {{{
"
" toggle NERDTree in current tab, use mirror if possible
fun! s:NERDTreeMirrorToggle()
let l:nerdtree_open = s:IsNERDTreeOpenInCurrentTab()
if l:nerdtree_open
silent NERDTreeClose
else
call s:NERDTreeMirrorOrCreate()
endif
endfun
" }}}
" s:NERDTreeOpenAllTabs() {{{
"
" switch NERDTree on for all tabs while making sure there is only one NERDTree buffer
fun! s:NERDTreeOpenAllTabs()
let s:nerdtree_globally_active = 1
" tabdo doesn't preserve current tab - save it and restore it afterwards
let l:current_tab = tabpagenr()
tabdo call s:NERDTreeMirrorOrCreate()
exe 'tabn ' . l:current_tab
endfun
" }}}
" s:NERDTreeCloseAllTabs() {{{
"
" close NERDTree across all tabs
fun! s:NERDTreeCloseAllTabs()
let s:nerdtree_globally_active = 0
" tabdo doesn't preserve current tab - save it and restore it afterwards
let l:current_tab = tabpagenr()
tabdo silent NERDTreeClose
exe 'tabn ' . l:current_tab
endfun
" }}}
" s:NERDTreeToggleAllTabs() {{{
"
" toggle NERDTree in current tab and match the state in all other tabs
fun! s:NERDTreeToggleAllTabs()
let l:nerdtree_open = s:IsNERDTreeOpenInCurrentTab()
let s:disable_handlers_for_tabdo = 1
if l:nerdtree_open
call s:NERDTreeCloseAllTabs()
else
call s:NERDTreeOpenAllTabs()
" force focus to NERDTree in current tab
if exists("t:NERDTreeBufName") && bufwinnr(t:NERDTreeBufName) != -1
exe bufwinnr(t:NERDTreeBufName) . "wincmd w"
endif
endif
let s:disable_handlers_for_tabdo = 0
endfun
" }}}
" s:NERDTreeSteppedOpen() {{{
"
" focus the NERDTree view, creating one first if none is present
fun! s:NERDTreeSteppedOpen()
if !s:IsCurrentWindowNERDTree()
if s:IsNERDTreeOpenInCurrentTab()
call s:NERDTreeFocus()
else
call s:NERDTreeMirrorOrCreate()
endif
endif
endfun
" }}}
" s:NERDTreeSteppedClose{() {{{
"
" unfocus the NERDTree view or closes it if it hadn't had focus at the time of
" the call
fun! s:NERDTreeSteppedClose()
if s:IsCurrentWindowNERDTree()
call s:NERDTreeUnfocus()
else
let l:nerdtree_open = s:IsNERDTreeOpenInCurrentTab()
if l:nerdtree_open
silent NERDTreeClose
endif
endif
endfun
" }}}
" s:NERDTreeFocusToggle() {{{
"
" focus the NERDTree view or creates it if in a file,
" or unfocus NERDTree view if in NERDTree
fun! s:NERDTreeFocusToggle()
let s:disable_handlers_for_tabdo = 1
if s:IsCurrentWindowNERDTree()
call s:NERDTreeUnfocus()
else
if !s:IsNERDTreeOpenInCurrentTab()
call s:NERDTreeOpenAllTabs()
endif
call s:NERDTreeFocus()
endif
let s:disable_handlers_for_tabdo = 0
endfun
" }}}
"
" === NERDTree manipulation (opening, closing etc.) === }}}
" === focus functions === {{{
"
" s:NERDTreeFocus() {{{
"
" if the current window is NERDTree, move focus to the next window
fun! s:NERDTreeFocus()
if !s:IsCurrentWindowNERDTree() && exists("t:NERDTreeBufName") && bufwinnr(t:NERDTreeBufName) != -1
exe bufwinnr(t:NERDTreeBufName) . "wincmd w"
endif
endfun
" }}}
" s:NERDTreeUnfocus() {{{
"
" if the current window is NERDTree, move focus to the next window
fun! s:NERDTreeUnfocus()
" save current window so that it's focus can be restored after switching
" back to this tab
let t:NERDTreeTabLastWindow = winnr()
if s:IsCurrentWindowNERDTree()
let l:winNum = s:NextNormalWindow()
if l:winNum != -1
exec l:winNum.'wincmd w'
else
wincmd w
endif
endif
endfun
" }}}
" s:NERDTreeRestoreFocus() {{{
"
" restore focus to the window that was focused before leaving current tab
fun! s:NERDTreeRestoreFocus()
if g:nerdtree_tabs_synchronize_focus
if s:is_nerdtree_globally_focused
call s:NERDTreeFocus()
elseif exists("t:NERDTreeTabLastWindow") && exists("t:NERDTreeBufName") && t:NERDTreeTabLastWindow != bufwinnr(t:NERDTreeBufName)
exe t:NERDTreeTabLastWindow . "wincmd w"
endif
elseif exists("t:NERDTreeTabLastWindow")
exe t:NERDTreeTabLastWindow . "wincmd w"
endif
endfun
" }}}
" s:SaveGlobalFocus() {{{
"
fun! s:SaveGlobalFocus()
let s:is_nerdtree_globally_focused = s:IsCurrentWindowNERDTree()
endfun
" }}}
" s:IfFocusOnStartup() {{{
"
fun! s:IfFocusOnStartup()
return strlen(bufname('$')) == 0 || !getbufvar('$', '&modifiable')
endfun
" }}}
"
" === focus functions === }}}
" === utility functions === {{{
"
" s:NextNormalWindow() {{{
"
" find next window with a normal buffer
fun! s:NextNormalWindow()
let l:i = 1
while(l:i <= winnr('$'))
let l:buf = winbufnr(l:i)
" skip unlisted buffers
if buflisted(l:buf) == 0
let l:i = l:i + 1
continue
endif
" skip un-modifiable buffers
if getbufvar(l:buf, '&modifiable') != 1
let l:i = l:i + 1
continue
endif
" skip temporary buffers with buftype set
if empty(getbufvar(l:buf, "&buftype")) != 1
let l:i = l:i + 1
continue
endif
return l:i
endwhile
return -1
endfun
" }}}
" s:CloseIfOnlyNerdTreeLeft() {{{
"
" Close all open buffers on entering a window if the only
" buffer that's left is the NERDTree buffer
fun! s:CloseIfOnlyNerdTreeLeft()
if exists("t:NERDTreeBufName") && bufwinnr(t:NERDTreeBufName) != -1 && winnr("$") == 1
q
endif
endfun
" }}}
" s:IsCurrentWindowNERDTree() {{{
"
" returns 1 if current window is NERDTree, false otherwise
fun! s:IsCurrentWindowNERDTree()
return exists("t:NERDTreeBufName") && bufwinnr(t:NERDTreeBufName) == winnr()
endfun
" }}}
" s:IsNERDTreeOpenInCurrentTab() {{{
"
" check if NERDTree is open in current tab
fun! s:IsNERDTreeOpenInCurrentTab()
return exists("t:NERDTreeBufName") && bufwinnr(t:NERDTreeBufName) != -1
endfun
" }}}
" s:IsNERDTreePresentInCurrentTab() {{{
"
" check if NERDTree is present in current tab (not necessarily visible)
fun! s:IsNERDTreePresentInCurrentTab()
return exists("t:NERDTreeBufName")
endfun
" }}}
"
" === utility functions === }}}
" === NERDTree view manipulation (scroll and cursor positions) === {{{
"
" s:SaveNERDTreeViewIfPossible() {{{
"
fun! s:SaveNERDTreeViewIfPossible()
if exists("t:NERDTreeBufName") && bufwinnr(t:NERDTreeBufName) == winnr()
" save scroll and cursor etc.
let s:nerdtree_view = winsaveview()
" save NERDTree window width
let s:nerdtree_width = winwidth(winnr())
" save buffer name (to be able to correct desync by commands spawning
" a new NERDTree instance)
let s:nerdtree_buffer = bufname("%")
endif
endfun
" }}}
" s:RestoreNERDTreeViewIfPossible() {{{
"
fun! s:RestoreNERDTreeViewIfPossible()
" if nerdtree exists in current tab, it is the current window and if saved
" state is available, restore it
let l:view_state_saved = exists('s:nerdtree_view') && exists('s:nerdtree_width')
if s:IsNERDTreeOpenInCurrentTab() && l:view_state_saved
let l:current_winnr = winnr()
let l:nerdtree_winnr = bufwinnr(t:NERDTreeBufName)
" switch to NERDTree window
exe l:nerdtree_winnr . "wincmd w"
" load the correct NERDTree buffer if not already loaded
if exists('s:nerdtree_buffer') && t:NERDTreeBufName != s:nerdtree_buffer
silent NERDTreeClose
silent NERDTreeMirror
endif
" restore cursor, scroll and window width
call winrestview(s:nerdtree_view)
exe "vertical resize " . s:nerdtree_width
" switch back to whatever window was focused before
exe l:current_winnr . "wincmd w"
endif
endfun
" }}}
" s:NERDTreeFindFile() {{{
"
fun! s:NERDTreeFindFile()
if s:IsNERDTreeOpenInCurrentTab()
silent NERDTreeFind
endif
endfun
" }}}
"
" === NERDTree view manipulation (scroll and cursor positions) === }}}
"
" === plugin functions === }}}
" === plugin event handlers === {{{
"
" s:LoadPlugin() {{{
"
fun! s:LoadPlugin()
if exists('g:nerdtree_tabs_loaded')
return
endif
let g:NERDTreeHijackNetrw = 0
let s:disable_handlers_for_tabdo = 0
" global on/off NERDTree state
" the exists check is to enable script reloading without resetting the state
if !exists('s:nerdtree_globally_active')
let s:nerdtree_globally_active = 0
endif
" global focused/unfocused NERDTree state
" the exists check is to enable script reloading without resetting the state
if !exists('s:is_nerdtree_globally_focused')
call s:SaveGlobalFocus()
end
augroup NERDTreeTabs
autocmd!
autocmd VimEnter * call <SID>VimEnterHandler()
autocmd TabEnter * call <SID>TabEnterHandler()
autocmd TabLeave * call <SID>TabLeaveHandler()
autocmd WinEnter * call <SID>WinEnterHandler()
autocmd WinLeave * call <SID>WinLeaveHandler()
autocmd BufWinEnter * call <SID>BufWinEnterHandler()
autocmd BufRead * call <SID>BufReadHandler()
augroup END
let g:nerdtree_tabs_loaded = 1
endfun
" }}}
" s:VimEnterHandler() {{{
"
fun! s:VimEnterHandler()
" if the argument to vim is a directory, cd into it
if g:nerdtree_tabs_startup_cd && isdirectory(argv(0))
exe 'cd ' . escape(argv(0), '\ ')
endif
let l:open_nerd_tree_on_startup = (g:nerdtree_tabs_open_on_console_startup && !has('gui_running')) ||
\ (g:nerdtree_tabs_open_on_gui_startup && has('gui_running'))
if g:nerdtree_tabs_no_startup_for_diff && &diff
let l:open_nerd_tree_on_startup = 0
endif
" this makes sure that globally_active is true when using 'gvim .'
let s:nerdtree_globally_active = l:open_nerd_tree_on_startup
if l:open_nerd_tree_on_startup
let l:focus_file = !s:IfFocusOnStartup()
let l:main_bufnr = bufnr('%')
if !s:IsNERDTreePresentInCurrentTab()
call s:NERDTreeOpenAllTabs()
endif
if (l:focus_file && g:nerdtree_tabs_smart_startup_focus == 1) || g:nerdtree_tabs_smart_startup_focus == 2
exe bufwinnr(l:main_bufnr) . "wincmd w"
endif
endif
endfun
" }}} s:NewTabCreated {{{
"
" A flag to indicate that a new tab has just been created.
"
" We will handle the remaining work for this newly created tab separately in
" BufWinEnter event.
"
let s:NewTabCreated = 0
" }}}
" s:TabEnterHandler() {{{
"
fun! s:TabEnterHandler()
if s:disable_handlers_for_tabdo
return
endif
if g:nerdtree_tabs_open_on_new_tab && s:nerdtree_globally_active && !s:IsNERDTreeOpenInCurrentTab()
call s:NERDTreeMirrorOrCreate()
" move focus to the previous window
wincmd p
" Turn on the 'NewTabCreated' flag
let s:NewTabCreated = 1
endif
if g:nerdtree_tabs_synchronize_view
call s:RestoreNERDTreeViewIfPossible()
endif
if g:nerdtree_tabs_focus_on_files
call s:NERDTreeUnfocus()
" Do not restore focus on newly created tab here
elseif !s:NewTabCreated
call s:NERDTreeRestoreFocus()
endif
endfun
" }}}
" s:TabLeaveHandler() {{{
"
fun! s:TabLeaveHandler()
if g:nerdtree_tabs_meaningful_tab_names
call s:SaveGlobalFocus()
call s:NERDTreeUnfocus()
endif
endfun
" }}}
" s:WinEnterHandler() {{{
"
fun! s:WinEnterHandler()
if s:disable_handlers_for_tabdo
return
endif
if g:nerdtree_tabs_autoclose
call s:CloseIfOnlyNerdTreeLeft()
endif
endfun
" }}}
" s:WinLeaveHandler() {{{
"
fun! s:WinLeaveHandler()
if s:disable_handlers_for_tabdo
return
endif
if g:nerdtree_tabs_synchronize_view
call s:SaveNERDTreeViewIfPossible()
endif
endfun
" }}}
" s:BufWinEnterHandler() {{{
"
" BufWinEnter event only gets triggered after a new buffer has been
" successfully loaded, it is a proper time to finish the remaining
" work for newly opened tab.
"
fun! s:BufWinEnterHandler()
if s:NewTabCreated
" Turn off the 'NewTabCreated' flag
let s:NewTabCreated = 0
" Restore focus to NERDTree if necessary
if !g:nerdtree_tabs_focus_on_files
call s:NERDTreeRestoreFocus()
endif
endif
endfun
" }}}
" s:BufReadHandler() {{{
"
" BufRead event gets triggered after a new buffer has been
" successfully read from file.
"
fun! s:BufReadHandler()
" Refresh NERDTree to show currently opened file
if g:nerdtree_tabs_autofind
call s:NERDTreeFindFile()
call s:NERDTreeUnfocus()
endif
endfun
" }}}
"
" === plugin event handlers === }}}
call s:LoadPlugin()