# HG changeset patch # User Steve Losh # Date 1273529929 14400 # Node ID 739f1bc274bb0e95bc7d15caa5e894aa79b0f818 # Parent 3a5a19f5dd1fa3a86cfd906e7ae2b32d92918084 Add the vim stuff. diff -r 3a5a19f5dd1f -r 739f1bc274bb .hgignore --- a/.hgignore Fri Apr 30 15:28:32 2010 -0400 +++ b/.hgignore Mon May 10 18:18:49 2010 -0400 @@ -2,3 +2,4 @@ .DS_Store *.pyc +.netrwhist diff -r 3a5a19f5dd1f -r 739f1bc274bb .hgsub --- a/.hgsub Fri Apr 30 15:28:32 2010 -0400 +++ b/.hgsub Mon May 10 18:18:49 2010 -0400 @@ -1,1 +1,2 @@ mercurial/templates = ../mercurial-cli-templates +vim/bundle/nerdtree = git+http://github.com/scrooloose/nerdtree.git diff -r 3a5a19f5dd1f -r 739f1bc274bb vim/.gvimrc --- a/vim/.gvimrc Fri Apr 30 15:28:32 2010 -0400 +++ b/vim/.gvimrc Mon May 10 18:18:49 2010 -0400 @@ -1,2 +1,14 @@ -set guifont=Monaco:h11 +set guifont=Menlo:h12 colorscheme molokai + +set go-=T + +if has("gui_macvim") + macmenu &File.New\ Tab key= + map PeepOpen +end + +"Invisible character colors +highlight NonText guifg=#444444 guibg=#1a1c1d +highlight SpecialKey guifg=#444444 guibg=#1a1c1d + diff -r 3a5a19f5dd1f -r 739f1bc274bb vim/.vimrc --- a/vim/.vimrc Fri Apr 30 15:28:32 2010 -0400 +++ b/vim/.vimrc Mon May 10 18:18:49 2010 -0400 @@ -1,25 +1,58 @@ +filetype off +filetype plugin indent on + set nocompatible -set autoindent -set smartindent + +" Tabs/spaces set tabstop=4 set shiftwidth=4 +set softtabstop=4 set expandtab + + +set autoindent +set smartindent + +" Soft/hard wrapping set wrap -set lbr +set textwidth=79 +set formatoptions=qrn1 -set showmatch set ruler set incsearch +set showmatch set backspace=indent,eol,start + +" Use the same symbols as TextMate for tabstops and EOLs +set list +set listchars=tab:▸\ ,eol:¬ + +" Line numbers set nu + +" Highlight search results set hls +" Color scheme (terminal) syntax on set background=dark +colorscheme delek -runtime! autoload/pathogen.vim -if exists('g:loaded_pathogen') - call pathogen#runtime_prepend_subdirectories(expand('~/.vimbundles')) -end +" Use Pathogen to load bundles +call pathogen#runtime_append_all_bundles() + +map :NERDTreeToggle -colorscheme delek +" Use the damn hjkl keys +map +map +map +map + +" Minibufexplorer +let g:miniBufExplMapWindowNavVim = 1 +let g:miniBufExplModSelTarget = 1 + +" Use F1 to fold/unfold +nnoremap za +vnoremap za diff -r 3a5a19f5dd1f -r 739f1bc274bb vim/ftplugin/python.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/ftplugin/python.vim Mon May 10 18:18:49 2010 -0400 @@ -0,0 +1,232 @@ +" Fold routines for python code, version 3.2 +" Source: http://www.vim.org/scripts/script.php?script_id=2527 +" Last Change: 2009 Feb 25 +" Author: Jurjen Bos +" Bug fixes and helpful comments: Grissiom, David Froger, Andrew McNabb + +" Principles: +" - a def/class starts a fold +" a line with indent less than the previous def/class ends a fold +" empty lines and comment lines are linked to the previous fold +" comment lines outside a def/class are never folded +" other lines outside a def/class are folded together as a group +" for algorithm, see bottom of script + +" - optionally, you can get empty lines between folds, see (***) +" - another option is to ignore non-python files see (**) +" - you can also modify the def/class check, +" allowing for multiline def and class definitions see (*) + +" Note for vim 7 users: +" Vim 6 line numbers always take 8 columns, while vim 7 has a numberwidth variable +" you can change the 8 below to &numberwidth if you have vim 7, +" this is only really useful when you plan to use more than 8 columns (i.e. never) + +" Note for masochists trying to read this: +" I wanted to keep the functions short, so I replaced occurences of +" if condition +" statement +" by +" if condition | statement +" wherever I found that useful + +" (*) +" class definitions are supposed to ontain a colon on the same line. +" function definitions are *not* required to have a colon, to allow for multiline defs. +" I you disagree, use instead of the pattern '^\s*\(class\s.*:\|def\s\)' +" to enforce : for defs: '^\s*\(class\|def\)\s.*:' +" you'll have to do this in two places. +let s:defpat = '^\s*\(@\|class\s.*:\|def\s\)' + +" (**) Ignore non-python files +" Commented out because some python files are not recognized by Vim +if &filetype != 'python' + finish +endif + +setlocal foldmethod=expr +setlocal foldexpr=GetPythonFold(v:lnum) +setlocal foldtext=PythonFoldText() + +function! PythonFoldText() + let fs = v:foldstart + while getline(fs) =~ '^\s*@' | let fs = nextnonblank(fs + 1) + endwhile + let line = getline(fs) + let nnum = nextnonblank(fs + 1) + let nextline = getline(nnum) + "get the document string: next line is ''' or """ + if nextline =~ "^\\s\\+[\"']\\{3}\\s*$" + let line = line . " " . matchstr(getline(nextnonblank(nnum + 1)), '^\s*\zs.*\ze$') + "next line starts with qoutes, and has text + elseif nextline =~ "^\\s\\+[\"']\\{1,3}" + let line = line." ".matchstr(nextline, "^\\s\\+[\"']\\{1,3}\\zs.\\{-}\\ze['\"]\\{0,3}$") + elseif nextline =~ '^\s\+pass\s*$' + let line = line . ' pass' + endif + "compute the width of the visible part of the window (see Note above) + let w = winwidth(0) - &foldcolumn - (&number ? 8 : 0) + let size = 1 + v:foldend - v:foldstart + "compute expansion string + let spcs = '................' + while strlen(spcs) < w | let spcs = spcs . spcs + endwhile + "expand tabs (mail me if you have tabstop>10) + let onetab = strpart(' ', 0, &tabstop) + let line = substitute(line, '\t', onetab, 'g') + return strpart(line.spcs, 0, w-strlen(size)-7).'.'.size.' lines' +endfunction + +function! GetBlockIndent(lnum) + " Auxiliary function; determines the indent level of the surrounding def/class + " "global" lines are level 0, first def &shiftwidth, and so on + " scan backwards for class/def that is shallower or equal + let ind = 100 + let p = a:lnum+1 + while indent(p) >= 0 + let p = p - 1 + " skip empty and comment lines + if getline(p) =~ '^$\|^\s*#' | continue + " zero-level regular line + elseif indent(p) == 0 | return 0 + " skip deeper or equal lines + elseif indent(p) >= ind || getline(p) =~ '^$\|^\s*#' | continue + " indent is strictly less at this point: check for def/class + elseif getline(p) =~ s:defpat && getline(p) !~ '^\s*@' + " level is one more than this def/class + return indent(p) + &shiftwidth + endif + " shallower line that is neither class nor def: continue search at new level + let ind = indent(p) + endwhile + "beginning of file + return 0 +endfunction + +" Clever debug code, use as: call PrintIfCount(n,"Line: ".a:lnum.", value: ".x) +let s:counter=0 +function! PrintIfCount(n,t) + "Print text the nth time this function is called + let s:counter = s:counter+1 + if s:counter==a:n | echo a:t + endif +endfunction + +function! GetPythonFold(lnum) + " Determine folding level in Python source (see "higher foldlevel theory" below) + let line = getline(a:lnum) + let ind = indent(a:lnum) + " Case D***: class and def start a fold + " If previous line is @, it is not the first + if line =~ s:defpat && getline(prevnonblank(a:lnum-1)) !~ '^\s*@' + " let's see if this range of 0 or more @'s end in a class/def + let n = a:lnum + while getline(n) =~ '^\s*@' | let n = nextnonblank(n + 1) + endwhile + " yes, we have a match: this is the first of a real def/class with decorators + if getline(n) =~ s:defpat + return ">".(ind/&shiftwidth+1) + endif + " Case E***: empty lines fold with previous + " (***) change '=' to -1 if you want empty lines/comment out of a fold + elseif line == '' && getline(a:lnum-1) == '' | return '-1' + elseif line == '' && getline(a:lnum-1) != '' | return '=' + endif + " now we need the indent from previous + let p = prevnonblank(a:lnum-1) + while p>0 && getline(p) =~ '^\s*#' | let p = prevnonblank(p-1) + endwhile + let pind = indent(p) + " If previous was definition: count as one level deeper + if getline(p) =~ s:defpat && getline(prevnonblank(a:lnum - 1)) !~ '^\s*@' + let pind = pind + &shiftwidth + " if begin of file: take zero + elseif p==0 | let pind = 0 + endif + " Case S*=* and C*=*: indent equal + if ind>0 && ind==pind | return '=' + " Case S*>* and C*>*: indent increase + elseif ind>pind | return '=' + " All cases with 0 indent + elseif ind==0 + " Case C*=0*: separate global code blocks + if pind==0 && line =~ '^#' | return 0 + " Case S*<0* and S*=0*: global code + elseif line !~'^#' + " Case S*<0*: new global statement if/while/for/try/with + if 01' + " Case S*=0*, after level 0 comment + elseif 0==pind && getline(prevnonblank(a:lnum-1)) =~ '^\s*#' | return '>1' + " Case S*=0*, other, stay 1 + else | return '=' + endif + endif + " Case C*<0= and C*<0<: compute next indent + let n = nextnonblank(a:lnum+1) + while n>0 && getline(n) =~'^\s*#' | let n = nextnonblank(n+1) + endwhile + " Case C*<0=: split definitions + if indent(n)==0 | return 0 + " Case C*<0<: shallow comment + else | return -1 + end + endif + " now we really need to compute the actual fold indent + " do the hard computation + let blockindent = GetBlockIndent(a:lnum) + " Case SG<* and CG<*: global code, level 1 + if blockindent==0 | return 1 + endif + " now we need the indent from next + let n = nextnonblank(a:lnum+1) + while n>0 && getline(n) =~'^\s*#' | let n = nextnonblank(n+1) + endwhile + let nind = indent(n) + " Case CR<= and CR<> + "if line !~ '^\s*#' | call PrintIfCount(4,"Line: ".a:lnum.", blockindent: ".blockindent.", n: ".n.", nind: ".nind.", p: ".p.", pind: ".pind) + endif + if line =~ '^\s*#' && ind>=nind | return -1 + " Case CR<<: return next indent + elseif line =~ '^\s*#' | return nind / &shiftwidth + " Case SR<*: return actual indent + else | return blockindent / &shiftwidth + endif +endfunction + +" higher foldlevel theory +" There are five kinds of statements: S (code), D (def/class), E (empty), C (comment) + +" Note that a decorator statement (beginning with @) counts as definition, +" but that of a sequence of @,@,@,def only the first one counts +" This means that a definiion only counts if not preceded by a decorator + +" There are two kinds of folds: R (regular), G (global statements) + +" There are five indent situations with respect to the previous non-emtpy non-comment line: +" > (indent), < (dedent), = (same); < and = combine with 0 (indent is zero) +" Note: if the previous line is class/def, its indent is interpreted as one higher + +" There are three indent situations with respect to the next (non-E non-C) line: +" > (dedent), < (indent), = (same) + +" Situations (in order of the script): +" stat fold prev next +" SDEC RG ><=00 ><= +" D * * * begin fold level if previous is not @: '>'.ind/&sw+1 +" E * * * keep with previous: '=' +" S * = * stays the same: '=' +" C * = * combine with previous: '=' +" S * > * stays the same: '=' +" C * > * combine with previous: '=' +" C * =0 * separate blocks: 0 +" S * <0 * becomes new level 1: >1 (except except/else: 1) +" S * =0 * stays 1: '=' (after level 0 comment: '>1') +" C * <0 = split definitions: 0 +" C * <0 < shallow comment: -1 +" C * <0 > [never occurs] +" S G < * global, not the first: 1 +" C G < * indent isn't 0: 1 +" C R < = foldlevel as computed for next line: -1 +" C R < > foldlevel as computed for next line: -1 +" S R < * compute foldlevel the hard way: use function +" C R < < foldlevel as computed for this line: use function diff -r 3a5a19f5dd1f -r 739f1bc274bb vim/plugin/minibufexpl.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/plugin/minibufexpl.vim Mon May 10 18:18:49 2010 -0400 @@ -0,0 +1,1838 @@ +" Mini Buffer Explorer +" +" 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 +" 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 +" +" mbe - Opens MiniBufExplorer +" +" or you may want to add something like the following +" key mapping to your _vimrc/.vimrc file. +" +" map b :MiniBufExplorer +" +" However, in most cases you won't need any key-bindings at all. +" +" is usually backslash so type "\mbe" (quickly) to open +" the -MiniBufExplorer- window. +" +" Other keymappings include: mbc to close the Explorer +" window, mbu to force the Explorer to Update and +" 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 mbe above.) +" +" You can map these additional commands as follows: +" +" map c :CMiniBufExplorer +" map u :UMiniBufExplorer +" map t :TMiniBufExplorer +" +" 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 = +" +" 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 = +" +" 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 = +" +" 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 = +" +" 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 and 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 and 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 [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('MiniBufExplorer') + map mbe MiniBufExplorer +endif +if !hasmapto('CMiniBufExplorer') + map mbc CMiniBufExplorer +endif +if !hasmapto('UMiniBufExplorer') + map mbu UMiniBufExplorer +endif +if !hasmapto('TMiniBufExplorer') + map mbt TMiniBufExplorer +endif + +" }}} +" MBE