summaryrefslogtreecommitdiff
path: root/.vim/ftplugin
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2009-10-07 17:05:19 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2009-10-07 17:05:19 +0200
commitdd5427baaf49f8de4355abeb6bc8c6dd14f74e25 (patch)
tree46fcfc70bd792e80ceebaab89a7f8fc06bc29101 /.vim/ftplugin
downloaddotfiles-dd5427baaf49f8de4355abeb6bc8c6dd14f74e25.tar.gz
dotfiles-dd5427baaf49f8de4355abeb6bc8c6dd14f74e25.tar.bz2
dotfiles-dd5427baaf49f8de4355abeb6bc8c6dd14f74e25.zip
Initial check-in of files
Diffstat (limited to '')
-rw-r--r--.vim/ftplugin/java/CTree.vim240
-rw-r--r--.vim/ftplugin/java/java.vim84
-rw-r--r--.vim/ftplugin/java/java_getset.vim871
-rw-r--r--.vim/ftplugin/python_fn.vim446
-rw-r--r--.vim/ftplugin/tex.vim10
5 files changed, 1651 insertions, 0 deletions
diff --git a/.vim/ftplugin/java/CTree.vim b/.vim/ftplugin/java/CTree.vim
new file mode 100644
index 0000000..a67fdbc
--- /dev/null
+++ b/.vim/ftplugin/java/CTree.vim
@@ -0,0 +1,240 @@
+" -------------------------------------------------------------------
+" CTree.vim -- Display Class/Interface Hierarchy "{{{
+"
+" Author: Yanbiao Zhao (yanbiao_zhao at yahoo.com)
+" Requires: Vim 7
+" Version: 1.1.2
+"
+" Command:
+" CTree -- Display a tree of Class/Interface hierarchy
+" CTag -- Jump to the class/interface definition of the tag
+" }}}
+
+if v:version < 700
+ echomsg "Vim 7 or higher is required for CTree.vim"
+ finish
+endif
+
+command! -nargs=1 -complete=tag CTree call s:CTree_GetTypeTree(<f-args>)
+command! -nargs=1 -complete=tag CTag call s:CT_Jump_To_ClassName(<f-args>)
+
+"Short cut to use the commands
+"nmap <silent> <M-F9> :exec "CTree ".expand("<cword>")<CR>
+"nmap <silent> <M-]> :exec "CTag ".expand("<cword>")<CR>
+
+function! s:CT_Jump_To_ClassName(className)
+ let tagEntry = {}
+ let tagEntry["name"] = a:className
+ if s:CT_Jump_To_Class(tagEntry)== 0
+ echohl WarningMsg | echo 'tag not found: '.a:className | echohl None
+ endif
+endfunction
+
+let s:CTree_AllTypeEntries = []
+let s:CTree_TagEnvCache = ''
+let s:CTree_tagFilesCache = {}
+
+function! s:CTree_GetTypeTree(typeName)
+ call s:CTree_LoadAllTypeEntries()
+
+ let rootEntry = s:CTree_GetRootType(a:typeName, '')
+
+ if empty(rootEntry)
+ let rootEntry["name"] = a:typeName
+ let rootEntry["namespace"] = ""
+ let rootEntry["kind"] = 'c'
+ let rootEntry["inherits"] = ""
+ endif
+
+ echohl Title | echo ' # tag' | echohl None
+
+ let allEntries = []
+ call s:CTree_GetChildren(allEntries, rootEntry, 0)
+
+ let i = input('Choice number (<Enter> cancels):')
+ let i = str2nr(i)
+ if i > 0 && i <= len(allEntries)
+ call s:CT_Jump_To_Class(allEntries[i-1])
+ endif
+endfunction
+
+function! s:CTree_GetChildren(allEntries, rootEntry, depth)
+ call add(a:allEntries, a:rootEntry)
+ call s:CTree_DisplayTagEntry(len(a:allEntries), a:rootEntry, a:depth)
+
+ let children = []
+ let rootTypeName = a:rootEntry["name"]
+ for tagEntry in s:CTree_AllTypeEntries
+ if index(split(tagEntry["inherits"], ","), rootTypeName) >= 0
+ call add(children, tagEntry)
+ endif
+ endfor
+
+ let rootKind = a:rootEntry["kind"]
+ for child in children
+ "We only want to display class that implement an interface directly
+ if child["kind"] == 'c' && rootKind == 'i'
+ call add(a:allEntries, child)
+ call s:CTree_DisplayTagEntry(len(a:allEntries), child, a:depth+1)
+ else
+ call s:CTree_GetChildren(a:allEntries, child, a:depth+1)
+ endif
+ endfor
+
+endfunction
+
+" Return if a tag file has changed in tagfiles()
+function! s:HasTagFileChanged()
+ let result = 0
+ let tagFiles = map(tagfiles(), 'escape(v:val, " ")')
+ let newTagFilesCache = {}
+
+ if len(tagFiles) != len(s:CTree_tagFilesCache)
+ let result = 1
+ endif
+
+ for tagFile in tagFiles
+ let currentFiletime = getftime(tagFile)
+ let newTagFilesCache[tagFile] = currentFiletime
+
+ if !has_key(s:CTree_tagFilesCache, tagFile)
+ let result = 1
+ elseif currentFiletime != s:CTree_tagFilesCache[tagFile]
+ let result = 1
+ endif
+ endfor
+
+ let s:CTree_tagFilesCache = newTagFilesCache
+ return result
+endfunc
+
+function! s:CTree_LoadAllTypeEntries()
+ if s:HasTagFileChanged()
+ let s:CTree_AllTypeEntries = []
+ else
+ return
+ endif
+
+ echo 'Loading tag information. It may take a while...'
+ let ch = 'A'
+ while ch <= 'Z'
+ call s:CTree_GetTypeEntryWithCh(ch)
+ let ch = nr2char(char2nr(ch)+1)
+ endwhile
+
+ call s:CTree_GetTypeEntryWithCh('_')
+
+ let ch = 'a'
+ while ch <= 'z'
+ call s:CTree_GetTypeEntryWithCh(ch)
+ let ch = nr2char(char2nr(ch)+1)
+ endwhile
+
+ echo "Count of type tag entries loaded: ".len(s:CTree_AllTypeEntries)
+endfunction
+
+function! s:CTree_GetTypeEntryWithCh(ch)
+ for tagEntry in taglist('^'.a:ch)
+ let kind = tagEntry["kind"]
+ if (kind == 'i' || kind == 'c') && has_key(tagEntry, "inherits")
+ call add(s:CTree_AllTypeEntries, tagEntry)
+ endif
+ endfor
+endfunction
+
+function! s:CTree_GetRootType(typeName, originalKind)
+ for tagEntry in taglist("^".a:typeName."$")
+
+ let kind = tagEntry["kind"]
+ if kind != 'c' && kind != 'i'
+ continue
+ endif
+
+ let originalKind = a:originalKind
+ if originalKind == ''
+ let originalKind = kind
+ elseif originalKind != tagEntry["kind"]
+ "We will not accept interface as a parent of class
+ return {}
+ endif
+
+ if !has_key(tagEntry, "inherits")
+ return tagEntry
+ endif
+
+ "interface support multiple inheritance, so we will not try to get its
+ "parent if it has more than one parent
+ let parents = split(tagEntry["inherits"], ",")
+ if originalKind == 'i' && len(parents) > 1
+ return tagEntry
+ endif
+
+ for parent in parents
+ let rootEntry = s:CTree_GetRootType(parent, originalKind)
+
+ if !empty(rootEntry)
+ return rootEntry
+ endif
+ endfor
+
+ return tagEntry
+ endfor
+
+ return {}
+endfunction
+
+function! s:CTree_DisplayTagEntry(index, typeEntry, depth)
+ let s = string(a:index)
+ while strlen(s) < 4
+ let s = ' '.s
+ endwhile
+
+ let s = s." "
+ let i = 0
+ while i < a:depth
+ let s = s." "
+ let i = i + 1
+ endwhile
+
+ let s = s.a:typeEntry["name"]
+
+ if has_key(a:typeEntry, "namespace")
+ let s = s.' ['.a:typeEntry["namespace"].']'
+ elseif has_key(a:typeEntry, "class")
+ let s = s.' <'.a:typeEntry["class"].'>'
+ endif
+
+ echo s
+endfunction
+
+function! s:CT_Jump_To_Class(tagEntry)
+ let className = a:tagEntry["name"]
+
+ if has_key(a:tagEntry, "namespace")
+ let keyName = "namespace"
+ elseif has_key(a:tagEntry, "class")
+ let keyName = "class"
+ else
+ let keyName = ""
+ endif
+
+ if keyName == ""
+ let namespace = ""
+ else
+ let namespace = a:tagEntry[keyName]
+ endif
+
+ let i = 1
+ let entries = taglist('^'.className.'$')
+ for entry in entries
+ let kind = entry["kind"]
+ if kind == 'c' || kind == 'i' || kind == 'g'
+ if namespace == "" || namespace == entry[keyName]
+ exec "silent ".i."tag ".className
+ return 1
+ endif
+ endif
+ let i += 1
+ endfor
+ return 0
+endfunction
diff --git a/.vim/ftplugin/java/java.vim b/.vim/ftplugin/java/java.vim
new file mode 100644
index 0000000..e442356
--- /dev/null
+++ b/.vim/ftplugin/java/java.vim
@@ -0,0 +1,84 @@
+
+" Editing settings
+"set tabstop=4 shiftwidth=4 expandtab textwidth=90
+
+" Syntax highlighting settings.
+"let g:java_allow_cpp_keywords=1
+"syntax on
+
+" Comma (,) prefixes a KEYWORD abbreviation
+inoremap <buffer> ,c class
+inoremap <buffer> ,i interface
+inoremap <buffer> ,I implements
+inoremap <buffer> ,m import
+inoremap <buffer> ,f final
+inoremap <buffer> ,s static
+inoremap <buffer> ,y synchronized
+inoremap <buffer> ,e extends
+inoremap <buffer> ,p public
+inoremap <buffer> ,P private
+inoremap <buffer> ,o protected
+inoremap <buffer> ,f final
+inoremap <buffer> ,s static
+inoremap <buffer> ,y synchronized
+inoremap <buffer> ,a package
+
+" Colon (:) prefixes a FLOW abbreviation
+
+inoremap <buffer> :f for
+inoremap <buffer> :w while
+inoremap <buffer> :s switch
+inoremap <buffer> :C case
+inoremap <buffer> :b break
+inoremap <buffer> :d default
+inoremap <buffer> :i if
+inoremap <buffer> :r return
+inoremap <buffer> :t try
+inoremap <buffer> :c catch
+inoremap <buffer> :f finally
+inoremap <buffer> :T throws
+inoremap <buffer> :R throw
+
+" CTRL + T (^T) prefixes a TYPE abbreviation
+
+inoremap <buffer> <C-T>i int
+inoremap <buffer> <C-T>I Integer
+inoremap <buffer> <C-T>l long
+inoremap <buffer> <C-T>L Long
+inoremap <buffer> <C-T>b boolean
+inoremap <buffer> <C-T>B Boolean
+inoremap <buffer> <C-T>c char
+inoremap <buffer> <C-T>C Char
+inoremap <buffer> <C-T>d Double
+inoremap <buffer> <C-T>D Double
+inoremap <buffer> <C-T>v void
+inoremap <buffer> <C-T>V Void
+inoremap <buffer> <C-T>s String
+inoremap <buffer> <C-T>S String
+inoremap <buffer> <C-T>e Exception
+inoremap <buffer> <C-T>E Exception
+
+" CTRL + Underscore (_) prefixes a GENERAL abbreviation
+
+inoremap <buffer> <C-_>m public static void main(String args[])
+inoremap <buffer> <C-_>o System.out.println(X);<Esc>FXs
+inoremap <buffer> <C-_>e System.err.println(X);<Esc>FXs
+inoremap <buffer> <C-_>t true
+inoremap <buffer> <C-_>f false
+inoremap <buffer> <C-_>E e.printStackTrace();
+inoremap <buffer> <C-_>C <C-V><code>
+inoremap <buffer> <C-_>c <C-V></code>
+
+" Helpful mappings when creating a new object
+" Type: Object o<F2>
+" Get: Object o = new Object();
+" F3 leaves the cursor between the parentheses.
+inoremap <buffer> <F2> <C-O>A = new <Esc>^yE<End>pA();<CR>
+inoremap <buffer> <F3> <C-O>A = new <Esc>^yE<End>pA();<Left><Left>
+
+" To create a javadoc comment above the current line
+nnoremap Zc O/**<CR><BS>*<CR>*/<Up><Space>
+
+" Useful when editing javadoc comments
+nnoremap ZR :se formatoptions+=ro<CR>
+nnoremap Zr :se formatoptions-=ro<CR>
diff --git a/.vim/ftplugin/java/java_getset.vim b/.vim/ftplugin/java/java_getset.vim
new file mode 100644
index 0000000..6a906e9
--- /dev/null
+++ b/.vim/ftplugin/java/java_getset.vim
@@ -0,0 +1,871 @@
+" Vim filetype plugin file for adding getter/setter methods
+" Language: Java
+" Maintainer: Pete Kazmier (pete-vim AT kazmier DOT com)
+" Last Change: 2002 Nov 21
+" Revision: $Id: java_getset.vim,v 1.10 2002/12/02 15:14:31 kaz Exp $
+" Credit:
+" - Based on jcommenter.vim by Kalle Björklid <bjorklid@st.jyu.fi.
+" - Thanks to Dan Sharp for his feedback, suggestions and help.
+" - Thanks to Steven Op de beeck for his feedback and help.
+"
+" =======================================================================
+"
+" Copyright 2002 by Peter Kazmier
+"
+" Redistribution and use in source and binary forms, with or without
+" modification, are permitted provided that the following conditions
+" are met:
+"
+" 1. Redistributions of source code must retain the above copyright
+" notice, this list of conditions and the following disclaimer.
+"
+" 2. Redistributions in binary form must reproduce the above
+" copyright notice, this list of conditions and the following
+" disclaimer in the documentation and/or other materials provided
+" with the distribution.
+"
+" 3. The name of the author may not be used to endorse or promote
+" products derived from this software without specific prior
+" written permission.
+"
+" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+"
+" =======================================================================
+"
+" DESCRIPTION
+" This filetype plugin enables a user to automatically add getter/setter
+" methods for Java properties. The script will insert a getter, setter,
+" or both depending on the command/mapping invoked. Users can select
+" properties one at a time, or in bulk (via a visual block or specifying a
+" range). In either case, the selected block may include comments as they
+" will be ignored during the parsing. For example, you could select all
+" of these properties with a single visual block.
+"
+" public class Test
+" {
+" // The global count
+" private static int count;
+"
+" /** The name */
+" private String name;
+"
+" /** The array of addresses */
+" private String[] address;
+" }
+"
+" The script will also add the 'static' modifier to the method if the
+" property was declared as 'static'. Array-based properties will get
+" additional methods added to support indexing. In addition, if a
+" property is declared 'final', it will not generate a setter for it.
+" If a previous getter OR setter exists for a property, the script will
+" not add any methods (under the assumption that you've manually added
+" your own).
+"
+" The getters/setters that are inserted can be configured by the user.
+" First, the insertion point can be selected. It can be one of the
+" following: before the current line / block, after the current line /
+" block, or at the end of the class (default). Finally, the text that is
+" inserted can be configured by defining your own templates. This allows
+" the user to format for his/her coding style. For example, the default
+" value for s:javagetset_getterTemplate is:
+"
+" /**
+" * Get %varname%.
+" *
+" * @return %varname% as %type%.
+" */
+" %modifiers% %type% %funcname%()
+" {
+" return %varname%;
+" }
+"
+" Where the items surrounded by % are parameters that are substituted when
+" the script is invoked on a particular property. For more information on
+" configuration, please see the section below on the INTERFACE.
+"
+" INTERFACE (commands, mappings, and variables)
+" The following section documents the commands, mappings, and variables
+" used to customize the behavior of this script.
+"
+" Commands:
+" :InsertGetterSetter
+" Inserts a getter/setter for the property on the current line, or
+" the range of properties specified via a visual block or x,y range
+" notation. The user is prompted to determine what type of method
+" to insert.
+"
+" :InsertGetterOnly
+" Inserts a getter for the property on the current line, or the
+" range of properties specified via a visual block or x,y range
+" notation. The user is not prompted.
+"
+" :InsertSetterOnly
+" Inserts a setter for the property on the current line, or the
+" range of properties specified via a visual block or x,y range
+" notation. The user is not prompted.
+"
+" :InsertBothGetterSetter
+" Inserts a getter and setter for the property on the current line,
+" or the range of properties specified via a visual block or x,y
+" range notation. The user is not prompted.
+"
+"
+" Mappings:
+" The following mappings are pre-defined. You can disable the mappings
+" by setting a variable (see the Variables section below). The default
+" key mappings use the <LocalLeader> which is the backslash key by
+" default '\'. This can also be configured via a variable (see below).
+"
+" <LocalLeader>p (or <Plug>JavagetsetInsertGetterSetter)
+" Inserts a getter/setter for the property on the current line, or
+" the range of properties specified via a visual block. User is
+" prompted for choice.
+"
+" <LocalLeader>g (or <Plug>JavagetsetInsertGetterOnly)
+" Inserts a getter for the property on the current line, or the
+" range of properties specified via a visual block. User is not
+" prompted.
+"
+" <LocalLeader>s (or <Plug>JavagetsetInsertSetterOnly)
+" Inserts a getter for the property on the current line, or the
+" range of properties specified via a visual block. User is not
+" prompted.
+"
+" <LocalLeader>b (or <Plug>JavagetsetInsertBothGetterSetter)
+" Inserts both a getter and setter for the property on the current
+" line, or the range of properties specified via a visual block.
+" User is not prompted.
+"
+" If you want to define your own mapping, you can map whatever you want
+" to <Plug>JavagetsetInsertGetterSetter (or any of the other <Plug>s
+" defined above). For example,
+"
+" map <buffer> <C-p> <Plug>JavagetsetInsertGetterSetter
+"
+" When you define your own mapping, the default mapping does not get
+" set, only the mapping you specify.
+"
+" Variables:
+" The following variables allow you to customize the behavior of this
+" script so that you do not need to make changes directly to the script.
+" These variables can be set in your vimrc.
+"
+" no_plugin_maps
+" Setting this variable will disable all key mappings defined by any
+" of your plugins (if the plugin writer adhered to the standard
+" convention documented in the scripting section of the VIM manual)
+" including this one.
+"
+" no_java_maps
+" Setting this variable will disable all key mappings defined by any
+" java specific plugin including this one.
+"
+" maplocalleader
+" By default, the key mappings defined by this script use
+" <LocalLeader> which is the backslash character by default. You can
+" change this by setting this variable to a different key. For
+" example, if you want to use the comma-key, you can add this line to
+" your vimrc:
+"
+" let maplocalleader = ','
+"
+" b:javagetset_insertPosition
+" This variable determines the location where the getter and/or setter
+" will be inserted. Currently, three positions have been defined:
+"
+" 0 - insert at the end of the class (default)
+" 1 - insert before the current line / block
+" 2 - insert after the current line / block
+"
+" b:javagetset_getterTemplate
+" b:javagetset_setterTemplate
+" b:javagetset_getterArrayTemplate
+" b:javagetset_setterArrayTemplate
+" These variables determine the text that will be inserted for a
+" getter, setter, array-based getter, and array-based setter
+" respectively. The templates may contain the following placeholders
+" which will be substituted by their appropriate values at insertion
+" time:
+"
+" %type% Java type of the property
+" %varname% The name of the property
+" %funcname% The method name ("getXzy" or "setXzy")
+" %modifiers% "public" followed by "static" if the property is static
+"
+" For example, if you wanted to set the default getter template so
+" that it would produce the following block of code for a property
+" defined as "public static String name":
+"
+" /**
+" * Get name.
+" * @return name as String
+" */
+" public static String getName() { return name; }
+"
+" This block of code can be produced by adding the following variable
+" definition to your vimrc file.
+"
+" let b:javagetset_getterTemplate =
+" \ "\n" .
+" \ "/**\n" .
+" \ " * Get %varname%.\n" .
+" \ " * @return %varname% as %type%.\n" .
+" \ " */\n" .
+" \ "%modifiers% %type% %funcname%() { return %varname%; }"
+"
+" The defaults for these variables are defined in the script. For
+" both the getterTemplate and setterTemplate, there is a corresponding
+" array-baded template that is invoked if a property is array-based.
+" This allows you to set indexed-based getters/setters if you desire.
+" This is the default behavior.
+"
+"
+" INSTALLATION
+" 1. Copy the script to your ${HOME}/.vim/ftplugins directory and make
+" sure its named "java_getset.vim" or "java_something.vim" where
+" "something" can be anything you want.
+"
+" 2. (Optional) Customize the mapping and/or templates. You can create
+" your own filetype plugin (just make sure its loaded before this one)
+" and set the variables in there (i.e. ${HOME}/.vim/ftplugin/java.vim)
+"
+" =======================================================================
+"
+" NOTE:
+" This is my very first VIM script. I read all of the documentation, and
+" have tried to follow the conventions outlined there; however, I may have
+" missed some so please bear with me.
+
+" Only do this when not done yet for this buffer
+if exists("b:did_javagetset_ftplugin")
+ finish
+endif
+let b:did_javagetset_ftplugin = 1
+
+" Make sure we are in vim mode
+let s:save_cpo = &cpo
+set cpo&vim
+
+" TEMPLATE SECTION:
+" The templates can use the following placeholders which will be replaced
+" with appropriate values when the template is invoked:
+"
+" %type% Java type of the property
+" %varname% The name of the property
+" %funcname% The method name ("getXzy" or "setXzy")
+" %modifiers% "public" followed by "static" if the property is static
+"
+" The templates consist of a getter and setter template. In addition,
+" there are also templates for array-based properties. These are defined
+" below.
+"
+" Getter Templates (non-array and array-based)
+if exists("b:javagetset_getterTemplate")
+ let s:javagetset_getterTemplate = b:javagetset_getterTemplate
+else
+ let s:javagetset_getterTemplate =
+ \ "\n" .
+ \ "/**\n" .
+ \ " * Get %varname%.\n" .
+ \ " *\n" .
+ \ " * @return %varname% as %type%.\n" .
+ \ " */\n" .
+ \ "%modifiers% %type% %funcname%()\n" .
+ \ "{\n" .
+ \ " return %varname%;\n" .
+ \ "}"
+endif
+
+if exists("b:javagetset_getterArrayTemplate")
+ let s:javagetset_getterArrayTemplate = b:javagetset_getterArrayTemplate
+else
+ let s:javagetset_getterArrayTemplate =
+ \ "\n" .
+ \ "/**\n" .
+ \ " * Get %varname%.\n" .
+ \ " *\n" .
+ \ " * @return %varname% as %type%[].\n" .
+ \ " */\n" .
+ \ "%modifiers% %type%[] %funcname%()\n" .
+ \ "{\n" .
+ \ " return %varname%;\n" .
+ \ "}\n" .
+ \ "\n" .
+ \ "/**\n" .
+ \ " * Get %varname% element at specified index.\n" .
+ \ " *\n" .
+ \ " * @param index the index.\n" .
+ \ " * @return %varname% at index as %type%.\n" .
+ \ " */\n" .
+ \ "%modifiers% %type% %funcname%(int index)\n" .
+ \ "{\n" .
+ \ " return %varname%[index];\n" .
+ \ "}"
+endif
+
+" Setter Templates (non-array and array-based)
+if exists("b:javagetset_setterTemplate")
+ let s:javagetset_setterTemplate = b:javagetset_setterTemplate
+else
+ let s:javagetset_setterTemplate =
+ \ "\n" .
+ \ "/**\n" .
+ \ " * Set %varname%.\n" .
+ \ " *\n" .
+ \ " * @param %varname% the value to set.\n" .
+ \ " */\n" .
+ \ "%modifiers% void %funcname%(%type% %varname%)\n" .
+ \ "{\n" .
+ \ " this.%varname% = %varname%;\n" .
+ \ "}"
+endif
+
+if exists("b:javagetset_setterArrayTemplate")
+ let s:javagetset_setterArrayTemplate = b:javagetset_setterArrayTemplate
+else
+ let s:javagetset_setterArrayTemplate =
+ \ "\n" .
+ \ "/**\n" .
+ \ " * Set %varname%.\n" .
+ \ " *\n" .
+ \ " * @param %varname% the value to set.\n" .
+ \ " */\n" .
+ \ "%modifiers% void %funcname%(%type%[] %varname%)\n" .
+ \ "{\n" .
+ \ " this.%varname% = %varname%;\n" .
+ \ "}\n" .
+ \ "\n" .
+ \ "/**\n" .
+ \ " * Set %varname% at the specified index.\n" .
+ \ " *\n" .
+ \ " * @param %varname% the value to set.\n" .
+ \ " * @param index the index.\n" .
+ \ " */\n" .
+ \ "%modifiers% void %funcname%(%type% %varname%, int index)\n" .
+ \ "{\n" .
+ \ " this.%varname%[index] = %varname%;\n" .
+ \ "}"
+endif
+
+" Position where methods are inserted. The possible values are:
+" 0 - end of class
+" 1 = above block / line
+" 2 = below block / line
+if exists("b:javagetset_insertPosition")
+ let s:javagetset_insertPosition = b:javagetset_insertPosition
+else
+ let s:javagetset_insertPosition = 0
+endif
+
+" Script local variables that are used like globals.
+"
+" If set to 1, the user has requested that getters be inserted
+let s:getter = 0
+
+" If set to 1, the user has requested that setters be inserted
+let s:setter = 0
+
+" If set to 1, the property was a static property (i.e. static methods)
+let s:static = 0
+
+" If set to 1, the property was declared final (i.e. doesn't need a setter)
+let s:final = 0
+
+" If set to 1, use the array based templates
+let s:isarray = 0
+
+" The current indentation level of the property (i.e. used for the methods)
+let s:indent = ''
+
+" The list of property modifiers
+let s:modifiers = ''
+
+" The type of the property
+let s:vartype = ''
+
+" If the property is an array, the []'s will be stored here
+let s:vararray = ''
+
+" The name of the property
+let s:varname = ''
+
+" The function name of the property (capitalized varname)
+let s:funcname = ''
+
+" The first line of the block selected
+let s:firstline = 0
+
+" The last line of the block selected
+let s:lastline = 0
+
+" Regular expressions used to match property statements
+let s:javaname = '[a-zA-Z_$][a-zA-Z0-9_$]*'
+let s:brackets = '\(\s*\(\[\s*\]\)\)\='
+let s:modifier = '\(private\|protected\|public\|volatile\|static\|final\)'
+let s:variable = '\(\s*\)\(\(' . s:modifier . '\s\+\)*\)\(' . s:javaname . '\)' . s:brackets . '\s\+\(' . s:javaname . '\)\s*\(;\|=[^;]\+;\)'
+
+" The main entry point. This function saves the current position of the
+" cursor without the use of a mark (see note below) Then the selected
+" region is processed for properties.
+"
+" FIXME: I wanted to avoid clobbering any marks in use by the user, so I
+" manually try to save the current position and restore it. The only drag
+" is that the position isn't restored correctly if the user opts to insert
+" the methods ABOVE the current position. Using a mark would solve this
+" problem as they are automatically adjusted. Perhaps I just haven't
+" found it yet, but I wish that VIM would let a scripter save a mark and
+" then restore it later. Why? In this case, I'd be able to use a mark
+" safely without clobbering any user marks already set. First, I'd save
+" the contents of the mark, then set the mark, do my stuff, jump back to
+" the mark, and finally restore the mark to what the user may have had
+" previously set. Seems weird to me that you can't save/restore marks.
+"
+if !exists("*s:InsertGetterSetter")
+ function s:InsertGetterSetter(flag) range
+ let restorepos = line(".") . "normal!" . virtcol(".") . "|"
+ let s:firstline = a:firstline
+ let s:lastline = a:lastline
+
+ if s:DetermineAction(a:flag)
+ call s:ProcessRegion(s:GetRangeAsString(a:firstline, a:lastline))
+ endif
+
+ execute restorepos
+
+ " Not sure why I need this but if I don't have it, the drawing on the
+ " screen is messed up from my insert. Perhaps I'm doing something
+ " wrong, but it seems to me that I probably shouldn't be calling
+ " redraw.
+ redraw!
+
+ endfunction
+endif
+
+" Set the appropriate script variables (s:getter and s:setter) to
+" appropriate values based on the flag that was selected. The current
+" valid values for flag are: 'g' for getter, 's' for setter, 'b' for both
+" getter/setter, and 'a' for ask/prompt user.
+if !exists("*s:DetermineAction")
+ function s:DetermineAction(flag)
+
+ if a:flag == 'g'
+ let s:getter = 1
+ let s:setter = 0
+
+ elseif a:flag == 's'
+ let s:getter = 0
+ let s:setter = 1
+
+ elseif a:flag == 'b'
+ let s:getter = 1
+ let s:setter = 1
+
+ elseif a:flag == 'a'
+ return s:DetermineAction(s:AskUser())
+
+ else
+ return 0
+ endif
+
+ return 1
+ endfunction
+endif
+
+" Ask the user what they want to insert, getter, setter, or both. Return
+" an appropriate flag for use with s:DetermineAction, or return 0 if the
+" user cancelled out.
+if !exists("*s:AskUser")
+ function s:AskUser()
+ let choice =
+ \ confirm("What do you want to insert?",
+ \ "&Getter\n&Setter\n&Both", 3)
+
+ if choice == 0
+ return 0
+
+ elseif choice == 1
+ return 'g'
+
+ elseif choice == 2
+ return 's'
+
+ elseif choice == 3
+ return 'b'
+
+ else
+ return 0
+
+ endif
+ endfunction
+endif
+
+" Gets a range specified by a first and last line and returns it as a
+" single string that will eventually be parsed using regular expresssions.
+" For example, if the following lines were selected:
+"
+" // Age
+" private int age;
+"
+" // Name
+" private static String name;
+"
+" Then, the following string would be returned:
+"
+" // Age private int age; // Name priavte static String name;
+"
+if !exists("*s:GetRangeAsString")
+ function s:GetRangeAsString(first, last)
+ let line = a:first
+ let string = s:TrimRight(getline(line))
+
+ while line < a:last
+ let line = line + 1
+ let string = string . s:TrimRight(getline(line))
+ endwhile
+
+ return string
+ endfunction
+endif
+
+" Trim whitespace from right of string.
+if !exists("*s:TrimRight")
+ function s:TrimRight(text)
+ return substitute(a:text, '\(\.\{-}\)\s*$', '\1', '')
+ endfunction
+endif
+
+" Process the specified region indicated by the user. The region is
+" simply a concatenated string of the lines that were selected by the
+" user. This string is searched for properties (that match the s:variable
+" regexp). Each property is then processed. For example, if the region
+" was:
+"
+" // Age private int age; // Name priavte static String name;
+"
+" Then, the following strings would be processed one at a time:
+"
+" private int age;
+" private static String name;
+"
+if !exists("*s:ProcessRegion")
+ function s:ProcessRegion(region)
+ let startPosition = match(a:region, s:variable, 0)
+ let endPosition = matchend(a:region, s:variable, 0)
+
+ while startPosition != -1
+ let result = strpart(a:region, startPosition, endPosition - startPosition)
+
+ "call s:DebugParsing(result)
+ call s:ProcessVariable(result)
+
+ let startPosition = match(a:region, s:variable, endPosition)
+ let endPosition = matchend(a:region, s:variable, endPosition)
+ endwhile
+
+ endfunction
+endif
+
+" Process a single property. The first thing this function does is
+" break apart the property into the following components: indentation,
+" modifiers ,type, array, and name. In addition, the following other
+" components are then derived from the previous: funcname, static,
+" final, and isarray. For example, if the specified variable was:
+"
+" private static String name;
+"
+" Then the following would be set for the global variables:
+"
+" indent = ' '
+" modifiers = 'private static'
+" vartype = 'String'
+" vararray = ''
+" varname = 'name'
+" funcname = 'Name'
+" static = 1
+" final = 0
+" isarray = 0
+"
+if !exists("*s:ProcessVariable")
+ function s:ProcessVariable(variable)
+ let s:static = 0
+ let s:isarray = 0
+ let s:final = 0
+ let s:indent = substitute(a:variable, s:variable, '\1', '')
+ let s:modifiers = substitute(a:variable, s:variable, '\2', '')
+ let s:vartype = substitute(a:variable, s:variable, '\5', '')
+ let s:vararray = substitute(a:variable, s:variable, '\7', '')
+ let s:varname = substitute(a:variable, s:variable, '\8', '')
+ let s:funcname = toupper(s:varname[0]) . strpart(s:varname, 1)
+
+ " If any getter or setter already exists, then just return as there
+ " is nothing to be done. The assumption is that the user already
+ " made his choice.
+ if s:AlreadyExists()
+ return
+ endif
+
+ if s:modifiers =~ 'static'
+ let s:static = 1
+ endif
+
+ if s:modifiers =~ 'final'
+ let s:final = 1
+ endif
+
+ if s:vararray =~ '['
+ let s:isarray = 1
+ endif
+
+ if s:getter
+ call s:InsertGetter()
+ endif
+
+ if s:setter && !s:final
+ call s:InsertSetter()
+ endif
+
+ endfunction
+endif
+
+" Checks to see if any getter/setter exists.
+if !exists("*s:AlreadyExists")
+ function s:AlreadyExists()
+ return search('\(get\|set\)' . s:funcname . '\_s*([^)]*)\_s*{', 'w')
+ endfunction
+endif
+
+" Inserts a getter by selecting the appropriate template to use and then
+" populating the template parameters with actual values.
+if !exists("*s:InsertGetter")
+ function s:InsertGetter()
+
+ if s:isarray
+ let method = s:javagetset_getterArrayTemplate
+ else
+ let method = s:javagetset_getterTemplate
+ endif
+
+ let mods = "public"
+ if s:static
+ let mods = mods . " static"
+ endif
+
+ let method = substitute(method, '%type%', s:vartype, 'g')
+ let method = substitute(method, '%varname%', s:varname, 'g')
+ let method = substitute(method, '%funcname%', 'get' . s:funcname, 'g')
+ let method = substitute(method, '%modifiers%', mods, 'g')
+
+ call s:InsertMethodBody(method)
+
+ endfunction
+endif
+
+" Inserts a setter by selecting the appropriate template to use and then
+" populating the template parameters with actual values.
+if !exists("*s:InsertSetter")
+ function s:InsertSetter()
+
+ if s:isarray
+ let method = s:javagetset_setterArrayTemplate
+ else
+ let method = s:javagetset_setterTemplate
+ endif
+
+ let mods = "public"
+ if s:static
+ let mods = mods . " static"
+ endif
+
+ let method = substitute(method, '%type%', s:vartype, 'g')
+ let method = substitute(method, '%varname%', s:varname, 'g')
+ let method = substitute(method, '%funcname%', 'set' . s:funcname, 'g')
+ let method = substitute(method, '%modifiers%', mods, 'g')
+
+ call s:InsertMethodBody(method)
+
+ endfunction
+endif
+
+" Inserts a body of text using the indentation level. The passed string
+" may have embedded newlines so we need to search for each "line" and then
+" call append separately. I couldn't figure out how to get a string with
+" newlines to be added in one single call to append (it kept inserting the
+" newlines as ^@ characters which is not what I wanted).
+if !exists("*s:InsertMethodBody")
+ function s:InsertMethodBody(text)
+ call s:MoveToInsertPosition()
+
+ let pos = line('.')
+ let string = a:text
+
+ while 1
+ let len = stridx(string, "\n")
+
+ if len == -1
+ call append(pos, s:indent . string)
+ break
+ endif
+
+ call append(pos, s:indent . strpart(string, 0, len))
+
+ let pos = pos + 1
+ let string = strpart(string, len + 1)
+
+ endwhile
+ endfunction
+endif
+
+" Move the cursor to the insertion point. This insertion point can be
+" defined by the user by setting the b:javagetset_insertPosition variable.
+if !exists("*s:MoveToInsertPosition")
+ function s:MoveToInsertPosition()
+
+ " 1 indicates above the current block / line
+ if s:javagetset_insertPosition == 1
+ execute "normal! " . (s:firstline - 1) . "G0"
+
+ " 2 indicates below the current block / line
+ elseif s:javagetset_insertPosition == 2
+ execute "normal! " . s:lastline . "G0"
+
+ " 0 indicates end of class (and is default)
+ else
+ execute "normal! ?{\<CR>w99[{%k" | nohls
+
+ endif
+
+ endfunction
+endif
+
+" Debug code to decode the properties.
+if !exists("*s:DebugParsing")
+ function s:DebugParsing(variable)
+ echo 'DEBUG: ===================================================='
+ echo 'DEBUG:' a:variable
+ echo 'DEBUG: ----------------------------------------------------'
+ echo 'DEBUG: indent:' substitute(a:variable, s:variable, '\1', '')
+ echo 'DEBUG: modifiers:' substitute(a:variable, s:variable, '\2', '')
+ echo 'DEBUG: type:' substitute(a:variable, s:variable, '\5', '')
+ echo 'DEBUG: array:' substitute(a:variable, s:variable, '\7', '')
+ echo 'DEBUG: name:' substitute(a:variable, s:variable, '\8', '')
+ echo ''
+ endfunction
+endif
+
+" Add mappings, unless the user didn't want this. I'm still not clear why
+" I need to have two (2) noremap statements for each, but that is what the
+" example shows in the documentation so I've stuck with that convention.
+" Ideally, I'd prefer to use only one noremap line and map the <Plug>
+" directly to the ':call <SID>function()<CR>'.
+if !exists("no_plugin_maps") && !exists("no_java_maps")
+ if !hasmapto('<Plug>JavagetsetInsertGetterSetter')
+ map <unique> <buffer> <LocalLeader>p <Plug>JavagetsetInsertGetterSetter
+ endif
+ noremap <buffer> <script>
+ \ <Plug>JavagetsetInsertGetterSetter
+ \ <SID>InsertGetterSetter
+ noremap <buffer>
+ \ <SID>InsertGetterSetter
+ \ :call <SID>InsertGetterSetter('a')<CR>
+
+ if !hasmapto('<Plug>JavagetsetInsertGetterOnly')
+ map <unique> <buffer> <LocalLeader>g <Plug>JavagetsetInsertGetterOnly
+ endif
+ noremap <buffer> <script>
+ \ <Plug>JavagetsetInsertGetterOnly
+ \ <SID>InsertGetterOnly
+ noremap <buffer>
+ \ <SID>InsertGetterOnly
+ \ :call <SID>InsertGetterSetter('g')<CR>
+
+ if !hasmapto('<Plug>JavagetsetInsertSetterOnly')
+ map <unique> <buffer> <LocalLeader>s <Plug>JavagetsetInsertSetterOnly
+ endif
+ noremap <buffer> <script>
+ \ <Plug>JavagetsetInsertSetterOnly
+ \ <SID>InsertSetterOnly
+ noremap <buffer>
+ \ <SID>InsertSetterOnly
+ \ :call <SID>InsertGetterSetter('s')<CR>
+
+ if !hasmapto('<Plug>JavagetsetInsertBothGetterSetter')
+ map <unique> <buffer> <LocalLeader>b <Plug>JavagetsetInsertBothGetterSetter
+ endif
+ noremap <buffer> <script>
+ \ <Plug>JavagetsetInsertBothGetterSetter
+ \ <SID>InsertBothGetterSetter
+ noremap <buffer>
+ \ <SID>InsertBothGetterSetter
+ \ :call <SID>InsertGetterSetter('b')<CR>
+endif
+
+" Add commands, unless already set.
+if !exists(":InsertGetterSetter")
+ command -range -buffer
+ \ InsertGetterSetter
+ \ :<line1>,<line2>call s:InsertGetterSetter('a')
+endif
+if !exists(":InsertGetterOnly")
+ command -range -buffer
+ \ InsertGetterOnly
+ \ :<line1>,<line2>call s:InsertGetterSetter('g')
+endif
+if !exists(":InsertSetterOnly")
+ command -range -buffer
+ \ InsertSetterOnly
+ \ :<line1>,<line2>call s:InsertGetterSetter('s')
+endif
+if !exists(":InsertBothGetterSetter")
+ command -range -buffer
+ \ InsertBothGetterSetter
+ \ :<line1>,<line2>call s:InsertGetterSetter('b')
+endif
+
+let &cpo = s:save_cpo
+
+"if !exists("*s:InsertText")
+" function s:InsertText(text)
+" let pos = line('.')
+" let beg = 0
+" let len = stridx(a:text, "\n")
+"
+" while beg < strlen(a:text)
+" if len == -1
+" call append(pos, s:indent . strpart(a:text, beg))
+" break
+" endif
+"
+" call append(pos, s:indent . strpart(a:text, beg, len))
+" let pos = pos + 1
+" let beg = beg + len + 1
+" let len = stridx(strpart(a:text, beg), "\n")
+" endwhile
+"
+" " Not too sure why I have to call redraw, but weirdo things appear
+" " on the screen if I don't.
+" redraw!
+"
+" endfunction
+"endif
+"
+"if !exists("*s:InsertAccessor")
+" function s:InsertAccessor()
+" echo "InsertAccessor was called"
+" endfunction
+"endif
+"
+"if !exists("*s:SqueezeWhitespace")
+" function s:SqueezeWhitespace(string)
+" return substitute(a:string, '\_s\+', ' ', 'g')
+" endfunction
+"endif
diff --git a/.vim/ftplugin/python_fn.vim b/.vim/ftplugin/python_fn.vim
new file mode 100644
index 0000000..7c7cf21
--- /dev/null
+++ b/.vim/ftplugin/python_fn.vim
@@ -0,0 +1,446 @@
+" -*- vim -*-
+" FILE: python_fn.vim
+" LAST MODIFICATION: 2008-08-28 8:19pm
+" (C) Copyright 2001-2005 Mikael Berthe <bmikael@lists.lilotux.net>
+" Maintained by Jon Franklin <jvfranklin@gmail.com>
+" Version: 1.13
+
+" USAGE:
+"
+" 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).
+" You can set the global variable "g:py_select_trailing_comments" to 0
+" if you don't want to select comments at the end of a function/class.
+" If these variables are not defined, both leading and trailing comments
+" are selected.
+" Example: (in your .vimrc) "let g:py_select_leading_comments = 0"
+" You may want to take a look at the 'shiftwidth' option for the
+" shift commands...
+"
+" REQUIREMENTS:
+" vim (>= 7)
+"
+" Shortcuts:
+" ]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
+" ]d -- Select current/previous function
+" ]<up> -- Jump to previous line with the same/lower indentation
+" ]<down> -- 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 ]t :PBoB<CR>
+vmap ]t :<C-U>PBOB<CR>m'gv``
+map ]e :PEoB<CR>
+vmap ]e :<C-U>PEoB<CR>m'gv``
+
+map ]v ]tV]e
+map ]< ]tV]e<
+vmap ]< <
+map ]> ]tV]e>
+vmap ]> >
+
+map ]# :call PythonCommentSelection()<CR>
+vmap ]# :call PythonCommentSelection()<CR>
+map ]u :call PythonUncommentSelection()<CR>
+vmap ]u :call PythonUncommentSelection()<CR>
+
+map ]c :call PythonSelectObject("class")<CR>
+map ]d :call PythonSelectObject("function")<CR>
+
+map ]<up> :call PythonNextLine(-1)<CR>
+map ]<down> :call PythonNextLine(1)<CR>
+" You may prefer use <s-up> and <s-down>... :-)
+
+" jump to previous class
+map ]J :call PythonDec("class", -1)<CR>
+vmap ]J :call PythonDec("class", -1)<CR>
+
+" jump to next class
+map ]j :call PythonDec("class", 1)<CR>
+vmap ]j :call PythonDec("class", 1)<CR>
+
+" jump to previous function
+map ]F :call PythonDec("function", -1)<CR>
+vmap ]F :call PythonDec("function", -1)<CR>
+
+" jump to next function
+map ]f :call PythonDec("function", 1)<CR>
+vmap ]f :call PythonDec("function", 1)<CR>
+
+
+
+" Menu entries
+nmenu <silent> &Python.Update\ IM-Python\ Menu
+ \:call UpdateMenu()<CR>
+nmenu &Python.-Sep1- :
+nmenu <silent> &Python.Beginning\ of\ Block<Tab>[t
+ \]t
+nmenu <silent> &Python.End\ of\ Block<Tab>]e
+ \]e
+nmenu &Python.-Sep2- :
+nmenu <silent> &Python.Shift\ Block\ Left<Tab>]<
+ \]<
+vmenu <silent> &Python.Shift\ Block\ Left<Tab>]<
+ \]<
+nmenu <silent> &Python.Shift\ Block\ Right<Tab>]>
+ \]>
+vmenu <silent> &Python.Shift\ Block\ Right<Tab>]>
+ \]>
+nmenu &Python.-Sep3- :
+vmenu <silent> &Python.Comment\ Selection<Tab>]#
+ \]#
+nmenu <silent> &Python.Comment\ Selection<Tab>]#
+ \]#
+vmenu <silent> &Python.Uncomment\ Selection<Tab>]u
+ \]u
+nmenu <silent> &Python.Uncomment\ Selection<Tab>]u
+ \]u
+nmenu &Python.-Sep4- :
+nmenu <silent> &Python.Previous\ Class<Tab>]J
+ \]J
+nmenu <silent> &Python.Next\ Class<Tab>]j
+ \]j
+nmenu <silent> &Python.Previous\ Function<Tab>]F
+ \]F
+nmenu <silent> &Python.Next\ Function<Tab>]f
+ \]f
+nmenu &Python.-Sep5- :
+nmenu <silent> &Python.Select\ Block<Tab>]v
+ \]v
+nmenu <silent> &Python.Select\ Function<Tab>]d
+ \]d
+nmenu <silent> &Python.Select\ Class<Tab>]c
+ \]c
+nmenu &Python.-Sep6- :
+nmenu <silent> &Python.Previous\ Line\ wrt\ indent<Tab>]<up>
+ \]<up>
+nmenu <silent> &Python.Next\ Line\ wrt\ indent<Tab>]<down>
+ \]<down>
+
+:com! PBoB execute "normal ".PythonBoB(line('.'), -1, 1)."G"
+:com! PEoB execute "normal ".PythonBoB(line('.'), 1, 1)."G"
+:com! UpdateMenu call UpdateMenu()
+
+
+" Go to a block boundary (-1: previous, 1: next)
+" If force_sel_comments is true, 'g:py_select_trailing_comments' is ignored
+function! PythonBoB(line, direction, force_sel_comments)
+ let ln = a:line
+ let ind = indent(ln)
+ let mark = ln
+ let indent_valid = strlen(getline(ln))
+ let ln = ln + a:direction
+ if (a:direction == 1) && (!a:force_sel_comments) &&
+ \ exists("g:py_select_trailing_comments") &&
+ \ (!g:py_select_trailing_comments)
+ let sel_comments = 0
+ else
+ let sel_comments = 1
+ endif
+
+ while((ln >= 1) && (ln <= line('$')))
+ if (sel_comments) || (match(getline(ln), "^\\s*#") == -1)
+ if (!indent_valid)
+ let indent_valid = strlen(getline(ln))
+ let ind = indent(ln)
+ let mark = ln
+ else
+ if (strlen(getline(ln)))
+ if (indent(ln) < ind)
+ break
+ endif
+ let mark = ln
+ endif
+ endif
+ endif
+ let ln = ln + a:direction
+ endwhile
+
+ return mark
+endfunction
+
+
+" Go to previous (-1) or next (1) class/function definition
+function! PythonDec(obj, direction)
+ if (a:obj == "class")
+ let objregexp = "^\\s*class\\s\\+[a-zA-Z0-9_]\\+"
+ \ . "\\s*\\((\\([a-zA-Z0-9_,. \\t\\n]\\)*)\\)\\=\\s*:"
+ else
+ let objregexp = "^\\s*def\\s\\+[a-zA-Z0-9_]\\+\\s*(\\_[^:#]*)\\s*:"
+ endif
+ let flag = "W"
+ if (a:direction == -1)
+ let flag = flag."b"
+ endif
+ let res = search(objregexp, flag)
+endfunction
+
+
+" Comment out selected lines
+" commentString is inserted in non-empty lines, and should be aligned with
+" the block
+function! PythonCommentSelection() range
+ let commentString = "#"
+ let cl = a:firstline
+ let ind = 1000 " I hope nobody use so long lines! :)
+
+ " Look for smallest indent
+ while (cl <= a:lastline)
+ if strlen(getline(cl))
+ let cind = indent(cl)
+ let ind = ((ind < cind) ? ind : cind)
+ endif
+ let cl = cl + 1
+ endwhile
+ if (ind == 1000)
+ let ind = 1
+ else
+ let ind = ind + 1
+ endif
+
+ let cl = a:firstline
+ execute ":".cl
+ " Insert commentString in each non-empty line, in column ind
+ while (cl <= a:lastline)
+ if strlen(getline(cl))
+ execute "normal ".ind."|i".commentString
+ endif
+ execute "normal \<Down>"
+ let cl = cl + 1
+ endwhile
+endfunction
+
+" Uncomment selected lines
+function! PythonUncommentSelection() range
+ " commentString could be different than the one from CommentSelection()
+ " For example, this could be "# \\="
+ let commentString = "#"
+ let cl = a:firstline
+ while (cl <= a:lastline)
+ let ul = substitute(getline(cl),
+ \"\\(\\s*\\)".commentString."\\(.*\\)$", "\\1\\2", "")
+ call setline(cl, ul)
+ let cl = cl + 1
+ endwhile
+endfunction
+
+
+" Select an object ("class"/"function")
+function! PythonSelectObject(obj)
+ " Go to the object declaration
+ normal $
+ call PythonDec(a:obj, -1)
+ let beg = line('.')
+
+ if !exists("g:py_select_leading_comments") || (g:py_select_leading_comments)
+ let decind = indent(beg)
+ let cl = beg
+ while (cl>1)
+ let cl = cl - 1
+ if (indent(cl) == decind) && (getline(cl)[decind] == "#")
+ let beg = cl
+ else
+ break
+ endif
+ endwhile
+ endif
+
+ if (a:obj == "class")
+ let eod = "\\(^\\s*class\\s\\+[a-zA-Z0-9_]\\+\\s*"
+ \ . "\\((\\([a-zA-Z0-9_,. \\t\\n]\\)*)\\)\\=\\s*\\)\\@<=:"
+ else
+ let eod = "\\(^\\s*def\\s\\+[a-zA-Z0-9_]\\+\\s*(\\_[^:#]*)\\s*\\)\\@<=:"
+ endif
+ " Look for the end of the declaration (not always the same line!)
+ call search(eod, "")
+
+ " Is it a one-line definition?
+ if match(getline('.'), "^\\s*\\(#.*\\)\\=$", col('.')) == -1
+ let cl = line('.')
+ execute ":".beg
+ execute "normal V".cl."G"
+ else
+ " Select the whole block
+ execute "normal \<Down>"
+ let cl = line('.')
+ execute ":".beg
+ execute "normal V".PythonBoB(cl, 1, 0)."G"
+ endif
+endfunction
+
+
+" Jump to the next line with the same (or lower) indentation
+" Useful for moving between "if" and "else", for example.
+function! PythonNextLine(direction)
+ let ln = line('.')
+ let ind = indent(ln)
+ let indent_valid = strlen(getline(ln))
+ let ln = ln + a:direction
+
+ while((ln >= 1) && (ln <= line('$')))
+ if (!indent_valid) && strlen(getline(ln))
+ break
+ else
+ if (strlen(getline(ln)))
+ if (indent(ln) <= ind)
+ break
+ endif
+ endif
+ endif
+ let ln = ln + a:direction
+ endwhile
+
+ execute "normal ".ln."G"
+endfunction
+
+function! UpdateMenu()
+ " delete menu if it already exists, then rebuild it.
+ " this is necessary in case you've got multiple buffers open
+ " a future enhancement to this would be to make the menu aware of
+ " all buffers currently open, and group classes and functions by buffer
+ if exists("g:menuran")
+ aunmenu IM-Python
+ endif
+ let restore_fe = &foldenable
+ set nofoldenable
+ " preserve disposition of window and cursor
+ let cline=line('.')
+ let ccol=col('.') - 1
+ norm H
+ let hline=line('.')
+ " create the menu
+ call MenuBuilder()
+ " restore disposition of window and cursor
+ exe "norm ".hline."Gzt"
+ let dnscroll=cline-hline
+ exe "norm ".dnscroll."j".ccol."l"
+ let &foldenable = restore_fe
+endfunction
+
+function! MenuBuilder()
+ norm gg0
+ let currentclass = -1
+ let classlist = []
+ let parentclass = ""
+ while line(".") < line("$")
+ " search for a class or function
+ if match ( getline("."), '^\s*class\s\+[_a-zA-Z].*\|^\s*def\s\+[_a-zA-Z].*' ) != -1
+ norm ^
+ let linenum = line('.')
+ let indentcol = col('.')
+ norm "nye
+ let classordef=@n
+ norm w"nywge
+ let objname=@n
+ let parentclass = FindParentClass(classlist, indentcol)
+ if classordef == "class"
+ call AddClass(objname, linenum, parentclass)
+ 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
+ endwhile
+endfunction
+
+" classlist contains the list of nested classes we are in.
+" in most cases it will be empty or contain a single class
+" but where a class is nested within another, it will contain 2 or more
+" this function adds or removes classes from the list based on indentation
+function! RebuildClassList(classlist, newclass, classordef)
+ let i = len(a:classlist) - 1
+ while i > -1
+ if a:newclass[1] <= a:classlist[i][1]
+ call remove(a:classlist, i)
+ endif
+ let i = i - 1
+ endwhile
+ if a:classordef == "class"
+ call add(a:classlist, a:newclass)
+ endif
+endfunction
+
+" we found a class or function, determine its parent class based on
+" indentation and what's contained in classlist
+function! FindParentClass(classlist, indentcol)
+ let i = 0
+ let parentclass = ""
+ while i < len(a:classlist)
+ if a:indentcol <= a:classlist[i][1]
+ break
+ else
+ if len(parentclass) == 0
+ let parentclass = a:classlist[i][0]
+ else
+ let parentclass = parentclass.'\.'.a:classlist[i][0]
+ endif
+ endif
+ let i = i + 1
+ endwhile
+ return parentclass
+endfunction
+
+" add a class to the menu
+function! AddClass(classname, lineno, parentclass)
+ if len(a:parentclass) > 0
+ let classstring = a:parentclass.'\.'.a:classname
+ else
+ let classstring = a:classname
+ endif
+ exe 'menu IM-Python.classes.'.classstring.' :call <SID>JumpToAndUnfold('.a:lineno.')<CR>'
+endfunction
+
+" add a function to the menu, grouped by member class
+function! AddFunction(functionname, lineno, parentclass)
+ if len(a:parentclass) > 0
+ let funcstring = a:parentclass.'.'.a:functionname
+ else
+ let funcstring = a:functionname
+ endif
+ exe 'menu IM-Python.functions.'.funcstring.' :call <SID>JumpToAndUnfold('.a:lineno.')<CR>'
+endfunction
+
+
+function! s:JumpToAndUnfold(line)
+ " Go to the right line
+ execute 'normal '.a:line.'gg'
+ " Check to see if we are in a fold
+ let lvl = foldlevel(a:line)
+ if lvl != 0
+ " and if so, then expand the fold out, other wise, ignore this part.
+ execute 'normal 15zo'
+ endif
+endfunction
+
+"" This one will work only on vim 6.2 because of the try/catch expressions.
+" function! s:JumpToAndUnfoldWithExceptions(line)
+" try
+" execute 'normal '.a:line.'gg15zo'
+" catch /^Vim\((\a\+)\)\=:E490:/
+" " Do nothing, just consume the error
+" endtry
+"endfunction
+
+
+" vim:set et sts=2 sw=2:
+
diff --git a/.vim/ftplugin/tex.vim b/.vim/ftplugin/tex.vim
new file mode 100644
index 0000000..ea41f39
--- /dev/null
+++ b/.vim/ftplugin/tex.vim
@@ -0,0 +1,10 @@
+let g:Tex_MultipleCompileFormats = "dvi,pdf"
+let g:Tex_ViewRule_pdf = "epdfview"
+let g:Tex_UseUtfMenus = 1
+let g:Tex_DefaultTargetFormat="pdf"
+let Tlist_Sort_Type = "order"
+set grepprg=grep\ -nH\ $*
+
+let tlist_tex_settings = 'latex;s:sections;g:graphics;l:labels'
+
+set lbr " Break only between words