e93c240fe42c

Moar.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Fri, 17 Jun 2011 10:19:17 -0400
parents 28dc966cf3f0
children 7eae993ccc65
branches/tags (none)
files .hgsubstate hgignore vim/.vimrc vim/ftplugin/python/folding.vim

Changes

--- a/.hgsubstate	Fri Jun 17 10:18:58 2011 -0400
+++ b/.hgsubstate	Fri Jun 17 10:19:17 2011 -0400
@@ -17,4 +17,4 @@
 4995b244e11d5aaa9956bba061c32140e6af8705 vim/bundle/threesome
 b9b4407a19acc4eb344cca0cc5beea75e9ff5491 vim/bundle/vim-coffee-script
 c2df2e430d7d5fe645aa40e36079ab51f082e06b vim/bundle/vim-javascript
-3d1692f635579e718b85dd8f24ac7fbd52a444f6 vim/bundle/vim-orgmode
+24c00fcb00145bd283fc6d2b4494ab02a46941f6 vim/bundle/vim-orgmode
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgignore	Fri Jun 17 10:19:17 2011 -0400
@@ -0,0 +1,5 @@
+syntax: glob
+
+.DS_Store
+*.pyc
+tags
--- a/vim/.vimrc	Fri Jun 17 10:18:58 2011 -0400
+++ b/vim/.vimrc	Fri Jun 17 10:19:17 2011 -0400
@@ -641,10 +641,12 @@
 
 if len( swanks ) == 0
     " Try to find SWANK in the standard SLIME installation locations
-    if g:slimv_windows || g:slimv_cygwin
-        let swanks = split( globpath( 'c:/slime/,c:/*lisp*/slime/,c:/*lisp*/site/lisp/slime/,c:/Program Files/*lisp*/site/lisp/slime/', 'start-swank.lisp' ), '\n' )
-    else
-        let swanks = split( globpath( '/usr/share/common-lisp/source/slime/', 'start-swank.lisp' ), '\n' )
+    if exists('g:slimv_windows')
+        if g:slimv_windows || g:slimv_cygwin
+            let swanks = split( globpath( 'c:/slime/,c:/*lisp*/slime/,c:/*lisp*/site/lisp/slime/,c:/Program Files/*lisp*/site/lisp/slime/', 'start-swank.lisp' ), '\n' )
+        else
+            let swanks = split( globpath( '/usr/share/common-lisp/source/slime/', 'start-swank.lisp' ), '\n' )
+        endif
     endif
 endif
 
--- a/vim/ftplugin/python/folding.vim	Fri Jun 17 10:18:58 2011 -0400
+++ b/vim/ftplugin/python/folding.vim	Fri Jun 17 10:19:17 2011 -0400
@@ -47,6 +47,8 @@
 setlocal foldmethod=expr
 setlocal foldexpr=GetPythonFold(v:lnum)
 setlocal foldtext=PythonFoldText()
+nnoremap <buffer> <localleader>D :setlocal foldtext=PythonFoldTextDocstrings()<cr>
+nnoremap <buffer> <localleader>d :setlocal foldtext=PythonFoldText()<cr>
 
 function! PythonFoldText()
     " ignore decorators
@@ -68,6 +70,33 @@
     return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' '
 endfunction
 
+function! PythonFoldTextDocstrings()
+    " ignore decorators
+    let fs = v:foldstart
+    while getline(fs) =~ '^\s*@' | let fs = nextnonblank(fs + 1)
+    endwhile
+
+    " add docstrings
+    let line = getline(fs)
+    if getline(fs + 1) =~ '^\s*"""'
+        let line = line . "  (" . getline(fs + 1) . ")"
+        let line = substitute(line, '\s*"""', '', 'g')
+        let line = substitute(line, '"""', '', 'g')
+    endif
+
+    let nucolwidth = &fdc + &number * &numberwidth
+    let windowwidth = winwidth(0) - nucolwidth - 3
+    let foldedlinecount = v:foldend - v:foldstart
+
+    " expand tabs into spaces
+    let onetab = strpart('          ', 0, &tabstop)
+    let line = substitute(line, '\t', onetab, 'g')
+
+    let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
+    let fillcharcount = windowwidth - len(line) - len(foldedlinecount)
+    return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' '
+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