From 6411a284c5419bd80d3805e1269f18cfc69243cd Mon Sep 17 00:00:00 2001 From: Jon Franklin Date: Sat, 17 May 2008 00:00:00 +0000 Subject: [PATCH] Version 1.12 * Changed to ftplugin and renamed to avoid collision with vim's ftplugin/python.vim. Patch provided by Christopher Lambacher * Fixed error opening python buffer with no classes or functions. Patch provided by Chris Farrow * Removed duplicate ]f key *Fixed block manipulation bugs due to collision on ]], [[ mappings. See menu for new mappings --- plugin/{python.vim => python_fn.vim} | 56 ++++++++++++++++------------ 1 file changed, 32 insertions(+), 24 deletions(-) rename plugin/{python.vim => python_fn.vim} (91%) diff --git a/plugin/python.vim b/plugin/python_fn.vim similarity index 91% rename from plugin/python.vim rename to plugin/python_fn.vim index a2e104b..fbdd003 100644 --- a/plugin/python.vim +++ b/plugin/python_fn.vim @@ -1,13 +1,17 @@ " -*- vim -*- " FILE: python.vim -" LAST MODIFICATION: 2006-11-29 4:09pm +" LAST MODIFICATION: 2008-05-17 6:29pm " (C) Copyright 2001-2005 Mikael Berthe -" Version: 1.11 +" Maintained by Jon Franklin +" Version: 1.12 " USAGE: " -" Just source this script when editing Python files. -" Example: au FileType python source ~me/.vim/scripts/python.vim +" Save this file to $VIMFILES/ftplugin/python.vim. You can have multiple +" python ftplugins by creating $VIMFILES/ftplugin/python and saving your +" ftplugins in that directory. If saving this to the global ftplugin +" directory, this is the recommended method, since vim ships with an +" ftplugin/python.vim file already. " You can set the global variable "g:py_select_leading_comments" to 0 " if you don't want to select comments preceding a declaration (these " are usually the description of the function/class). @@ -23,28 +27,33 @@ " vim (>= 7) " " Shortcuts: -" [[ -- Jump to beginning of block -" ]] -- Jump to end of block +" ]t -- Jump to beginning of block +" ]e -- Jump to end of block " ]v -- Select (Visual Line Mode) block " ]< -- Shift block to left " ]> -- Shift block to right " ]# -- Comment selection " ]u -- Uncomment selection " ]c -- Select current/previous class -" ]f -- Select current/previous function +" ]d -- Select current/previous function " ] -- Jump to previous line with the same/lower indentation " ] -- Jump to next line with the same/lower indentation +" Only do this when not done yet for this buffer +if exists("b:loaded_py_ftplugin") + finish +endif +let b:loaded_py_ftplugin = 1 -map [[ :PBoB -vmap [[ :PBoBm'gv`` -map ]] :PEoB -vmap ]] :PEoBm'gv`` +map ]t :PBoB +vmap ]t :PBOBm'gv`` +map ]e :PEoB +vmap ]e :PEoBm'gv`` -map ]v [[V]] -map ]< [[V]]< +map ]v ]tV]e +map ]< ]tV]e< vmap ]< < -map ]> [[V]]> +map ]> ]tV]e> vmap ]> > map ]# :call PythonCommentSelection() @@ -53,7 +62,7 @@ map ]u :call PythonUncommentSelection() vmap ]u :call PythonUncommentSelection() map ]c :call PythonSelectObject("class") -map ]f :call PythonSelectObject("function") +map ]d :call PythonSelectObject("function") map ] :call PythonNextLine(-1) map ] :call PythonNextLine(1) @@ -81,10 +90,10 @@ vmap ]f :call PythonDec("function", 1) nmenu &Python.Update\ IM-Python\ Menu \:call UpdateMenu() nmenu &Python.-Sep1- : -nmenu &Python.Beginning\ of\ Block[[ - \[[ -nmenu &Python.End\ of\ Block]] - \]] +nmenu &Python.Beginning\ of\ Block[t + \]t +nmenu &Python.End\ of\ Block]e + \]e nmenu &Python.-Sep2- : nmenu &Python.Shift\ Block\ Left]< \]< @@ -115,8 +124,8 @@ nmenu &Python.Next\ Function]f nmenu &Python.-Sep5- : nmenu &Python.Select\ Block]v \]v -nmenu &Python.Select\ Function]f - \]f +nmenu &Python.Select\ Function]d + \]d nmenu &Python.Select\ Class]c \]c nmenu &Python.-Sep6- : @@ -125,7 +134,6 @@ nmenu &Python.Previous\ Line\ wrt\ indent] nmenu &Python.Next\ Line\ wrt\ indent] \] - :com! PBoB execute "normal ".PythonBoB(line('.'), -1, 1)."G" :com! PEoB execute "normal ".PythonBoB(line('.'), 1, 1)."G" :com! UpdateMenu call UpdateMenu() @@ -309,8 +317,6 @@ function! UpdateMenu() " all buffers currently open, and group classes and functions by buffer if exists("g:menuran") aunmenu IM-Python - else - let g:menuran=1 endif let restore_fe = &foldenable set nofoldenable @@ -349,6 +355,8 @@ function! MenuBuilder() else " this is a function call AddFunction(objname, linenum, parentclass) endif + " We actually created a menu, so lets set the global variable + let g:menuran=1 call RebuildClassList(classlist, [objname, indentcol], classordef) endif " line matched norm j