Mercurial > dotfiles
changeset 25:ee9306f1098c
Merged more hgrc stuff.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 21 Nov 2011 19:53:52 -0800 |
parents | b2ad38814e5f (diff) 4b35035cb781 (current diff) |
children | dbf00b8d9f04 |
files | |
diffstat | 12 files changed, 2759 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hgrc/hgrc-MacOSX Mon Nov 21 19:53:52 2011 -0800 @@ -0,0 +1,7 @@ + +[extensions] +hggit = /usr/local/hg-git/hggit/ + +[extdiff] +cmd.opendiff = opendiff-w +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/.hgignore Mon Nov 21 19:53:52 2011 -0800 @@ -0,0 +1,5 @@ +syntax:glob +temp/* +backup/* +.netrwhist +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/.hgsub Mon Nov 21 19:53:52 2011 -0800 @@ -0,0 +1,12 @@ +bundle/colorschemes = [git]https://github.com/flazz/vim-colorschemes.git +bundle/command-t = [git]https://github.com/wincent/Command-T.git +bundle/gundo = https://bitbucket.org/sjl/gundo.vim +bundle/markdown = [git]https://github.com/tpope/vim-markdown.git +bundle/surround = [git]https://github.com/tpope/vim-surround.git +bundle/commentary = [git]git://github.com/tpope/vim-commentary.git +bundle/ragtag = [git]git://github.com/tpope/vim-ragtag.git +bundle/repeat = [git]git://github.com/tpope/vim-repeat.git +bundle/haml = [git]git://github.com/tpope/vim-haml.git +bundle/supertab = [git]https://github.com/ervandew/supertab.git +bundle/nerdtree = [git]https://github.com/scrooloose/nerdtree.git +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/.hgsubstate Mon Nov 21 19:53:52 2011 -0800 @@ -0,0 +1,11 @@ +c51066bd048ca47e9b6d1385703a4d3462ea8c93 bundle/colorschemes +f19aee00f6b7a9c451a7aa168e05f0cdd0d99374 bundle/command-t +62b72580aba57cb5185bd077ac7a905c1c6893ea bundle/commentary +91190e67720f852c17602504d5225d4e675b6499 bundle/gundo +a995d4aabb794bd60028537ecb41ca7f2c738e65 bundle/haml +2b18a534162bc2c3964cb3a8fe42ca8c100bb571 bundle/markdown +30f6bcc30caf76bc1213f5c3d4001ba5d5fbe7fc bundle/nerdtree +bdc8b580b5b583aeb43efb19aac2ab8ce5566dff bundle/ragtag +cdffdd43816ddaeee858ae42da3ab6ddcfa25d19 bundle/repeat +688b5d706c21fbc6b2db6499f3cfbdeb35309b5a bundle/supertab +4eb2cdfccc016889acfa3b5d63e8f390a87863cf bundle/surround
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/README.md Mon Nov 21 19:53:52 2011 -0800 @@ -0,0 +1,7 @@ + +This is my own [Vim] environment. Feel free to poke around and see how I my setup +works but keep in mind I'm myself a Vim newbie so this may not be the best place +to look at if you want to learn anything worthwhile. + + [vim]: http://vim.org +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/autoload/pathogen.vim Mon Nov 21 19:53:52 2011 -0800 @@ -0,0 +1,233 @@ +" pathogen.vim - path option manipulation +" Maintainer: Tim Pope <http://tpo.pe/> +" Version: 2.0 + +" Install in ~/.vim/autoload (or ~\vimfiles\autoload). +" +" For management of individually installed plugins in ~/.vim/bundle (or +" ~\vimfiles\bundle), adding `call pathogen#infect()` to your .vimrc +" prior to `filetype plugin indent on` is the only other setup necessary. +" +" The API is documented inline below. For maximum ease of reading, +" :set foldmethod=marker + +if exists("g:loaded_pathogen") || &cp + finish +endif +let g:loaded_pathogen = 1 + +" Point of entry for basic default usage. Give a directory name to invoke +" pathogen#runtime_append_all_bundles() (defaults to "bundle"), or a full path +" to invoke pathogen#runtime_prepend_subdirectories(). Afterwards, +" pathogen#cycle_filetype() is invoked. +function! pathogen#infect(...) abort " {{{1 + let source_path = a:0 ? a:1 : 'bundle' + if source_path =~# '[\\/]' + call pathogen#runtime_prepend_subdirectories(source_path) + else + call pathogen#runtime_append_all_bundles(source_path) + endif + call pathogen#cycle_filetype() +endfunction " }}}1 + +" Split a path into a list. +function! pathogen#split(path) abort " {{{1 + if type(a:path) == type([]) | return a:path | endif + let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,') + return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")') +endfunction " }}}1 + +" Convert a list to a path. +function! pathogen#join(...) abort " {{{1 + if type(a:1) == type(1) && a:1 + let i = 1 + let space = ' ' + else + let i = 0 + let space = '' + endif + let path = "" + while i < a:0 + if type(a:000[i]) == type([]) + let list = a:000[i] + let j = 0 + while j < len(list) + let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g') + let path .= ',' . escaped + let j += 1 + endwhile + else + let path .= "," . a:000[i] + endif + let i += 1 + endwhile + return substitute(path,'^,','','') +endfunction " }}}1 + +" Convert a list to a path with escaped spaces for 'path', 'tag', etc. +function! pathogen#legacyjoin(...) abort " {{{1 + return call('pathogen#join',[1] + a:000) +endfunction " }}}1 + +" Remove duplicates from a list. +function! pathogen#uniq(list) abort " {{{1 + let i = 0 + let seen = {} + while i < len(a:list) + if (a:list[i] ==# '' && exists('empty')) || has_key(seen,a:list[i]) + call remove(a:list,i) + elseif a:list[i] ==# '' + let i += 1 + let empty = 1 + else + let seen[a:list[i]] = 1 + let i += 1 + endif + endwhile + return a:list +endfunction " }}}1 + +" \ on Windows unless shellslash is set, / everywhere else. +function! pathogen#separator() abort " {{{1 + return !exists("+shellslash") || &shellslash ? '/' : '\' +endfunction " }}}1 + +" Convenience wrapper around glob() which returns a list. +function! pathogen#glob(pattern) abort " {{{1 + let files = split(glob(a:pattern),"\n") + return map(files,'substitute(v:val,"[".pathogen#separator()."/]$","","")') +endfunction "}}}1 + +" Like pathogen#glob(), only limit the results to directories. +function! pathogen#glob_directories(pattern) abort " {{{1 + return filter(pathogen#glob(a:pattern),'isdirectory(v:val)') +endfunction "}}}1 + +" Turn filetype detection off and back on again if it was already enabled. +function! pathogen#cycle_filetype() " {{{1 + if exists('g:did_load_filetypes') + filetype off + filetype on + endif +endfunction " }}}1 + +" Checks if a bundle is 'disabled'. A bundle is considered 'disabled' if +" its 'basename()' is included in g:pathogen_disabled[]' or ends in a tilde. +function! pathogen#is_disabled(path) " {{{1 + if a:path =~# '\~$' + return 1 + elseif !exists("g:pathogen_disabled") + return 0 + endif + let sep = pathogen#separator() + return index(g:pathogen_disabled, strpart(a:path, strridx(a:path, sep)+1)) != -1 +endfunction "}}}1 + +" Prepend all subdirectories of path to the rtp, and append all 'after' +" directories in those subdirectories. +function! pathogen#runtime_prepend_subdirectories(path) " {{{1 + let sep = pathogen#separator() + let before = filter(pathogen#glob_directories(a:path.sep."*"), '!pathogen#is_disabled(v:val)') + let after = filter(pathogen#glob_directories(a:path.sep."*".sep."after"), '!pathogen#is_disabled(v:val[0:-7])') + let rtp = pathogen#split(&rtp) + let path = expand(a:path) + call filter(rtp,'v:val[0:strlen(path)-1] !=# path') + let &rtp = pathogen#join(pathogen#uniq(before + rtp + after)) + return &rtp +endfunction " }}}1 + +" For each directory in rtp, check for a subdirectory named dir. If it +" exists, add all subdirectories of that subdirectory to the rtp, immediately +" after the original directory. If no argument is given, 'bundle' is used. +" Repeated calls with the same arguments are ignored. +function! pathogen#runtime_append_all_bundles(...) " {{{1 + let sep = pathogen#separator() + let name = a:0 ? a:1 : 'bundle' + if "\n".s:done_bundles =~# "\\M\n".name."\n" + return "" + endif + let s:done_bundles .= name . "\n" + let list = [] + for dir in pathogen#split(&rtp) + if dir =~# '\<after$' + let list += filter(pathogen#glob_directories(substitute(dir,'after$',name,'').sep.'*[^~]'.sep.'after'), '!pathogen#is_disabled(v:val[0:-7])') + [dir] + else + let list += [dir] + filter(pathogen#glob_directories(dir.sep.name.sep.'*[^~]'), '!pathogen#is_disabled(v:val)') + endif + endfor + let &rtp = pathogen#join(pathogen#uniq(list)) + return 1 +endfunction + +let s:done_bundles = '' +" }}}1 + +" Invoke :helptags on all non-$VIM doc directories in runtimepath. +function! pathogen#helptags() " {{{1 + let sep = pathogen#separator() + for dir in pathogen#split(&rtp) + if (dir.sep)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir.sep.'doc') == 2 && !empty(glob(dir.sep.'doc'.sep.'*')) && (!filereadable(dir.sep.'doc'.sep.'tags') || filewritable(dir.sep.'doc'.sep.'tags')) + helptags `=dir.'/doc'` + endif + endfor +endfunction " }}}1 + +command! -bar Helptags :call pathogen#helptags() + +" Like findfile(), but hardcoded to use the runtimepath. +function! pathogen#runtime_findfile(file,count) "{{{1 + let rtp = pathogen#join(1,pathogen#split(&rtp)) + return fnamemodify(findfile(a:file,rtp,a:count),':p') +endfunction " }}}1 + +function! s:find(count,cmd,file,lcd) " {{{1 + let rtp = pathogen#join(1,pathogen#split(&runtimepath)) + let file = pathogen#runtime_findfile(a:file,a:count) + if file ==# '' + return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'" + elseif a:lcd + let path = file[0:-strlen(a:file)-2] + execute 'lcd `=path`' + return a:cmd.' '.fnameescape(a:file) + else + return a:cmd.' '.fnameescape(file) + endif +endfunction " }}}1 + +function! s:Findcomplete(A,L,P) " {{{1 + let sep = pathogen#separator() + let cheats = { + \'a': 'autoload', + \'d': 'doc', + \'f': 'ftplugin', + \'i': 'indent', + \'p': 'plugin', + \'s': 'syntax'} + if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0]) + let request = cheats[a:A[0]].a:A[1:-1] + else + let request = a:A + endif + let pattern = substitute(request,'\'.sep,'*'.sep,'g').'*' + let found = {} + for path in pathogen#split(&runtimepath) + let matches = split(glob(path.sep.pattern),"\n") + call map(matches,'isdirectory(v:val) ? v:val.sep : v:val') + call map(matches,'v:val[strlen(path)+1:-1]') + for match in matches + let found[match] = 1 + endfor + endfor + return sort(keys(found)) +endfunction " }}}1 + +command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(<count>,'edit<bang>',<q-args>,0) +command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(<count>,'edit<bang>',<q-args>,0) +command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(<count>,'edit<bang>',<q-args>,1) +command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(<count>,'split',<q-args>,<bang>1) +command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(<count>,'vsplit',<q-args>,<bang>1) +command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(<count>,'tabedit',<q-args>,<bang>1) +command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(<count>,'pedit',<q-args>,<bang>1) +command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(<count>,'read',<q-args>,<bang>1) + +" vim:set ft=vim ts=8 sw=2 sts=2:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/bundle/minibufexpl/plugin/minibufexpl.vim Mon Nov 21 19:53:52 2011 -0800 @@ -0,0 +1,1838 @@ +" Mini Buffer Explorer <minibufexpl.vim> +" +" HINT: Type zR if you don't know how to use folds +" +" Script Info and Documentation {{{ +"============================================================================= +" Copyright: Copyright (C) 2002 & 2003 Bindu Wavell +" Permission is hereby granted to use and distribute this code, +" with or without modifications, provided that this copyright +" notice is copied with it. Like anything else that's free, +" minibufexplorer.vim is provided *as is* and comes with no +" warranty of any kind, either expressed or implied. In no +" event will the copyright holder be liable for any damamges +" resulting from the use of this software. +" +" Name Of File: minibufexpl.vim +" Description: Mini Buffer Explorer Vim Plugin +" Maintainer: Bindu Wavell <bindu@wavell.net> +" URL: http://vim.sourceforge.net/scripts/script.php?script_id=159 +" Last Change: Sunday, June 21, 2004 +" Version: 6.3.2 +" Derived from Jeff Lanzarotta's bufexplorer.vim version 6.0.7 +" Jeff can be reached at (jefflanzarotta@yahoo.com) and the +" original plugin can be found at: +" http://lanzarotta.tripod.com/vim/plugin/6/bufexplorer.vim.zip +" +" Usage: Normally, this file should reside in the plugins +" directory and be automatically sourced. If not, you must +" manually source this file using ':source minibufexplorer.vim'. +" +" You may use the default keymappings of +" +" <Leader>mbe - Opens MiniBufExplorer +" +" or you may want to add something like the following +" key mapping to your _vimrc/.vimrc file. +" +" map <Leader>b :MiniBufExplorer<cr> +" +" However, in most cases you won't need any key-bindings at all. +" +" <Leader> is usually backslash so type "\mbe" (quickly) to open +" the -MiniBufExplorer- window. +" +" Other keymappings include: <Leader>mbc to close the Explorer +" window, <Leader>mbu to force the Explorer to Update and +" <Leader>mbt to toggle the Explorer window; it will open if +" closed or close if open. Each of these key bindings can be +" overridden (see the notes on <Leader>mbe above.) +" +" You can map these additional commands as follows: +" +" map <Leader>c :CMiniBufExplorer<cr> +" map <Leader>u :UMiniBufExplorer<cr> +" map <Leader>t :TMiniBufExplorer<cr> +" +" NOTE: you can change the key binding used in these mappings +" so that they fit with your configuration of vim. +" +" You can also call each of these features by typing the +" following in command mode: +" +" :MiniBufExplorer " Open and/or goto Explorer +" :CMiniBufExplorer " Close the Explorer if it's open +" :UMiniBufExplorer " Update Explorer without navigating +" :TMiniBufExplorer " Toggle the Explorer window open and +" closed. +" +" To control where the new split window goes relative to the +" current window, use the setting: +" +" let g:miniBufExplSplitBelow=0 " Put new window above +" " current or on the +" " left for vertical split +" let g:miniBufExplSplitBelow=1 " Put new window below +" " current or on the +" " right for vertical split +" +" The default for this is read from the &splitbelow VIM option. +" +" By default we are now (as of 6.0.2) forcing the -MiniBufExplorer- +" window to open up at the edge of the screen. You can turn this +" off by setting the following variable in your .vimrc: +" +" let g:miniBufExplSplitToEdge = 0 +" +" If you would like a vertical explorer you can assign the column +" width (in characters) you want for your explorer window with the +" following .vimrc variable (this was introduced in 6.3.0): +" +" let g:miniBufExplVSplit = 20 " column width in chars +" +" IN HORIZONTAL MODE: +" It is now (as of 6.1.1) possible to set a maximum height for +" the -MiniBufExplorer- window. You can set the max height by +" letting the following variable in your .vimrc: +" +" let g:miniBufExplMaxSize = <max lines: defualt 0> +" +" setting this to 0 will mean the window gets as big as +" needed to fit all your buffers. +" +" NOTE: This was g:miniBufExplMaxHeight before 6.3.0; the old +" setting is backwards compatible if you don't use MaxSize. +" +" As of 6.2.2 it is possible to set a minimum height for the +" -MiniBufExplorer- window. You can set the min height by +" letting the following variable in your .vimrc: +" +" let g:miniBufExplMinSize = <min height: default 1> +" +" NOTE: This was g:miniBufExplMinHeight before 6.3.0; the old +" setting is backwards compatible if you don't use MinSize. +" +" IN VERTICAL MODE: (as of 6.3.0) +" By default the vertical explorer has a fixed width. If you put: +" +" let g:miniBufExplMaxSize = <max width: default 0> +" +" into your .vimrc then MBE will attempt to set the width of the +" MBE window to be as wide as your widest tab. The width will not +" exceed MaxSize even if you have wider tabs. +" +" Accepting the default value of 0 for this will give you a fixed +" width MBE window. +" +" You can specify a MinSize for the vertical explorer window by +" putting the following in your .vimrc: +" +" let g:miniBufExplMinSize = <min width: default 1> +" +" This will have no effect unless you also specivy MaxSize. +" +" By default we are now (as of 6.0.1) turning on the MoreThanOne +" option. This stops the -MiniBufExplorer- from opening +" automatically until more than one eligible buffer is available. +" You can turn this feature off by setting the following variable +" in your .vimrc: +" +" let g:miniBufExplorerMoreThanOne=1 +" +" (The following enhancement is as of 6.2.2) +" Setting this to 0 will cause the MBE window to be loaded even +" if no buffers are available. Setting it to 1 causes the MBE +" window to be loaded as soon as an eligible buffer is read. You +" can also set it to larger numbers. So if you set it to 4 for +" example the MBE window wouldn't auto-open until 4 eligibles +" buffers had been loaded. This is nice for folks that don't +" want an MBE window unless they are editing more than two or +" three buffers. +" +" To enable the optional mapping of Control + Vim Direction Keys +" [hjkl] to window movement commands, you can put the following into +" your .vimrc: +" +" let g:miniBufExplMapWindowNavVim = 1 +" +" To enable the optional mapping of Control + Arrow Keys to window +" movement commands, you can put the following into your .vimrc: +" +" let g:miniBufExplMapWindowNavArrows = 1 +" +" To enable the optional mapping of <C-TAB> and <C-S-TAB> to a +" function that will bring up the next or previous buffer in the +" current window, you can put the following into your .vimrc: +" +" let g:miniBufExplMapCTabSwitchBufs = 1 +" +" To enable the optional mapping of <C-TAB> and <C-S-TAB> to mappings +" that will move to the next and previous (respectively) window, you +" can put the following into your .vimrc: +" +" let g:miniBufExplMapCTabSwitchWindows = 1 +" +" +" NOTE: If you set the ...TabSwitchBufs AND ...TabSwitchWindows, +" ...TabSwitchBufs will be enabled and ...TabSwitchWindows +" will not. +" +" As of MBE 6.3.0, you can put the following into your .vimrc: +" +" let g:miniBufExplUseSingleClick = 1 +" +" If you would like to single click on tabs rather than double +" clicking on them to goto the selected buffer. +" +" NOTE: If you use the single click option in taglist.vim you may +" need to get an updated version that includes a patch I +" provided to allow both explorers to provide single click +" buffer selection. +" +" It is possible to customize the the highlighting for the tabs in +" the MBE by configuring the following highlighting groups: +" +" MBENormal - for buffers that have NOT CHANGED and +" are NOT VISIBLE. +" MBEChanged - for buffers that HAVE CHANGED and are +" NOT VISIBLE +" MBEVisibleNormal - buffers that have NOT CHANGED and are +" VISIBLE +" MBEVisibleChanged - buffers that have CHANGED and are VISIBLE +" +" You can either link to an existing highlighting group by +" adding a command like: +" +" hi link MBEVisibleChanged Error +" +" to your .vimrc or you can specify exact foreground and background +" colors using the following syntax: +" +" hi MBEChanged guibg=darkblue ctermbg=darkblue termbg=white +" +" NOTE: If you set a colorscheme in your .vimrc you should do it +" BEFORE updating the MBE highlighting groups. +" +" If you use other explorers like TagList you can (As of 6.2.8) put: +" +" let g:miniBufExplModSelTarget = 1 +" +" into your .vimrc in order to force MBE to try to place selected +" buffers into a window that does not have a nonmodifiable buffer. +" The upshot of this should be that if you go into MBE and select +" a buffer, the buffer should not show up in a window that is +" hosting an explorer. +" +" There is a VIM bug that can cause buffers to show up without +" their highlighting. The following setting will cause MBE to +" try and turn highlighting back on (introduced in 6.3.1): +" +" let g:miniBufExplForceSyntaxEnable = 1 +" +" MBE has had a basic debugging capability for quite some time. +" However, it has not been very friendly in the past. As of 6.0.8, +" you can put one of each of the following into your .vimrc: +" +" let g:miniBufExplorerDebugLevel = 0 " MBE serious errors output +" let g:miniBufExplorerDebugLevel = 4 " MBE all errors output +" let g:miniBufExplorerDebugLevel = 10 " MBE reports everything +" +" You can also set a DebugMode to cause output to be target as +" follows (default is mode 3): +" +" let g:miniBufExplorerDebugMode = 0 " Errors will show up in +" " a vim window +" let g:miniBufExplorerDebugMode = 1 " Uses VIM's echo function +" " to display on the screen +" let g:miniBufExplorerDebugMode = 2 " Writes to a file +" " MiniBufExplorer.DBG +" let g:miniBufExplorerDebugMode = 3 " Store output in global: +" " g:miniBufExplorerDebugOutput +" +" Or if you are able to start VIM, you might just perform these +" at a command prompt right before you do the operation that is +" failing. +" +" History: Moved to end of file +" +" Known Issues: When debugging is turned on and set to output to a window, there +" are some cases where the window is opened more than once, there +" are other cases where an old debug window can be lost. +" +" Several MBE commands can break the window history so <C-W>[pnw] +" might not take you to the expected window. +" +" Todo: Add the ability to specify a regexp for eligible buffers +" allowing the ability to filter out certain buffers that +" you don't want to control from MBE +" +"============================================================================= +" }}} + +" Startup Check +" +" Has this plugin already been loaded? {{{ +" +if exists('loaded_minibufexplorer') + finish +endif +let loaded_minibufexplorer = 1 +" }}} + +" Mappings and Commands +" +" MBE Keyboard Mappings {{{ +" If we don't already have keyboard mappings for MBE then create them +" +if !hasmapto('<Plug>MiniBufExplorer') + map <unique> <Leader>mbe <Plug>MiniBufExplorer +endif +if !hasmapto('<Plug>CMiniBufExplorer') + map <unique> <Leader>mbc <Plug>CMiniBufExplorer +endif +if !hasmapto('<Plug>UMiniBufExplorer') + map <unique> <Leader>mbu <Plug>UMiniBufExplorer +endif +if !hasmapto('<Plug>TMiniBufExplorer') + map <unique> <Leader>mbt <Plug>TMiniBufExplorer +endif + +" }}} +" MBE <Script> internal map {{{ +" +noremap <unique> <script> <Plug>MiniBufExplorer :call <SID>StartExplorer(1, -1)<CR>:<BS> +noremap <unique> <script> <Plug>CMiniBufExplorer :call <SID>StopExplorer(1)<CR>:<BS> +noremap <unique> <script> <Plug>UMiniBufExplorer :call <SID>AutoUpdate(-1)<CR>:<BS> +noremap <unique> <script> <Plug>TMiniBufExplorer :call <SID>ToggleExplorer()<CR>:<BS> + +" }}} +" MBE commands {{{ +" +if !exists(':MiniBufExplorer') + command! MiniBufExplorer call <SID>StartExplorer(1, -1) +endif +if !exists(':CMiniBufExplorer') + command! CMiniBufExplorer call <SID>StopExplorer(1) +endif +if !exists(':UMiniBufExplorer') + command! UMiniBufExplorer call <SID>AutoUpdate(-1) +endif +if !exists(':TMiniBufExplorer') + command! TMiniBufExplorer call <SID>ToggleExplorer() +endif +if !exists(':MBEbn') + command! MBEbn call <SID>CycleBuffer(1) +endif +if !exists(':MBEbp') + command! MBEbp call <SID>CycleBuffer(0) +endif " }}} + +" Global Configuration Variables +" +" Debug Level {{{ +" +" 0 = no logging +" 1=5 = errors ; 1 is the most important +" 5-9 = info ; 5 is the most important +" 10 = Entry/Exit +if !exists('g:miniBufExplorerDebugLevel') + let g:miniBufExplorerDebugLevel = 0 +endif + +" }}} +" Debug Mode {{{ +" +" 0 = debug to a window +" 1 = use vim's echo facility +" 2 = write to a file named MiniBufExplorer.DBG +" in the directory where vim was started +" THIS IS VERY SLOW +" 3 = Write into g:miniBufExplorerDebugOutput +" global variable [This is the default] +if !exists('g:miniBufExplorerDebugMode') + let g:miniBufExplorerDebugMode = 3 +endif + +" }}} +" Allow auto update? {{{ +" +" We start out with this off for startup, but once vim is running we +" turn this on. +if !exists('g:miniBufExplorerAutoUpdate') + let g:miniBufExplorerAutoUpdate = 0 +endif + +" }}} +" MoreThanOne? {{{ +" Display Mini Buf Explorer when there are 'More Than One' eligible buffers +" +if !exists('g:miniBufExplorerMoreThanOne') + let g:miniBufExplorerMoreThanOne = 2 +endif + +" }}} +" Split below/above/left/right? {{{ +" When opening a new -MiniBufExplorer- window, split the new windows below or +" above the current window? 1 = below, 0 = above. +" +if !exists('g:miniBufExplSplitBelow') + let g:miniBufExplSplitBelow = &splitbelow +endif + +" }}} +" Split to edge? {{{ +" When opening a new -MiniBufExplorer- window, split the new windows to the +" full edge? 1 = yes, 0 = no. +" +if !exists('g:miniBufExplSplitToEdge') + let g:miniBufExplSplitToEdge = 1 +endif + +" }}} +" MaxHeight (depreciated) {{{ +" When sizing the -MiniBufExplorer- window, assign a maximum window height. +" 0 = size to fit all buffers, otherwise the value is number of lines for +" buffer. [Depreciated use g:miniBufExplMaxSize] +" +if !exists('g:miniBufExplMaxHeight') + let g:miniBufExplMaxHeight = 0 +endif + +" }}} +" MaxSize {{{ +" Same as MaxHeight but also works for vertical splits if specified with a +" vertical split then vertical resizing will be performed. If left at 0 +" then the number of columns in g:miniBufExplVSplit will be used as a +" static window width. +if !exists('g:miniBufExplMaxSize') + let g:miniBufExplMaxSize = g:miniBufExplMaxHeight +endif + +" }}} +" MinHeight (depreciated) {{{ +" When sizing the -MiniBufExplorer- window, assign a minumum window height. +" the value is minimum number of lines for buffer. Setting this to zero can +" cause strange height behavior. The default value is 1 [Depreciated use +" g:miniBufExplMinSize] +" +if !exists('g:miniBufExplMinHeight') + let g:miniBufExplMinHeight = 1 +endif + +" }}} +" MinSize {{{ +" Same as MinHeight but also works for vertical splits. For vertical splits, +" this is ignored unless g:miniBufExplMax(Size|Height) are specified. +if !exists('g:miniBufExplMinSize') + let g:miniBufExplMinSize = g:miniBufExplMinHeight +endif + +" }}} +" Horizontal or Vertical explorer? {{{ +" For folks that like vertical explorers, I'm caving in and providing for +" veritcal splits. If this is set to 0 then the current horizontal +" splitting logic will be run. If however you want a vertical split, +" assign the width (in characters) you wish to assign to the MBE window. +" +if !exists('g:miniBufExplVSplit') + let g:miniBufExplVSplit = 0 +endif + +" }}} +" TabWrap? {{{ +" By default line wrap is used (possibly breaking a tab name between two +" lines.) Turning this option on (setting it to 1) can take more screen +" space, but will make sure that each tab is on one and only one line. +" +if !exists('g:miniBufExplTabWrap') + let g:miniBufExplTabWrap = 0 +endif + +" }}} +" Extended window navigation commands? {{{ +" Global flag to turn extended window navigation commands on or off +" enabled = 1, dissabled = 0 +" +if !exists('g:miniBufExplMapWindowNav') + " This is for backwards compatibility and may be removed in a + " later release, please use the ...NavVim and/or ...NavArrows + " settings. + let g:miniBufExplMapWindowNav = 0 +endif +if !exists('g:miniBufExplMapWindowNavVim') + let g:miniBufExplMapWindowNavVim = 0 +endif +if !exists('g:miniBufExplMapWindowNavArrows') + let g:miniBufExplMapWindowNavArrows = 0 +endif +if !exists('g:miniBufExplMapCTabSwitchBufs') + let g:miniBufExplMapCTabSwitchBufs = 0 +endif +" Notice: that if CTabSwitchBufs is turned on then +" we turn off CTabSwitchWindows. +if g:miniBufExplMapCTabSwitchBufs == 1 || !exists('g:miniBufExplMapCTabSwitchWindows') + let g:miniBufExplMapCTabSwitchWindows = 0 +endif + +" +" If we have enabled control + vim direction key remapping +" then perform the remapping +" +" Notice: I left g:miniBufExplMapWindowNav in for backward +" compatibility. Eventually this mapping will be removed so +" please use the newer g:miniBufExplMapWindowNavVim setting. +if g:miniBufExplMapWindowNavVim || g:miniBufExplMapWindowNav + noremap <C-J> <C-W>j + noremap <C-K> <C-W>k + noremap <C-H> <C-W>h + noremap <C-L> <C-W>l +endif + +" +" If we have enabled control + arrow key remapping +" then perform the remapping +" +if g:miniBufExplMapWindowNavArrows + noremap <C-Down> <C-W>j + noremap <C-Up> <C-W>k + noremap <C-Left> <C-W>h + noremap <C-Right> <C-W>l +endif + +" If we have enabled <C-TAB> and <C-S-TAB> to switch buffers +" in the current window then perform the remapping +" +if g:miniBufExplMapCTabSwitchBufs + noremap <C-TAB> :call <SID>CycleBuffer(1)<CR>:<BS> + noremap <C-S-TAB> :call <SID>CycleBuffer(0)<CR>:<BS> +endif + +" +" If we have enabled <C-TAB> and <C-S-TAB> to switch windows +" then perform the remapping +" +if g:miniBufExplMapCTabSwitchWindows + noremap <C-TAB> <C-W>w + noremap <C-S-TAB> <C-W>W +endif + +" }}} +" Modifiable Select Target {{{ +" +if !exists('g:miniBufExplModSelTarget') + let g:miniBufExplModSelTarget = 0 +endif + +"}}} +" Force Syntax Enable {{{ +" +if !exists('g:miniBufExplForceSyntaxEnable') + let g:miniBufExplForceSyntaxEnable = 0 +endif + +" }}} +" Single/Double Click? {{{ +" flag that can be set to 1 in a users .vimrc to allow +" single click switching of tabs. By default we use +" double click for tab selection. +" +if !exists('g:miniBufExplUseSingleClick') + let g:miniBufExplUseSingleClick = 0 +endif + +" +" attempt to perform single click mapping, it would be much +" nicer if we could nnoremap <buffer> ... however vim does +" not fire the <buffer> <leftmouse> when you use the mouse +" to enter a buffer. +" +if g:miniBufExplUseSingleClick == 1 + let s:clickmap = ':if bufname("%") == "-MiniBufExplorer-" <bar> call <SID>MBEClick() <bar> endif <CR>' + if maparg('<LEFTMOUSE>', 'n') == '' + " no mapping for leftmouse + exec ':nnoremap <silent> <LEFTMOUSE> <LEFTMOUSE>' . s:clickmap + else + " we have a mapping + let g:miniBufExplDoneClickSave = 1 + let s:m = ':nnoremap <silent> <LEFTMOUSE> <LEFTMOUSE>' + let s:m = s:m . substitute(substitute(maparg('<LEFTMOUSE>', 'n'), '|', '<bar>', 'g'), '\c^<LEFTMOUSE>', '', '') + let s:m = s:m . s:clickmap + exec s:m + endif +endif " }}} + +" Variables used internally +" +" Script/Global variables {{{ +" Global used to store the buffer list so we don't update the +" UI unless the list has changed. +if !exists('g:miniBufExplBufList') + let g:miniBufExplBufList = '' +endif + +" Variable used as a mutex so that we don't do lots +" of AutoUpdates at the same time. +if !exists('g:miniBufExplInAutoUpdate') + let g:miniBufExplInAutoUpdate = 0 +endif + +" In debug mode 3 this variable will hold the debug output +if !exists('g:miniBufExplorerDebugOutput') + let g:miniBufExplorerDebugOutput = '' +endif + +" In debug mode 3 this variable will hold the debug output +if !exists('g:miniBufExplForceDisplay') + let g:miniBufExplForceDisplay = 0 +endif + +" Variable used to pass maxTabWidth info between functions +let s:maxTabWidth = 0 + +" Variable used to count debug output lines +let s:debugIndex = 0 + + +" }}} +" Setup an autocommand group and some autocommands {{{ +" that keep our explorer updated automatically. +" +augroup MiniBufExplorer +autocmd MiniBufExplorer BufDelete * call <SID>DEBUG('-=> BufDelete AutoCmd', 10) |call <SID>AutoUpdate(expand('<abuf>')) +autocmd MiniBufExplorer BufEnter * call <SID>DEBUG('-=> BufEnter AutoCmd', 10) |call <SID>AutoUpdate(-1) +autocmd MiniBufExplorer VimEnter * call <SID>DEBUG('-=> VimEnter AutoCmd', 10) |let g:miniBufExplorerAutoUpdate = 1 |call <SID>AutoUpdate(-1) +" }}} + +" Functions +" +" StartExplorer - Sets up our explorer and causes it to be displayed {{{ +" +function! <SID>StartExplorer(sticky, delBufNum) + call <SID>DEBUG('===========================',10) + call <SID>DEBUG('Entering StartExplorer()' ,10) + call <SID>DEBUG('===========================',10) + + if a:sticky == 1 + let g:miniBufExplorerAutoUpdate = 1 + endif + + " Store the current buffer + let l:curBuf = bufnr('%') + + " Prevent a report of our actions from showing up. + let l:save_rep = &report + let l:save_sc = &showcmd + let &report = 10000 + set noshowcmd + + call <SID>FindCreateWindow('-MiniBufExplorer-', -1, 1, 1) + + " Make sure we are in our window + if bufname('%') != '-MiniBufExplorer-' + call <SID>DEBUG('StartExplorer called in invalid window',1) + let &report = l:save_rep + let &showcmd = l:save_sc + return + endif + + " !!! We may want to make the following optional -- Bindu + " New windows don't cause all windows to be resized to equal sizes + set noequalalways + " !!! We may want to make the following optional -- Bindu + " We don't want the mouse to change focus without a click + set nomousefocus + + " If folks turn numbering and columns on by default we will turn + " them off for the MBE window + setlocal foldcolumn=0 + setlocal nonumber + + if has("syntax") + syn clear + syn match MBENormal '\[[^\]]*\]' + syn match MBEChanged '\[[^\]]*\]+' + syn match MBEVisibleNormal '\[[^\]]*\]\*+\=' + syn match MBEVisibleChanged '\[[^\]]*\]\*+' + + if !exists("g:did_minibufexplorer_syntax_inits") + let g:did_minibufexplorer_syntax_inits = 1 + hi def link MBENormal Comment + hi def link MBEChanged String + hi def link MBEVisibleNormal Special + hi def link MBEVisibleChanged Special + endif + endif + + " If you press return in the -MiniBufExplorer- then try + " to open the selected buffer in the previous window. + nnoremap <buffer> <CR> :call <SID>MBESelectBuffer()<CR>:<BS> + " If you DoubleClick in the -MiniBufExplorer- then try + " to open the selected buffer in the previous window. + nnoremap <buffer> <2-LEFTMOUSE> :call <SID>MBEDoubleClick()<CR>:<BS> + " If you press d in the -MiniBufExplorer- then try to + " delete the selected buffer. + nnoremap <buffer> d :call <SID>MBEDeleteBuffer()<CR>:<BS> + " If you press w in the -MiniBufExplorer- then switch back + " to the previous window. + nnoremap <buffer> p :wincmd p<CR>:<BS> + " The following allow us to use regular movement keys to + " scroll in a wrapped single line buffer + nnoremap <buffer> j gj + nnoremap <buffer> k gk + nnoremap <buffer> <down> gj + nnoremap <buffer> <up> gk + " The following allows for quicker moving between buffer + " names in the [MBE] window it also saves the last-pattern + " and restores it. + nnoremap <buffer> <TAB> :call search('\[[0-9]*:[^\]]*\]')<CR>:<BS> + nnoremap <buffer> <S-TAB> :call search('\[[0-9]*:[^\]]*\]','b')<CR>:<BS> + + call <SID>DisplayBuffers(a:delBufNum) + + if (l:curBuf != -1) + call search('\['.l:curBuf.':'.expand('#'.l:curBuf.':t').'\]') + else + call <SID>DEBUG('No current buffer to search for',9) + endif + + let &report = l:save_rep + let &showcmd = l:save_sc + + call <SID>DEBUG('===========================',10) + call <SID>DEBUG('Completed StartExplorer()' ,10) + call <SID>DEBUG('===========================',10) + +endfunction + +" }}} +" StopExplorer - Looks for our explorer and closes the window if it is open {{{ +" +function! <SID>StopExplorer(sticky) + call <SID>DEBUG('===========================',10) + call <SID>DEBUG('Entering StopExplorer()' ,10) + call <SID>DEBUG('===========================',10) + + if a:sticky == 1 + let g:miniBufExplorerAutoUpdate = 0 + endif + + let l:winNum = <SID>FindWindow('-MiniBufExplorer-', 1) + + if l:winNum != -1 + exec l:winNum.' wincmd w' + silent! close + wincmd p + endif + + call <SID>DEBUG('===========================',10) + call <SID>DEBUG('Completed StopExplorer()' ,10) + call <SID>DEBUG('===========================',10) + +endfunction + +" }}} +" ToggleExplorer - Looks for our explorer and opens/closes the window {{{ +" +function! <SID>ToggleExplorer() + call <SID>DEBUG('===========================',10) + call <SID>DEBUG('Entering ToggleExplorer()' ,10) + call <SID>DEBUG('===========================',10) + + let g:miniBufExplorerAutoUpdate = 0 + + let l:winNum = <SID>FindWindow('-MiniBufExplorer-', 1) + + if l:winNum != -1 + call <SID>StopExplorer(1) + else + call <SID>StartExplorer(1, -1) + wincmd p + endif + + call <SID>DEBUG('===========================',10) + call <SID>DEBUG('Completed ToggleExplorer()' ,10) + call <SID>DEBUG('===========================',10) + +endfunction + +" }}} +" FindWindow - Return the window number of a named buffer {{{ +" If none is found then returns -1. +" +function! <SID>FindWindow(bufName, doDebug) + if a:doDebug + call <SID>DEBUG('Entering FindWindow()',10) + endif + + " Try to find an existing window that contains + " our buffer. + let l:bufNum = bufnr(a:bufName) + if l:bufNum != -1 + if a:doDebug + call <SID>DEBUG('Found buffer ('.a:bufName.'): '.l:bufNum,9) + endif + let l:winNum = bufwinnr(l:bufNum) + else + let l:winNum = -1 + endif + + return l:winNum + +endfunction + +" }}} +" FindCreateWindow - Attempts to find a window for a named buffer. {{{ +" +" If it is found then moves there. Otherwise creates a new window and +" configures it and moves there. +" +" forceEdge, -1 use defaults, 0 below, 1 above +" isExplorer, 0 no, 1 yes +" doDebug, 0 no, 1 yes +" +function! <SID>FindCreateWindow(bufName, forceEdge, isExplorer, doDebug) + if a:doDebug + call <SID>DEBUG('Entering FindCreateWindow('.a:bufName.')',10) + endif + + " Save the user's split setting. + let l:saveSplitBelow = &splitbelow + + " Set to our new values. + let &splitbelow = g:miniBufExplSplitBelow + + " Try to find an existing explorer window + let l:winNum = <SID>FindWindow(a:bufName, a:doDebug) + + " If found goto the existing window, otherwise + " split open a new window. + if l:winNum != -1 + if a:doDebug + call <SID>DEBUG('Found window ('.a:bufName.'): '.l:winNum,9) + endif + exec l:winNum.' wincmd w' + let l:winFound = 1 + else + + if g:miniBufExplSplitToEdge == 1 || a:forceEdge >= 0 + + let l:edge = &splitbelow + if a:forceEdge >= 0 + let l:edge = a:forceEdge + endif + + if l:edge + if g:miniBufExplVSplit == 0 + exec 'bo sp '.a:bufName + else + exec 'bo vsp '.a:bufName + endif + else + if g:miniBufExplVSplit == 0 + exec 'to sp '.a:bufName + else + exec 'to vsp '.a:bufName + endif + endif + else + if g:miniBufExplVSplit == 0 + exec 'sp '.a:bufName + else + " &splitbelow doesn't affect vertical splits + " so we have to do this explicitly.. ugh. + if &splitbelow + exec 'rightb vsp '.a:bufName + else + exec 'vsp '.a:bufName + endif + endif + endif + + let g:miniBufExplForceDisplay = 1 + + " Try to find an existing explorer window + let l:winNum = <SID>FindWindow(a:bufName, a:doDebug) + if l:winNum != -1 + if a:doDebug + call <SID>DEBUG('Created and then found window ('.a:bufName.'): '.l:winNum,9) + endif + exec l:winNum.' wincmd w' + else + if a:doDebug + call <SID>DEBUG('FindCreateWindow failed to create window ('.a:bufName.').',1) + endif + return + endif + + if a:isExplorer + " Turn off the swapfile, set the buffer type so that it won't get written, + " and so that it will get deleted when it gets hidden and turn on word wrap. + setlocal noswapfile + setlocal buftype=nofile + setlocal bufhidden=delete + if g:miniBufExplVSplit == 0 + setlocal wrap + else + setlocal nowrap + exec('setlocal winwidth='.g:miniBufExplMinSize) + endif + endif + + if a:doDebug + call <SID>DEBUG('Window ('.a:bufName.') created: '.winnr(),9) + endif + + endif + + " Restore the user's split setting. + let &splitbelow = l:saveSplitBelow + +endfunction + +" }}} +" DisplayBuffers - Wrapper for getting MBE window shown {{{ +" +" Makes sure we are in our explorer, then erases the current buffer and turns +" it into a mini buffer explorer window. +" +function! <SID>DisplayBuffers(delBufNum) + call <SID>DEBUG('Entering DisplayBuffers()',10) + + " Make sure we are in our window + if bufname('%') != '-MiniBufExplorer-' + call <SID>DEBUG('DisplayBuffers called in invalid window',1) + return + endif + + " We need to be able to modify the buffer + setlocal modifiable + + call <SID>ShowBuffers(a:delBufNum) + call <SID>ResizeWindow() + + normal! zz + + " Prevent the buffer from being modified. + setlocal nomodifiable + set nobuflisted + +endfunction + +" }}} +" Resize Window - Set width/height of MBE window {{{ +" +" Makes sure we are in our explorer, then sets the height/width for our explorer +" window so that we can fit all of our information without taking extra lines. +" +function! <SID>ResizeWindow() + call <SID>DEBUG('Entering ResizeWindow()',10) + + " Make sure we are in our window + if bufname('%') != '-MiniBufExplorer-' + call <SID>DEBUG('ResizeWindow called in invalid window',1) + return + endif + + let l:width = winwidth('.') + + " Horizontal Resize + if g:miniBufExplVSplit == 0 + + if g:miniBufExplTabWrap == 0 + let l:length = strlen(getline('.')) + let l:height = 0 + if (l:width == 0) + let l:height = winheight('.') + else + let l:height = (l:length / l:width) + " handle truncation from div + if (l:length % l:width) != 0 + let l:height = l:height + 1 + endif + endif + else + exec("setlocal textwidth=".l:width) + normal gg + normal gq} + normal G + let l:height = line('.') + normal gg + endif + + " enforce max window height + if g:miniBufExplMaxSize != 0 + if g:miniBufExplMaxSize < l:height + let l:height = g:miniBufExplMaxSize + endif + endif + + " enfore min window height + if l:height < g:miniBufExplMinSize || l:height == 0 + let l:height = g:miniBufExplMinSize + endif + + call <SID>DEBUG('ResizeWindow to '.l:height.' lines',9) + + exec('resize '.l:height) + + " Vertical Resize + else + + if g:miniBufExplMaxSize != 0 + let l:newWidth = s:maxTabWidth + if l:newWidth > g:miniBufExplMaxSize + let l:newWidth = g:miniBufExplMaxSize + endif + if l:newWidth < g:miniBufExplMinSize + let l:newWidth = g:miniBufExplMinSize + endif + else + let l:newWidth = g:miniBufExplVSplit + endif + + if l:width != l:newWidth + call <SID>DEBUG('ResizeWindow to '.l:newWidth.' columns',9) + exec('vertical resize '.l:newWidth) + endif + + endif + +endfunction + +" }}} +" ShowBuffers - Clear current buffer and put the MBE text into it {{{ +" +" Makes sure we are in our explorer, then adds a list of all modifiable +" buffers to the current buffer. Special marks are added for buffers that +" are in one or more windows (*) and buffers that have been modified (+) +" +function! <SID>ShowBuffers(delBufNum) + call <SID>DEBUG('Entering ShowBuffers()',10) + + let l:ListChanged = <SID>BuildBufferList(a:delBufNum, 1) + + if (l:ListChanged == 1 || g:miniBufExplForceDisplay) + let l:save_rep = &report + let l:save_sc = &showcmd + let &report = 10000 + set noshowcmd + + " Delete all lines in buffer. + 1,$d _ + + " Goto the end of the buffer put the buffer list + " and then delete the extra trailing blank line + $ + put! =g:miniBufExplBufList + $ d _ + + let g:miniBufExplForceDisplay = 0 + + let &report = l:save_rep + let &showcmd = l:save_sc + else + call <SID>DEBUG('Buffer list not update since there was no change',9) + endif + +endfunction + +" }}} +" Max - Returns the max of two numbers {{{ +" +function! <SID>Max(argOne, argTwo) + if a:argOne > a:argTwo + return a:argOne + else + return a:argTwo + endif +endfunction + +" }}} +" BuildBufferList - Build the text for the MBE window {{{ +" +" Creates the buffer list string and returns 1 if it is different than +" last time this was called and 0 otherwise. +" +function! <SID>BuildBufferList(delBufNum, updateBufList) + call <SID>DEBUG('Entering BuildBufferList()',10) + + let l:NBuffers = bufnr('$') " Get the number of the last buffer. + let l:i = 0 " Set the buffer index to zero. + + let l:fileNames = '' + let l:maxTabWidth = 0 + + " Loop through every buffer less than the total number of buffers. + while(l:i <= l:NBuffers) + let l:i = l:i + 1 + + " If we have a delBufNum and it is the current + " buffer then ignore the current buffer. + " Otherwise, continue. + if (a:delBufNum == -1 || l:i != a:delBufNum) + " Make sure the buffer in question is listed. + if(getbufvar(l:i, '&buflisted') == 1) + " Get the name of the buffer. + let l:BufName = bufname(l:i) + " Check to see if the buffer is a blank or not. If the buffer does have + " a name, process it. + if(strlen(l:BufName)) + " Only show modifiable buffers (The idea is that we don't + " want to show Explorers) + if (getbufvar(l:i, '&modifiable') == 1 && BufName != '-MiniBufExplorer-') + + " Get filename & Remove []'s & ()'s + let l:shortBufName = fnamemodify(l:BufName, ":t") + let l:shortBufName = substitute(l:shortBufName, '[][()]', '', 'g') + let l:tab = '['.l:i.':'.l:shortBufName.']' + + " If the buffer is open in a window mark it + if bufwinnr(l:i) != -1 + let l:tab = l:tab . '*' + endif + + " If the buffer is modified then mark it + if(getbufvar(l:i, '&modified') == 1) + let l:tab = l:tab . '+' + endif + + let l:maxTabWidth = <SID>Max(strlen(l:tab), l:maxTabWidth) + let l:fileNames = l:fileNames.l:tab + + " If horizontal and tab wrap is turned on we need to add spaces + if g:miniBufExplVSplit == 0 + if g:miniBufExplTabWrap != 0 + let l:fileNames = l:fileNames.' ' + endif + " If not horizontal we need a newline + else + let l:fileNames = l:fileNames . "\n" + endif + endif + endif + endif + endif + endwhile + + if (g:miniBufExplBufList != l:fileNames) + if (a:updateBufList) + let g:miniBufExplBufList = l:fileNames + let s:maxTabWidth = l:maxTabWidth + endif + return 1 + else + return 0 + endif + +endfunction + +" }}} +" HasEligibleBuffers - Are there enough MBE eligible buffers to open the MBE window? {{{ +" +" Returns 1 if there are any buffers that can be displayed in a +" mini buffer explorer. Otherwise returns 0. If delBufNum is +" any non -1 value then don't include that buffer in the list +" of eligible buffers. +" +function! <SID>HasEligibleBuffers(delBufNum) + call <SID>DEBUG('Entering HasEligibleBuffers()',10) + + let l:save_rep = &report + let l:save_sc = &showcmd + let &report = 10000 + set noshowcmd + + let l:NBuffers = bufnr('$') " Get the number of the last buffer. + let l:i = 0 " Set the buffer index to zero. + let l:found = 0 " No buffer found + + if (g:miniBufExplorerMoreThanOne > 1) + call <SID>DEBUG('More Than One mode turned on',6) + endif + let l:needed = g:miniBufExplorerMoreThanOne + + " Loop through every buffer less than the total number of buffers. + while(l:i <= l:NBuffers && l:found < l:needed) + let l:i = l:i + 1 + + " If we have a delBufNum and it is the current + " buffer then ignore the current buffer. + " Otherwise, continue. + if (a:delBufNum == -1 || l:i != a:delBufNum) + " Make sure the buffer in question is listed. + if (getbufvar(l:i, '&buflisted') == 1) + " Get the name of the buffer. + let l:BufName = bufname(l:i) + " Check to see if the buffer is a blank or not. If the buffer does have + " a name, process it. + if (strlen(l:BufName)) + " Only show modifiable buffers (The idea is that we don't + " want to show Explorers) + if ((getbufvar(l:i, '&modifiable') == 1) && (BufName != '-MiniBufExplorer-')) + + let l:found = l:found + 1 + + endif + endif + endif + endif + endwhile + + let &report = l:save_rep + let &showcmd = l:save_sc + + call <SID>DEBUG('HasEligibleBuffers found '.l:found.' eligible buffers of '.l:needed.' needed',6) + + return (l:found >= l:needed) + +endfunction + +" }}} +" Auto Update - Function called by auto commands for auto updating the MBE {{{ +" +" IF auto update is turned on AND +" we are in a real buffer AND +" we have enough eligible buffers THEN +" Update our explorer and get back to the current window +" +" If we get a buffer number for a buffer that +" is being deleted, we need to make sure and +" remove the buffer from the list of eligible +" buffers in case we are down to one eligible +" buffer, in which case we will want to close +" the MBE window. +" +function! <SID>AutoUpdate(delBufNum) + call <SID>DEBUG('===========================',10) + call <SID>DEBUG('Entering AutoUpdate('.a:delBufNum.') : '.bufnr('%').' : '.bufname('%'),10) + call <SID>DEBUG('===========================',10) + + if (g:miniBufExplInAutoUpdate == 1) + call <SID>DEBUG('AutoUpdate recursion stopped',9) + call <SID>DEBUG('===========================',10) + call <SID>DEBUG('Terminated AutoUpdate()' ,10) + call <SID>DEBUG('===========================',10) + return + else + let g:miniBufExplInAutoUpdate = 1 + endif + + " Don't bother autoupdating the MBE window + if (bufname('%') == '-MiniBufExplorer-') + " If this is the only buffer left then toggle the buffer + if (winbufnr(2) == -1) + call <SID>CycleBuffer(1) + call <SID>DEBUG('AutoUpdate does not run for cycled windows', 9) + else + call <SID>DEBUG('AutoUpdate does not run for the MBE window', 9) + endif + + call <SID>DEBUG('===========================',10) + call <SID>DEBUG('Terminated AutoUpdate()' ,10) + call <SID>DEBUG('===========================',10) + + let g:miniBufExplInAutoUpdate = 0 + return + + endif + + if (a:delBufNum != -1) + call <SID>DEBUG('AutoUpdate will make sure that buffer '.a:delBufNum.' is not included in the buffer list.', 5) + endif + + " Only allow updates when the AutoUpdate flag is set + " this allows us to stop updates on startup. + if g:miniBufExplorerAutoUpdate == 1 + " Only show MiniBufExplorer if we have a real buffer + if ((g:miniBufExplorerMoreThanOne == 0) || (bufnr('%') != -1 && bufname('%') != "")) + if <SID>HasEligibleBuffers(a:delBufNum) == 1 + " if we don't have a window then create one + let l:bufnr = <SID>FindWindow('-MiniBufExplorer-', 0) + if (l:bufnr == -1) + call <SID>DEBUG('About to call StartExplorer (Create MBE)', 9) + call <SID>StartExplorer(0, a:delBufNum) + else + " otherwise only update the window if the contents have + " changed + let l:ListChanged = <SID>BuildBufferList(a:delBufNum, 0) + if (l:ListChanged) + call <SID>DEBUG('About to call StartExplorer (Update MBE)', 9) + call <SID>StartExplorer(0, a:delBufNum) + endif + endif + + " go back to the working buffer + if (bufname('%') == '-MiniBufExplorer-') + wincmd p + endif + else + call <SID>DEBUG('Failed in eligible check', 9) + call <SID>StopExplorer(0) + endif + + " VIM sometimes turns syntax highlighting off, + " we can force it on, but this may cause weird + " behavior so this is an optional hack to force + " syntax back on when we enter a buffer + if g:miniBufExplForceSyntaxEnable + call <SID>DEBUG('Enable Syntax', 9) + exec 'syntax enable' + endif + + else + call <SID>DEBUG('No buffers loaded...',9) + endif + else + call <SID>DEBUG('AutoUpdates are turned off, terminating',9) + endif + + call <SID>DEBUG('===========================',10) + call <SID>DEBUG('Completed AutoUpdate()' ,10) + call <SID>DEBUG('===========================',10) + + let g:miniBufExplInAutoUpdate = 0 + +endfunction + +" }}} +" GetSelectedBuffer - From the MBE window, return the bufnum for buf under cursor {{{ +" +" If we are in our explorer window then return the buffer number +" for the buffer under the cursor. +" +function! <SID>GetSelectedBuffer() + call <SID>DEBUG('Entering GetSelectedBuffer()',10) + + " Make sure we are in our window + if bufname('%') != '-MiniBufExplorer-' + call <SID>DEBUG('GetSelectedBuffer called in invalid window',1) + return -1 + endif + + let l:save_reg = @" + let @" = "" + normal ""yi[ + if @" != "" + let l:retv = substitute(@",'\([0-9]*\):.*', '\1', '') + 0 + let @" = l:save_reg + return l:retv + else + let @" = l:save_reg + return -1 + endif + +endfunction + +" }}} +" MBESelectBuffer - From the MBE window, open buffer under the cursor {{{ +" +" If we are in our explorer, then we attempt to open the buffer under the +" cursor in the previous window. +" +function! <SID>MBESelectBuffer() + call <SID>DEBUG('===========================',10) + call <SID>DEBUG('Entering MBESelectBuffer()' ,10) + call <SID>DEBUG('===========================',10) + + " Make sure we are in our window + if bufname('%') != '-MiniBufExplorer-' + call <SID>DEBUG('MBESelectBuffer called in invalid window',1) + return + endif + + let l:save_rep = &report + let l:save_sc = &showcmd + let &report = 10000 + set noshowcmd + + let l:bufnr = <SID>GetSelectedBuffer() + let l:resize = 0 + + if(l:bufnr != -1) " If the buffer exists. + + let l:saveAutoUpdate = g:miniBufExplorerAutoUpdate + let g:miniBufExplorerAutoUpdate = 0 + " Switch to the previous window + wincmd p + + " If we are in the buffer explorer or in a nonmodifiable buffer with + " g:miniBufExplModSelTarget set then try another window (a few times) + if bufname('%') == '-MiniBufExplorer-' || (g:miniBufExplModSelTarget == 1 && getbufvar(bufnr('%'), '&modifiable') == 0) + wincmd w + if bufname('%') == '-MiniBufExplorer-' || (g:miniBufExplModSelTarget == 1 && getbufvar(bufnr('%'), '&modifiable') == 0) + wincmd w + if bufname('%') == '-MiniBufExplorer-' || (g:miniBufExplModSelTarget == 1 && getbufvar(bufnr('%'), '&modifiable') == 0) + wincmd w + " The following handles the case where -MiniBufExplorer- + " is the only window left. We need to resize so we don't + " end up with a 1 or two line buffer. + if bufname('%') == '-MiniBufExplorer-' + let l:resize = 1 + endif + endif + endif + endif + + exec('b! '.l:bufnr) + if (l:resize) + resize + endif + let g:miniBufExplorerAutoUpdate = l:saveAutoUpdate + call <SID>AutoUpdate(-1) + + endif + + let &report = l:save_rep + let &showcmd = l:save_sc + + call <SID>DEBUG('===========================',10) + call <SID>DEBUG('Completed MBESelectBuffer()',10) + call <SID>DEBUG('===========================',10) + +endfunction + +" }}} +" MBEDeleteBuffer - From the MBE window, delete selected buffer from list {{{ +" +" After making sure that we are in our explorer, This will delete the buffer +" under the cursor. If the buffer under the cursor is being displayed in a +" window, this routine will attempt to get different buffers into the +" windows that will be affected so that windows don't get removed. +" +function! <SID>MBEDeleteBuffer() + call <SID>DEBUG('===========================',10) + call <SID>DEBUG('Entering MBEDeleteBuffer()' ,10) + call <SID>DEBUG('===========================',10) + + " Make sure we are in our window + if bufname('%') != '-MiniBufExplorer-' + call <SID>DEBUG('MBEDeleteBuffer called in invalid window',1) + return + endif + + let l:curLine = line('.') + let l:curCol = virtcol('.') + let l:selBuf = <SID>GetSelectedBuffer() + let l:selBufName = bufname(l:selBuf) + + if l:selBufName == 'MiniBufExplorer.DBG' && g:miniBufExplorerDebugLevel > 0 + call <SID>DEBUG('MBEDeleteBuffer will not delete the debug window, when debugging is turned on.',1) + return + endif + + let l:save_rep = &report + let l:save_sc = &showcmd + let &report = 10000 + set noshowcmd + + + if l:selBuf != -1 + + " Don't want auto updates while we are processing a delete + " request. + let l:saveAutoUpdate = g:miniBufExplorerAutoUpdate + let g:miniBufExplorerAutoUpdate = 0 + + " Save previous window so that if we show a buffer after + " deleting. The show will come up in the correct window. + wincmd p + let l:prevWin = winnr() + let l:prevWinBuf = winbufnr(winnr()) + + call <SID>DEBUG('Previous window: '.l:prevWin.' buffer in window: '.l:prevWinBuf,5) + call <SID>DEBUG('Selected buffer is <'.l:selBufName.'>['.l:selBuf.']',5) + + " If buffer is being displayed in a window then + " move window to a different buffer before + " deleting this one. + let l:winNum = (bufwinnr(l:selBufName) + 0) + " while we have windows that contain our buffer + while l:winNum != -1 + call <SID>DEBUG('Buffer '.l:selBuf.' is being displayed in window: '.l:winNum,5) + + " move to window that contains our selected buffer + exec l:winNum.' wincmd w' + + call <SID>DEBUG('We are now in window: '.winnr().' which contains buffer: '.bufnr('%').' and should contain buffer: '.l:selBuf,5) + + let l:origBuf = bufnr('%') + call <SID>CycleBuffer(1) + let l:curBuf = bufnr('%') + + call <SID>DEBUG('Window now contains buffer: '.bufnr('%').' which should not be: '.l:selBuf,5) + + if l:origBuf == l:curBuf + " we wrapped so we are going to have to delete a buffer + " that is in an open window. + let l:winNum = -1 + else + " see if we have anymore windows with our selected buffer + let l:winNum = (bufwinnr(l:selBufName) + 0) + endif + endwhile + + " Attempt to restore previous window + call <SID>DEBUG('Restoring previous window to: '.l:prevWin,5) + exec l:prevWin.' wincmd w' + + " Try to get back to the -MiniBufExplorer- window + let l:winNum = bufwinnr(bufnr('-MiniBufExplorer-')) + if l:winNum != -1 + exec l:winNum.' wincmd w' + call <SID>DEBUG('Got to -MiniBufExplorer- window: '.winnr(),5) + else + call <SID>DEBUG('Unable to get to -MiniBufExplorer- window',1) + endif + + " Delete the buffer selected. + call <SID>DEBUG('About to delete buffer: '.l:selBuf,5) + exec('silent! bd '.l:selBuf) + + let g:miniBufExplorerAutoUpdate = l:saveAutoUpdate + call <SID>DisplayBuffers(-1) + call cursor(l:curLine, l:curCol) + + endif + + let &report = l:save_rep + let &showcmd = l:save_sc + + call <SID>DEBUG('===========================',10) + call <SID>DEBUG('Completed MBEDeleteBuffer()',10) + call <SID>DEBUG('===========================',10) + +endfunction + +" }}} +" MBEClick - Handle mouse double click {{{ +" +function! s:MBEClick() + call <SID>DEBUG('Entering MBEClick()',10) + call <SID>MBESelectBuffer() +endfunction + +" +" MBEDoubleClick - Double click with the mouse. +" +function! s:MBEDoubleClick() + call <SID>DEBUG('Entering MBEDoubleClick()',10) + call <SID>MBESelectBuffer() +endfunction + +" }}} +" CycleBuffer - Cycle Through Buffers {{{ +" +" Move to next or previous buffer in the current window. If there +" are no more modifiable buffers then stay on the current buffer. +" can be called with no parameters in which case the buffers are +" cycled forward. Otherwise a single argument is accepted, if +" it's 0 then the buffers are cycled backwards, otherwise they +" are cycled forward. +" +function! <SID>CycleBuffer(forward) + + " The following hack handles the case where we only have one + " window open and it is too small + let l:saveAutoUpdate = g:miniBufExplorerAutoUpdate + if (winbufnr(2) == -1) + resize + let g:miniBufExplorerAutoUpdate = 0 + endif + + " Change buffer (keeping track of before and after buffers) + let l:origBuf = bufnr('%') + if (a:forward == 1) + bn! + else + bp! + endif + let l:curBuf = bufnr('%') + + " Skip any non-modifiable buffers, but don't cycle forever + " This should stop us from stopping in any of the [Explorers] + while getbufvar(l:curBuf, '&modifiable') == 0 && l:origBuf != l:curBuf + if (a:forward == 1) + bn! + else + bp! + endif + let l:curBuf = bufnr('%') + endwhile + + let g:miniBufExplorerAutoUpdate = l:saveAutoUpdate + if (l:saveAutoUpdate == 1) + call <SID>AutoUpdate(-1) + endif + +endfunction + +" }}} +" DEBUG - Display debug output when debugging is turned on {{{ +" +" Thanks to Charles E. Campbell, Jr. PhD <cec@NgrOyphSon.gPsfAc.nMasa.gov> +" for Decho.vim which was the inspiration for this enhanced debugging +" capability. +" +function! <SID>DEBUG(msg, level) + + if g:miniBufExplorerDebugLevel >= a:level + + " Prevent a report of our actions from showing up. + let l:save_rep = &report + let l:save_sc = &showcmd + let &report = 10000 + set noshowcmd + + " Debug output to a buffer + if g:miniBufExplorerDebugMode == 0 + " Save the current window number so we can come back here + let l:prevWin = winnr() + wincmd p + let l:prevPrevWin = winnr() + wincmd p + + " Get into the debug window or create it if needed + call <SID>FindCreateWindow('MiniBufExplorer.DBG', 1, 0, 0) + + " Make sure we really got to our window, if not we + " will display a confirm dialog and turn debugging + " off so that we won't break things even more. + if bufname('%') != 'MiniBufExplorer.DBG' + call confirm('Error in window debugging code. Dissabling MiniBufExplorer debugging.', 'OK') + let g:miniBufExplorerDebugLevel = 0 + endif + + " Write Message to DBG buffer + let res=append("$",s:debugIndex.':'.a:level.':'.a:msg) + norm G + "set nomodified + + " Return to original window + exec l:prevPrevWin.' wincmd w' + exec l:prevWin.' wincmd w' + " Debug output using VIM's echo facility + elseif g:miniBufExplorerDebugMode == 1 + echo s:debugIndex.':'.a:level.':'.a:msg + " Debug output to a file -- VERY SLOW!!! + " should be OK on UNIX and Win32 (not the 95/98 variants) + elseif g:miniBufExplorerDebugMode == 2 + if has('system') || has('fork') + if has('win32') && !has('win95') + let l:result = system("cmd /c 'echo ".s:debugIndex.':'.a:level.':'.a:msg." >> MiniBufExplorer.DBG'") + endif + if has('unix') + let l:result = system("echo '".s:debugIndex.':'.a:level.':'.a:msg." >> MiniBufExplorer.DBG'") + endif + else + call confirm('Error in file writing version of the debugging code, vim not compiled with system or fork. Dissabling MiniBufExplorer debugging.', 'OK') + let g:miniBufExplorerDebugLevel = 0 + endif + elseif g:miniBufExplorerDebugMode == 3 + let g:miniBufExplorerDebugOutput = g:miniBufExplorerDebugOutput."\n".s:debugIndex.':'.a:level.':'.a:msg + endif + let s:debugIndex = s:debugIndex + 1 + + let &report = l:save_rep + let &showcmd = l:save_sc + + endif + +endfunc " }}} + +" MBE Script History {{{ +"============================================================================= +" +" History: 6.3.2 o For some reason there was still a call to StopExplorer +" with 2 params. Very old bug. I know I fixed before, +" any way many thanks to Jason Mills for reporting this! +" 6.3.1 o Include folds in source so that it's easier to +" navigate. +" o Added g:miniBufExplForceSyntaxEnable setting for folks +" that want a :syntax enable to be called when we enter +" buffers. This can resolve issues caused by a vim bug +" where buffers show up without highlighting when another +" buffer has been closed, quit, wiped or deleted. +" 6.3.0 o Added an option to allow single click (rather than +" the default double click) to select buffers in the +" MBE window. This feature was requested by AW Law +" and was inspired by taglist.vim. Note that you will +" need the latest version of taglist.vim if you want to +" use MBE and taglist both with singleclick turned on. +" Also thanks to AW Law for pointing out that you can +" make an Explorer not be listed in a standard :ls. +" o Added the ability to have your tabs show up in a +" vertical window rather than the standard horizontal +" one. Just let g:miniBufExplVSplit = <width> in your +" .vimrc and your will get this functionality. +" o If you use the vertical explorer and you want it to +" autosize then let g:miniBufExplMaxSize = <max width> +" in your .vimrc. You may use the MinSize letting in +" addition to the MaxLetting if you don't want a super +" thin window. +" o g:miniBufExplMaxHeight was renamed g:miniBufExplMaxSize +" g:miniBufExplMinHeight was renamed g:miniBufExplMinSize +" the old settings are backwards compatible if you don't +" use the new settings, but they are depreciated. +" 6.2.8 o Add an option to stop MBE from targeting non-modifiable +" buffers when switching buffers. Thanks to AW Law for +" the inspiration for this. This may not work if a user +" has lots of explorer/help windows open. +" 6.2.7 o Very minor bug fix for people who want to set +" loaded_minibufexplorer in their .vimrc in order to +" stop MBE from loading. 99.99% of users do not need +" this update. +" 6.2.6 o Moved history to end of source file +" o Updated highlighting documentation +" o Created global commands MBEbn and MBEbp that can be +" used in mappings if folks want to cycle buffers while +" skipping non-eligible buffers. +" 6.2.5 o Added <Leader>mbt key mapping which will toggle +" the MBE window. I map this to F3 in my .vimrc +" with "map <F3> :TMiniBufExplorer<CR>" which +" means I can easily close the MBE window when I'm +" not using it and get it back when I want it. +" o Changed default debug mode to 3 (write to global +" g:miniBufExplorerDebugOutput) +" o Made a pass through the documentation to clarify +" serveral issues and provide more complete docs +" for mappings and commands. +" 6.2.4 o Because of the autocommand switch (see 6.2.0) it +" was possible to remove the restriction on the +" :set hidden option. It is now possible to use +" this option with MBE. +" 6.2.3 o Added miniBufExplTabWrap option. It is turned +" off by default. When turned on spaces are added +" between tabs and gq} is issued to perform line +" formatting. This won't work very well if filenames +" contain spaces. It would be pretty easy to write +" my own formatter, but I'm too lazy, so if someone +" really needs that feature I'll add it :) +" 6.2.2 o Changed the way the g:miniBufExplorerMoreThanOne +" global is handled. You can set this to the number +" of eligible buffers you want to be loaded before +" the MBE window is loaded. Setting it to 0 causes +" the MBE window to be opened even if there are no +" buffers. Setting it to 4 causes the window to stay +" closed until the 4th eligible buffer is loaded. +" o Added a MinHeight option. This is nice if you want +" the MBE window to always take the same amount of +" space. For example set MaxSize and MinSize to 2 +" and set MoreThanOne to 0 and you will always have +" a 2 row (plus the ruler :) MBE window. +" NOTE: in 6.3.0 we started using MinSize instead of +" Minheight. This will still work if MinSize is not +" specified, but it is depreciated. Use MinSize instead. +" o I now setlocal foldcomun=0 and nonumber in the MBE +" window. This is for those of you that like to have +" these options turned on locally. I'm assuming noone +" outthere wants foldcolumns and line numbers in the +" MBE window? :) +" o Fixed a bug where an empty MBE window was taking half +" of the screen (partly why the MinHeight option was +" added.) +" 6.2.1 o If MBE is the only window (because of :bd for example) +" and there are still eligible buffers then one of them +" will be displayed. +" o The <Leader>mbe mapping now highlights the buffer from +" the current window. +" o The delete ('d') binding in the MBE window now restors +" the cursor position, which can help if you want to +" delete several buffers in a row that are not at the +" beginning of the buffer list. +" o Added a new key binding ('p') in the MBE window to +" switch to the previous window (last edit window) +" 6.2.0 o Major overhaul of autocommand and list updating code, +" we now have much better handling of :bd (which is the +" most requested feature.) As well as resolving other +" issues where the buffer list would not be updated +" automatically. The old version tried to trap specific +" events, this one just updates frequently, but it keeps +" track and only changes the screen if there has been +" a change. +" o Added g:miniBufExplMaxHeight variable so you can keep +" the -MiniBufExplorer- window small when you have lots +" of buffers (or buffers with long names :) +" NOTE: in 6.3.0 we started using MaxSize instead of +" MaxHeight. This will still work if MaxSize is not +" specified, but it is depreciated. Use MaxSize instead. +" o Improvement to internal syntax highlighting code +" I renamed the syntax group names. Anyone who has +" figured out how to use them already shouldn't have +" any trouble with the new Nameing :) +" o Added debug mode 3 which writes to a global variable +" this is fast and doesn't mess with the buffer/window +" lists. +" 6.1.0 o <Leader>mbc was failing because I was calling one of +" my own functions with the wrong number of args. :( +" Thanks to Gerry Patterson for finding this! +" This code is very stable (although it has some +" idiocyncracies.) +" 6.0.9 o Double clicking tabs was overwriting the cliboard +" register on MS Windows. Thanks to Shoeb Bhinderwala +" for reporting this issue. +" 6.0.8 o Apparently some VIM builds are having a hard time with +" line continuation in scripts so the few that were here +" have been removed. +" o Generalized FindExplorer and FindCreateExplorer so +" that they can be used for the debug window. Renaming +" to FindWindow and FindCreateWindow. +" o Updated debugging code so that debug output is put into +" a buffer which can then be written to disk or emailed +" to me when someone is having a major issue. Can also +" write directly to a file (VERY SLOWLY) on UNIX or Win32 +" (not 95 or 98 at the moment) or use VIM's echo function +" to display the output to the screen. +" o Several people have had issues when the hidden option +" is turned on. So I have put in several checks to make +" sure folks know this if they try to use MBE with this +" option set. +" 6.0.7 o Handling BufDelete autocmd so that the UI updates +" properly when using :bd (rather than going through +" the MBE UI.) +" o The AutoUpdate code will now close the MBE window when +" there is a single eligible buffer available. +" This has the usefull side effect of stopping the MBE +" window from blocking the VIM session open when you close +" the last buffer. +" o Added functions, commands and maps to close & update +" the MBE window (<leader>mbc and <leader>mbu.) +" o Made MBE open/close state be sticky if set through +" StartExplorer(1) or StopExplorer(1), which are +" called from the standard mappings. So if you close +" the mbe window with \mbc it won't be automatically +" opened again unless you do a \mbe (or restart VIM). +" o Removed spaces between "tabs" (even more mini :) +" o Simplified MBE tab processing +" 6.0.6 o Fixed register overwrite bug found by Sébastien Pierre +" 6.0.5 o Fixed an issue with window sizing when we run out of +" buffers. +" o Fixed some weird commenting bugs. +" o Added more optional fancy window/buffer navigation: +" o You can turn on the capability to use control and the +" arrow keys to move between windows. +" o You can turn on the ability to use <C-TAB> and +" <C-S-TAB> to open the next and previous (respectively) +" buffer in the current window. +" o You can turn on the ability to use <C-TAB> and +" <C-S-TAB> to switch windows (forward and backwards +" respectively.) +" 6.0.4 o Added optional fancy window navigation: +" o Holding down control and pressing a vim direction +" [hjkl] will switch windows in the indicated direction. +" 6.0.3 o Changed buffer name to -MiniBufExplorer- to resolve +" Issue in filename pattern matching on Windows. +" 6.0.2 o 2 Changes requested by Suresh Govindachar: +" o Added SplitToEdge option and set it on by default +" o Added tab and shift-tab mappings in [MBE] window +" 6.0.1 o Added MoreThanOne option and set it on by default +" MiniBufExplorer will not automatically open until +" more than one eligible buffers are opened. This +" reduces cluter when you are only working on a +" single file. +" NOTE: See change log for 6.2.2 for more details about +" this feature +" 6.0.0 o Initial Release on November 20, 2001 +" +"============================================================================= +" }}} +" vim:ft=vim:fdm=marker:ff=unix:nowrap:tabstop=4:shiftwidth=4:softtabstop=4:smarttab:shiftround:expandtab
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/bundle/scratch/plugin/scratch.vim Mon Nov 21 19:53:52 2011 -0800 @@ -0,0 +1,110 @@ +" File: scratch.vim +" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com) +" Version: 1.0 +" Last Modified: June 3, 2003 +" +" Overview +" -------- +" You can use the scratch plugin to create a temporary scratch buffer to store +" and edit text that will be discarded when you quit/exit vim. The contents +" of the scratch buffer are not saved/stored in a file. +" +" Installation +" ------------ +" 1. Copy the scratch.vim plugin to the $HOME/.vim/plugin directory. Refer to +" the following Vim help topics for more information about Vim plugins: +" +" :help add-plugin +" :help add-global-plugin +" :help runtimepath +" +" 2. Restart Vim. +" +" Usage +" ----- +" You can use the following command to open/edit the scratch buffer: +" +" :Scratch +" +" To open the scratch buffer in a new split window, use the following command: +" +" :Sscratch +" +" When you close the scratch buffer window, the buffer will retain the +" contents. You can again edit the scratch buffer by openeing it using one of +" the above commands. There is no need to save the scatch buffer. +" +" When you quit/exit Vim, the contents of the scratch buffer will be lost. +" You will not be prompted to save the contents of the modified scratch +" buffer. +" +" You can have only one scratch buffer open in a single Vim instance. If the +" current buffer has unsaved modifications, then the scratch buffer will be +" opened in a new window +" +" ****************** Do not modify after this line ************************ +if exists('loaded_scratch') || &cp + finish +endif +let loaded_scratch=1 + +" Scratch buffer name +let ScratchBufferName = "__Scratch__" + +" ScratchBufferOpen +" Open the scratch buffer +function! s:ScratchBufferOpen(new_win) + let split_win = a:new_win + + " If the current buffer is modified then open the scratch buffer in a new + " window + if !split_win && &modified + let split_win = 1 + endif + + " Check whether the scratch buffer is already created + let scr_bufnum = bufnr(g:ScratchBufferName) + if scr_bufnum == -1 + " open a new scratch buffer + if split_win + exe "new " . g:ScratchBufferName + else + exe "edit " . g:ScratchBufferName + endif + else + " Scratch buffer is already created. Check whether it is open + " in one of the windows + let scr_winnum = bufwinnr(scr_bufnum) + if scr_winnum != -1 + " Jump to the window which has the scratch buffer if we are not + " already in that window + if winnr() != scr_winnum + exe scr_winnum . "wincmd w" + endif + else + " Create a new scratch buffer + if split_win + exe "split +buffer" . scr_bufnum + else + exe "buffer " . scr_bufnum + endif + endif + endif +endfunction + +" ScratchMarkBuffer +" Mark a buffer as scratch +function! s:ScratchMarkBuffer() + setlocal buftype=nofile + setlocal bufhidden=hide + setlocal noswapfile + setlocal buflisted +endfunction + +autocmd BufNewFile __Scratch__ call s:ScratchMarkBuffer() + +" Command to edit the scratch buffer in the current window +command! -nargs=0 Scratch call s:ScratchBufferOpen(0) +" Command to open the scratch buffer in a new split window +command! -nargs=0 Sscratch call s:ScratchBufferOpen(1) +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/colors/macvim.vim Mon Nov 21 19:53:52 2011 -0800 @@ -0,0 +1,133 @@ +" MacVim colorscheme +" +" Maintainer: Bjorn Winckler <bjorn.winckler@gmail.com> +" Last Change: 2008 May 9 +" +" This is the default MacVim color scheme. It supports both light and dark +" backgrounds (see :h 'background'). +" + + +highlight clear + +" Reset String -> Constant links etc if they were reset +if exists("syntax_on") + syntax reset +endif + +let colors_name = "macvim" + + +" +" First list all groups common to both 'light' and 'dark' background. +" + +" `:he highlight-groups` +hi DiffAdd guibg=MediumSeaGreen +hi Directory guifg=#1600FF +hi ErrorMsg guibg=Firebrick2 guifg=White +hi FoldColumn guibg=Grey guifg=DarkBlue +hi Folded guibg=#E6E6E6 guifg=DarkBlue +hi IncSearch gui=reverse +hi ModeMsg gui=bold +hi MoreMsg gui=bold guifg=SeaGreen4 +hi NonText gui=bold guifg=Blue +hi Pmenu guibg=LightSteelBlue1 +hi PmenuSbar guibg=Grey +hi PmenuSel guifg=White guibg=SkyBlue4 +hi PmenuThumb gui=reverse +hi Question gui=bold guifg=Chartreuse4 +hi SignColumn guibg=Grey guifg=DarkBlue +hi SpecialKey guifg=Blue +hi SpellBad guisp=Firebrick2 gui=undercurl +hi SpellCap guisp=Blue gui=undercurl +hi SpellLocal guisp=DarkCyan gui=undercurl +hi SpellRare guisp=Magenta gui=undercurl +hi StatusLine gui=NONE guifg=White guibg=DarkSlateGray +hi StatusLineNC gui=NONE guifg=SlateGray guibg=Gray90 +hi TabLine gui=underline guibg=LightGrey +hi TabLineFill gui=reverse +hi TabLineSel gui=bold +hi Title gui=bold guifg=DeepSkyBlue3 +hi VertSplit gui=NONE guifg=DarkSlateGray guibg=Gray90 +if has("gui_macvim") + hi Visual guibg=MacSelectedTextBackgroundColor +else + hi Visual guibg=#72F7FF +endif +hi WarningMsg guifg=Firebrick2 + +" Syntax items (`:he group-name` -- more groups are available, these are just +" the top level syntax items for now). +hi Error gui=NONE guifg=White guibg=Firebrick3 +hi Identifier gui=NONE guifg=Aquamarine4 guibg=NONE +hi Ignore gui=NONE guifg=bg guibg=NONE +hi PreProc gui=NONE guifg=DodgerBlue3 guibg=NONE +hi Special gui=NONE guifg=BlueViolet guibg=NONE +hi String gui=NONE guifg=SkyBlue4 guibg=NONE +hi Underlined gui=underline guifg=SteelBlue1 + + +" +" Groups that differ between 'light' and 'dark' background. +" + +if &background == "dark" + hi Boolean gui=NONE guifg=DeepPink4 guibg=NONE + hi Comment gui=italic guifg=CadetBlue3 + hi Constant gui=NONE guifg=Goldenrod1 guibg=NONE + hi Cursor guibg=LightGoldenrod guifg=bg + hi CursorColumn guibg=Gray20 + hi CursorIM guibg=LightSlateGrey guifg=bg + hi CursorLine guibg=Gray20 + hi DiffChange guibg=MediumPurple4 + hi DiffDelete gui=bold guifg=White guibg=SlateBlue + hi DiffText gui=NONE guifg=White guibg=SteelBlue + hi LineNr guifg=#552A7B guibg=Grey5 + hi MatchParen guifg=White guibg=Magenta + hi Normal guifg=Grey50 guibg=Grey10 + hi Search guibg=Blue4 guifg=NONE + hi Statement gui=bold guifg=Purple1 guibg=NONE + hi Todo gui=NONE guifg=Green4 guibg=DeepSkyBlue1 + hi Type gui=bold guifg=Cyan4 guibg=NONE + hi WildMenu guibg=SkyBlue guifg=White + hi lCursor guibg=LightSlateGrey guifg=bg +else + hi Boolean gui=NONE guifg=Red3 guibg=NONE + hi Comment gui=italic guifg=Blue2 guibg=NONE + hi Constant gui=NONE guifg=DarkOrange guibg=NONE + hi Cursor guibg=fg guifg=bg + hi CursorColumn guibg=#F1F5FA + hi CursorIM guibg=fg guifg=bg + hi CursorLine guibg=#F1F5FA + hi DiffChange guibg=DeepSkyBlue + hi DiffDelete gui=bold guifg=Black guibg=SlateBlue + hi DiffText gui=NONE guibg=Gold + hi LineNr guifg=#888888 guibg=#E6E6E6 + hi MatchParen guifg=White guibg=MediumPurple1 + if has("gui_macvim") + hi Normal gui=NONE guifg=MacTextColor guibg=MacTextBackgroundColor + else + hi Normal gui=NONE guifg=Black guibg=White + endif + hi Search guibg=CadetBlue1 guifg=NONE + hi Statement gui=bold guifg=Maroon guibg=NONE + hi Todo gui=NONE guifg=DarkGreen guibg=PaleGreen1 + hi Type gui=bold guifg=Green4 guibg=NONE + hi WildMenu guibg=SkyBlue guifg=Black + hi lCursor guibg=fg guifg=bg +endif + + +" +" Change the selection color on focus change (but only if the "macvim" +" colorscheme is active). +" +if has("gui_macvim") && !exists("s:augroups_defined") + au FocusLost * if exists("colors_name") && colors_name == "macvim" | hi Visual guibg=MacSecondarySelectedControlColor | endif + au FocusGained * if exists("colors_name") && colors_name == "macvim" | hi Visual guibg=MacSelectedTextBackgroundColor | endif + + let s:augroups_defined = 1 +endif + +" vim: sw=2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/colors/miro8.vim Mon Nov 21 19:53:52 2011 -0800 @@ -0,0 +1,115 @@ +" Author: jasonwryan +" URL: http://jasonwryan.com + +set background=dark +hi clear +if exists("syntax on") + syntax reset +endif + +let g:color_name="miro8" + +hi Normal ctermfg=white cterm=bold +hi Ignore ctermfg=black cterm=bold +hi Comment ctermfg=white +hi LineNr ctermfg=black cterm=bold +hi Float ctermfg=yellow +hi Include ctermfg=magenta +hi Define ctermfg=green +hi Macro ctermfg=magenta cterm=bold +hi PreProc ctermfg=green cterm=bold +hi PreCondit ctermfg=magenta cterm=bold +hi NonText ctermfg=cyan +hi Directory ctermfg=cyan +hi SpecialKey ctermfg=yellow cterm=bold +hi Type ctermfg=cyan +hi String ctermfg=green +hi Constant ctermfg=magenta cterm=bold +hi Special ctermfg=green cterm=bold +hi SpecialChar ctermfg=red cterm=bold +hi Number ctermfg=yellow cterm=bold +hi Identifier ctermfg=magenta cterm=bold +hi Conditional ctermfg=cyan cterm=bold +hi Repeat ctermfg=red cterm=bold +hi Statement ctermfg=blue +hi Label ctermfg=magenta cterm=bold +hi Operator ctermfg=yellow +hi Keyword ctermfg=red cterm=bold +hi StorageClass ctermfg=yellow cterm=bold +hi Structure ctermfg=magenta +hi Typedef ctermfg=cyan +hi Function ctermfg=yellow cterm=bold +hi Exception ctermfg=red +hi Underlined ctermfg=blue +hi Title ctermfg=yellow +hi Tag ctermfg=yellow cterm=bold +hi Delimiter ctermfg=blue cterm=bold +hi SpecialComment ctermfg=red cterm=bold +hi Boolean ctermfg=yellow +hi Todo ctermfg=red ctermbg=None cterm=bold +hi MoreMsg ctermfg=magenta ctermbg=None cterm=bold +hi ModeMsg ctermfg=yellow ctermbg=None cterm=bold +hi Debug ctermfg=red ctermbg=None +hi MatchParen ctermfg=black ctermbg=white +hi ErrorMsg ctermfg=red ctermbg=None +hi WildMenu ctermfg=magenta ctermbg=white cterm=bold +hi Folded cterm=reverse ctermfg=cyan ctermbg=black +hi Search ctermfg=red ctermbg=white cterm=bold +hi IncSearch ctermfg=red ctermbg=white +hi WarningMsg ctermfg=red ctermbg=white +hi Question ctermfg=green ctermbg=white cterm=bold +hi Pmenu ctermfg=green ctermbg=white cterm=bold +hi PmenuSel ctermfg=red ctermbg=white +hi Visual ctermfg=black ctermbg=None cterm=bold +hi StatusLine ctermfg=black ctermbg=white +hi StatusLineNC ctermfg=black ctermbg=black cterm=bold + +" Specific for Vim script --- +hi vimCommentTitle ctermfg=green cterm=bold +hi vimFold ctermfg=black ctermbg=white cterm=bold + +" Specific for help files --- +hi helpHyperTextJump ctermfg=yellow cterm=bold + +" JS numbers only --- +hi javaScriptNumber ctermfg=yellow cterm=bold + +" Special for HTML --- +hi htmlTag ctermfg=cyan +hi htmlEndTag ctermfg=cyan +hi htmlTagName ctermfg=yellow cterm=bold + +" Specific for Perl --- +hi perlSharpBang ctermfg=green cterm=bold term=standout +hi perlStatement ctermfg=magenta cterm=bold +hi perlStatementStorage ctermfg=red +hi perlVarPlain ctermfg=yellow +hi perlVarPlain2 ctermfg=yellow cterm=bold + +" Specific for Ruby --- +hi rubySharpBang ctermfg=green cterm=bold term=standout + +" Specific for diff --- +hi diffLine ctermfg=green cterm=bold +hi diffOldLine ctermfg=green +hi diffOldFile ctermfg=green +hi diffNewFile ctermfg=yellow +hi diffAdded ctermfg=blue +hi diffRemoved ctermfg=red +hi diffChanged ctermfg=cyan + +" Spell checking --- +if version >= 700 + hi clear SpellBad + hi clear SpellCap + hi clear SpellRare + hi clear SpellLocal + hi SpellBad cterm=underline + hi SpellCap cterm=underline + hi SpellRare cterm=underline + hi SpellLocal cterm=underline +endif + +"endif + +" vim: foldmethod=marker foldmarker={{{,}}}:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/colors/tolerable.vim Mon Nov 21 19:53:52 2011 -0800 @@ -0,0 +1,43 @@ +" Vim color file +" Maintainer: Ian Langworth +" Last Change: 2004 Dec 24 +" Email: <langworth.com> + +" Color settings inspired by BBEdit for Mac OS, plus I liked +" the low-contrast comments from the 'oceandeep' colorscheme + +set background=light +hi clear +if exists("syntax_on") + syntax reset +endif +let g:colors_name="tolerable" + +hi Cursor guifg=white guibg=darkgreen + +hi Normal gui=none guifg=black guibg=white +hi NonText gui=none guifg=orange guibg=white + +hi Statement gui=none guifg=blue +hi Special gui=none guifg=red +hi Constant gui=none guifg=darkred +hi Comment gui=none guifg=#555555 +hi Preproc gui=none guifg=darkcyan +hi Type gui=none guifg=darkmagenta +hi Identifier gui=none guifg=darkgreen +hi Title gui=none guifg=black + +hi StatusLine gui=none guibg=#333333 guifg=white +hi StatusLineNC gui=none guibg=#333333 guifg=white +hi VertSplit gui=none guibg=#333333 guifg=white + +hi Visual gui=none guibg=green guifg=black +hi Search gui=none guibg=yellow +hi Directory gui=none guifg=darkblue +hi WarningMsg gui=none guifg=red +hi Error gui=none guifg=white guibg=red +hi Todo gui=none guifg=black guibg=yellow + +hi MoreMsg gui=none +hi ModeMsg gui=none +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/vimrc Mon Nov 21 19:53:52 2011 -0800 @@ -0,0 +1,245 @@ +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" +" Ludovic Chabant's ~/.vimrc +" +" http://ludovic.chabant.com +" +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" Use Vim settings, rather then Vi settings (much better!). +" This must be first, because it changes other options as a side effect. +set nocompatible + +" Set some important system-dependent variables. +if has("win32") || has("win64") || has("dos32") + let $HOMEVIM = "vimfiles" + let $PLATFORM = "windows" +else + let $HOMEVIM = ".vim" + let $PLATFORM = "unix" +endif + +" Disable some plugins. +let g:pathogen_disabled = [] +call add(g:pathogen_disabled, 'command-t') + +" Load pathogen. +call pathogen#infect() + +" Hide the toolbar in MacVim/gVIM, and set a nice window size. +if has("gui_running") + set guioptions=-t + set lines=50 + set columns=135 +endif + +" Disable modelines. +set modelines=0 + +" Don't unload abandoned buffers. +set hidden + +" Show line numbers. +set number + +" Show what mode we're in, and what command we're typing. +set showmode +set showcmd + +" Keep the cursor off the top/bottom edges. +set scrolloff=3 + +" Smart auto-indenting. +set autoindent +set smartindent + +" Use confirmation dialog. +set confirm + +" Remember lots of commands. +set history=1000 + +" Use incremental search, with highlighting, +" case-insensitive unless we actually type some +" mixed-case stuff. +set incsearch +set hlsearch +set ignorecase +set smartcase + +" Always show window status lines. +set laststatus=2 + +" Enable using the mouse like some everyday guy. +set mouse=a + +" Show interesting stuff at the bottom of the window. +set showcmd +set ruler + +" Don't pollute the hard-drive with *~ files. Only +" create them in hidden backup/temp directories while +" we edit the file, and then get rid of it. +set nobackup +set writebackup +set backupdir=~/$HOMEVIM/backup +set directory=~/$HOMEVIM/temp + +" Better command-line completion, but don't show some +" stuff we don't care about. +set wildmenu +set wildignore+=.DS_Store,Thumbs.db + +" Always display the tab-page line. +set showtabline=2 + +" Show matching braces. +set showmatch + +" Set the file-formats. +set ffs=unix,mac,dos + +" Tabs and indenting are 4 characters, and tabs behave like +" spaces during editing. They're smart, too, and when you +" press <TAB> it actually inserts a soft-tab so everything's +" indented the same. +set tabstop=4 +set shiftwidth=4 +set softtabstop=4 +set smarttab +set expandtab + +" Default encoding +set encoding=utf-8 + +" Clipboard buffer. +set clipboard=unnamed + +" Smoot terminal experience. +set ttyfast + +" Allow backspacing over anything. +set backspace=indent,eol,start + +" Going left and right let you go to other lines. +set whichwrap+=<,>,h,l + +" And now, for some system-dependent settings: +" - font to use +if $PLATFORM == "windows" + set guifont=Consolas:h12 +else + set guifont=Monaco:h12 +endif + + +" Syntax highlighting +syntax on + +" Change the current directory to the home directory. +cd ~/ + +" Default color scheme +colorscheme peaksea +set background=dark + +" Enable file type detection. +filetype indent plugin on + +" MiniBufExplorer +" Navigate with CTRL+Tab/CTRL+Shift+Tab +let g:miniBufExplMapCTabSwitchBufs = 1 + +" Custom mappings. +let mapleader="\\" +" MiniBufExplorer mappings +map <leader>e :MiniBufExplorer<cr> +" Open NERDtree +map <leader>n :NERDTreeToggle<cr> + +" Temporary stuff +"let mapleader="," " Use , as Leader +"let gmapleader="," +"map Y y$ " Yank to the end of the line w/ Y +"map <leader>nt :tabnew<CR> " New tab w/ ,nt +"map <leader>f :FufFile<CR> " Find files with ,f +"nmap <leader>w :w!<cr> +"map <F3> :r !pbpaste<CR> +"map <F4> :setlocal spell spelllang=en_gb<CR> " Turn on spellcheck with <F4> +"map <F5> :set nospell<CR> +"set pastetoggle=<F6> +"map <F7> :set complete+=k<CR> +"map <S-F7> :set complete=-k<CR> +"map <F8> :YRShow<CR> " Show the YankRing w/ <F8> +"nnoremap <F3> :GundoToggle<CR> " Show the undo tree w/ <F3> +"nnoremap ; : +"autocmd BufRead,BufNewfile ~/notes/* set filetype=markdown " All files in ~/notes are Markdown +"au BufWinLeave *.html,*.css mkview +"au BufWinEnter *.html,*.css silent loadview +"au FileType mail set tw=65 " Thin width when writing mail in mutt +"au FocusLost * :wa " Saves file when vim loses focus +"if has('statusline') " Status line with git repo info +" set statusline=%<%f\ +" set statusline+=%w%h%m%r +" set statusline+=%{fugitive#statusline()} +" set statusline+=\ [%{&ff}/%Y] +" set statusline+=\ [%{getcwd()}] +" set statusline+=%=%-14.(Line:\ %l\ of\ %L\ [%p%%]\ -\ Col:\ %c%V%) +"endif + +" When started as "evim", evim.vim will already have done these settings. +"if v:progname =~? "evim" +" finish +"endif + +" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries +" let &guioptions = substitute(&guioptions, "t", "", "g") + +" Don't use Ex mode, use Q for formatting +"map Q gq + +" This is an alternative that also works in block mode, but the deleted +" text is lost and it only works for putting the current register. +"vnoremap p "_dp + +" Switch syntax highlighting on, when the terminal has colors +" Also switch on highlighting the last used search pattern. +"if &t_Co > 2 || has("gui_running") +" syntax on +" set hlsearch +"endif + +" Only do this part when compiled with support for autocommands. +"if has("autocmd") + + " Enable file type detection. + " Use the default filetype settings, so that mail gets 'tw' set to 72, + " 'cindent' is on in C files, etc. + " Also load indent files, to automatically do language-dependent indenting. +" filetype plugin indent on + + " Put these in an autocmd group, so that we can delete them easily. +" augroup vimrcEx +" au! + + " For all text files set 'textwidth' to 78 characters. +" autocmd FileType text setlocal textwidth=78 + + " When editing a file, always jump to the last known cursor position. + " Don't do it when the position is invalid or when inside an event handler + " (happens when dropping a file on gvim). +" autocmd BufReadPost * +" \ if line("'\"") > 0 && line("'\"") <= line("$") | +" \ exe "normal g`\"" | +" \ endif + +" augroup END + +"else + +" set autoindent " always set autoindenting on + +"endif " has("autocmd") + +"set fileformats=dos,unix " set fileformat to DOS by default +