Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add pathogen and vundle. Start being pep8 compliant.

--HG--
branch : myvim
  • Loading branch information...
commit 6a166b332a5d9b2c5db70116a86d6e9135671a4a 1 parent 048e80b
jeffbuttars authored
1  .hgignore
@@ -3,3 +3,4 @@ swapback
3 3 undos
4 4 view/*
5 5 doc/
  6 +bundle/
54 .vimrc
@@ -289,11 +289,24 @@ vnoremap <silent> # :call VisualSearch('b')<CR>
289 289 set diffopt=filler,vertical,context:15
290 290 let g:html_diff_one_file = 1
291 291
292   -"Use real tabs, 4 spaces
  292 +" Use real tabs, 4 spaces
  293 +" I prefer to use realtabs, but, I'm overruled by spaces.
  294 +" Use this if you want real tabs.
  295 +"<pre>
  296 +" set tabstop=4
  297 +" set shiftwidth=4
  298 +" set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
  299 +" set smarttab
  300 +"</pre>
  301 +
  302 +" A gave in and use spaces instead of real tabs
293 303 set tabstop=4
  304 +set softtabstop=4
294 305 set shiftwidth=4
295   -set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
  306 +set textwidth=80
296 307 set smarttab
  308 +set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
  309 +set expandtab
297 310
298 311 " Show matching braces
299 312 set showmatch
@@ -724,7 +737,7 @@ let g:NiceMenuMin = 1
724 737 "autocmd BufRead *.py set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\
725 738 "%l%.%#,%Z%[%^\ ]%\\@=%m
726 739
727   -let g:maxLineLength=100
  740 +let g:maxLineLength=80
728 741
729 742 " BellyButton settings
730 743 let g:BellyButton_javascript_jslint_options = {'white':'false', 'vars':'true','bitwise':'false',
@@ -739,6 +752,37 @@ let g:sparkupNextMapping = '<c-h>'
739 752
740 753 let g:snips_author = 'Jeff Buttars'
741 754
  755 +" [Pathogen](https://github.com/tpope/vim-pathogen)
  756 +call pathogen#infect()
  757 +
  758 +" [Vundle](https://github.com/gmarik/vundle) Configuration
  759 +"
  760 +"
  761 +" Brief help
  762 +" :BundleList - list configured bundles
  763 +" :BundleInstall(!) - install(update) bundles
  764 +" :BundleSearch(!) foo - search(or refresh cache first) for foo
  765 +" :BundleClean(!) - confirm(or auto-approve) removal of unused
  766 +"
  767 +" see :h vundle for more details or wiki for FAQ
  768 +" NOTE: comments after Bundle command are not allowed..
  769 +"
  770 +" Add vundle to our runtime path (rtp) and start vundle
  771 +"
  772 +set rtp+=~/.vim/bundle/vundle/
  773 +call vundle#rc()
  774 +
  775 +" bundles
  776 +" let Vundle manage Vundle
  777 +" required!
  778 +Bundle 'gmarik/vundle'
  779 +
  780 +" git repos:
  781 +
  782 +" vim-script repos
  783 +
  784 +" non-github repos
  785 +
742 786 "End Plugins and external addons
743 787 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
744 788
@@ -760,4 +804,8 @@ let g:snips_author = 'Jeff Buttars'
760 804 " au WinEnter * setlocal number
761 805 " au WinLeave * setlocal nonumber
762 806
  807 +" For tweaks that don't need to be a plugin but are too verbose
  808 +" for my .vimrc I push them into the hacks.vim file. Calling
  809 +" runtime on the file will make sure it's contents are used
  810 +" when this .vimrc is sourced.
763 811 runtime hacks.vim
245 autoload/pathogen.vim
... ... @@ -0,0 +1,245 @@
  1 +" pathogen.vim - path option manipulation
  2 +" Maintainer: Tim Pope <http://tpo.pe/>
  3 +" Version: 2.0
  4 +
  5 +" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
  6 +"
  7 +" For management of individually installed plugins in ~/.vim/bundle (or
  8 +" ~\vimfiles\bundle), adding `call pathogen#infect()` to your .vimrc
  9 +" prior to `filetype plugin indent on` is the only other setup necessary.
  10 +"
  11 +" The API is documented inline below. For maximum ease of reading,
  12 +" :set foldmethod=marker
  13 +
  14 +if exists("g:loaded_pathogen") || &cp
  15 + finish
  16 +endif
  17 +let g:loaded_pathogen = 1
  18 +
  19 +" Point of entry for basic default usage. Give a directory name to invoke
  20 +" pathogen#runtime_append_all_bundles() (defaults to "bundle"), or a full path
  21 +" to invoke pathogen#runtime_prepend_subdirectories(). Afterwards,
  22 +" pathogen#cycle_filetype() is invoked.
  23 +function! pathogen#infect(...) abort " {{{1
  24 + let source_path = a:0 ? a:1 : 'bundle'
  25 + if source_path =~# '[\\/]'
  26 + call pathogen#runtime_prepend_subdirectories(source_path)
  27 + else
  28 + call pathogen#runtime_append_all_bundles(source_path)
  29 + endif
  30 + call pathogen#cycle_filetype()
  31 +endfunction " }}}1
  32 +
  33 +" Split a path into a list.
  34 +function! pathogen#split(path) abort " {{{1
  35 + if type(a:path) == type([]) | return a:path | endif
  36 + let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
  37 + return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
  38 +endfunction " }}}1
  39 +
  40 +" Convert a list to a path.
  41 +function! pathogen#join(...) abort " {{{1
  42 + if type(a:1) == type(1) && a:1
  43 + let i = 1
  44 + let space = ' '
  45 + else
  46 + let i = 0
  47 + let space = ''
  48 + endif
  49 + let path = ""
  50 + while i < a:0
  51 + if type(a:000[i]) == type([])
  52 + let list = a:000[i]
  53 + let j = 0
  54 + while j < len(list)
  55 + let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
  56 + let path .= ',' . escaped
  57 + let j += 1
  58 + endwhile
  59 + else
  60 + let path .= "," . a:000[i]
  61 + endif
  62 + let i += 1
  63 + endwhile
  64 + return substitute(path,'^,','','')
  65 +endfunction " }}}1
  66 +
  67 +" Convert a list to a path with escaped spaces for 'path', 'tag', etc.
  68 +function! pathogen#legacyjoin(...) abort " {{{1
  69 + return call('pathogen#join',[1] + a:000)
  70 +endfunction " }}}1
  71 +
  72 +" Remove duplicates from a list.
  73 +function! pathogen#uniq(list) abort " {{{1
  74 + let i = 0
  75 + let seen = {}
  76 + while i < len(a:list)
  77 + if (a:list[i] ==# '' && exists('empty')) || has_key(seen,a:list[i])
  78 + call remove(a:list,i)
  79 + elseif a:list[i] ==# ''
  80 + let i += 1
  81 + let empty = 1
  82 + else
  83 + let seen[a:list[i]] = 1
  84 + let i += 1
  85 + endif
  86 + endwhile
  87 + return a:list
  88 +endfunction " }}}1
  89 +
  90 +" \ on Windows unless shellslash is set, / everywhere else.
  91 +function! pathogen#separator() abort " {{{1
  92 + return !exists("+shellslash") || &shellslash ? '/' : '\'
  93 +endfunction " }}}1
  94 +
  95 +" Convenience wrapper around glob() which returns a list.
  96 +function! pathogen#glob(pattern) abort " {{{1
  97 + let files = split(glob(a:pattern),"\n")
  98 + return map(files,'substitute(v:val,"[".pathogen#separator()."/]$","","")')
  99 +endfunction "}}}1
  100 +
  101 +" Like pathogen#glob(), only limit the results to directories.
  102 +function! pathogen#glob_directories(pattern) abort " {{{1
  103 + return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
  104 +endfunction "}}}1
  105 +
  106 +" Turn filetype detection off and back on again if it was already enabled.
  107 +function! pathogen#cycle_filetype() " {{{1
  108 + if exists('g:did_load_filetypes')
  109 + filetype off
  110 + filetype on
  111 + endif
  112 +endfunction " }}}1
  113 +
  114 +" Checks if a bundle is 'disabled'. A bundle is considered 'disabled' if
  115 +" its 'basename()' is included in g:pathogen_disabled[]' or ends in a tilde.
  116 +function! pathogen#is_disabled(path) " {{{1
  117 + if a:path =~# '\~$'
  118 + return 1
  119 + elseif !exists("g:pathogen_disabled")
  120 + return 0
  121 + endif
  122 + let sep = pathogen#separator()
  123 + return index(g:pathogen_disabled, strpart(a:path, strridx(a:path, sep)+1)) != -1
  124 +endfunction "}}}1
  125 +
  126 +" Prepend all subdirectories of path to the rtp, and append all 'after'
  127 +" directories in those subdirectories.
  128 +function! pathogen#runtime_prepend_subdirectories(path) " {{{1
  129 + let sep = pathogen#separator()
  130 + let before = filter(pathogen#glob_directories(a:path.sep."*"), '!pathogen#is_disabled(v:val)')
  131 + let after = filter(pathogen#glob_directories(a:path.sep."*".sep."after"), '!pathogen#is_disabled(v:val[0:-7])')
  132 + let rtp = pathogen#split(&rtp)
  133 + let path = expand(a:path)
  134 + call filter(rtp,'v:val[0:strlen(path)-1] !=# path')
  135 + let &rtp = pathogen#join(pathogen#uniq(before + rtp + after))
  136 + return &rtp
  137 +endfunction " }}}1
  138 +
  139 +" For each directory in rtp, check for a subdirectory named dir. If it
  140 +" exists, add all subdirectories of that subdirectory to the rtp, immediately
  141 +" after the original directory. If no argument is given, 'bundle' is used.
  142 +" Repeated calls with the same arguments are ignored.
  143 +function! pathogen#runtime_append_all_bundles(...) " {{{1
  144 + let sep = pathogen#separator()
  145 + let name = a:0 ? a:1 : 'bundle'
  146 + if "\n".s:done_bundles =~# "\\M\n".name."\n"
  147 + return ""
  148 + endif
  149 + let s:done_bundles .= name . "\n"
  150 + let list = []
  151 + for dir in pathogen#split(&rtp)
  152 + if dir =~# '\<after$'
  153 + let list += filter(pathogen#glob_directories(substitute(dir,'after$',name,'').sep.'*[^~]'.sep.'after'), '!pathogen#is_disabled(v:val[0:-7])') + [dir]
  154 + else
  155 + let list += [dir] + filter(pathogen#glob_directories(dir.sep.name.sep.'*[^~]'), '!pathogen#is_disabled(v:val)')
  156 + endif
  157 + endfor
  158 + let &rtp = pathogen#join(pathogen#uniq(list))
  159 + return 1
  160 +endfunction
  161 +
  162 +let s:done_bundles = ''
  163 +" }}}1
  164 +
  165 +" Invoke :helptags on all non-$VIM doc directories in runtimepath.
  166 +function! pathogen#helptags() " {{{1
  167 + let sep = pathogen#separator()
  168 + for dir in pathogen#split(&rtp)
  169 + 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'))
  170 + helptags `=dir.'/doc'`
  171 + endif
  172 + endfor
  173 +endfunction " }}}1
  174 +
  175 +command! -bar Helptags :call pathogen#helptags()
  176 +
  177 +" Like findfile(), but hardcoded to use the runtimepath.
  178 +function! pathogen#runtime_findfile(file,count) "{{{1
  179 + let rtp = pathogen#join(1,pathogen#split(&rtp))
  180 + return fnamemodify(findfile(a:file,rtp,a:count),':p')
  181 +endfunction " }}}1
  182 +
  183 +" Backport of fnameescape().
  184 +function! pathogen#fnameescape(string) " {{{1
  185 + if exists('*fnameescape')
  186 + return fnameescape(a:string)
  187 + elseif a:string ==# '-'
  188 + return '\-'
  189 + else
  190 + return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','')
  191 + endif
  192 +endfunction " }}}1
  193 +
  194 +function! s:find(count,cmd,file,lcd) " {{{1
  195 + let rtp = pathogen#join(1,pathogen#split(&runtimepath))
  196 + let file = pathogen#runtime_findfile(a:file,a:count)
  197 + if file ==# ''
  198 + return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'"
  199 + elseif a:lcd
  200 + let path = file[0:-strlen(a:file)-2]
  201 + execute 'lcd `=path`'
  202 + return a:cmd.' '.pathogen#fnameescape(a:file)
  203 + else
  204 + return a:cmd.' '.pathogen#fnameescape(file)
  205 + endif
  206 +endfunction " }}}1
  207 +
  208 +function! s:Findcomplete(A,L,P) " {{{1
  209 + let sep = pathogen#separator()
  210 + let cheats = {
  211 + \'a': 'autoload',
  212 + \'d': 'doc',
  213 + \'f': 'ftplugin',
  214 + \'i': 'indent',
  215 + \'p': 'plugin',
  216 + \'s': 'syntax'}
  217 + if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0])
  218 + let request = cheats[a:A[0]].a:A[1:-1]
  219 + else
  220 + let request = a:A
  221 + endif
  222 + let pattern = substitute(request,'\'.sep,'*'.sep,'g').'*'
  223 + let found = {}
  224 + for path in pathogen#split(&runtimepath)
  225 + let path = expand(path, ':p')
  226 + let matches = split(glob(path.sep.pattern),"\n")
  227 + call map(matches,'isdirectory(v:val) ? v:val.sep : v:val')
  228 + call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]')
  229 + for match in matches
  230 + let found[match] = 1
  231 + endfor
  232 + endfor
  233 + return sort(keys(found))
  234 +endfunction " }}}1
  235 +
  236 +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(<count>,'edit<bang>',<q-args>,0)
  237 +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(<count>,'edit<bang>',<q-args>,0)
  238 +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(<count>,'edit<bang>',<q-args>,1)
  239 +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(<count>,'split',<q-args>,<bang>1)
  240 +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(<count>,'vsplit',<q-args>,<bang>1)
  241 +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(<count>,'tabedit',<q-args>,<bang>1)
  242 +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(<count>,'pedit',<q-args>,<bang>1)
  243 +command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(<count>,'read',<q-args>,<bang>1)
  244 +
  245 +" vim:set ft=vim ts=8 sw=2 sts=2:
4 hacks.vim
@@ -91,8 +91,8 @@ function! SetColorColumn( ccol )
91 91 let l:mlist = getmatches()
92 92 if len(l:mlist) < 1 || b:longLineMatchID == 0 || &colorcolumn != (a:ccol+1)
93 93 "echo "SetColorColumn applying" b:longLineMatchID "" a:ccol "\%>".a:ccol."v.\+"
94   - let &colorcolumn = (a:ccol+1)
95   - let &textwidth = (a:ccol)
  94 + let &colorcolumn = (a:ccol)
  95 + let &textwidth = (a:ccol-1)
96 96 let b:longLineMatchID=matchadd( "ErrorMsg", '\%>'.a:ccol.'v.\+', -1 )
97 97 endif
98 98 endfunction
196 indent/python.vim
... ... @@ -0,0 +1,196 @@
  1 +" Python indent file
  2 +" Language: Python
  3 +" Maintainer: Eric Mc Sween <em@tomcom.de>
  4 +" Original Author: David Bustos <bustos@caltech.edu>
  5 +" Last Change: 2004 Jun 07
  6 +
  7 +" Only load this indent file when no other was loaded.
  8 +if exists("b:did_indent")
  9 + finish
  10 +endif
  11 +let b:did_indent = 1
  12 +
  13 +setlocal expandtab
  14 +setlocal nolisp
  15 +setlocal autoindent
  16 +setlocal indentexpr=GetPythonIndent(v:lnum)
  17 +setlocal indentkeys=!^F,o,O,<:>,0),0],0},=elif,=except
  18 +
  19 +let s:maxoff = 50
  20 +
  21 +" Find backwards the closest open parenthesis/bracket/brace.
  22 +function! s:SearchParensPair()
  23 + let line = line('.')
  24 + let col = col('.')
  25 +
  26 + " Skip strings and comments and don't look too far
  27 + let skip = "line('.') < " . (line - s:maxoff) . " ? dummy :" .
  28 + \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? ' .
  29 + \ '"string\\|comment"'
  30 +
  31 + " Search for parentheses
  32 + call cursor(line, col)
  33 + let parlnum = searchpair('(', '', ')', 'bW', skip)
  34 + let parcol = col('.')
  35 +
  36 + " Search for brackets
  37 + call cursor(line, col)
  38 + let par2lnum = searchpair('\[', '', '\]', 'bW', skip)
  39 + let par2col = col('.')
  40 +
  41 + " Search for braces
  42 + call cursor(line, col)
  43 + let par3lnum = searchpair('{', '', '}', 'bW', skip)
  44 + let par3col = col('.')
  45 +
  46 + " Get the closest match
  47 + if par2lnum > parlnum || (par2lnum == parlnum && par2col > parcol)
  48 + let parlnum = par2lnum
  49 + let parcol = par2col
  50 + endif
  51 + if par3lnum > parlnum || (par3lnum == parlnum && par3col > parcol)
  52 + let parlnum = par3lnum
  53 + let parcol = par3col
  54 + endif
  55 +
  56 + " Put the cursor on the match
  57 + if parlnum > 0
  58 + call cursor(parlnum, parcol)
  59 + endif
  60 + return parlnum
  61 +endfunction
  62 +
  63 +" Find the start of a multi-line statement
  64 +function! s:StatementStart(lnum)
  65 + let lnum = a:lnum
  66 + while 1
  67 + if getline(lnum - 1) =~ '\\$'
  68 + let lnum = lnum - 1
  69 + else
  70 + call cursor(lnum, 1)
  71 + let maybe_lnum = s:SearchParensPair()
  72 + if maybe_lnum < 1
  73 + return lnum
  74 + else
  75 + let lnum = maybe_lnum
  76 + endif
  77 + endif
  78 + endwhile
  79 +endfunction
  80 +
  81 +" Find the block starter that matches the current line
  82 +function! s:BlockStarter(lnum, block_start_re)
  83 + let lnum = a:lnum
  84 + let maxindent = 10000 " whatever
  85 + while lnum > 1
  86 + let lnum = prevnonblank(lnum - 1)
  87 + if indent(lnum) < maxindent
  88 + if getline(lnum) =~ a:block_start_re
  89 + return lnum
  90 + else
  91 + let maxindent = indent(lnum)
  92 + " It's not worth going further if we reached the top level
  93 + if maxindent == 0
  94 + return -1
  95 + endif
  96 + endif
  97 + endif
  98 + endwhile
  99 + return -1
  100 +endfunction
  101 +
  102 +function! GetPythonIndent(lnum)
  103 +
  104 + " First line has indent 0
  105 + if a:lnum == 1
  106 + return 0
  107 + endif
  108 +
  109 + " If we can find an open parenthesis/bracket/brace, line up with it.
  110 + call cursor(a:lnum, 1)
  111 + let parlnum = s:SearchParensPair()
  112 + if parlnum > 0
  113 + let parcol = col('.')
  114 + let closing_paren = match(getline(a:lnum), '^\s*[])}]') != -1
  115 + if match(getline(parlnum), '[([{]\s*$', parcol - 1) != -1
  116 + if closing_paren
  117 + return indent(parlnum)
  118 + else
  119 + return indent(parlnum) + &shiftwidth
  120 + endif
  121 + else
  122 + if closing_paren
  123 + return parcol - 1
  124 + else
  125 + return parcol
  126 + endif
  127 + endif
  128 + endif
  129 +
  130 + " Examine this line
  131 + let thisline = getline(a:lnum)
  132 + let thisindent = indent(a:lnum)
  133 +
  134 + " If the line starts with 'elif' or 'else', line up with 'if' or 'elif'
  135 + if thisline =~ '^\s*\(elif\|else\)\>'
  136 + let bslnum = s:BlockStarter(a:lnum, '^\s*\(if\|elif\)\>')
  137 + if bslnum > 0
  138 + return indent(bslnum)
  139 + else
  140 + return -1
  141 + endif
  142 + endif
  143 +
  144 + " If the line starts with 'except' or 'finally', line up with 'try'
  145 + " or 'except'
  146 + if thisline =~ '^\s*\(except\|finally\)\>'
  147 + let bslnum = s:BlockStarter(a:lnum, '^\s*\(try\|except\)\>')
  148 + if bslnum > 0
  149 + return indent(bslnum)
  150 + else
  151 + return -1
  152 + endif
  153 + endif
  154 +
  155 + " Examine previous line
  156 + let plnum = a:lnum - 1
  157 + let pline = getline(plnum)
  158 + let sslnum = s:StatementStart(plnum)
  159 +
  160 + " If the previous line is blank, keep the same indentation
  161 + if pline =~ '^\s*$'
  162 + return -1
  163 + endif
  164 +
  165 + " If this line is explicitly joined, try to find an indentation that looks
  166 + " good.
  167 + if pline =~ '\\$'
  168 + let compound_statement = '^\s*\(if\|while\|for\s.*\sin\|except\)\s*'
  169 + let maybe_indent = matchend(getline(sslnum), compound_statement)
  170 + if maybe_indent != -1
  171 + return maybe_indent
  172 + else
  173 + return indent(sslnum) + &sw * 2
  174 + endif
  175 + endif
  176 +
  177 + " If the previous line ended with a colon, indent relative to
  178 + " statement start.
  179 + if pline =~ ':\s*$'
  180 + return indent(sslnum) + &sw
  181 + endif
  182 +
  183 + " If the previous line was a stop-execution statement or a pass
  184 + if getline(sslnum) =~ '^\s*\(break\|continue\|raise\|return\|pass\)\>'
  185 + " See if the user has already dedented
  186 + if indent(a:lnum) > indent(sslnum) - &sw
  187 + " If not, recommend one dedent
  188 + return indent(sslnum) - &sw
  189 + endif
  190 + " Otherwise, trust the user
  191 + return -1
  192 + endif
  193 +
  194 + " In all other cases, line up with the start of the previous statement.
  195 + return indent(sslnum)
  196 +endfunction

0 comments on commit 6a166b3

Please sign in to comment.
Something went wrong with that request. Please try again.