├── .gitignore ├── bin ├── git_vimdiff ├── cyg-wrapper.sh ├── git_fmdiff ├── _alt_switch.ahk ├── macports-bootstrap └── findleak ├── inputrc ├── vim ├── ftdetect │ └── scala.vim ├── doc │ ├── bufexplorer.txt │ ├── chef.txt │ ├── surround.txt │ └── tags ├── snippets │ ├── snippet.snippets │ ├── _.snippets │ ├── sh.snippets │ ├── vim.snippets │ ├── cpp.snippets │ ├── mako.snippets │ ├── zsh.snippets │ ├── autoit.snippets │ ├── java.snippets │ ├── javascript.snippets │ ├── tcl.snippets │ ├── tex.snippets │ ├── c.snippets │ ├── perl.snippets │ ├── objc.snippets │ ├── php.snippets │ ├── html.snippets │ ├── python.snippets │ └── ruby.snippets ├── ftplugin │ ├── html_snip_helper.vim │ ├── python │ │ ├── python_doc.py │ │ ├── python_doc.py.vim │ │ └── jpythonfold.vim │ └── javascript │ │ ├── json_formatter.py │ │ └── json_formatter.py.vim ├── plugin │ ├── _python_support.vim │ ├── 31-create-scala.vim │ ├── toggle_words.py.vim │ ├── toggle_words.py │ ├── chef.vim │ ├── snipMate.vim │ └── tasklist.vim ├── autoload │ └── chef │ │ ├── finder │ │ ├── source.vim │ │ ├── lwrp.vim │ │ ├── recipe.vim │ │ ├── related.vim │ │ ├── definition.vim │ │ └── attribute.vim │ │ ├── environment.vim │ │ ├── finder.vim │ │ └── controller.vim ├── syntax │ ├── snippet.vim │ ├── pyrex.vim │ ├── scala.vim │ └── rst.vim ├── after │ └── plugin │ │ └── snipMate.vim ├── nerdtree_plugin │ ├── exec_menuitem.vim │ └── fs_menu.vim ├── indent │ └── scala.vim └── colors │ └── ambv.vim ├── bazaar ├── ignore ├── authentication.conf └── bazaar.conf ├── profile_machine ├── debian ├── redhat ├── cygwin └── darwin ├── my.cnf ├── pdbrc ├── ackrc ├── pythonstartup ├── hgrc ├── gvimrc ├── gitignore ├── gitconfig ├── hgignore ├── profile ├── README.rst ├── zshrc ├── profile_common ├── install.py └── vimrc /.gitignore: -------------------------------------------------------------------------------- 1 | /vim/.netrwhist 2 | -------------------------------------------------------------------------------- /bin/git_vimdiff: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | $EDITOR -d "$2" "$5" 4 | -------------------------------------------------------------------------------- /inputrc: -------------------------------------------------------------------------------- 1 | "^[1;5D": backward-word 2 | "^[1;5C": forward-word 3 | 4 | -------------------------------------------------------------------------------- /vim/ftdetect/scala.vim: -------------------------------------------------------------------------------- 1 | 2 | au BufRead,BufNewFile *.scala set filetype=scala 3 | -------------------------------------------------------------------------------- /bin/cyg-wrapper.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zen/.dot_files/master/bin/cyg-wrapper.sh -------------------------------------------------------------------------------- /bazaar/ignore: -------------------------------------------------------------------------------- 1 | *.a 2 | *.o 3 | *.py[co] 4 | *.so 5 | *.sw[nop] 6 | *~ 7 | .#* 8 | [#]*# 9 | -------------------------------------------------------------------------------- /vim/doc/bufexplorer.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zen/.dot_files/master/vim/doc/bufexplorer.txt -------------------------------------------------------------------------------- /bazaar/authentication.conf: -------------------------------------------------------------------------------- 1 | [Launchpad] 2 | host = .launchpad.net 3 | scheme = ssh 4 | user = tzn 5 | -------------------------------------------------------------------------------- /profile_machine/debian: -------------------------------------------------------------------------------- 1 | # Debian specific settings 2 | eval "`dircolors`" 3 | alias ls='ls $LS_OPTIONS' 4 | -------------------------------------------------------------------------------- /my.cnf: -------------------------------------------------------------------------------- 1 | [mysqldump] 2 | quick 3 | quote-names 4 | max_allowed_packet = 16M 5 | 6 | [mysql] 7 | prompt="(\u@\h) [\d]>" 8 | 9 | -------------------------------------------------------------------------------- /pdbrc: -------------------------------------------------------------------------------- 1 | import os, rlcompleter 2 | if not os.environ.get('IN_REGRTEST'): pdb.Pdb.complete = rlcompleter.Completer(locals()).complete 3 | -------------------------------------------------------------------------------- /bin/git_fmdiff: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #/Applications/Xcode.app/Contents/Applications/FileMerge.app/Contents/MacOS/FileMerge "$2" "$5" 4 | opendiff $2 $5 5 | -------------------------------------------------------------------------------- /ackrc: -------------------------------------------------------------------------------- 1 | --type-set=rest=.rst 2 | --type-set=ruby=.json 3 | --type-set=ruby=.erb 4 | --type-set=ruby=.rb 5 | --type-set=yaml=.yml 6 | --nojs 7 | --nohtml 8 | --ignore-dir=.svn 9 | -------------------------------------------------------------------------------- /profile_machine/redhat: -------------------------------------------------------------------------------- 1 | # RedHat specific settings 2 | alias ls='ls $LS_OPTIONS' 3 | alias screen='TERM=xterm-color screen' 4 | 5 | export PATH=${PATH}:/user/sbin:/usr/local/bin:/usr/local/sbin -------------------------------------------------------------------------------- /vim/snippets/snippet.snippets: -------------------------------------------------------------------------------- 1 | # snippets for making snippets :) 2 | snippet snip 3 | snippet ${1:trigger} 4 | ${2} 5 | snippet msnip 6 | snippet ${1:trigger} ${2:description} 7 | ${3} 8 | -------------------------------------------------------------------------------- /bazaar/bazaar.conf: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | email = Tomasz 'Zen' Napierala 3 | viz-graph-size = 960x240 4 | viz-revisionview-size = 960x289 5 | viz-window-size = 960x600 6 | launchpad_username = tzn 7 | -------------------------------------------------------------------------------- /vim/snippets/_.snippets: -------------------------------------------------------------------------------- 1 | # Global snippets 2 | 3 | # (c) holds no legal value ;) 4 | snippet c) 5 | `&enc[:2] == "utf" ? "©" : "(c)"` Copyright `strftime("%Y")` ${1:`g:snips_author`}. All Rights Reserved.${2} 6 | snippet date 7 | `strftime("%Y-%m-%d")` 8 | -------------------------------------------------------------------------------- /bin/_alt_switch.ahk: -------------------------------------------------------------------------------- 1 | ; Windows AutoHotKey script 2 | ; Run using http://www.autohotkey.com/download/ 3 | 4 | ; For remapping of Alts to behave like on Mac OS X. 5 | ; Capslock remapped to Ctrl as a nice bonus. 6 | 7 | LAlt::^RAlt 8 | LWin::^RAlt 9 | ^RAlt::Alt 10 | Capslock::Ctrl 11 | -------------------------------------------------------------------------------- /vim/ftplugin/html_snip_helper.vim: -------------------------------------------------------------------------------- 1 | " Helper function for (x)html snippets 2 | if exists('s:did_snip_helper') || &cp || !exists('loaded_snips') 3 | finish 4 | endif 5 | let s:did_snip_helper = 1 6 | 7 | " Automatically closes tag if in xhtml 8 | fun! Close() 9 | return stridx(&ft, 'xhtml') == -1 ? '' : ' /' 10 | endf 11 | -------------------------------------------------------------------------------- /pythonstartup: -------------------------------------------------------------------------------- 1 | import readline 2 | import rlcompleter 3 | import atexit 4 | import os 5 | readline.parse_and_bind('tab: complete') 6 | histfile = os.path.join(os.environ['HOME'], '.pythonhistory') 7 | try: 8 | readline.read_history_file(histfile) 9 | except IOError: 10 | pass 11 | atexit.register(readline.write_history_file, histfile) 12 | del os, histfile, readline, rlcompleter 13 | -------------------------------------------------------------------------------- /profile_machine/cygwin: -------------------------------------------------------------------------------- 1 | # Cygwin specific settings 2 | export DISPLAY=":0" 3 | export LS_OPTIONS="$LS_OPTIONS -G" 4 | export EDITOR=$HOME'/.dot_files/bin/cyg-wrapper.sh "/cygdrive/c/Tools/Vim/vim73/gvim.exe" --cyg-env-clear=HOME --binary-opt=-c,--cmd,-T,-t,--servername,--remote-send,--remote-expr --fork=1' 5 | alias ls="ls $LS_OPTIONS" 6 | alias gvim="$EDITOR" 7 | alias vim="$EDITOR" 8 | alias vi="$EDITOR" 9 | -------------------------------------------------------------------------------- /hgrc: -------------------------------------------------------------------------------- 1 | [ui] 2 | askusername = True 3 | fallbackencoding = utf-8 4 | ignore = ~/.hgignore 5 | 6 | [merge-tools] 7 | filemerge.executable = vim 8 | filemerge.args = -d $base $local $other 9 | filemerge.checkchanged = true 10 | 11 | [trusted] 12 | 13 | [extensions] 14 | color = 15 | convert = 16 | extdiff = 17 | fetch = 18 | mq = 19 | 20 | [extdiff] 21 | cmd.vimdiff = 22 | 23 | [alias] 24 | vi = vimdiff 25 | vim = vimdiff 26 | -------------------------------------------------------------------------------- /gvimrc: -------------------------------------------------------------------------------- 1 | if &background == "dark" 2 | hi normal guifg=#eeeeee guibg=black 3 | hi cursor guifg=#d7ff00 4 | hi lcursor guifg=#00cd00 5 | if has("gui_macvim") 6 | set transp=8 7 | endif 8 | endif 9 | 10 | if has("gui_macvim") 11 | set guifont=Terminus:h14 12 | else 13 | set guifont=Lucida\ Console:h10 14 | set encoding=utf-8 15 | setglobal fileencoding=utf-8 16 | endif 17 | set go=cegt 18 | set cursorcolumn 19 | -------------------------------------------------------------------------------- /gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Python scripts 2 | *.pyc 3 | *.pyo 4 | __pycache__ 5 | 6 | # Compiled Java classes 7 | *.class 8 | 9 | # Compiled C files 10 | *.a 11 | *.o 12 | 13 | # SQLite databases 14 | *.db 15 | *.sqlite 16 | 17 | # Temporary or runtime files 18 | *.old 19 | *.bak 20 | *.swp 21 | *.swo 22 | *.swn 23 | *.local 24 | *.log 25 | *.pid 26 | *.cache 27 | *.orig 28 | *~ 29 | 30 | # Python Sphinx and setuptools files 31 | /doc/_build 32 | /build 33 | /dist 34 | *.egg-info 35 | 36 | # Mac OS X specific 37 | .DS_Store 38 | -------------------------------------------------------------------------------- /vim/plugin/_python_support.vim: -------------------------------------------------------------------------------- 1 | " Vim Python support routines. 2 | " 3 | " Version: 1.0 4 | " Author: Łukasz Langa 5 | 6 | if exists('g:embedded_python_version') 7 | finish 8 | endif 9 | 10 | if v:version < 700 || !has('python') 11 | echo ".dot_files require vim7.0+ with Python support." 12 | finish 13 | endif 14 | 15 | python << endpython 16 | import os, sys, vim 17 | vim.command("let g:embedded_python_version=%d" % (sys.version_info[0] * 100 + sys.version_info[1] * 10 + sys.version_info[2])) 18 | endpython 19 | -------------------------------------------------------------------------------- /gitconfig: -------------------------------------------------------------------------------- 1 | [user] 2 | email = tomasz@napierala.org 3 | name = Tomasz 'Zen' Napierala 4 | [push] 5 | default = current 6 | [color] 7 | branch = auto 8 | diff = auto 9 | interactive = auto 10 | status = auto 11 | [diff] 12 | external = git_fmdiff 13 | [pager] 14 | diff = 15 | [core] 16 | excludesfile = ~/.gitignore 17 | [merge] 18 | ff = false 19 | [alias] 20 | ci = commit 21 | co = checkout 22 | st = status 23 | hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short 24 | rst = diff --stat 25 | -------------------------------------------------------------------------------- /vim/ftplugin/python/python_doc.py: -------------------------------------------------------------------------------- 1 | from subprocess import Popen 2 | 3 | def PyDocSearch(keyword=None, current_buffer=False): 4 | if keyword: 5 | search = 'search.html?q=%s' % keyword 6 | elif current_buffer: 7 | import vim 8 | isk = vim.eval('&isk') 9 | vim.command('set isk+=.') 10 | print vim.eval('&isk') 11 | search = 'search.html?q=%s' % vim.eval('expand("")') 12 | vim.command('set isk=%s' % isk) 13 | else: 14 | search = '' 15 | Popen(['open', 'http://docs.python.org/%s' % search]) 16 | -------------------------------------------------------------------------------- /vim/snippets/sh.snippets: -------------------------------------------------------------------------------- 1 | # #!/bin/bash 2 | snippet #! 3 | #!/bin/bash 4 | 5 | snippet if 6 | if [[ ${1:condition} ]]; then 7 | ${2:#statements} 8 | fi 9 | snippet elif 10 | elif [[ ${1:condition} ]]; then 11 | ${2:#statements} 12 | snippet for 13 | for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do 14 | ${3:#statements} 15 | done 16 | snippet wh 17 | while [[ ${1:condition} ]]; do 18 | ${2:#statements} 19 | done 20 | snippet until 21 | until [[ ${1:condition} ]]; do 22 | ${2:#statements} 23 | done 24 | snippet case 25 | case ${1:word} in 26 | ${2:pattern}) 27 | ${3};; 28 | esac 29 | -------------------------------------------------------------------------------- /vim/snippets/vim.snippets: -------------------------------------------------------------------------------- 1 | snippet header 2 | " File: ${1:`expand('%:t')`} 3 | " Author: ${2:`g:snips_author`} 4 | " Description: ${3} 5 | ${4:" Last Modified: `strftime("%B %d, %Y")`} 6 | snippet guard 7 | if exists('${1:did_`Filename()`}') || &cp${2: || version < 700} 8 | finish 9 | endif 10 | let $1 = 1${3} 11 | snippet f 12 | fun ${1:function_name}(${2}) 13 | ${3:" code} 14 | endf 15 | snippet for 16 | for ${1:needle} in ${2:haystack} 17 | ${3:" code} 18 | endfor 19 | snippet wh 20 | while ${1:condition} 21 | ${2:" code} 22 | endw 23 | snippet if 24 | if ${1:condition} 25 | ${2:" code} 26 | endif 27 | snippet ife 28 | if ${1:condition} 29 | ${2} 30 | else 31 | ${3} 32 | endif 33 | -------------------------------------------------------------------------------- /hgignore: -------------------------------------------------------------------------------- 1 | # Compiled Python scripts 2 | syntax: glob 3 | 4 | *.pyc 5 | *.pyo 6 | __pycache__ 7 | 8 | # Compiled Java classes 9 | syntax: glob 10 | 11 | *.class 12 | 13 | # Compiled C files 14 | syntax: glob 15 | 16 | *.a 17 | *.o 18 | 19 | # SQLite databases 20 | syntax: glob 21 | 22 | *.db 23 | *.sqlite 24 | 25 | # Temporary or runtime files 26 | syntax: glob 27 | 28 | *.old 29 | *.bak 30 | *.swp 31 | *.swo 32 | *.swn 33 | *.local 34 | *.log 35 | *.pid 36 | *.cache 37 | *.orig 38 | *~ 39 | 40 | # Python Sphinx and setuptools files 41 | syntax: regexp 42 | 43 | ^doc/_build 44 | ^build 45 | ^dist 46 | 47 | syntax: glob 48 | 49 | *.egg-info 50 | 51 | # Mac OS X specific 52 | syntax: glob 53 | 54 | .DS_Store 55 | -------------------------------------------------------------------------------- /vim/snippets/cpp.snippets: -------------------------------------------------------------------------------- 1 | # Read File Into Vector 2 | snippet readfile 3 | std::vector v; 4 | if (FILE *${2:fp} = fopen(${1:"filename"}, "r")) { 5 | char buf[1024]; 6 | while (size_t len = fread(buf, 1, sizeof(buf), $2)) 7 | v.insert(v.end(), buf, buf + len); 8 | fclose($2); 9 | }${3} 10 | # std::map 11 | snippet map 12 | std::map<${1:key}, ${2:value}> map${3}; 13 | # std::vector 14 | snippet vector 15 | std::vector<${1:char}> v${2}; 16 | # Namespace 17 | snippet ns 18 | namespace ${1:`Filename('', 'my')`} { 19 | ${2} 20 | } /* $1 */ 21 | # Class 22 | snippet cl 23 | class ${1:`Filename('$1_t', 'name')`} { 24 | public: 25 | $1 (${2:arguments}); 26 | virtual ~$1 (); 27 | 28 | private: 29 | ${3:/* data */} 30 | }; 31 | -------------------------------------------------------------------------------- /vim/autoload/chef/finder/source.vim: -------------------------------------------------------------------------------- 1 | let s:finder = {} 2 | 3 | function! s:finder.condition() "{{{1 4 | return (self.env.line =~# '\s\+source\>' && self.env.cword !=# 'source') 5 | endfunction 6 | 7 | function! s:finder.find() "{{{1 8 | let type = self.env.ext == 'erb' ? 'templates' : 'files' 9 | let fpath = join([self.env.path.recipe , type, 'default' , self.env.cfile ], '/') 10 | if isdirectory(fpath) || filereadable(fpath) 11 | call self.edit(fpath) 12 | return 1 13 | else 14 | call self.msghl([[self.env.cfile, "Identifier"], [" not found", "Normal"]], ' ') 15 | return 0 16 | endif 17 | endfunction 18 | 19 | function! chef#finder#source#new() "{{{1 20 | return chef#finder#new(s:finder) 21 | endfunction 22 | " vim: set sw=4 sts=4 et fdm=marker: 23 | -------------------------------------------------------------------------------- /vim/syntax/snippet.vim: -------------------------------------------------------------------------------- 1 | " Syntax highlighting for snippet files (used for snipMate.vim) 2 | " Hopefully this should make snippets a bit nicer to write! 3 | syn match snipComment '^#.*' 4 | syn match placeHolder '\${\d\+\(:.\{-}\)\=}' contains=snipCommand 5 | syn match tabStop '\$\d\+' 6 | syn match snipCommand '`.\{-}`' 7 | syn match snippet '^snippet.*' transparent contains=multiSnipText,snipKeyword 8 | syn match multiSnipText '\S\+ \zs.*' contained 9 | syn match snipKeyword '^snippet'me=s+8 contained 10 | syn match snipError "^[^#s\t].*$" 11 | 12 | hi link snipComment Comment 13 | hi link multiSnipText String 14 | hi link snipKeyword Keyword 15 | hi link snipComment Comment 16 | hi link placeHolder Special 17 | hi link tabStop Special 18 | hi link snipCommand String 19 | hi link snipError Error 20 | -------------------------------------------------------------------------------- /vim/ftplugin/python/python_doc.py.vim: -------------------------------------------------------------------------------- 1 | " Vim Python documentation invoker. 2 | " 3 | " Version: 1.0 4 | " Author: Łukasz Langa 5 | 6 | " don't load twice 7 | if exists('g:loaded_python_doc') 8 | finish 9 | endif 10 | 11 | if !exists('g:embedded_python_version') || g:embedded_python_version < 240 || g:embedded_python_version > 299 12 | "echo "This plugin requires Python 2.4+ (not 3.x though)." 13 | let g:loaded_python_doc = "ERROR" 14 | finish 15 | else 16 | let g:loaded_python_doc = "py1.0" 17 | endif 18 | 19 | python << endpython 20 | import os, sys, vim 21 | path = "/ftplugin/python/python_doc.py" 22 | prefix = "~/.vim" 23 | if sys.platform in ('win32',): 24 | path = path.replace('/', '\\') 25 | prefix = r"C:\Tools\Vim\vimfiles" 26 | vim.command("pyfile %s%s" % (prefix, path)) 27 | endpython 28 | 29 | command! -nargs=* Pydoc :py PyDocSearch() 30 | 31 | nmap ,p :py PyDocSearch(current_buffer=True) 32 | -------------------------------------------------------------------------------- /vim/ftplugin/javascript/json_formatter.py: -------------------------------------------------------------------------------- 1 | import re 2 | position_regexp = re.compile(r'line (\d+) column (\d+)') 3 | imports_ok = True 4 | 5 | try: 6 | import simplejson as json 7 | except ImportError: 8 | try: 9 | import json 10 | except ImportError: 11 | imports_ok = False 12 | 13 | import vim 14 | 15 | def ReformatJSON(): 16 | if not imports_ok: 17 | print "JSON formatter requires simplejson or Python 2.6+." 18 | return 19 | 20 | try: 21 | json_string = json.loads('\n'.join(vim.current.buffer)) 22 | vim.current.buffer[:] = json.dumps(json_string, indent=2).split('\n') 23 | except ValueError, ve: 24 | message = str(ve) 25 | positions = position_regexp.search(message) 26 | if positions: 27 | vim.command('norm ' + positions.group(1) + 'G') 28 | vim.command('norm ' + str(int(positions.group(2)) + 1) + '|') 29 | print message 30 | -------------------------------------------------------------------------------- /vim/ftplugin/javascript/json_formatter.py.vim: -------------------------------------------------------------------------------- 1 | " json_formatter_py.vim 2 | " Author: Łukasz Langa 3 | " Created: Mon Feb 02 00:32:12 CET 2010 4 | " Requires: Vim Ver7.0+ 5 | " Version: 1.0 6 | " 7 | " Documentation: 8 | " This plugin validates and formats JSON files. 9 | " 10 | " History: 11 | " 1.0: 12 | " - initial version 13 | 14 | if v:version < 700 || !has('python') 15 | echo "This script requires vim7.0+ with Python support." 16 | finish 17 | endif 18 | 19 | if exists("g:load_json_formatter") 20 | finish 21 | endif 22 | 23 | let g:load_json_formatter = "py1.0" 24 | 25 | python << endpython 26 | import os, sys, vim 27 | path = "/ftplugin/javascript/json_formatter.py" 28 | prefix = "~/.vim" 29 | if sys.platform in ('win32',): 30 | path = path.replace('/', '\\') 31 | prefix = r"C:\Tools\Vim\vimfiles" 32 | vim.command("pyfile %s%s" % (prefix, path)) 33 | endpython 34 | 35 | command! ReformatJSON :py ReformatJSON() 36 | 37 | nmap ,= :ReformatJSON 38 | vmap ,= :ReformatJSON 39 | -------------------------------------------------------------------------------- /vim/snippets/mako.snippets: -------------------------------------------------------------------------------- 1 | snippet def 2 | <%def name="${1:name}"> 3 | ${2:} 4 | 5 | snippet call 6 | <%call expr="${1:name}"> 7 | ${2:} 8 | 9 | snippet doc 10 | <%doc> 11 | ${1:} 12 | 13 | snippet text 14 | <%text> 15 | ${1:} 16 | 17 | snippet for 18 | % for ${1:i} in ${2:iter}: 19 | ${3:} 20 | % endfor 21 | snippet if if 22 | % if ${1:condition}: 23 | ${2:} 24 | % endif 25 | snippet if if/else 26 | % if ${1:condition}: 27 | ${2:} 28 | % else: 29 | ${3:} 30 | % endif 31 | snippet try 32 | % try: 33 | ${1:} 34 | % except${2:}: 35 | ${3:pass} 36 | % endtry 37 | snippet wh 38 | % while ${1:}: 39 | ${2:} 40 | % endwhile 41 | snippet $ 42 | ${ ${1:} } 43 | snippet <% 44 | <% ${1:} %> 45 | snippet 47 | snippet inherit 48 | <%inherit file="${1:filename}" /> 49 | snippet include 50 | <%include file="${1:filename}" /> 51 | snippet namespace 52 | <%namespace file="${1:name}" /> 53 | snippet page 54 | <%page args="${1:}" /> 55 | -------------------------------------------------------------------------------- /vim/autoload/chef/finder/lwrp.vim: -------------------------------------------------------------------------------- 1 | let s:finder = {} 2 | 3 | function! s:finder.condition() "{{{1 4 | return index(self.lwrp_names(), self.env.cword) != -1 5 | endfunction 6 | 7 | function! s:finder.find() "{{{1 8 | let ident = self.env.cword 9 | call self.debug("search " . ident) 10 | 11 | let file = self.lwrp()[ident] 12 | call self.edit(file) 13 | call remove(self, '_cache') 14 | return 1 15 | endfunction 16 | 17 | function! s:finder.lwrp() 18 | if has_key(self, '._cache') 19 | return self._cache 20 | endif 21 | let lwrp = {} 22 | for path in split(globpath(self.env.path.cookbooks, '*/providers/*.rb', 1), '\n') 23 | let name = join(matchlist(path, 'cookbooks/\zs\(.*\)/providers/\(.*\)\.rb$')[1:2], '_') 24 | let lwrp[name] = path 25 | endfor 26 | let self._cache = lwrp 27 | return self._cache 28 | endfunction 29 | 30 | function! s:finder.lwrp_names() 31 | return keys(self.lwrp()) 32 | endfunction 33 | 34 | function! chef#finder#lwrp#new() "{{{1 35 | return chef#finder#new(s:finder) 36 | endfunction 37 | " vim: set sw=4 sts=4 et fdm=marker: 38 | -------------------------------------------------------------------------------- /vim/autoload/chef/finder/recipe.vim: -------------------------------------------------------------------------------- 1 | let s:finder = {} 2 | 3 | function! s:finder.condition() "{{{1 4 | let val1 = (self.env.line =~# '\' && self.env.cword !=# 'include_recipe') 5 | if val1 | return 1 | endif 6 | 7 | let val2 = (self.env.basename == 'metadata.rb' 8 | \ && self.env.line =~# '^recipe\s\+' 9 | \ && self.env.cword !=# 'recipe' ) 10 | if val2 | return 1 | endif 11 | endfunction 12 | 13 | function! s:finder.find() "{{{1 14 | let [recipe ;node_part ] = split(self.env.cword, "::") 15 | 16 | call self.debug(string([recipe, node_part])) 17 | let node = empty(node_part) ? 'default.rb' : node_part[0] . ".rb" 18 | let fpath = join([self.env.path.cookbooks, recipe, "recipes", node ], '/') 19 | if filereadable(fpath) 20 | call self.edit(fpath) 21 | return 1 22 | else 23 | call self.msg(fpath . " not found") 24 | return 0 25 | endif 26 | endfunction 27 | 28 | 29 | function! chef#finder#recipe#new() "{{{1 30 | return chef#finder#new(s:finder) 31 | endfunction 32 | " vim: set sw=4 sts=4 et fdm=marker: 33 | 34 | -------------------------------------------------------------------------------- /profile_machine/darwin: -------------------------------------------------------------------------------- 1 | # Mac OS X specific settings 2 | 3 | # 4 | # my exports 5 | # 6 | # Brew 7 | export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:$PATH 8 | export EDITOR="/usr/local/bin/mvim -f" 9 | if [[ $TERM_PROGRAM == "iTerm.app" ]]; then 10 | export TERM=xterm-256color 11 | fi 12 | 13 | export PATH=${PATH}:/Applications/android-sdk/platform-tools 14 | export PATH=${PATH}:$HOME/Documents/scripts 15 | 16 | # 17 | # my aliases 18 | # 19 | 20 | # 21 | # my functions 22 | # 23 | 24 | unalias vim 25 | function vim { 26 | # this handles cases where no file is expected or 27 | # unnecessary E247 errors at first MacVim startup 28 | # or when there is no MacVim window open 29 | FILE_SPECIFIED=0 30 | for arg in "$@"; do 31 | if [[ `expr "$arg" : '-'` -eq 0 ]]; then 32 | FILE_SPECIFIED=1 33 | fi 34 | done 35 | if [[ $FILE_SPECIFIED -eq 1 ]]; then 36 | mvim -XO1 --remote-tab-silent $@ 37 | else 38 | mvim -XO1 $@ 39 | fi 40 | } 41 | 42 | # git completion 43 | if [ -f `brew --prefix`/etc/bash_completion.d/git-completion.bash ]; then 44 | . `brew --prefix`/etc/bash_completion.d/git-completion.bash 45 | fi 46 | -------------------------------------------------------------------------------- /vim/snippets/zsh.snippets: -------------------------------------------------------------------------------- 1 | # #!/bin/zsh 2 | snippet #! 3 | #!/bin/zsh 4 | 5 | snippet if 6 | if ${1:condition}; then 7 | ${2:# statements} 8 | fi 9 | snippet ife 10 | if ${1:condition}; then 11 | ${2:# statements} 12 | else 13 | ${3:# statements} 14 | fi 15 | snippet elif 16 | elif ${1:condition} ; then 17 | ${2:# statements} 18 | snippet for 19 | for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do 20 | ${3:# statements} 21 | done 22 | snippet fore 23 | for ${1:item} in ${2:list}; do 24 | ${3:# statements} 25 | done 26 | snippet wh 27 | while ${1:condition}; do 28 | ${2:# statements} 29 | done 30 | snippet until 31 | until ${1:condition}; do 32 | ${2:# statements} 33 | done 34 | snippet repeat 35 | repeat ${1:integer}; do 36 | ${2:# statements} 37 | done 38 | snippet case 39 | case ${1:word} in 40 | ${2:pattern}) 41 | ${3};; 42 | esac 43 | snippet select 44 | select ${1:answer} in ${2:choices}; do 45 | ${3:# statements} 46 | done 47 | snippet ( 48 | ( ${1:#statements} ) 49 | snippet { 50 | { ${1:#statements} } 51 | snippet [ 52 | [[ ${1:test} ]] 53 | snippet always 54 | { ${1:try} } always { ${2:always} } 55 | snippet fun 56 | function ${1:name} (${2:args}) { 57 | ${3:# body} 58 | } 59 | -------------------------------------------------------------------------------- /vim/after/plugin/snipMate.vim: -------------------------------------------------------------------------------- 1 | " These are the mappings for snipMate.vim. Putting it here ensures that it 2 | " will be mapped after other plugins such as supertab.vim. 3 | if !exists('loaded_snips') || exists('s:did_snips_mappings') 4 | finish 5 | endif 6 | let s:did_snips_mappings = 1 7 | 8 | ino =TriggerSnippet() 9 | snor i=TriggerSnippet() 10 | ino =BackwardsSnippet() 11 | snor i=BackwardsSnippet() 12 | ino =ShowAvailableSnips() 13 | 14 | " The default mappings for these are annoying & sometimes break snipMate. 15 | " You can change them back if you want, I've put them here for convenience. 16 | snor b 17 | snor a 18 | snor bi 19 | snor ' b' 20 | snor ` b` 21 | snor % b% 22 | snor U bU 23 | snor ^ b^ 24 | snor \ b\ 25 | snor b 26 | 27 | " By default load snippets in snippets_dir 28 | if empty(snippets_dir) 29 | finish 30 | endif 31 | 32 | call GetSnippets(snippets_dir, '_') " Get global snippets 33 | 34 | au FileType * if &ft != 'help' | call GetSnippets(snippets_dir, &ft) | endif 35 | " vim:noet:sw=4:ts=4:ft=vim 36 | -------------------------------------------------------------------------------- /profile: -------------------------------------------------------------------------------- 1 | # 2 | # Bash-specific profile. For Zsh specific look at zshrc, 3 | # for common variables look at profile_common. 4 | # 5 | 6 | # 7 | # the prompt 8 | # 9 | if [ -e ~/.pscolors ]; then 10 | source ~/.pscolors 11 | fi 12 | export PS1="$PS_USERCOLOR\\u$PS_ATCOLOR@$PS_HOSTCOLOR\\H$PS_COLONCOLOR:$PS_PATHCOLOR\\w$PS_PROMPTCOLOR $ $PS_NOCOLOR" 13 | 14 | # 15 | # my Bash modifications 16 | # 17 | shopt -s histappend cdspell 18 | bind Space:magic-space 19 | bind -m vi-insert "\C-n":menu-complete 20 | bind -m vi-insert "\C-p":dynamic-complete-history 21 | bind -m vi-insert "\C-a":vi-append-eol 22 | 23 | export HISTCONTROL=erasedups 24 | export HISTSIZE=10000 25 | export PROMPT_COMMAND="history -a; history -n; $PROMPT_COMMAND" 26 | set -o vi 27 | 28 | 29 | source ~/.profile_common 30 | 31 | # 32 | # load Bash completion if found 33 | # 34 | if [ -f /opt/local/etc/bash_completion ]; then 35 | . /opt/local/etc/bash_completion 36 | elif [ -f /etc/bash_completion ]; then 37 | . /etc/bash_completion 38 | fi 39 | 40 | if [ -f ~/.bash_customizations ]; then 41 | . ~/.bash_customizations 42 | fi 43 | 44 | if [ -f ~/.bash_aliases ]; then 45 | . ~/.bash_aliases 46 | fi 47 | test -e /home/zen/.wikia-profile && source /home/zen/.wikia-profile #=- Wikia 48 | -------------------------------------------------------------------------------- /vim/autoload/chef/finder/related.vim: -------------------------------------------------------------------------------- 1 | let s:finder = {} 2 | 3 | let s:relation = { 4 | \ 'recipes': "attributes", 5 | \ 'attributes': "recipes", 6 | \ 'providers': "resources", 7 | \ 'resources': "providers", 8 | \ } 9 | function! s:finder.find() "{{{1 10 | let candidate = [] 11 | let related = get(s:relation, self.env.type_name,"") 12 | if !empty(related) 13 | let candidate = [ 14 | \ self.env.path[related] . "/" . self.env.basename, 15 | \ self.env.path[related] . "/" . "default.rb" 16 | \ ] 17 | endif 18 | 19 | call self.debug(candidate) 20 | let related_found = 0 21 | 22 | for file in candidate 23 | if filereadable(file) 24 | let related_found = 1 25 | call self.edit(file) 26 | break 27 | endif 28 | endfor 29 | 30 | if related_found 31 | return 1 32 | else 33 | if !empty(related) 34 | call self.msg(related . "not found") 35 | else 36 | call self.msg("can't detemine related file") 37 | endif 38 | return 0 39 | endif 40 | endfunction 41 | 42 | function! chef#finder#related#new() "{{{1 43 | return chef#finder#new(s:finder) 44 | endfunction 45 | " vim: set sw=4 sts=4 et fdm=marker: 46 | 47 | -------------------------------------------------------------------------------- /vim/snippets/autoit.snippets: -------------------------------------------------------------------------------- 1 | snippet if 2 | If ${1:condition} Then 3 | ${2:; True code} 4 | EndIf 5 | snippet el 6 | Else 7 | ${1} 8 | snippet elif 9 | ElseIf ${1:condition} Then 10 | ${2:; True code} 11 | # If/Else block 12 | snippet ifel 13 | If ${1:condition} Then 14 | ${2:; True code} 15 | Else 16 | ${3:; Else code} 17 | EndIf 18 | # If/ElseIf/Else block 19 | snippet ifelif 20 | If ${1:condition 1} Then 21 | ${2:; True code} 22 | ElseIf ${3:condition 2} Then 23 | ${4:; True code} 24 | Else 25 | ${5:; Else code} 26 | EndIf 27 | # Switch block 28 | snippet switch 29 | Switch (${1:condition}) 30 | Case {$2:case1}: 31 | {$3:; Case 1 code} 32 | Case Else: 33 | {$4:; Else code} 34 | EndSwitch 35 | # Select block 36 | snippet select 37 | Select (${1:condition}) 38 | Case {$2:case1}: 39 | {$3:; Case 1 code} 40 | Case Else: 41 | {$4:; Else code} 42 | EndSelect 43 | # While loop 44 | snippet while 45 | While (${1:condition}) 46 | ${2:; code...} 47 | WEnd 48 | # For loop 49 | snippet for 50 | For ${1:n} = ${3:1} to ${2:count} 51 | ${4:; code...} 52 | Next 53 | # New Function 54 | snippet func 55 | Func ${1:fname}(${2:`indent('.') ? 'self' : ''`}): 56 | ${4:Return} 57 | EndFunc 58 | # Message box 59 | snippet msg 60 | MsgBox(${3:MsgType}, ${1:"Title"}, ${2:"Message Text"}) 61 | # Debug Message 62 | snippet debug 63 | MsgBox(0, "Debug", ${1:"Debug Message"}) 64 | # Show Variable Debug Message 65 | snippet showvar 66 | MsgBox(0, "${1:VarName}", $1) 67 | -------------------------------------------------------------------------------- /vim/snippets/java.snippets: -------------------------------------------------------------------------------- 1 | snippet main 2 | public static void main (String [] args) 3 | { 4 | ${1:/* code */} 5 | } 6 | snippet pu 7 | public 8 | snippet po 9 | protected 10 | snippet pr 11 | private 12 | snippet st 13 | static 14 | snippet fi 15 | final 16 | snippet ab 17 | abstract 18 | snippet re 19 | return 20 | snippet br 21 | break; 22 | snippet de 23 | default: 24 | ${1} 25 | snippet ca 26 | catch(${1:Exception} ${2:e}) ${3} 27 | snippet th 28 | throw 29 | snippet sy 30 | synchronized 31 | snippet im 32 | import 33 | snippet j.u 34 | java.util 35 | snippet j.i 36 | java.io. 37 | snippet j.b 38 | java.beans. 39 | snippet j.n 40 | java.net. 41 | snippet j.m 42 | java.math. 43 | snippet if 44 | if (${1}) ${2} 45 | snippet el 46 | else 47 | snippet elif 48 | else if (${1}) ${2} 49 | snippet wh 50 | while (${1}) ${2} 51 | snippet for 52 | for (${1}; ${2}; ${3}) ${4} 53 | snippet fore 54 | for (${1} : ${2}) ${3} 55 | snippet sw 56 | switch (${1}) ${2} 57 | snippet cs 58 | case ${1}: 59 | ${2} 60 | ${3} 61 | snippet tc 62 | public class ${1:`Filename()`} extends ${2:TestCase} 63 | snippet t 64 | public void test${1:Name}() throws Exception ${2} 65 | snippet cl 66 | class ${1:`Filename("", "untitled")`} ${2} 67 | snippet in 68 | interface ${1:`Filename("", "untitled")`} ${2:extends Parent}${3} 69 | snippet m 70 | ${1:void} ${2:method}(${3}) ${4:throws }${5} 71 | snippet v 72 | ${1:String} ${2:var}${3: = null}${4};${5} 73 | snippet co 74 | static public final ${1:String} ${2:var} = ${3};${4} 75 | snippet cos 76 | static public final String ${1:var} = "${2}";${3} 77 | snippet as 78 | assert ${1:test} : "${2:Failure message}";${3} 79 | -------------------------------------------------------------------------------- /vim/snippets/javascript.snippets: -------------------------------------------------------------------------------- 1 | # Prototype 2 | snippet proto 3 | ${1:class_name}.prototype.${2:method_name} = 4 | function(${3:first_argument}) { 5 | ${4:// body...} 6 | }; 7 | # Function 8 | snippet fun 9 | function ${1:function_name} (${2:argument}) { 10 | ${3:// body...} 11 | } 12 | # Anonymous Function 13 | snippet f 14 | function(${1}) {${2}}; 15 | # if 16 | snippet if 17 | if (${1:true}) {${2}}; 18 | # if ... else 19 | snippet ife 20 | if (${1:true}) {${2}} 21 | else{${3}}; 22 | # tertiary conditional 23 | snippet t 24 | ${1:/* condition */} ? ${2:a} : ${3:b} 25 | # switch 26 | snippet switch 27 | switch(${1:expression}) { 28 | case '${3:case}': 29 | ${4:// code} 30 | break; 31 | ${5} 32 | default: 33 | ${2:// code} 34 | } 35 | # case 36 | snippet case 37 | case '${1:case}': 38 | ${2:// code} 39 | break; 40 | ${3} 41 | # for (...) {...} 42 | snippet for 43 | for (var ${2:i} = 0; $2 < ${1:Things}.length; $2${3:++}) { 44 | ${4:$1[$2]} 45 | }; 46 | # for (...) {...} (Improved Native For-Loop) 47 | snippet forr 48 | for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2${3:--}) { 49 | ${4:$1[$2]} 50 | }; 51 | # while (...) {...} 52 | snippet wh 53 | while (${1:/* condition */}) { 54 | ${2:/* code */} 55 | } 56 | # do...while 57 | snippet do 58 | do { 59 | ${2:/* code */} 60 | } while (${1:/* condition */}); 61 | # Object Method 62 | snippet :f 63 | ${1:method_name}: function(${2:attribute}) { 64 | ${4} 65 | }${3:,} 66 | # setTimeout function 67 | snippet timeout 68 | setTimeout(function() {${3}}${2}, ${1:10}; 69 | # Get Elements 70 | snippet get 71 | getElementsBy${1:TagName}('${2}')${3} 72 | # Get Element 73 | snippet gett 74 | getElementBy${1:Id}('${2}')${3} 75 | -------------------------------------------------------------------------------- /bin/macports-bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #port clean installed 4 | #port -f uninstall installed 5 | 6 | #port selfupdate 7 | 8 | P="port install" 9 | 10 | $P bash-completion 11 | $P colordiff 12 | $P curl 13 | $P fwknop 14 | $P gawk 15 | $P gimp2 16 | $P gtk2-aurora 17 | $P gtk-theme-switch 18 | $P htop 19 | $P ImageMagick +jpeg2 20 | $P lftp 21 | $P mc 22 | $P memcached 23 | $P minicom 24 | $P mysql5-server 25 | $P nmap 26 | $P pbzip2 27 | $P postgresql84 28 | $P postgresql84-server 29 | $P ctags 30 | $P python24 31 | $P py-setuptools 32 | $P py-ctags 33 | $P python25 34 | $P py25-setuptools 35 | $P py25-ctags 36 | $P python26 37 | $P py26-distribute 38 | $P py26-ctags 39 | $P python27 40 | $P py27-distribute 41 | $P python31 42 | $P py31-distribute 43 | $P pwgen 44 | $P smartmontools 45 | $P source-highlight 46 | $P spidermonkey 47 | $P splint 48 | $P sqlite3 49 | $P subversion +bash_completion +tools 50 | $P TeXShop 51 | $P tree 52 | $P valgrind 53 | $P watch 54 | $P wget 55 | $P wine-devel 56 | $P zsh-devel 57 | 58 | # with dependencies 59 | $P bzr 60 | $P git-core +bash_completion +svn 61 | $P MacVim +huge +python26 +cscope 62 | $P mercurial +bash_completion 63 | $P vim +huge +python26 +shell +x11 +cscope 64 | 65 | # do some default setup 66 | defaults write org.vim.MacVim MMZoomBoth 1 67 | defaults write org.vim.MacVim MMCellWidthMultiplier 1.0 68 | # if the second one does not work, remember to use the "experimental renderer" 69 | 70 | port load memcached 71 | echo "You might want to set your hostname permanently:" 72 | echo "$ sudo scutil --set HostName Macallan.local" 73 | echo. 74 | echo "You might want to load and configure MySQL Server:" 75 | echo "$ sudo port load mysql5-server" 76 | echo "$ sudo -u _mysql mysql_install_db5" 77 | -------------------------------------------------------------------------------- /vim/autoload/chef/finder/definition.vim: -------------------------------------------------------------------------------- 1 | let s:finder = {} 2 | 3 | function! s:finder.condition() "{{{1 4 | " echo s:definition_names() 5 | return index(self.definition_names(), ":" . self.env.cword) != -1 6 | endfunction 7 | 8 | function! s:finder.find() "{{{1 9 | " call self.debug(self.definition_table()) 10 | let ident = ':' . self.env.cword 11 | call self.debug("search " . ident) 12 | 13 | let file = self.definition_table()[ident] 14 | call self.edit(file) 15 | call search(ident) 16 | return 1 17 | endfunction 18 | 19 | function! s:finder.definition_files() 20 | ret result = [] 21 | let result = split(globpath(self.env.path.cookbooks, '*/definitions/*.rb', 1),"\n") 22 | return result 23 | endfunction 24 | 25 | function! s:finder.definition_names() 26 | let names = keys(self.definition_table()) 27 | call self.debug(names) 28 | return names 29 | endfunction 30 | 31 | function! s:finder.definition_table() 32 | " if !has_key(self, '_table') 33 | let table = {} 34 | let pattern = '^define\s\+\(:\w\+\)[, ]' 35 | for file in self.definition_files() 36 | for line in readfile(file) 37 | " echo line 38 | let m = matchlist(line, pattern) 39 | if !empty(m) 40 | let table[m[1]] = file 41 | " let table[m[1]] = { 'file': file, 'mtime': getftime(file)} 42 | endif 43 | endfor 44 | endfor 45 | call self.debug("table initialized") 46 | let self._table = table 47 | " endif 48 | return self._table 49 | endfunction 50 | 51 | function! chef#finder#definition#new() "{{{1 52 | return chef#finder#new(s:finder) 53 | endfunction 54 | " vim: set sw=4 sts=4 et fdm=marker: 55 | -------------------------------------------------------------------------------- /vim/nerdtree_plugin/exec_menuitem.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================ 2 | " File: exec_menuitem.vim 3 | " Description: plugin for NERD Tree that provides an execute file menu item 4 | " Maintainer: Martin Grenfell 5 | " Last Change: 22 July, 2009 6 | " License: This program is free software. It comes without any warranty, 7 | " to the extent permitted by applicable law. You can redistribute 8 | " it and/or modify it under the terms of the Do What The Fuck You 9 | " Want To Public License, Version 2, as published by Sam Hocevar. 10 | " See http://sam.zoy.org/wtfpl/COPYING for more details. 11 | " 12 | " ============================================================================ 13 | if exists("g:loaded_nerdtree_exec_menuitem") 14 | finish 15 | endif 16 | let g:loaded_nerdtree_exec_menuitem = 1 17 | 18 | call NERDTreeAddMenuItem({ 19 | \ 'text': '(!)Execute file', 20 | \ 'shortcut': '!', 21 | \ 'callback': 'NERDTreeExecFile', 22 | \ 'isActiveCallback': 'NERDTreeExecFileActive' }) 23 | 24 | function! NERDTreeExecFileActive() 25 | let node = g:NERDTreeFileNode.GetSelected() 26 | return !node.path.isDirectory && node.path.isExecutable 27 | endfunction 28 | 29 | function! NERDTreeExecFile() 30 | let treenode = g:NERDTreeFileNode.GetSelected() 31 | echo "==========================================================\n" 32 | echo "Complete the command to execute (add arguments etc):\n" 33 | let cmd = treenode.path.str({'escape': 1}) 34 | let cmd = input(':!', cmd . ' ') 35 | 36 | if cmd != '' 37 | exec ':!' . cmd 38 | else 39 | echo "Aborted" 40 | endif 41 | endfunction 42 | -------------------------------------------------------------------------------- /vim/plugin/31-create-scala.vim: -------------------------------------------------------------------------------- 1 | " Vim plugin that generates new Scala source file when you type 2 | " vim nonexistent.scala. 3 | " Scripts tries to detect package name from the directory path, e. g. 4 | " .../src/main/scala/com/mycompany/myapp/app.scala gets header 5 | " package com.mycompany.myapp 6 | " 7 | " Author : Stepan Koltsov 8 | 9 | function! MakeScalaFile() 10 | if exists("b:template_used") && b:template_used 11 | return 12 | endif 13 | 14 | let b:template_used = 1 15 | 16 | let filename = expand(":p") 17 | let x = substitute(filename, "\.scala$", "", "") 18 | 19 | let p = substitute(x, "/[^/]*$", "", "") 20 | let p = substitute(p, "/", ".", "g") 21 | let p = substitute(p, ".*\.src$", "@", "") " unnamed package 22 | let p = substitute(p, ".*\.src\.", "!", "") 23 | let p = substitute(p, "^!main\.scala\.", "!", "") " 24 | let p = substitute(p, "^!.*\.ru\.", "!ru.", "") 25 | let p = substitute(p, "^!.*\.org\.", "!org.", "") 26 | let p = substitute(p, "^!.*\.com\.", "!com.", "") 27 | 28 | " ! marks that we found package name. 29 | if match(p, "^!") == 0 30 | let p = substitute(p, "^!", "", "") 31 | else 32 | " Don't know package name. 33 | let p = "@" 34 | endif 35 | 36 | let class = substitute(x, ".*/", "", "") 37 | 38 | if p != "@" 39 | call append("0", "package " . p) 40 | endif 41 | 42 | "norm G 43 | "call append(".", "class " . class . " {") 44 | 45 | "norm G 46 | "call append(".", "} /// end of " . class) 47 | 48 | call append(".", "// vim: set ts=4 sw=4 et:") 49 | call append(".", "") 50 | 51 | endfunction 52 | 53 | au BufNewFile *.scala call MakeScalaFile() 54 | 55 | " vim: set ts=4 sw=4 et: 56 | -------------------------------------------------------------------------------- /vim/snippets/tcl.snippets: -------------------------------------------------------------------------------- 1 | # #!/usr/bin/tclsh 2 | snippet #! 3 | #!/usr/bin/tclsh 4 | 5 | # Process 6 | snippet pro 7 | proc ${1:function_name} {${2:args}} { 8 | ${3:#body ...} 9 | } 10 | #xif 11 | snippet xif 12 | ${1:expr}? ${2:true} : ${3:false} 13 | # Conditional 14 | snippet if 15 | if {${1}} { 16 | ${2:# body...} 17 | } 18 | # Conditional if..else 19 | snippet ife 20 | if {${1}} { 21 | ${2:# body...} 22 | } else { 23 | ${3:# else...} 24 | } 25 | # Conditional if..elsif..else 26 | snippet ifee 27 | if {${1}} { 28 | ${2:# body...} 29 | } elseif {${3}} { 30 | ${4:# elsif...} 31 | } else { 32 | ${5:# else...} 33 | } 34 | # If catch then 35 | snippet ifc 36 | if { [catch {${1:#do something...}} ${2:err}] } { 37 | ${3:# handle failure...} 38 | } 39 | # Catch 40 | snippet catch 41 | catch {${1}} ${2:err} ${3:options} 42 | # While Loop 43 | snippet wh 44 | while {${1}} { 45 | ${2:# body...} 46 | } 47 | # For Loop 48 | snippet for 49 | for {set ${2:var} 0} {$$2 < ${1:count}} {${3:incr} $2} { 50 | ${4:# body...} 51 | } 52 | # Foreach Loop 53 | snippet fore 54 | foreach ${1:x} {${2:#list}} { 55 | ${3:# body...} 56 | } 57 | # after ms script... 58 | snippet af 59 | after ${1:ms} ${2:#do something} 60 | # after cancel id 61 | snippet afc 62 | after cancel ${1:id or script} 63 | # after idle 64 | snippet afi 65 | after idle ${1:script} 66 | # after info id 67 | snippet afin 68 | after info ${1:id} 69 | # Expr 70 | snippet exp 71 | expr {${1:#expression here}} 72 | # Switch 73 | snippet sw 74 | switch ${1:var} { 75 | ${3:pattern 1} { 76 | ${4:#do something} 77 | } 78 | default { 79 | ${2:#do something} 80 | } 81 | } 82 | # Case 83 | snippet ca 84 | ${1:pattern} { 85 | ${2:#do something} 86 | }${3} 87 | # Namespace eval 88 | snippet ns 89 | namespace eval ${1:path} {${2:#script...}} 90 | # Namespace current 91 | snippet nsc 92 | namespace current 93 | -------------------------------------------------------------------------------- /vim/autoload/chef/environment.vim: -------------------------------------------------------------------------------- 1 | let s:Environment = {} 2 | 3 | function! s:index(list, regexp) "{{{1 4 | for [idx, val] in reverse(map(copy(a:list), '[v:key, v:val]')) 5 | if val =~# a:regexp 6 | return idx 7 | endif 8 | endfor 9 | return -1 10 | endfunction 11 | 12 | function! s:Environment.new() "{{{1 13 | let org = expand('%:p') 14 | let dirs = split(org, '/') 15 | let cookbook_root = "/" . join(dirs[0: s:index(dirs, '\v.*cookbooks')], '/') 16 | let recipe_name = dirs[s:index(dirs, '\v.*cookbooks')+1] 17 | let recipe_root = cookbook_root . "/" . recipe_name 18 | 19 | let part = split(org[len(recipe_root):],'/') 20 | let type_name = len(part) > 1 ? part[0] : "NONE" 21 | 22 | let env = { 23 | \ 'line': getline('.'), 24 | \ 'cword': expand(''), 25 | \ 'cWORD': expand(''), 26 | \ 'cfile': expand(''), 27 | \ 'basename': fnamemodify(org,":p:t"), 28 | \ 'recipe_name': recipe_name, 29 | \ 'type_name': type_name, 30 | \ } 31 | let env.ext = fnamemodify(env.cfile,":p:e") 32 | 33 | let env.path = {} 34 | let env.path = { 35 | \ 'org': org, 36 | \ 'cookbooks': cookbook_root, 37 | \ 'recipe': recipe_root, 38 | \ 'recipes': recipe_root."/recipes", 39 | \ 'providers': recipe_root."/providers", 40 | \ 'resources': recipe_root."/resources", 41 | \ 'files': recipe_root."/files", 42 | \ 'templates': recipe_root."/templates", 43 | \ 'attributes': recipe_root."/attributes", 44 | \ 'definitions': recipe_root."/definitions" 45 | \ } 46 | return env 47 | endfunction 48 | 49 | function! chef#environment#new() "{{{1 50 | return s:Environment.new() 51 | endfunction 52 | " vim: set sw=4 sts=4 et fdm=marker: 53 | -------------------------------------------------------------------------------- /vim/plugin/toggle_words.py.vim: -------------------------------------------------------------------------------- 1 | " toggle_words_py.vim 2 | " Author: Łukasz Langa 3 | " Created: Mon Feb 01 22:43:12 CET 2010 4 | " Requires: Vim Ver7.0+ 5 | " Version: 1.0 6 | " 7 | " Documentation: 8 | " The purpose of this plugin is very simple, it can toggle words among 9 | " 'true'=>'false', 'True'=>'False', 'if'=>'elseif'=>'else'=>'endif' etc . 10 | " 11 | " To use it, move the cursor on some words like 'true', 'False', 'YES', etc, 12 | " call command 13 | " :ToggleWord 14 | " 15 | " It will toggle 'true'=>'false', 'False'=>'True', 'YES'=>'NO' etc. Yes, 16 | " this script will try to take the case into account when toggling words, so 17 | " 'True' will be toggled to 'False' instead of 'false'. If the translation 18 | " includes upper case letters, the translation case will be preserved. 19 | " 20 | " This script can search the candicate words to toggle based on 21 | " current filetype, for example, you can put the following configuration 22 | " into your .vimrc to define some words for python: 23 | " let g:toggle_words_dict = {'python': [['if', 'elif', 'else']]} 24 | " 25 | " There are some default words for toggling predefined in the 26 | " script(g:_toogle_words_dict) that will work for all filetypes. 27 | " Any comment, suggestion, bug report are welcomed. 28 | " 29 | " History: 30 | " 1.0: 31 | " - initial version based on Vincent Wang's VimScript plugin 32 | 33 | if exists("g:load_toggle_words") 34 | finish 35 | endif 36 | 37 | if !exists('g:embedded_python_version') || g:embedded_python_version < 230 || g:embedded_python_version > 299 38 | "echo "This plugin requires Python 2.3+ (not 3.x though)." 39 | let g:load_toggle_words = "ERROR" 40 | finish 41 | else 42 | let g:load_toggle_words = "py1.0" 43 | endif 44 | 45 | python << endpython 46 | import os, sys, vim 47 | path = "/plugin/toggle_words.py" 48 | prefix = "~/.vim" 49 | if sys.platform in ('win32',): 50 | path = path.replace('/', '\\') 51 | prefix = r"C:\Tools\Vim\vimfiles" 52 | vim.command("pyfile %s%s" % (prefix, path)) 53 | endpython 54 | 55 | command! ToggleWord :py ToggleWord() 56 | 57 | nmap ,t :ToggleWord 58 | -------------------------------------------------------------------------------- /vim/autoload/chef/finder.vim: -------------------------------------------------------------------------------- 1 | let s:finderBase = {} 2 | 3 | function! s:finderBase.new(finder) "{{{1 4 | let o = deepcopy(self) 5 | call extend(o, a:finder, 'force') 6 | return o 7 | endfunction 8 | 9 | function! s:finderBase.init(env) "{{{1 10 | let self.env = a:env 11 | endfunction 12 | 13 | function! s:finderBase.condition() "{{{1 14 | return 1 15 | endfunction 16 | 17 | function! s:finderBase.edit(fpath) "{{{1 18 | silent execute self.env.editcmd . ' ' . a:fpath 19 | call self.path_hl(a:fpath) 20 | endfunction 21 | 22 | function! s:finderBase.path_hl(fpath) "{{{1 23 | let path_str = a:fpath[len(self.env.path.cookbooks) + 1 : ] 24 | let [ recipe, type; rest ] = split(path_str, '/') 25 | let type_color = get(s:color_table, type, 'Special') 26 | let msgs = [[ recipe, "Directory" ], [ type, type_color ], [join(rest,'/'), 'Normal']] 27 | call self.msghl(msgs, '/') 28 | endfunction 29 | 30 | let s:color_table = { 31 | \ 'recipes': "Identifier", 32 | \ 'attributes': "Keyword", 33 | \ 'templates': "Define", 34 | \ 'files': "Define", 35 | \ 'definitions': "String", 36 | \ 'providers': "String", 37 | \ 'resources': "String", 38 | \ } 39 | 40 | function! s:finderBase.msghl(msgs, sep) "{{{1 41 | echohl Identifier 42 | echo "[". self.id ."] " 43 | let last = len(a:msgs) - 1 44 | for idx in range(len(a:msgs)) 45 | let [msg, hl] = a:msgs[idx] 46 | silent execute 'echohl ' . hl 47 | echon msg 48 | echohl Normal 49 | if ! (idx == last) 50 | echon a:sep 51 | endif 52 | endfor 53 | echohl Normal 54 | endfunction 55 | 56 | function! s:finderBase.msg(msg) "{{{1 57 | try 58 | echohl Function 59 | echo "[". self.id ."] " 60 | echohl Normal 61 | echon a:msg 62 | finally 63 | echohl Normal 64 | endtry 65 | endfunction 66 | 67 | function! s:finderBase.debug(msg) "{{{1 68 | if !g:ChefDebug 69 | return 70 | endif 71 | echo "[". self.id ."] " . string(a:msg) 72 | endfunction 73 | 74 | function! chef#finder#new(finder) "{{{1 75 | let finder = s:finderBase.new(a:finder) 76 | return finder 77 | endfunction 78 | " vim: set sw=4 sts=4 et fdm=marker: 79 | -------------------------------------------------------------------------------- /vim/syntax/pyrex.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: Pyrex 3 | " Maintainer: Marco Barisione 4 | " URL: http://marcobari.altervista.org/pyrex_vim.html 5 | " Last Change: 2004 May 16 6 | 7 | " For version 5.x: Clear all syntax items 8 | " For version 6.x: Quit when a syntax file was already loaded 9 | if version < 600 10 | syntax clear 11 | elseif exists("b:current_syntax") 12 | finish 13 | endif 14 | 15 | " Read the Python syntax to start with 16 | if version < 600 17 | so :p:h/python.vim 18 | else 19 | runtime! syntax/python.vim 20 | unlet b:current_syntax 21 | endif 22 | 23 | " Pyrex extentions 24 | syn keyword pyrexStatement cdef typedef ctypedef sizeof 25 | syn keyword pyrexType int long short float double char object void 26 | syn keyword pyrexType signed unsigned 27 | syn keyword pyrexStructure struct union enum 28 | syn keyword pyrexPrecondit include cimport 29 | syn keyword pyrexAccess public private property readonly extern 30 | " If someome wants Python's built-ins highlighted probably he 31 | " also wants Pyrex's built-ins highlighted 32 | if exists("python_highlight_builtins") || exists("pyrex_highlight_builtins") 33 | syn keyword pyrexBuiltin NULL 34 | endif 35 | 36 | " This deletes "from" from the keywords and re-adds it as a 37 | " match with lower priority than pyrexForFrom 38 | syn clear pythonPreCondit 39 | syn keyword pythonPreCondit import 40 | syn match pythonPreCondit "from" 41 | 42 | " With "for[^:]*\zsfrom" VIM does not match "for" anymore, so 43 | " I used the slower "\@<=" form 44 | syn match pyrexForFrom "\(for[^:]*\)\@<=from" 45 | 46 | " Default highlighting 47 | if version >= 508 || !exists("did_pyrex_syntax_inits") 48 | if version < 508 49 | let did_pyrex_syntax_inits = 1 50 | command -nargs=+ HiLink hi link 51 | else 52 | command -nargs=+ HiLink hi def link 53 | endif 54 | HiLink pyrexStatement Statement 55 | HiLink pyrexType Type 56 | HiLink pyrexStructure Structure 57 | HiLink pyrexPrecondit PreCondit 58 | HiLink pyrexAccess pyrexStatement 59 | if exists("python_highlight_builtins") || exists("pyrex_highlight_builtins") 60 | HiLink pyrexBuiltin Function 61 | endif 62 | HiLink pyrexForFrom Statement 63 | 64 | delcommand HiLink 65 | endif 66 | 67 | let b:current_syntax = "pyrex" 68 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | zen's ``.dot_files`` 2 | original author:ambv 3 | 4 | This is my distributed configuration I use for my command-line work on all 5 | servers I have access to. It consists of following parts: 6 | 7 | * ZSh, Bash and coreutils configuration which makes the shell look and behave 8 | virtually the same regardless whether I'm working on *Mac OS X*, *Debian*, 9 | *Fedora*, *Solaris* or *Cygwin* (sic!) 10 | 11 | * the most badass *Python*-oriented *Vim* configuration out there 12 | 13 | * `ack `_ with a sensible default configuration 14 | 15 | * *Git* config that makes the command-line a bit more sexy (*Vim* used for 16 | diffing, colors everywhere) 17 | 18 | * a *Mercurial* config that should be the default (convert, extdiff, fetch, mq 19 | extensions on, ask for username if I didn't input any, merge and diff with 20 | Vim) 21 | 22 | * decent global ``.gitignore`` and ``.hgignore`` files with the most common 23 | temporary and runtime file masks included, plus some *Python* related goodies 24 | 25 | * a *Python* shell startup config that enables readline support 26 | 27 | * an installer for the whole package (for *Python* 2.4-2.7) that enables me to 28 | setup my environment anywhere by simply cloning the repo and running 29 | ``./install.py`` 30 | 31 | * a *MacPorts* bootstrap script that lets me set up a Mac OS X box in just 10 32 | hours or so (compiling, compiling, compiling). No user attendance needed 33 | though so I can run it overnight. 34 | 35 | Y U NO USE PATHOGEN / OHMYZSH / HOMEBREW 36 | ======================================== 37 | 38 | A question I get sometimes is why isn't this configuration using the new and hip 39 | package managers like *Pathogen* for Vim scripts, *oh-my-zsh* for ZSh or 40 | *homebrew* for Mac OS X. The answer is that I want to avoid additional package 41 | managers that become dependencies themselves. I didn't actually try using them 42 | in a distributed manner but my intuition tells me it would complicate the setup. 43 | Remember that its greatest feature is currently the ability to use the whole 44 | thing unmodified on Linux, Mac OS X, Solaris and Cygwin (and native Win32 Vim!). 45 | 46 | How can you benefit from this 47 | ============================= 48 | 49 | The whole thing is virtually public domain, you can take whatever you like and 50 | paste it to your own configuration (e.g. the *Vim* part). Feel free to browse 51 | through the package. I'm open to suggestions, updates and corrections. 52 | -------------------------------------------------------------------------------- /vim/snippets/tex.snippets: -------------------------------------------------------------------------------- 1 | # \begin{}...\end{} 2 | snippet begin 3 | \begin{${1:env}} 4 | ${2} 5 | \end{$1} 6 | # Tabular 7 | snippet tab 8 | \begin{${1:tabular}}{${2:c}} 9 | ${3} 10 | \end{$1} 11 | # Align(ed) 12 | snippet ali 13 | \begin{align${1:ed}} 14 | ${2} 15 | \end{align$1} 16 | # Gather(ed) 17 | snippet gat 18 | \begin{gather${1:ed}} 19 | ${2} 20 | \end{gather$1} 21 | # Equation 22 | snippet eq 23 | \begin{equation} 24 | ${1} 25 | \end{equation} 26 | # Unnumbered Equation 27 | snippet \ 28 | \\[ 29 | ${1} 30 | \\] 31 | # Enumerate 32 | snippet enum 33 | \begin{enumerate} 34 | \item ${1} 35 | \end{enumerate} 36 | # Itemize 37 | snippet item 38 | \begin{itemize} 39 | \item ${1} 40 | \end{itemize} 41 | # Description 42 | snippet desc 43 | \begin{description} 44 | \item[${1}] ${2} 45 | \end{description} 46 | # Matrix 47 | snippet mat 48 | \begin{${1:p/b/v/V/B/small}matrix} 49 | ${2} 50 | \end{$1matrix} 51 | # Cases 52 | snippet cas 53 | \begin{cases} 54 | ${1:equation}, &\text{ if }${2:case}\\ 55 | ${3} 56 | \end{cases} 57 | # Split 58 | snippet spl 59 | \begin{split} 60 | ${1} 61 | \end{split} 62 | # Part 63 | snippet part 64 | \part{${1:part name}} % (fold) 65 | \label{prt:${2:$1}} 66 | ${3} 67 | % part $2 (end) 68 | # Chapter 69 | snippet cha 70 | \chapter{${1:chapter name}} % (fold) 71 | \label{cha:${2:$1}} 72 | ${3} 73 | % chapter $2 (end) 74 | # Section 75 | snippet sec 76 | \section{${1:section name}} % (fold) 77 | \label{sec:${2:$1}} 78 | ${3} 79 | % section $2 (end) 80 | # Sub Section 81 | snippet sub 82 | \subsection{${1:subsection name}} % (fold) 83 | \label{sub:${2:$1}} 84 | ${3} 85 | % subsection $2 (end) 86 | # Sub Sub Section 87 | snippet subs 88 | \subsubsection{${1:subsubsection name}} % (fold) 89 | \label{ssub:${2:$1}} 90 | ${3} 91 | % subsubsection $2 (end) 92 | # Paragraph 93 | snippet par 94 | \paragraph{${1:paragraph name}} % (fold) 95 | \label{par:${2:$1}} 96 | ${3} 97 | % paragraph $2 (end) 98 | # Sub Paragraph 99 | snippet subp 100 | \subparagraph{${1:subparagraph name}} % (fold) 101 | \label{subp:${2:$1}} 102 | ${3} 103 | % subparagraph $2 (end) 104 | snippet itd 105 | \item[${1:description}] ${2:item} 106 | snippet figure 107 | ${1:Figure}~\ref{${2:fig:}}${3} 108 | snippet table 109 | ${1:Table}~\ref{${2:tab:}}${3} 110 | snippet listing 111 | ${1:Listing}~\ref{${2:list}}${3} 112 | snippet section 113 | ${1:Section}~\ref{${2:sec:}}${3} 114 | snippet page 115 | ${1:page}~\pageref{${2}}${3} 116 | -------------------------------------------------------------------------------- /bin/findleak: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # findleak 4 | ########################################################################## 5 | # Script that displays an overview of the virtual memory growth per process 6 | # for the last 14 days. Per process you can find the PID and process name, 7 | # how many days the process has lived (max. 14 days), the total growth of 8 | # the memory consumption during that number of days, and the growth for 9 | # each day (in MiB). 10 | # Processes that were only present for 1 day and processes that did not 11 | # grow are ignored. 12 | # 13 | # Condition to run the script: 14 | # atop version >= 1.24 should be logging in the background. 15 | # ======================================================================== 16 | # Author: Gerlof Langeveld gerlof.langeveld@atoptool.nl 17 | # Initial date: March 2010 18 | # 19 | # Changed by: Gerrit A. Smit GerritASmit@ATComputing.nl 20 | # 21 | # Version: 1.1 22 | ########################################################################## 23 | PERIOD=yyyyyyyyyyyyyyy 24 | DAYCNT=0 25 | 26 | printf " PID COMMAND #DAYS TOTGROWTH DAILYGROWTH (MB)\n" 27 | 28 | # read all data of processes and remember their virtual size 29 | # 30 | while [ "$PERIOD" != "" ] 31 | do 32 | let DAYCNT+=1 33 | 34 | printf -- "Processing day $DAYCNT\r" >&2 35 | 36 | atop -m -r $PERIOD -b 16:58 -e 17:02 2> /dev/null | 37 | grep -v '^[A-Za-z]' | 38 | grep -v '^ *$' | grep -v 'VSIZE' | grep -v ' *?' | 39 | awk '{print $1 "@" $10, $5}' 40 | 41 | PERIOD=`echo $PERIOD | sed 's/y$//'` 42 | done | 43 | awk ' # PROCESS THE FILTERED DATA 44 | # transform the memory-unit (K, M, G) to kilobytes 45 | # 46 | $2 ~ /K$/ { sub(/K$/, "", $2) } 47 | $2 ~ /M$/ { sub(/M$/, "", $2); $2 *= 1024 } 48 | $2 ~ /G$/ { sub(/G$/, "", $2); $2 *= 1024 * 1024 } 49 | 50 | # store info in arrays 51 | # 52 | { if ($1 in procpre) 53 | { 54 | procsiz[$1] = procsiz[$1] " " ($2 - procpre[$1]) 55 | procpre[$1] = $2 56 | procnum[$1] += 1 57 | } 58 | else 59 | { 60 | procpre[$1] = $2 61 | procbeg[$1] = $2 62 | } 63 | 64 | procend[$1] = $2 - procbeg[$1] 65 | } 66 | 67 | END { 68 | for (key in procsiz) 69 | { 70 | if (procend[key] <= 0) 71 | continue 72 | 73 | split(key, keypart, "@") 74 | n = split(procsiz[key], sz) 75 | 76 | printf("%5d %-12.12s %5d %7.2f MB ", 77 | keypart[1], keypart[2], 78 | procnum[key], procend[key]/1024) 79 | 80 | for (i=1; i <= n; i++) 81 | printf("%5.2f ", sz[i]/1024) 82 | 83 | printf("\n") 84 | } 85 | } 86 | ' | sort -k4n 87 | -------------------------------------------------------------------------------- /vim/indent/scala.vim: -------------------------------------------------------------------------------- 1 | " Vim indent file 2 | " Language : Scala (http://scala-lang.org/) 3 | " Maintainer : Stefan Matthias Aust 4 | " Last Change: 2006 Apr 13 5 | " svn co http://lampsvn.epfl.ch/svn-repos/scala/scala-tool-support/trunk/src/vim 6 | 7 | if exists("b:did_indent") 8 | finish 9 | endif 10 | let b:did_indent = 1 11 | 12 | setlocal indentexpr=GetScalaIndent() 13 | 14 | setlocal indentkeys=0{,0},0),!^F,<>>, 15 | 16 | setlocal autoindent sw=2 et 17 | 18 | if exists("*GetScalaIndent") 19 | finish 20 | endif 21 | 22 | function! CountParens(line) 23 | let line = substitute(a:line, '"\(.\|\\"\)*"', '', 'g') 24 | let open = substitute(line, '[^(]', '', 'g') 25 | let close = substitute(line, '[^)]', '', 'g') 26 | return strlen(open) - strlen(close) 27 | endfunction 28 | 29 | function! GetScalaIndent() 30 | " Find a non-blank line above the current line. 31 | let lnum = prevnonblank(v:lnum - 1) 32 | 33 | " Hit the start of the file, use zero indent. 34 | if lnum == 0 35 | return 0 36 | endif 37 | 38 | let ind = indent(lnum) 39 | let prevline = getline(lnum) 40 | 41 | "Indent html literals 42 | if prevline !~ '/>\s*$' && prevline =~ '^\s*<[a-zA-Z][^>]*>\s*$' 43 | return ind + &shiftwidth 44 | endif 45 | 46 | " Add a 'shiftwidth' after lines that start a block 47 | " If if, for or while end with ), this is a one-line block 48 | " If val, var, def end with =, this is a one-line block 49 | if prevline =~ '^\s*\<\(\(else\s\+\)\?if\|for\|while\|va[lr]\|def\)\>.*[)=]\s*$' 50 | \ || prevline =~ '^\s*\\s*$' 51 | \ || prevline =~ '{\s*$' 52 | let ind = ind + &shiftwidth 53 | endif 54 | 55 | " If parenthesis are unbalanced, indent or dedent 56 | let c = CountParens(prevline) 57 | echo c 58 | if c > 0 59 | let ind = ind + &shiftwidth 60 | elseif c < 0 61 | let ind = ind - &shiftwidth 62 | endif 63 | 64 | " Dedent after if, for, while and val, var, def without block 65 | let pprevline = getline(prevnonblank(lnum - 1)) 66 | if pprevline =~ '^\s*\<\(\(else\s\+\)\?if\|for\|while\|va[lr]\|def\)\>.*[)=]\s*$' 67 | \ || pprevline =~ '^\s*\\s*$' 68 | let ind = ind - &shiftwidth 69 | endif 70 | 71 | " Align 'for' clauses nicely 72 | if prevline =~ '^\s*\ (.*;\s*$' 73 | let ind = ind - &shiftwidth + 5 74 | endif 75 | 76 | " Subtract a 'shiftwidth' on '}' or html 77 | let thisline = getline(v:lnum) 78 | if thisline =~ '^\s*[})]' 79 | \ || thisline =~ '^\s*]*>' 80 | let ind = ind - &shiftwidth 81 | endif 82 | 83 | return ind 84 | endfunction 85 | -------------------------------------------------------------------------------- /vim/colors/ambv.vim: -------------------------------------------------------------------------------- 1 | " Vim color file based on David Schweikert's "delek" 2 | " Last Change: 2010 Feb 2 3 | 4 | set background=dark 5 | 6 | hi clear 7 | 8 | if exists("syntax_on") 9 | syntax reset 10 | endif 11 | 12 | let colors_name = "ambv" 13 | 14 | if version >= 700 15 | hi CursorLine ctermbg=233 guibg=#1c1c1c gui=underline 16 | hi CursorColumn ctermbg=233 guibg=#1c1c1c 17 | endif 18 | 19 | " Normal should come first 20 | " hi Normal 21 | " hi Cursor 22 | " hi lCursor 23 | 24 | " Note: we never set 'term' because the defaults for B&W terminals are OK 25 | hi DiffAdd ctermbg=234 guibg=#1c1c1c 26 | hi DiffChange ctermbg=235 guibg=#262626 27 | "hi DiffDelete ctermbg=52 28 | hi DiffDelete ctermfg=52 ctermbg=0 guifg=#5f0000 guibg=#000000 29 | hi DiffText ctermbg=238 ctermfg=White cterm=NONE guibg=#444444 guifg=#ffffff gui=NONE 30 | hi Directory ctermfg=DarkBlue guifg=#2222ee 31 | hi ErrorMsg ctermfg=White ctermbg=DarkRed gui=BOLD guifg=#ffffff guibg=#cd2222 32 | hi FoldColumn ctermfg=White ctermbg=238 guifg=#ffffff guibg=#444444 33 | hi Folded ctermbg=Grey ctermfg=Black guibg=#7f7f7f guifg=#000000 34 | hi IncSearch cterm=reverse gui=reverse 35 | hi LineNr ctermfg=242 guifg=#7c7c7c 36 | hi ModeMsg cterm=bold gui=BOLD 37 | hi MoreMsg ctermfg=DarkGreen guifg=#22cd22 38 | hi NonText ctermfg=237 guifg=#3a3a3a 39 | hi Pmenu ctermfg=White ctermbg=240 guifg=#ffffff guibg=#585858 40 | hi PmenuSel ctermfg=Black ctermbg=250 guifg=#000000 guibg=#bcbcbc 41 | hi Question ctermfg=DarkGreen guifg=#22cd22 42 | hi Search ctermfg=NONE ctermbg=DarkBlue guifg=NONE guibg=#2222ee 43 | hi SpecialKey ctermfg=DarkBlue guifg=#2222ee 44 | hi StatusLine ctermfg=240 ctermbg=white guifg=#585858 guibg=#ffffff 45 | hi StatusLineNC ctermfg=238 ctermbg=253 guifg=#444444 guibg=#dadada 46 | hi Title ctermfg=DarkMagenta guifg=#cd22cd 47 | hi VertSplit ctermfg=238 guifg=#444444 48 | hi Visual ctermbg=235 guibg=#262626 49 | hi VisualNOS cterm=underline,bold gui=underline,bold 50 | hi WarningMsg ctermfg=DarkRed guifg=#cd2222 51 | hi WildMenu ctermfg=Black ctermbg=250 guifg=#000000 guibg=#bcbcbc 52 | 53 | " syntax highlighting 54 | hi Comment cterm=NONE ctermfg=DarkRed gui=NONE guifg=#cd2222 55 | hi Constant cterm=NONE ctermfg=DarkGreen gui=NONE guifg=#22cd22 56 | hi Identifier cterm=NONE ctermfg=DarkCyan gui=BOLD guifg=#22cdcd 57 | hi PreProc cterm=NONE ctermfg=DarkMagenta gui=NONE guifg=#cd22cd 58 | hi Special cterm=NONE ctermfg=60 gui=NONE guifg=#5f5f87 59 | hi Statement cterm=bold ctermfg=Blue gui=BOLD guifg=#7c7cff 60 | hi Type cterm=NONE ctermfg=Blue gui=BOLD guifg=#7c7cff 61 | 62 | highlight OverLength ctermbg=17 ctermfg=white guibg=#000040 63 | highlight ExtraWhitespace ctermbg=17 guibg=#000040 64 | -------------------------------------------------------------------------------- /vim/snippets/c.snippets: -------------------------------------------------------------------------------- 1 | # main() 2 | snippet main 3 | int main(int argc, const char *argv[]) 4 | { 5 | ${1} 6 | return 0; 7 | } 8 | # #include <...> 9 | snippet inc 10 | #include <${1:stdio}.h>${2} 11 | # #include "..." 12 | snippet Inc 13 | #include "${1:`Filename("$1.h")`}"${2} 14 | # #ifndef ... #define ... #endif 15 | snippet Def 16 | #ifndef $1 17 | #define ${1:SYMBOL} ${2:value} 18 | #endif${3} 19 | snippet def 20 | #define 21 | snippet ifdef 22 | #ifdef ${1:FOO} 23 | ${2:#define } 24 | #endif 25 | snippet #if 26 | #if ${1:FOO} 27 | ${2} 28 | #endif 29 | # Header Include-Guard 30 | # (the randomizer code is taken directly from TextMate; it could probably be 31 | # cleaner, I don't know how to do it in vim script) 32 | snippet once 33 | #ifndef ${1:`toupper(Filename('', 'UNTITLED').'_'.system("/usr/bin/ruby -e 'print (rand * 2821109907455).round.to_s(36)'"))`} 34 | 35 | #define $1 36 | 37 | ${2} 38 | 39 | #endif /* end of include guard: $1 */ 40 | # If Condition 41 | snippet if 42 | if (${1:/* condition */}) { 43 | ${2:/* code */} 44 | } 45 | snippet el 46 | else { 47 | ${1} 48 | } 49 | # Tertiary conditional 50 | snippet t 51 | ${1:/* condition */} ? ${2:a} : ${3:b} 52 | # Do While Loop 53 | snippet do 54 | do { 55 | ${2:/* code */} 56 | } while (${1:/* condition */}); 57 | # While Loop 58 | snippet wh 59 | while (${1:/* condition */}) { 60 | ${2:/* code */} 61 | } 62 | # For Loop 63 | snippet for 64 | for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) { 65 | ${4:/* code */} 66 | } 67 | # Custom For Loop 68 | snippet forr 69 | for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) { 70 | ${5:/* code */} 71 | } 72 | # Function 73 | snippet fun 74 | ${1:void} ${2:function_name}(${3}) 75 | { 76 | ${4:/* code */} 77 | } 78 | # Function Declaration 79 | snippet fund 80 | ${1:void} ${2:function_name}(${3});${4} 81 | # Typedef 82 | snippet td 83 | typedef ${1:int} ${2:MyCustomType};${3} 84 | # Struct 85 | snippet st 86 | struct ${1:`Filename('$1_t', 'name')`} { 87 | ${2:/* data */} 88 | }${3: /* optional variable list */};${4} 89 | # Typedef struct 90 | snippet tds 91 | typedef struct ${2:_$1 }{ 92 | ${3:/* data */} 93 | } ${1:`Filename('$1_t', 'name')`}; 94 | # Typdef enum 95 | snippet tde 96 | typedef enum { 97 | ${1:/* data */} 98 | } ${2:foo}; 99 | # printf 100 | # unfortunately version this isn't as nice as TextMates's, given the lack of a 101 | # dynamic `...` 102 | snippet pr 103 | printf("${1:%s}\n"${2});${3} 104 | # fprintf (again, this isn't as nice as TextMate's version, but it works) 105 | snippet fpr 106 | fprintf(${1:stderr}, "${2:%s}\n"${3});${4} 107 | snippet . 108 | [${1}]${2} 109 | snippet un 110 | unsigned 111 | -------------------------------------------------------------------------------- /vim/snippets/perl.snippets: -------------------------------------------------------------------------------- 1 | # #!/usr/bin/perl 2 | snippet #! 3 | #!/usr/bin/perl 4 | 5 | snippet !! 6 | #!/usr/bin/env perl 7 | # -*- coding: utf-8 -*- 8 | 9 | # Copyright (C) 2010 ${1:`g:snips_author`} 10 | # 11 | # This program is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, version 3 of the License. 14 | 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program. If not, see . 22 | 23 | use warnings; 24 | use strict; 25 | 26 | # Hash Pointer 27 | snippet . 28 | => 29 | # Function 30 | snippet sub 31 | sub ${1:function_name} { 32 | ${2:#body ...} 33 | } 34 | # Conditional 35 | snippet if 36 | if (${1}) { 37 | ${2:# body...} 38 | } 39 | # Conditional if..else 40 | snippet ife 41 | if (${1}) { 42 | ${2:# body...} 43 | } else { 44 | ${3:# else...} 45 | } 46 | # Conditional if..elsif..else 47 | snippet ifee 48 | if (${1}) { 49 | ${2:# body...} 50 | } elsif (${3}) { 51 | ${4:# elsif...} 52 | } else { 53 | ${5:# else...} 54 | } 55 | # Conditional One-line 56 | snippet xif 57 | ${1:expression} if ${2:condition};${3} 58 | # Unless conditional 59 | snippet unless 60 | unless (${1}) { 61 | ${2:# body...} 62 | } 63 | # Unless conditional One-line 64 | snippet xunless 65 | ${1:expression} unless ${2:condition};${3} 66 | # Try/Except 67 | snippet eval 68 | eval { 69 | ${1:# do something risky...} 70 | }; 71 | if ($@) { 72 | ${2:# handle failure...} 73 | } 74 | # While Loop 75 | snippet wh 76 | while (${1}) { 77 | ${2:# body...} 78 | } 79 | # While Loop One-line 80 | snippet xwh 81 | ${1:expression} while ${2:condition};${3} 82 | # For Loop 83 | snippet for 84 | for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) { 85 | ${4:# body...} 86 | } 87 | # Foreach Loop 88 | snippet fore 89 | foreach my $${1:x} (@${2:array}) { 90 | ${3:# body...} 91 | } 92 | # Foreach Loop One-line 93 | snippet xfore 94 | ${1:expression} foreach @${2:array};${3} 95 | # Package 96 | snippet cl 97 | package ${1:ClassName}; 98 | 99 | use base qw(${2:ParentClass}); 100 | 101 | sub new { 102 | my $class = shift; 103 | $class = ref $class if ref $class; 104 | my $self = bless {}, $class; 105 | $self; 106 | } 107 | 108 | 1;${3} 109 | # Read File 110 | snippet slurp 111 | my $${1:var}; 112 | { local $/ = undef; local *FILE; open FILE, "<${2:file}"; $$1 = ; close FILE }${3} 113 | -------------------------------------------------------------------------------- /vim/plugin/toggle_words.py: -------------------------------------------------------------------------------- 1 | import vim 2 | 3 | toggle_words_dict = { 4 | '*': [ 5 | ['==', '!='], 6 | ['>', '<'], 7 | ['[', ']'], 8 | ['[', ']'], 9 | ['{', '}'], 10 | ['+', '-'], 11 | ['allow', 'deny'], 12 | ['before', 'after'], 13 | ['block', 'inline', 'none'], 14 | ['define', 'undef'], 15 | ['good', 'bad'], 16 | ['if', 'elseif', 'else', 'endif'], 17 | ['in', 'out'], 18 | ['left', 'right'], 19 | ['min', 'max'], 20 | ['on', 'off'], 21 | ['start', 'stop'], 22 | ['success', 'failure'], 23 | ['true', 'false'], 24 | ['up', 'down'], 25 | ['left', 'right'], 26 | ['yes', 'no'], 27 | ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'], 28 | ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'], 29 | ['1', '0'], 30 | ['top', 'bottom'], 31 | ['even', 'odd'], 32 | ['pick', 'squash'], # git rebase -i 33 | ], 34 | 'python': [ 35 | ['if', 'elif', 'else'], 36 | ['in'], 37 | ['def', 'class'], 38 | ['null', 'None'], 39 | ['this', 'self'], 40 | ['True', 'False'], 41 | ['true', 'True'], 42 | ['false', 'False'], 43 | ], 44 | 'javascript': [ 45 | ['true', 'false'], 46 | ['True', 'true'], 47 | ['False', 'false'], 48 | ['None', 'null'], 49 | ], 50 | } 51 | 52 | 53 | def ToggleWord(): 54 | toggle_words_list = toggle_words_dict['*'] 55 | 56 | cur_filetype = vim.eval("&filetype") 57 | if cur_filetype in toggle_words_dict: 58 | toggle_words_list = toggle_words_dict[cur_filetype] + toggle_words_list 59 | 60 | cur_word = vim.eval('expand("")') 61 | cur_word_lower = cur_word.lower() 62 | 63 | next_word = None 64 | for toggles in toggle_words_list: 65 | if cur_word in toggles: 66 | index = (toggles.index(cur_word) + 1) % len(toggles) 67 | next_word = toggles[index] 68 | break 69 | 70 | if next_word: 71 | vim.command('norm ciw' + next_word) 72 | return 73 | 74 | for toggles in toggle_words_list: 75 | if cur_word_lower in toggles: 76 | index = (toggles.index(cur_word_lower) + 1) % len(toggles) 77 | next_word = toggles[index] 78 | if next_word == next_word.lower(): # we do smart-casing on lower case values 79 | try: 80 | if cur_word == cur_word.upper(): 81 | next_word = next_word.upper() 82 | elif cur_word[0].upper() + cur_word[1:] == cur_word: 83 | next_word = next_word[0].upper() + next_word[1:] 84 | except IndexRange, e: 85 | pass 86 | break 87 | 88 | if next_word: 89 | vim.command('norm ciw' + next_word) 90 | -------------------------------------------------------------------------------- /vim/autoload/chef/controller.vim: -------------------------------------------------------------------------------- 1 | let s:finders = {} 2 | let s:Controller = {} 3 | 4 | function! s:Controller.main(...) "{{{1 5 | let success = 0 6 | try 7 | let org_iskeyword = &iskeyword 8 | silent set iskeyword+=:,- 9 | let env = chef#environment#new() 10 | finally 11 | let &iskeyword = org_iskeyword 12 | endtry 13 | 14 | let env.editcmd = a:0 ? a:1 : "edit" 15 | 16 | for finder in self.finders 17 | call self.debug(finder.id) 18 | 19 | call finder.init(env) 20 | if finder.condition() 21 | call self.debug('condition met for ' . finder.id) 22 | let success = finder.find() 23 | break 24 | endif 25 | endfor 26 | 27 | call self.debug('find finish ' . finder.id) 28 | 29 | if success 30 | for s:hook in get(g:chef, "hooks", []) 31 | call self.debug('calling hook ' . s:hook ) 32 | if type(function(s:hook)) == 2 33 | call call(function(s:hook),[env]) 34 | endif 35 | unlet s:hook 36 | endfor 37 | endif 38 | endfunction 39 | 40 | 41 | function! s:Controller.debug(msg) "{{{1 42 | if !g:ChefDebug | return | endif 43 | echo "[Controller] " . string(a:msg) 44 | endfunction 45 | 46 | 47 | function! s:finder_for(name) 48 | if !has_key(s:finders, a:name) || g:ChefDebugEveryInit 49 | let s:finders[a:name] = s:create_finder(a:name) 50 | endif 51 | return s:finders[a:name] 52 | endfunction 53 | 54 | function! s:create_finder(name) 55 | let finder = chef#finder#{tolower(a:name)}#new() 56 | let finder.id = a:name 57 | call finder.debug("initialized") 58 | return finder 59 | endfunction 60 | 61 | function! chef#controller#findAny(...) "{{{1 62 | let s:Controller.finders = map(copy(g:chef.any_finders), "s:finder_for(v:val)") 63 | call call(s:Controller.main, a:000, s:Controller) 64 | endfunction 65 | 66 | function! chef#controller#findAttribute(...) "{{{1 67 | let s:Controller.finders = [ s:finder_for("Attribute") ] 68 | call call(s:Controller.main, a:000, s:Controller) 69 | endfunction 70 | 71 | function! chef#controller#findSource(...) "{{{1 72 | let s:Controller.finders = [ s:finder_for("Source") ] 73 | call call(s:Controller.main, a:000, s:Controller) 74 | endfunction 75 | 76 | function! chef#controller#findRecipe(...) "{{{1 77 | let s:Controller.finders = [ s:finder_for("Recipe") ] 78 | call call(s:Controller.main, a:000, s:Controller) 79 | endfunction 80 | 81 | function! chef#controller#findDefinition(...) "{{{1 82 | let s:Controller.finders = [ s:finder_for("Definition") ] 83 | call call(s:Controller.main, a:000, s:Controller) 84 | endfunction 85 | 86 | function! chef#controller#findLWRP(...) "{{{1 87 | let s:Controller.finders = [ s:finder_for("LWRP") ] 88 | call call(s:Controller.main, a:000, s:Controller) 89 | endfunction 90 | 91 | function! chef#controller#findRelated(...) "{{{1 92 | let s:Controller.finders = [ s:finder_for("Related") ] 93 | call call(s:Controller.main, a:000, s:Controller) 94 | endfunction 95 | 96 | " vim: set sw=4 sts=4 et fdm=marker: 97 | -------------------------------------------------------------------------------- /vim/plugin/chef.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " File: chef.vim 3 | " Author: t9md 4 | " Version: 1.0 5 | " WebPage: https://github.com/t9md/vim-chef 6 | " License: BSD 7 | 8 | " GUARD: {{{1 9 | "============================================================ 10 | " if exists('g:loaded_chef') 11 | " finish 12 | " endif 13 | 14 | let g:loaded_chef = 1 15 | let s:old_cpo = &cpo 16 | set cpo&vim 17 | 18 | " Declaration: {{{1 19 | "================================================================= 20 | if ! exists('g:ChefEditCmd') 21 | let g:ChefEditCmd = 'edit ' 22 | endif 23 | if ! exists('g:ChefDebug') 24 | let g:ChefDebug = 0 25 | endif 26 | if ! exists('g:ChefDebugEveryInit') 27 | let g:ChefDebugEveryInit = 0 28 | endif 29 | 30 | if !exists('g:chef') 31 | let g:chef= {} 32 | endif 33 | if !has_key(g:chef, 'hooks') 34 | let g:chef.hooks = [] 35 | endif 36 | if !has_key(g:chef, 'any_finders') 37 | let g:chef.any_finders = [ "Attribute", "Source", "Recipe", "Definition", "LWRP", "Related" ] 38 | endif 39 | 40 | 41 | " Command: {{{1 42 | "================================================================= 43 | command! ChefDoWhatIMean :call chef#controller#findAny() 44 | command! ChefDoWhatIMeanSplit :call chef#controller#findAny('split') 45 | command! ChefDoWhatIMeanVsplit :call chef#controller#findAny('vsplit') 46 | 47 | command! ChefFindAny :call chef#controller#findAny() 48 | command! ChefFindAnySplit :call chef#controller#findAny('split') 49 | command! ChefFindAnyVsplit :call chef#controller#findAny('vsplit') 50 | 51 | command! ChefFindAttribute :call chef#controller#findAttribute() 52 | command! ChefFindAttributeSplit :call chef#controller#findAttribute('split') 53 | command! ChefFindAttributeVsplit :call chef#controller#findAttribute('vsplit') 54 | 55 | command! ChefFindRecipe :call chef#controller#findRecipe() 56 | command! ChefFindRecipeSplit :call chef#controller#findRecipe('split') 57 | command! ChefFindRecipeVsplit :call chef#controller#findRecipe('vsplit') 58 | 59 | command! ChefFindDefinition :call chef#controller#findDefinition() 60 | command! ChefFindDefinitionSplit :call chef#controller#findDefinition('split') 61 | command! ChefFindDefinitionVsplit :call chef#controller#findDefinition('vsplit') 62 | 63 | command! ChefFindLWRP :call chef#controller#findLWRP() 64 | command! ChefFindLWRP :call chef#controller#findLWRP('split') 65 | command! ChefFindLWRP :call chef#controller#findLWRP('vsplit') 66 | 67 | command! ChefFindSource :call chef#controller#findSource() 68 | command! ChefFindSourceSplit :call chef#controller#findSource('split') 69 | command! ChefFindSourceVsplit :call chef#controller#findSource('vsplit') 70 | 71 | command! ChefFindRelated :call chef#controller#findRelated() 72 | command! ChefFindRelatedSplit :call chef#controller#findRelated('split') 73 | command! ChefFindRelatedVsplit :call chef#controller#findRelated('vsplit') 74 | 75 | " Finalize: {{{1 76 | "================================================================= 77 | let &cpo = s:old_cpo 78 | " vim: set sw=4 sts=4 et fdm=marker fdc=3 fdl=3: 79 | -------------------------------------------------------------------------------- /zshrc: -------------------------------------------------------------------------------- 1 | # Zsh-specific profile. For Bash specific look at profile, 2 | # for common variables look at profile_common. 3 | # 4 | setopt allexport 5 | 6 | if [ -e ~/.pscolors ]; then 7 | source ~/.pscolors 8 | fi 9 | PS1="%{$PS_USERCOLOR%}%n%{$PS_ATCOLOR%}@%{$PS_HOSTCOLOR%}%M%{$PS_COLONCOLOR%}:%{$PS_PATHCOLOR%}%~%{$PS_PROMPTCOLOR%} $ %{$PS_NOCOLOR%}" 10 | #RPROMPT="%D{%T}" 11 | HISTFILE=~/.zhistory 12 | HISTSIZE=10000 13 | SAVEHIST=10000 14 | HISTIGNORE="&:ls:[bf]g:exit:reset:clear:cd:cd ..:cd.." 15 | setopt INC_APPEND_HISTORY HIST_IGNORE_ALL_DUPS HIST_IGNORE_SPACE \ 16 | HIST_REDUCE_BLANKS HIST_SAVE_NO_DUPS HIST_VERIFY EXTENDED_HISTORY 17 | unsetopt share_history 18 | 19 | setopt alwaystoend autocontinue autolist autoresume autopushd \ 20 | clobber combiningchars correct listrowsfirst longlistjobs mailwarning \ 21 | nomatch notify pushdtohome menucomplete extendedhistory 22 | unsetopt autocd bgnice beep 23 | 24 | # unsetopt autoparamslash 25 | 26 | bindkey -e 27 | 28 | #preexec() { 29 | # print -rn -- $terminfo[cuu1] 30 | # let cols=$terminfo[cols]-9 31 | # while [[ $cols -gt 0 ]]; do 32 | # print -n $terminfo[cuf1] 33 | # let cols=cols-1 34 | # done 35 | # print `date +%H:%M:%S` 36 | #} 37 | 38 | autoload -Uz compinit 39 | compinit 40 | 41 | bindkey '\e[1~' beginning-of-line 42 | bindkey '\e[4~' end-of-line 43 | bindkey '\e[7~' beginning-of-line 44 | bindkey '\e[8~' end-of-line 45 | bindkey '^F' forward-word 46 | bindkey '^B' backward-word 47 | bindkey '\e[1;5C' forward-word 48 | bindkey '\e[1;5D' backward-word 49 | bindkey '\eOH' beginning-of-line 50 | bindkey '\eOF' end-of-line 51 | bindkey '\e[H' beginning-of-line 52 | bindkey '\e[F' end-of-line 53 | bindkey '\e[3~' delete-char 54 | 55 | zstyle ':completion::complete:*' use-cache on 56 | zstyle ':completion::complete:*' cache-path ~/.zcache 57 | zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} 58 | zstyle ':completion:*' list-prompt \ 59 | '%SAt %p: Hit TAB for more, or the character to insert%s' 60 | #zstyle ':completion:*' menu select=1 _complete _ignored _approximate 61 | zstyle ':completion:*' menu select=long-list select=1 _complete _ignored _approximate 62 | zstyle -e ':completion:*:approximate:*' max-errors \ 63 | 'reply=( $(( ($#PREFIX+$#SUFFIX)/2 )) numeric )' 64 | zstyle ':completion:*' select-prompt \ 65 | '%SScrolling active: current selection at %p%s' 66 | zstyle ':completion:*:processes' command 'ps -axw' 67 | zstyle ':completion:*:processes-names' command 'ps -awxho command' 68 | zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' 69 | zstyle ':completion:*::::' completer _expand _complete _ignored _approximate 70 | zstyle -e ':completion:*:approximate:*' max-errors \ 71 | 'reply=( $(( ($#PREFIX+$#SUFFIX)/2 )) numeric )' 72 | zstyle ':completion:*:expand:*' tag-order all-expansions 73 | # formatting and messages 74 | zstyle ':completion:*' verbose yes 75 | zstyle ':completion:*:descriptions' format '%B%d%b' 76 | zstyle ':completion:*:messages' format '%d' 77 | zstyle ':completion:*:warnings' format 'No matches for: %d' 78 | zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b' 79 | zstyle ':completion:*' group-name '' 80 | # match uppercase from lowercase 81 | # zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' 82 | # ignore completion functions (until the _ignored completer) 83 | zstyle ':completion:*:functions' ignored-patterns '_*' 84 | zstyle ':completion:*:scp:*' tag-order \ 85 | files users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *' 86 | zstyle ':completion:*:scp:*' group-order \ 87 | files all-files users hosts-domain hosts-host hosts-ipaddr 88 | zstyle ':completion:*:ssh:*' tag-order \ 89 | users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *' 90 | zstyle ':completion:*:ssh:*' group-order \ 91 | hosts-domain hosts-host users hosts-ipaddr 92 | zstyle '*' single-ignored show 93 | 94 | source ~/.profile_common 95 | 96 | PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting 97 | -------------------------------------------------------------------------------- /vim/snippets/objc.snippets: -------------------------------------------------------------------------------- 1 | # #import <...> 2 | snippet Imp 3 | #import <${1:Cocoa/Cocoa.h}>${2} 4 | # #import "..." 5 | snippet imp 6 | #import "${1:`Filename()`.h}"${2} 7 | # @selector(...) 8 | snippet sel 9 | @selector(${1:method}:)${3} 10 | # @"..." string 11 | snippet s 12 | @"${1}"${2} 13 | # Object 14 | snippet o 15 | ${1:NSObject} *${2:foo} = [${3:$1 alloc}]${4};${5} 16 | # NSLog(...) 17 | snippet log 18 | NSLog(@"${1:%@}"${2});${3} 19 | # Class 20 | snippet objc 21 | @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject} 22 | { 23 | } 24 | @end 25 | 26 | @implementation $1 27 | ${3} 28 | @end 29 | # Class Interface 30 | snippet int 31 | @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject} 32 | {${3} 33 | } 34 | ${4} 35 | @end 36 | # Class Implementation 37 | snippet impl 38 | @implementation ${1:`Filename('', 'someClass')`} 39 | ${2} 40 | @end 41 | snippet init 42 | - (id)init 43 | { 44 | [super init]; 45 | return self; 46 | } 47 | snippet ifself 48 | if (self = [super init]) { 49 | ${1:/* code */} 50 | } 51 | return self; 52 | snippet ibo 53 | IBOutlet ${1:NSSomeClass} *${2:$1};${3} 54 | # Category 55 | snippet cat 56 | @interface ${1:NSObject} (${2:Category}) 57 | @end 58 | 59 | @implementation $1 ($2) 60 | ${3} 61 | @end 62 | # Category Interface 63 | snippet cath 64 | @interface ${1:NSObject} (${2:Category}) 65 | ${3} 66 | @end 67 | # NSArray 68 | snippet array 69 | NSMutableArray *${1:array} = [NSMutable array];${2} 70 | # NSDictionary 71 | snippet dict 72 | NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];${2} 73 | # NSBezierPath 74 | snippet bez 75 | NSBezierPath *${1:path} = [NSBezierPath bezierPath];${2} 76 | # Method 77 | snippet m 78 | - (${1:id})${2:method} 79 | { 80 | ${3} 81 | } 82 | # Method declaration 83 | snippet md 84 | - (${1:id})${2:method};${3} 85 | # IBAction declaration 86 | snippet ibad 87 | - (IBAction)${1:method}:(${2:id})sender;${3} 88 | # IBAction method 89 | snippet iba 90 | - (IBAction)${1:method}:(${2:id})sender 91 | { 92 | ${3} 93 | } 94 | # awakeFromNib method 95 | snippet wake 96 | - (void)awakeFromNib 97 | { 98 | ${1} 99 | } 100 | # Class Method 101 | snippet M 102 | + (${1:id})${2:method} 103 | {${3} 104 | return nil; 105 | } 106 | # Sub-method (Call super) 107 | snippet sm 108 | - (${1:id})${2:method} 109 | { 110 | [super $2];${3} 111 | return self; 112 | } 113 | # Method: Initialize 114 | snippet I 115 | + (void) initialize 116 | { 117 | [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWIthObjectsAndKeys: 118 | ${1}@"value", @"key", 119 | nil]]; 120 | } 121 | # Accessor Methods For: 122 | # Object 123 | snippet objacc 124 | - (${1:id})${2:thing} 125 | { 126 | return $2; 127 | } 128 | 129 | - (void)set$2:($1)${3:new$2} 130 | { 131 | [$3 retain]; 132 | [$2 release]; 133 | $2 = $3; 134 | }${4} 135 | # for (object in array) 136 | snippet forin 137 | for (${1:Class} *${2:some$1} in ${3:array}) { 138 | ${4} 139 | } 140 | snippet forarray 141 | unsigned int ${1:object}Count = [${2:array} count]; 142 | 143 | for (unsigned int index = 0; index < $1Count; index++) { 144 | ${3:id} $1 = [$2 $1AtIndex:index]; 145 | ${4} 146 | } 147 | # IBOutlet 148 | # @property (Objective-C 2.0) 149 | snippet prop 150 | @property (${1:retain}) ${2:NSSomeClass} ${3:*$2};${4} 151 | # @synthesize (Objective-C 2.0) 152 | snippet syn 153 | @synthesize ${1:property};${2} 154 | # [[ alloc] init] 155 | snippet alloc 156 | [[${1:foo} alloc] init${2}];${3} 157 | # retain 158 | snippet ret 159 | [${1:foo} retain];${2} 160 | # release 161 | snippet rel 162 | [${1:foo} release]; 163 | ${2:$1 = nil;} 164 | # autorelease 165 | snippet arel 166 | [${1:foo} autorelease]; 167 | # autorelease pool 168 | snippet pool 169 | NSAutoreleasePool *${1:pool} = [[NSAutoreleasePool alloc] init]; 170 | ${2:/* code */} 171 | [$1 drain]; 172 | # Throw an exception 173 | snippet except 174 | NSException *${1:badness}; 175 | $1 = [NSException exceptionWithName:@"${2:$1Name}" 176 | reason:@"${3}" 177 | userInfo:nil]; 178 | [$1 raise]; 179 | snippet prag 180 | #pragma mark ${1:foo} 181 | snippet cl 182 | @class ${1:Foo};${2} 183 | snippet color 184 | [[NSColor ${1:blackColor}] set]; 185 | -------------------------------------------------------------------------------- /profile_common: -------------------------------------------------------------------------------- 1 | # 2 | # Common routines for startup. 3 | # 4 | # PLEASE NOTE: THIS FILE SHOULD BE KEPT 5 | # COMPATIBLE WITH BOTH BASH 3+ AND ZSHELL 4.3.10+. 6 | # 7 | 8 | # 9 | # my exports 10 | # 11 | 12 | export HOSTNAME="`hostname`" 13 | export LC_ALL=en_US.UTF-8 14 | export LANG=en_US.UTF-8 15 | export LANGUAGE=en_US.UTF-8 16 | export TZ="Europe/Warsaw" 17 | export CLICOLOR=1 18 | export LSCOLORS=ExFxCxDxBxegedabagacad 19 | export LS_COLORS="no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:" 20 | export LS_OPTIONS=--color=auto 21 | export EDITOR=vim 22 | export VIMFILES=~/.vim/ 23 | export PYTHONSTARTUP=~/.pythonstartup 24 | export PIP_REQUIRE_VIRTUALENV=true 25 | export PIP_RESPECT_VIRTUALENV=true 26 | export PIP_DOWNLOAD_CACHE=~/.pip-cache 27 | export VIRTUALENV_USE_DISTRIBUTE=true 28 | LOCAL_BIN=~/.dot_files/bin 29 | export PATH="$LOCAL_BIN:/opt/automation:$PATH" 30 | 31 | # merged from my old configs 32 | export HISTSIZE=100000 33 | export HISTFILESIZE=500000 34 | # date and time in history 35 | export HISTTIMEFORMAT="%h/%d - %H:%M:%S " 36 | export GREP_OPTIONS='--color=auto' 37 | export HISTCONTROL=erasedups 38 | export PROMPT_COMMAND="history -a; history -n; $PROMPT_COMMAND" 39 | set -o vi 40 | 41 | # Debian stuff 42 | export DEBFULLNAME="Tomasz 'Zen' Napierala" 43 | export DEBEMAIL='tomasz@napierala.org' 44 | export DEBSIGN_KEYID="2F9BEB1D" 45 | 46 | # 47 | # my aliases 48 | # 49 | 50 | # SAFE COMMANDS 51 | alias rm="rm -i" 52 | alias mv="mv -i" 53 | alias cp="cp -ir" 54 | alias ll="ls -lah" 55 | alias lt="tree -AphL" 56 | alias tree="tree -A" 57 | alias vim="vim -XO" # if you want the default, just type vim -O1 58 | alias vi="vim" 59 | alias ci="echo \"You probably meant vi. Or are you still using RCS?\"; false" 60 | alias dc="echo \"You don't really use 'dc', do you?\"; false" 61 | alias grep="grep --color=auto" 62 | 63 | # shortcuts 64 | alias :q='logout' 65 | alias :qa='logout' 66 | alias die='logout' 67 | alias jloc='let "a = 0"; for num in `find . -iname "*.java" | xargs -I {} wc -l {} | cut -d. -f1 | tr -d " "`; do let "a = a + num"; done; echo $a;' 68 | alias loc='let "a = 0"; for num in `find . -iname "*.py" | xargs -I {} wc -l {} | cut -d. -f1 | tr -d " "`; do let "a = a + num"; done; echo $a;' 69 | alias todo-list="ack --column -w \"\\W(TODO|FIXME|REMEMBER|WEDNESDAY|XXX|BUG|WTF|OMF?G|pdb\\.set_trace)\\W{1}\"" 70 | alias depyc='find . -iname "*.pyc" -print -exec rm {} \;' 71 | 72 | # Django 73 | alias djrun='python -Wd manage.py runserver' 74 | alias djrs='python -Wd manage.py runserver' 75 | alias djsync='python -Wd manage.py syncdb' 76 | alias djevo='python -Wd manage.py evolve --hint' 77 | alias djmm='python -Wd manage.py makemessages -ae html,txt' 78 | alias djcm='python -Wd manage.py compilemessages' 79 | alias djsh='python -Wd manage.py shell' 80 | 81 | # Knife aliases 82 | alias kcu='knife cookbook upload' 83 | alias kne='knife node edit' 84 | alias kns='knife node show' 85 | alias krf='knife role from file' 86 | 87 | # Host aliases 88 | alias sshr='ssh -lroot ' 89 | alias sshesp='ssh -p22388 redmine.espeo.pl' 90 | alias sshmyc='ssh srv3.mycork.org' 91 | alias sshesp2='ssh -p22399 redmine.espeo.pl' 92 | alias sshkra='ssh 91.102.119.70' 93 | alias sshmgm='ssh mgm.grimstad.solita.fi' 94 | 95 | # 96 | # my functions 97 | # 98 | function wintitle { 99 | echo -ne "\033]0;$1\007" 100 | } 101 | 102 | function git_diff { 103 | git diff --no-ext-diff -w "$@" | vim -R - 104 | } 105 | 106 | function dot_files_version { 107 | CWD=`pwd` 108 | cd ~/.dot_files 109 | echo `git log --pretty=format:"%h: %ar" | head -n 1` 110 | cd $CWD 111 | } 112 | 113 | function dot_files_update { 114 | CWD=`pwd` 115 | cd ~/.dot_files 116 | git pull && ./install.py 117 | cd $CWD 118 | } 119 | 120 | function pipcached { 121 | pip install `find ~/.pip-cache/ -iname "*$@*" | grep -v content-type` 122 | } 123 | 124 | # 125 | # execute machine-specific settings 126 | # 127 | if [ -e ~/.profile_machine ]; then 128 | source ~/.profile_machine 129 | fi 130 | 131 | # 132 | # execute local-specific settings 133 | # 134 | if [ -e ~/.profile_local ]; then 135 | source ~/.profile_local 136 | fi 137 | 138 | -------------------------------------------------------------------------------- /vim/autoload/chef/finder/attribute.vim: -------------------------------------------------------------------------------- 1 | let s:finder = {} 2 | 3 | function! s:finder.condition() "{{{1 4 | let self.env.attr = s:extract_attribute(self.env.cWORD) 5 | call self.debug('extracted attr is ' . self.env.attr) 6 | return !empty(self.env.attr) 7 | endfunction 8 | 9 | function! s:finder.find() "{{{1 10 | let found_attribute = 0 11 | try "{{{ 12 | for pattern in self.attr_patterns() 13 | for file in self.candidate() 14 | call self.debug('search ' . pattern . ' in file ' . file ) 15 | 16 | if match(readfile(file), pattern) != -1 17 | call self.edit(file) 18 | keepjump normal! gg 19 | call search(pattern, 'e') 20 | normal! hzz 21 | throw "AttributeFound" 22 | endif 23 | endfor 24 | endfor 25 | 26 | catch /AttributeFound/ 27 | let found_attribute = 1 28 | endtry "}}} 29 | 30 | if found_attribute 31 | return 1 32 | else 33 | call self.msghl([[self.env.attr, "Identifier"],["not found", "Normal"]], " ") 34 | return 0 35 | endif 36 | endfunction 37 | 38 | function! s:finder.candidate() "{{{1 39 | let attr_list = s:scan(self.env.attr, '\[\(.\{-}\)\]\+') 40 | if len(attr_list) < 2 41 | return [] 42 | endif 43 | let recipe_name = substitute(attr_list[0],'[:"'']','','g') 44 | 45 | let attributes_dir = join([ self.env.path.cookbooks, recipe_name, 'attributes' ], '/') 46 | 47 | let candidate = split(globpath(self.env.path.cookbooks, '*/attributes/*.rb', 1),"\n") 48 | 49 | " call self.debug("pre-prioritize: " . string(candidate)) 50 | if attributes_dir == self.env.path.attributes 51 | " If there is attribute file which have same file name as current 52 | " recipe, it should be more likely contain target attribute. 53 | let f = join([ self.env.path.attributes, self.env.basename ], '/') 54 | let idx = index(candidate, f) 55 | if idx != -1 56 | let f = remove(candidate, idx) 57 | call insert(candidate, f) 58 | endif 59 | endif 60 | " call self.debug("post-prioritize: " . string(candidate)) 61 | return candidate 62 | endfunction 63 | 64 | function! s:scan(str, pattern) "{{{1 65 | let ret = [] 66 | let pattern = a:pattern 67 | let nth = 1 68 | while 1 69 | let m = matchlist(a:str, pattern, 0, nth) 70 | if empty(m) 71 | break 72 | endif 73 | call add(ret, m[1]) 74 | let nth += 1 75 | endwhile 76 | return ret 77 | endfunction 78 | 79 | function! s:quote(attr, quote_str) "{{{1 80 | let tmp = substitute(a:attr, '[:"'']','','g') 81 | let tmp = substitute(tmp, "[", "[" . a:quote_str ,'g') 82 | return substitute(tmp, "]", a:quote_str . "]",'g') 83 | endfunction 84 | 85 | function! s:single_quote(attr) "{{{1 86 | return s:quote(a:attr, "'") 87 | endfunction 88 | 89 | function! s:double_quote(attr) "{{{1 90 | return s:quote(a:attr, '"') 91 | endfunction 92 | 93 | function! s:symbolize(attr) "{{{1 94 | if matchstr(a:attr, '[:') != '' 95 | return a:attr 96 | endif 97 | let tmp = substitute(a:attr, '[:"'']','','g') 98 | return substitute(tmp, "[", '[:','g') 99 | endfunction 100 | 101 | function! s:finder.attr_patterns() "{{{1 102 | let attr = matchlist(self.env.attr, '[.*\]')[0] 103 | let idx = len(attr) 104 | 105 | let s:attr_transfunc = [ 106 | \ function("s:single_quote"), 107 | \ function("s:double_quote"), 108 | \ function("s:symbolize"), 109 | \ ] 110 | 111 | let candidate = [] 112 | while 1 113 | let idx = strridx(attr, ']', idx-1) 114 | if idx == -1| break | endif 115 | let org = attr[ : idx ] 116 | call add(candidate, org) 117 | for F in s:attr_transfunc 118 | call add(candidate, call(F,[org])) 119 | unlet F 120 | endfor 121 | endwhile 122 | return map(candidate, "escape(v:val, '[]')") 123 | endfunction 124 | 125 | function! s:extract_attribute(str) "{{{1 126 | " let m = matchlist(a:str, '\(node\[[^}]*\]\)') 127 | let m = matchlist(a:str, '\(\w\+\[[^}]*\]\)') 128 | if !empty(m) 129 | return m[1] 130 | else 131 | return "" 132 | endif 133 | endfunction 134 | 135 | function! chef#finder#attribute#new() "{{{1 136 | return chef#finder#new(s:finder) 137 | endfunction 138 | " vim: set sw=4 sts=4 et fdm=marker: 139 | -------------------------------------------------------------------------------- /vim/snippets/php.snippets: -------------------------------------------------------------------------------- 1 | snippet php 2 | 5 | snippet ec 6 | echo "${1:string}"${2}; 7 | snippet inc 8 | include '${1:file}';${2} 9 | snippet inc1 10 | include_once '${1:file}';${2} 11 | snippet req 12 | require '${1:file}';${2} 13 | snippet req1 14 | require_once '${1:file}';${2} 15 | # $GLOBALS['...'] 16 | snippet globals 17 | $GLOBALS['${1:variable}']${2: = }${3:something}${4:;}${5} 18 | snippet $_ COOKIE['...'] 19 | $_COOKIE['${1:variable}']${2} 20 | snippet $_ ENV['...'] 21 | $_ENV['${1:variable}']${2} 22 | snippet $_ FILES['...'] 23 | $_FILES['${1:variable}']${2} 24 | snippet $_ Get['...'] 25 | $_GET['${1:variable}']${2} 26 | snippet $_ POST['...'] 27 | $_POST['${1:variable}']${2} 28 | snippet $_ REQUEST['...'] 29 | $_REQUEST['${1:variable}']${2} 30 | snippet $_ SERVER['...'] 31 | $_SERVER['${1:variable}']${2} 32 | snippet $_ SESSION['...'] 33 | $_SESSION['${1:variable}']${2} 34 | # Start Docblock 35 | snippet /* 36 | /** 37 | * ${1} 38 | **/ 39 | # Class - post doc 40 | snippet doc_cp 41 | /** 42 | * ${1:undocumented class} 43 | * 44 | * @package ${2:default} 45 | * @author ${3:`g:snips_author`} 46 | **/${4} 47 | # Class Variable - post doc 48 | snippet doc_vp 49 | /** 50 | * ${1:undocumented class variable} 51 | * 52 | * @var ${2:string} 53 | **/${3} 54 | # Class Variable 55 | snippet doc_v 56 | /** 57 | * ${3:undocumented class variable} 58 | * 59 | * @var ${4:string} 60 | **/ 61 | ${1:var} $${2};${5} 62 | # Class 63 | snippet doc_c 64 | /** 65 | * ${3:undocumented class} 66 | * 67 | * @packaged ${4:default} 68 | * @author ${5:`g:snips_author`} 69 | **/ 70 | ${1:}class ${2:} 71 | {${6} 72 | } // END $1class $2 73 | # Constant Definition - post doc 74 | snippet doc_dp 75 | /** 76 | * ${1:undocumented constant} 77 | **/${2} 78 | # Constant Definition 79 | snippet doc_d 80 | /** 81 | * ${3:undocumented constant} 82 | **/ 83 | define(${1}, ${2});${4} 84 | # Function - post doc 85 | snippet doc_fp 86 | /** 87 | * ${1:undocumented function} 88 | * 89 | * @return ${2:void} 90 | * @author ${3:`g:snips_author`} 91 | **/${4} 92 | # Function signature 93 | snippet doc_s 94 | /** 95 | * ${4:undocumented function} 96 | * 97 | * @return ${5:void} 98 | * @author ${6:`g:snips_author`} 99 | **/ 100 | ${1}function ${2}(${3});${7} 101 | # Function 102 | snippet doc_f 103 | /** 104 | * ${4:undocumented function} 105 | * 106 | * @return ${5:void} 107 | * @author ${6:`g:snips_author`} 108 | **/ 109 | ${1}function ${2}(${3}) 110 | {${7} 111 | } 112 | # Header 113 | snippet doc_h 114 | /** 115 | * ${1} 116 | * 117 | * @author ${2:`g:snips_author`} 118 | * @version ${3:$Id$} 119 | * @copyright ${4:$2}, `strftime('%d %B, %Y')` 120 | * @package ${5:default} 121 | **/ 122 | 123 | /** 124 | * Define DocBlock 125 | *// 126 | # Interface 127 | snippet doc_i 128 | /** 129 | * ${2:undocumented class} 130 | * 131 | * @package ${3:default} 132 | * @author ${4:`g:snips_author`} 133 | **/ 134 | interface ${1:} 135 | {${5} 136 | } // END interface $1 137 | # class ... 138 | snippet class 139 | /** 140 | * ${1} 141 | **/ 142 | class ${2:ClassName} 143 | { 144 | ${3} 145 | function ${4:__construct}(${5:argument}) 146 | { 147 | ${6:// code...} 148 | } 149 | } 150 | # define(...) 151 | snippet def 152 | define('${1}'${2});${3} 153 | # defined(...) 154 | snippet def? 155 | ${1}defined('${2}')${3} 156 | snippet wh 157 | while (${1:/* condition */}) { 158 | ${2:// code...} 159 | } 160 | # do ... while 161 | snippet do 162 | do { 163 | ${2:// code... } 164 | } while (${1:/* condition */}); 165 | snippet if 166 | if (${1:/* condition */}) { 167 | ${2:// code...} 168 | } 169 | snippet ife 170 | if (${1:/* condition */}) { 171 | ${2:// code...} 172 | } else { 173 | ${3:// code...} 174 | } 175 | ${4} 176 | snippet else 177 | else { 178 | ${1:// code...} 179 | } 180 | snippet elseif 181 | elseif (${1:/* condition */}) { 182 | ${2:// code...} 183 | } 184 | # Tertiary conditional 185 | snippet t 186 | $${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5} 187 | snippet switch 188 | switch ($${1:variable}) { 189 | case '${2:value}': 190 | ${3:// code...} 191 | break; 192 | ${5} 193 | default: 194 | ${4:// code...} 195 | break; 196 | } 197 | snippet case 198 | case '${1:value}': 199 | ${2:// code...} 200 | break;${3} 201 | snippet for 202 | for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) { 203 | ${4: // code...} 204 | } 205 | snippet foreach 206 | foreach ($${1:variable} as $${2:key}) { 207 | ${3:// code...} 208 | } 209 | snippet fun 210 | ${1:public }function ${2:FunctionName}(${3}) 211 | { 212 | ${4:// code...} 213 | } 214 | # $... = array (...) 215 | snippet array 216 | $${1:arrayName} = array('${2}' => ${3});${4} 217 | -------------------------------------------------------------------------------- /vim/snippets/html.snippets: -------------------------------------------------------------------------------- 1 | # Some useful Unicode entities 2 | # Non-Breaking Space 3 | snippet nbs 4 |   5 | # ← 6 | snippet left 7 | ← 8 | # → 9 | snippet right 10 | → 11 | # ↑ 12 | snippet up 13 | ↑ 14 | # ↓ 15 | snippet down 16 | ↓ 17 | # ↩ 18 | snippet return 19 | ↩ 20 | # ⇤ 21 | snippet backtab 22 | ⇤ 23 | # ⇥ 24 | snippet tab 25 | ⇥ 26 | # ⇧ 27 | snippet shift 28 | ⇧ 29 | # ⌃ 30 | snippet control 31 | ⌃ 32 | # ⌅ 33 | snippet enter 34 | ⌅ 35 | # ⌘ 36 | snippet command 37 | ⌘ 38 | # ⌥ 39 | snippet option 40 | ⌥ 41 | # ⌦ 42 | snippet delete 43 | ⌦ 44 | # ⌫ 45 | snippet backspace 46 | ⌫ 47 | # ⎋ 48 | snippet escape 49 | ⎋ 50 | # Generic Doctype 51 | snippet doctype HTML 4.01 Strict 52 | 54 | snippet doctype HTML 4.01 Transitional 55 | 57 | snippet doctype HTML 5 58 | 59 | snippet doctype XHTML 1.0 Frameset 60 | 62 | snippet doctype XHTML 1.0 Strict 63 | 65 | snippet doctype XHTML 1.0 Transitional 66 | 68 | snippet doctype XHTML 1.1 69 | 71 | # HTML Doctype 4.01 Strict 72 | snippet docts 73 | 75 | # HTML Doctype 4.01 Transitional 76 | snippet doct 77 | 79 | # HTML Doctype 5 80 | snippet doct5 81 | 82 | # XHTML Doctype 1.0 Frameset 83 | snippet docxf 84 | 86 | # XHTML Doctype 1.0 Strict 87 | snippet docxs 88 | 90 | # XHTML Doctype 1.0 Transitional 91 | snippet docxt 92 | 94 | # XHTML Doctype 1.1 95 | snippet docx 96 | 98 | snippet html 99 | 100 | ${1} 101 | 102 | snippet xhtml 103 | 104 | ${1} 105 | 106 | snippet body 107 | 108 | ${1} 109 | 110 | snippet head 111 | 112 | 113 | 114 | ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`} 115 | ${2} 116 | 117 | snippet title 118 | ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}${2} 119 | snippet script 120 | ${2} 123 | snippet scriptsrc 124 | ${2} 125 | snippet style 126 | ${3} 129 | snippet base 130 | 131 | snippet r 132 | 133 | snippet div 134 |
135 | ${2} 136 |
137 | # Embed QT Movie 138 | snippet movie 139 | 141 | 142 | 143 | 144 | 150 | ${6} 151 | snippet fieldset 152 |
153 | ${1:name} 154 | 155 | ${3} 156 |
157 | snippet form 158 |
159 | ${3} 160 | 161 | 162 |

163 |
164 | snippet h1 165 |

${2:$1}

166 | snippet input 167 | ${4} 168 | snippet label 169 | ${7} 170 | snippet link 171 | ${4} 172 | snippet mailto 173 | ${3:email me} 174 | snippet meta 175 | ${3} 176 | snippet opt 177 | ${3} 178 | snippet optt 179 | ${2} 180 | snippet select 181 | ${5} 184 | snippet table 185 | 186 | 187 | 188 |
${2:Header}
${3:Data}
${4} 189 | snippet textarea 190 | ${5} 191 | -------------------------------------------------------------------------------- /vim/snippets/python.snippets: -------------------------------------------------------------------------------- 1 | snippet #! 2 | #!/usr/bin/env python 3 | # -*- coding: utf-8 -*- 4 | snippet fut 5 | from __future__ import absolute_import 6 | from __future__ import division 7 | from __future__ import print_function 8 | from __future__ import unicode_literals 9 | snippet gpl 10 | # Copyright (C) 2011 ${1:`g:snips_author`} 11 | # 12 | # This program is free software: you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation, version 3 of the License. 15 | 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program. If not, see . 23 | snippet mit 24 | # Copyright (C) 2011 by ${1:`g:snips_author`} 25 | # 26 | # Permission is hereby granted, free of charge, to any person obtaining a copy 27 | # of this software and associated documentation files (the "Software"), to deal 28 | # in the Software without restriction, including without limitation the rights 29 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 30 | # copies of the Software, and to permit persons to whom the Software is 31 | # furnished to do so, subject to the following conditions: 32 | 33 | # The above copyright notice and this permission notice shall be included in 34 | # all copies or substantial portions of the Software. 35 | 36 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 37 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 38 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 39 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 40 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 41 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 42 | # THE SOFTWARE. 43 | snippet docs 44 | """${1:Module name} 45 | ---- 46 | 47 | ${2:description}""" 48 | snippet !!! 49 | #!/usr/bin/env python 50 | # -*- coding: utf-8 -*- 51 | 52 | # Copyright (C) 2011 by ${1:`g:snips_author`} 53 | # 54 | # Permission is hereby granted, free of charge, to any person obtaining a copy 55 | # of this software and associated documentation files (the "Software"), to deal 56 | # in the Software without restriction, including without limitation the rights 57 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 58 | # copies of the Software, and to permit persons to whom the Software is 59 | # furnished to do so, subject to the following conditions: 60 | 61 | # The above copyright notice and this permission notice shall be included in 62 | # all copies or substantial portions of the Software. 63 | 64 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 65 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 66 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 67 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 68 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 69 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 70 | # THE SOFTWARE. 71 | 72 | """${2:Module name} 73 | ---- 74 | 75 | ${3:description}""" 76 | 77 | from __future__ import absolute_import 78 | from __future__ import division 79 | from __future__ import print_function 80 | from __future__ import unicode_literals 81 | snippet !! 82 | #!/usr/bin/env python 83 | # -*- coding: utf-8 -*- 84 | 85 | # Copyright (C) 2011 ${1:`g:snips_author`} 86 | 87 | """${2:short description}""" 88 | 89 | from __future__ import absolute_import 90 | from __future__ import division 91 | from __future__ import print_function 92 | from __future__ import unicode_literals 93 | snippet imp 94 | import ${1:module} 95 | snippet pdb 96 | import pdb; pdb.set_trace() 97 | snippet wh 98 | while ${1:condition}: 99 | ${2:# code...} 100 | snippet for 101 | for ${1:needle} in ${2:haystack}: 102 | ${3:# code...} 103 | # New Class 104 | snippet cl 105 | class ${1:ClassName}(${2:object}): 106 | """${3:docstring for $1}""" 107 | def __init__(self, ${4:arg}): 108 | ${5:super($1, self).__init__()} 109 | self.$4 = $4 110 | ${6} 111 | # New Function 112 | snippet def 113 | def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): 114 | """${3:docstring for $1}""" 115 | ${4:pass} 116 | snippet deff 117 | def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): 118 | ${3} 119 | # New Method 120 | snippet defs 121 | def ${1:mname}(self, ${2:arg}): 122 | ${3:pass} 123 | # New Property 124 | snippet property 125 | def ${1:foo}(): 126 | doc = "${2:The $1 property.}" 127 | def fget(self): 128 | ${3:return self._$1} 129 | def fset(self, value): 130 | ${4:self._$1 = value} 131 | # Lambda 132 | snippet ld 133 | ${1:var} = lambda ${2:vars} : ${3:action} 134 | snippet . 135 | self. 136 | snippet try Try/Except 137 | try: 138 | ${1:pass} 139 | except ${2:Exception}, ${3:e}: 140 | ${4:raise $3} 141 | snippet try Try/Except/Else 142 | try: 143 | ${1:pass} 144 | except ${2:Exception}, ${3:e}: 145 | ${4:raise $3} 146 | else: 147 | ${5:pass} 148 | snippet try Try/Except/Finally 149 | try: 150 | ${1:pass} 151 | except ${2:Exception}, ${3:e}: 152 | ${4:raise $3} 153 | finally: 154 | ${5:pass} 155 | snippet try Try/Except/Else/Finally 156 | try: 157 | ${1:pass} 158 | except ${2:Exception}, ${3:e}: 159 | ${4:raise $3} 160 | else: 161 | ${5:pass} 162 | finally: 163 | ${6:pass} 164 | # if __name__ == '__main__': 165 | snippet ifmain 166 | if __name__ == '__main__': 167 | ${1:main()} 168 | # __magic__ 169 | snippet _ 170 | __${1:init}__${2} 171 | -------------------------------------------------------------------------------- /install.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | import os 4 | import subprocess 5 | import optparse 6 | 7 | try: 8 | from hashlib import md5 9 | except ImportError: 10 | import md5 11 | md5 = md5.new 12 | 13 | if sys.version_info[:2] < (2, 4): 14 | # subprocess was introduced in Python 2.4 15 | print "Sorry, Python 2.4 required." 16 | sys.exit(1) 17 | 18 | user_home_dir = os.path.expanduser("~") 19 | dot_files_dir = os.path.dirname(__file__) 20 | if not dot_files_dir: 21 | dot_files_dir = '.' 22 | parser = optparse.OptionParser() 23 | parser.add_option("-U", "--uninstall", 24 | action="store_true", 25 | dest="uninstall", 26 | default=False, 27 | help="uninstall the distribution from the home directory") 28 | parser.add_option("-v", "--verbose", 29 | action="store_true", 30 | dest="verbose", 31 | default=False, 32 | help="more detailed output") 33 | parser.add_option("-d", "--dir", 34 | dest="dir", 35 | default=user_home_dir, 36 | help="specify a directory to install to/uninstall from", 37 | metavar="DIR") 38 | 39 | (options, args) = parser.parse_args() 40 | 41 | 42 | class Command(object): 43 | warnings = [] 44 | verbose = [] 45 | 46 | 47 | class Install(Command): 48 | cmd_message = "Installing dot_files to" 49 | 50 | def no_target(self, source, target): 51 | status = subprocess.call("ln -s %s %s" % (os.path.realpath(source), os.path.realpath(target)), shell=True) 52 | if status == 0: 53 | self.verbose.append("linked %s to %s" % (source, target)) 54 | else: 55 | self.warnings.append("creating link %s to %s failed with status code %d" % (source, target, status)) 56 | 57 | def target_link_same(self, source, target, real_source, real_target): 58 | self.verbose.append("link from %s to %s already exists" % (source, target)) 59 | 60 | def target_link_different(self, source, target, real_source, real_target): 61 | self.warnings.append("link at %s exists but points to %s" % (target, real_target)) 62 | 63 | def target_different(self, source, target): 64 | self.warnings.append("target %s exists but is not a link" % (target, )) 65 | 66 | 67 | class Uninstall(Command): 68 | cmd_message = "Uninstalling dot_files from" 69 | 70 | def no_target(self, source, target): 71 | self.verbose.append("target %s was missing" % (target,)) 72 | 73 | def target_link_same(self, source, target, real_source, real_target): 74 | os.unlink(target) 75 | self.verbose.append("link from %s to %s removed" % (source, target)) 76 | 77 | def target_link_different(self, source, target, real_source, real_target): 78 | self.warnings.append("skipped target at %s: link points to %s" % (target, real_target)) 79 | 80 | def target_different(self, source, target): 81 | self.warnings.append("skipped target at %s: not a link" % (target, )) 82 | 83 | 84 | def obtain_machine_type(): 85 | """Checks common locations for files holding the current version of the OS.""" 86 | 87 | if os.path.exists('/etc/redhat-release'): 88 | f = open('/etc/redhat-release') 89 | os_version = f.read().strip() 90 | os_type = 'redhat' 91 | elif os.path.exists('/etc/debian_version'): 92 | f = open('/etc/debian_version') 93 | os_version = f.read().strip() 94 | os_type = 'debian' 95 | elif os.path.exists('/System/Library/CoreServices/SystemVersion.plist'): 96 | from xml.dom.minidom import parse 97 | f = parse('/System/Library/CoreServices/SystemVersion.plist') 98 | keys = f.getElementsByTagName('dict')[0].getElementsByTagName('key') 99 | prod_name = "" 100 | prod_version = "" 101 | for k in keys: 102 | if k.childNodes[0].data.strip() == u"ProductName": 103 | sibling = k.nextSibling 104 | while sibling.__class__.__name__ != 'Element': 105 | sibling = sibling.nextSibling 106 | if sibling.tagName == u"string": 107 | prod_name = sibling.childNodes[0].data.strip() 108 | if k.childNodes[0].data.strip() == u"ProductVersion": 109 | sibling = k.nextSibling 110 | while sibling.__class__.__name__ != 'Element': 111 | sibling = sibling.nextSibling 112 | if sibling.tagName == u"string": 113 | prod_version = sibling.childNodes[0].data.strip() 114 | os_version = "%s %s" % (prod_name, prod_version) 115 | os_type = 'darwin' 116 | elif os.path.exists('/cygdrive'): 117 | os_version = 'Cygwin' 118 | os_type = 'cygwin' 119 | else: 120 | os_version = 'unknown' 121 | os_type = None 122 | 123 | return os_type, os_version 124 | 125 | 126 | if not options.uninstall: 127 | handler = Install() 128 | else: 129 | handler = Uninstall() 130 | 131 | machine_type, machine_version = obtain_machine_type() 132 | 133 | if machine_type: 134 | additional_info = "%s with extras for %s" % (options.dir, machine_version) 135 | else: 136 | additional_info = options.dir 137 | 138 | print handler.cmd_message, "%s..." % additional_info, 139 | 140 | for entry in os.listdir(dot_files_dir): 141 | source = os.path.join(dot_files_dir, entry) 142 | target = os.path.join(options.dir, ".%s" % entry) 143 | 144 | if entry.startswith('.') or entry.endswith('~') or \ 145 | entry in ('install.py', 'bin', 'README.rst'): 146 | continue 147 | elif entry == 'profile_machine': 148 | if not machine_type: 149 | continue 150 | source = os.path.join(dot_files_dir, entry, machine_type) 151 | 152 | if not os.path.exists(target): 153 | handler.no_target(source, target) 154 | elif os.path.islink(target): 155 | real_source = os.path.realpath(source) 156 | real_target = os.path.realpath(target) 157 | if real_source == real_target: 158 | handler.target_link_same(source, target, real_source, real_target) 159 | else: 160 | handler.target_link_different(source, target, real_source, real_target) 161 | else: 162 | handler.target_different(source, target) 163 | 164 | print "done." 165 | 166 | for w in handler.warnings: 167 | print "Warning:", w 168 | 169 | if options.verbose: 170 | for v in handler.verbose: 171 | print v 172 | -------------------------------------------------------------------------------- /vim/syntax/scala.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language : Scala (http://scala-lang.org/) 3 | " Maintainers: Stefan Matthias Aust, Julien Wetterwald 4 | " Last Change: 2007 June 13 5 | " svn co http://lampsvn.epfl.ch/svn-repos/scala/scala-tool-support/trunk/src/vim 6 | 7 | if version < 600 8 | syntax clear 9 | elseif exists("b:current_syntax") 10 | finish 11 | endif 12 | 13 | syn case match 14 | syn sync minlines=50 15 | 16 | " most Scala keywords 17 | syn keyword scalaKeyword abstract case catch do else extends final finally for forSome if implicit lazy match new null override private protected requires return sealed super this throw try type while with yield 18 | syn match scalaKeyword "=>" 19 | syn match scalaKeyword "<-" 20 | syn match scalaKeyword "\<_\>" 21 | 22 | syn match scalaOperator ":\{2,\}" "this is not a type 23 | 24 | " package and import statements 25 | syn keyword scalaPackage package nextgroup=scalaFqn skipwhite 26 | syn keyword scalaImport import nextgroup=scalaFqn skipwhite 27 | syn match scalaFqn "\<[._$a-zA-Z0-9,]*" contained nextgroup=scalaFqnSet 28 | syn region scalaFqnSet start="{" end="}" contained 29 | 30 | " boolean literals 31 | syn keyword scalaBoolean true false 32 | 33 | " definitions 34 | syn keyword scalaDef def nextgroup=scalaDefName skipwhite 35 | syn keyword scalaVal val nextgroup=scalaValName skipwhite 36 | syn keyword scalaVar var nextgroup=scalaVarName skipwhite 37 | syn keyword scalaClass class nextgroup=scalaClassName skipwhite 38 | syn keyword scalaObject object nextgroup=scalaClassName skipwhite 39 | syn keyword scalaTrait trait nextgroup=scalaClassName skipwhite 40 | syn match scalaDefName "[^ =:;([]\+" contained nextgroup=scalaDefSpecializer skipwhite 41 | syn match scalaValName "[^ =:;([]\+" contained 42 | syn match scalaVarName "[^ =:;([]\+" contained 43 | syn match scalaClassName "[^ =:;(\[]\+" contained nextgroup=scalaClassSpecializer skipwhite 44 | syn region scalaDefSpecializer start="\[" end="\]" contained contains=scalaDefSpecializer 45 | syn region scalaClassSpecializer start="\[" end="\]" contained contains=scalaClassSpecializer 46 | 47 | " type constructor (actually anything with an uppercase letter) 48 | syn match scalaConstructor "\<[A-Z][_$a-zA-Z0-9]*\>" nextgroup=scalaConstructorSpecializer 49 | syn region scalaConstructorSpecializer start="\[" end="\]" contained contains=scalaConstructorSpecializer 50 | 51 | " method call 52 | syn match scalaRoot "\<[a-zA-Z][_$a-zA-Z0-9]*\."me=e-1 53 | syn match scalaMethodCall "\.[a-z][_$a-zA-Z0-9]*"ms=s+1 54 | 55 | " type declarations in val/var/def 56 | syn match scalaType ":\s*\(=>\s*\)\?[._$a-zA-Z0-9]\+\(\[[^]]*\]\+\)\?\(\s*\(<:\|>:\|#\|=>\)\s*[._$a-zA-Z0-9]\+\(\[[^]]*\]\+\)*\)*"ms=s+1 57 | 58 | " comments 59 | syn match scalaTodo "[tT][oO][dD][oO]" contained 60 | syn match scalaLineComment "//.*" contains=scalaTodo 61 | syn region scalaComment start="/\*" end="\*/" contains=scalaTodo 62 | syn case ignore 63 | syn include @scalaHtml syntax/html.vim 64 | unlet b:current_syntax 65 | syn case match 66 | syn region scalaDocComment start="/\*\*" end="\*/" contains=scalaDocTags,scalaTodo,@scalaHtml keepend 67 | syn region scalaDocTags start="{@\(link\|linkplain\|inherit[Dd]oc\|doc[rR]oot\|value\)" end="}" contained 68 | syn match scalaDocTags "@[a-z]\+" contained 69 | 70 | syn match scalaEmptyString "\"\"" 71 | 72 | " multi-line string literals 73 | syn region scalaMultiLineString start="\"\"\"" end="\"\"\"" contains=scalaUnicode 74 | syn match scalaUnicode "\\u[0-9a-fA-F]\{4}" contained 75 | 76 | " string literals with escapes 77 | syn region scalaString start="\"[^"]" skip="\\\"" end="\"" contains=scalaStringEscape " TODO end \n or not? 78 | syn match scalaStringEscape "\\u[0-9a-fA-F]\{4}" contained 79 | syn match scalaStringEscape "\\[nrfvb\\\"]" contained 80 | 81 | " symbol and character literals 82 | syn match scalaSymbol "'[_a-zA-Z0-9][_a-zA-Z0-9]*\>" 83 | syn match scalaChar "'[^'\\]'\|'\\.'\|'\\u[0-9a-fA-F]\{4}'" 84 | 85 | " number literals 86 | syn match scalaNumber "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>" 87 | syn match scalaNumber "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\=" 88 | syn match scalaNumber "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>" 89 | syn match scalaNumber "\<\d\+\([eE][-+]\=\d\+\)\=[fFdD]\>" 90 | 91 | " xml literals 92 | syn match scalaXmlTag "<[a-zA-Z]\_[^>]*/>" contains=scalaXmlQuote,scalaXmlEscape,scalaXmlString 93 | syn region scalaXmlString start="\"" end="\"" contained 94 | syn match scalaXmlStart "<[a-zA-Z]\_[^>]*>" contained contains=scalaXmlQuote,scalaXmlEscape,scalaXmlString 95 | syn region scalaXml start="<\([a-zA-Z]\_[^>]*\_[^/]\|[a-zA-Z]\)>" matchgroup=scalaXmlStart end="]\+>" contains=scalaXmlEscape,scalaXmlQuote,scalaXml,scalaXmlStart,scalaXmlComment 96 | syn region scalaXmlEscape matchgroup=scalaXmlEscapeSpecial start="{" matchgroup=scalaXmlEscapeSpecial end="}" contained contains=TOP 97 | syn match scalaXmlQuote "&[^;]\+;" contained 98 | syn match scalaXmlComment "" contained 99 | 100 | syn sync fromstart 101 | 102 | " map Scala groups to standard groups 103 | hi link scalaKeyword Keyword 104 | hi link scalaPackage Include 105 | hi link scalaImport Include 106 | hi link scalaBoolean Boolean 107 | hi link scalaOperator Normal 108 | hi link scalaNumber Number 109 | hi link scalaEmptyString String 110 | hi link scalaString String 111 | hi link scalaChar String 112 | hi link scalaMultiLineString String 113 | hi link scalaStringEscape Special 114 | hi link scalaSymbol Special 115 | hi link scalaUnicode Special 116 | hi link scalaComment Comment 117 | hi link scalaLineComment Comment 118 | hi link scalaDocComment Comment 119 | hi link scalaDocTags Special 120 | hi link scalaTodo Todo 121 | hi link scalaType Type 122 | hi link scalaTypeSpecializer scalaType 123 | hi link scalaXml String 124 | hi link scalaXmlTag Include 125 | hi link scalaXmlString String 126 | hi link scalaXmlStart Include 127 | hi link scalaXmlEscape Normal 128 | hi link scalaXmlEscapeSpecial Special 129 | hi link scalaXmlQuote Special 130 | hi link scalaXmlComment Comment 131 | hi link scalaDef Keyword 132 | hi link scalaVar Keyword 133 | hi link scalaVal Keyword 134 | hi link scalaClass Keyword 135 | hi link scalaObject Keyword 136 | hi link scalaTrait Keyword 137 | hi link scalaDefName Function 138 | hi link scalaDefSpecializer Function 139 | hi link scalaClassName Special 140 | hi link scalaClassSpecializer Special 141 | hi link scalaConstructor Special 142 | hi link scalaConstructorSpecializer scalaConstructor 143 | 144 | let b:current_syntax = "scala" 145 | 146 | " you might like to put these lines in your .vimrc 147 | " 148 | " customize colors a little bit (should be a different file) 149 | " hi scalaNew gui=underline 150 | " hi scalaMethodCall gui=italic 151 | " hi scalaValName gui=underline 152 | " hi scalaVarName gui=underline 153 | -------------------------------------------------------------------------------- /vim/nerdtree_plugin/fs_menu.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================ 2 | " File: fs_menu.vim 3 | " Description: plugin for the NERD Tree that provides a file system menu 4 | " Maintainer: Martin Grenfell 5 | " Last Change: 17 July, 2009 6 | " License: This program is free software. It comes without any warranty, 7 | " to the extent permitted by applicable law. You can redistribute 8 | " it and/or modify it under the terms of the Do What The Fuck You 9 | " Want To Public License, Version 2, as published by Sam Hocevar. 10 | " See http://sam.zoy.org/wtfpl/COPYING for more details. 11 | " 12 | " ============================================================================ 13 | if exists("g:loaded_nerdtree_fs_menu") 14 | finish 15 | endif 16 | let g:loaded_nerdtree_fs_menu = 1 17 | 18 | call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'}) 19 | call NERDTreeAddMenuItem({'text': '(m)ove the curent node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) 20 | call NERDTreeAddMenuItem({'text': '(d)elete the curent node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) 21 | if g:NERDTreePath.CopyingSupported() 22 | call NERDTreeAddMenuItem({'text': '(c)copy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) 23 | endif 24 | 25 | "FUNCTION: s:echo(msg){{{1 26 | function! s:echo(msg) 27 | redraw 28 | echomsg "NERDTree: " . a:msg 29 | endfunction 30 | 31 | "FUNCTION: s:echoWarning(msg){{{1 32 | function! s:echoWarning(msg) 33 | echohl warningmsg 34 | call s:echo(a:msg) 35 | echohl normal 36 | endfunction 37 | 38 | "FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1 39 | "prints out the given msg and, if the user responds by pushing 'y' then the 40 | "buffer with the given bufnum is deleted 41 | " 42 | "Args: 43 | "bufnum: the buffer that may be deleted 44 | "msg: a message that will be echoed to the user asking them if they wish to 45 | " del the buffer 46 | function! s:promptToDelBuffer(bufnum, msg) 47 | echo a:msg 48 | if nr2char(getchar()) ==# 'y' 49 | exec "silent bdelete! " . a:bufnum 50 | endif 51 | endfunction 52 | 53 | "FUNCTION: NERDTreeAddNode(){{{1 54 | function! NERDTreeAddNode() 55 | let curDirNode = g:NERDTreeDirNode.GetSelected() 56 | 57 | let newNodeName = input("Add a childnode\n". 58 | \ "==========================================================\n". 59 | \ "Enter the dir/file name to be created. Dirs end with a '/'\n" . 60 | \ "", curDirNode.path.str({'format': 'Glob'}) . g:NERDTreePath.Slash()) 61 | 62 | if newNodeName ==# '' 63 | call s:echo("Node Creation Aborted.") 64 | return 65 | endif 66 | 67 | try 68 | let newPath = g:NERDTreePath.Create(newNodeName) 69 | let parentNode = b:NERDTreeRoot.findNode(newPath.getParent()) 70 | 71 | let newTreeNode = g:NERDTreeFileNode.New(newPath) 72 | if parentNode.isOpen || !empty(parentNode.children) 73 | call parentNode.addChild(newTreeNode, 1) 74 | call NERDTreeRender() 75 | call newTreeNode.putCursorHere(1, 0) 76 | endif 77 | catch /^NERDTree/ 78 | call s:echoWarning("Node Not Created.") 79 | endtry 80 | endfunction 81 | 82 | "FUNCTION: NERDTreeMoveNode(){{{1 83 | function! NERDTreeMoveNode() 84 | let curNode = g:NERDTreeFileNode.GetSelected() 85 | let newNodePath = input("Rename the current node\n" . 86 | \ "==========================================================\n" . 87 | \ "Enter the new path for the node: \n" . 88 | \ "", curNode.path.str()) 89 | 90 | if newNodePath ==# '' 91 | call s:echo("Node Renaming Aborted.") 92 | return 93 | endif 94 | 95 | try 96 | let bufnum = bufnr(curNode.path.str()) 97 | 98 | call curNode.rename(newNodePath) 99 | call NERDTreeRender() 100 | 101 | "if the node is open in a buffer, ask the user if they want to 102 | "close that buffer 103 | if bufnum != -1 104 | let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" 105 | call s:promptToDelBuffer(bufnum, prompt) 106 | endif 107 | 108 | call curNode.putCursorHere(1, 0) 109 | 110 | redraw 111 | catch /^NERDTree/ 112 | call s:echoWarning("Node Not Renamed.") 113 | endtry 114 | endfunction 115 | 116 | " FUNCTION: NERDTreeDeleteNode() {{{1 117 | function! NERDTreeDeleteNode() 118 | let currentNode = g:NERDTreeFileNode.GetSelected() 119 | let confirmed = 0 120 | 121 | if currentNode.path.isDirectory 122 | let choice =input("Delete the current node\n" . 123 | \ "==========================================================\n" . 124 | \ "STOP! To delete this entire directory, type 'yes'\n" . 125 | \ "" . currentNode.path.str() . ": ") 126 | let confirmed = choice ==# 'yes' 127 | else 128 | echo "Delete the current node\n" . 129 | \ "==========================================================\n". 130 | \ "Are you sure you wish to delete the node:\n" . 131 | \ "" . currentNode.path.str() . " (yN):" 132 | let choice = nr2char(getchar()) 133 | let confirmed = choice ==# 'y' 134 | endif 135 | 136 | 137 | if confirmed 138 | try 139 | call currentNode.delete() 140 | call NERDTreeRender() 141 | 142 | "if the node is open in a buffer, ask the user if they want to 143 | "close that buffer 144 | let bufnum = bufnr(currentNode.path.str()) 145 | if buflisted(bufnum) 146 | let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" 147 | call s:promptToDelBuffer(bufnum, prompt) 148 | endif 149 | 150 | redraw 151 | catch /^NERDTree/ 152 | call s:echoWarning("Could not remove node") 153 | endtry 154 | else 155 | call s:echo("delete aborted") 156 | endif 157 | 158 | endfunction 159 | 160 | " FUNCTION: NERDTreeCopyNode() {{{1 161 | function! NERDTreeCopyNode() 162 | let currentNode = g:NERDTreeFileNode.GetSelected() 163 | let newNodePath = input("Copy the current node\n" . 164 | \ "==========================================================\n" . 165 | \ "Enter the new path to copy the node to: \n" . 166 | \ "", currentNode.path.str()) 167 | 168 | if newNodePath != "" 169 | "strip trailing slash 170 | let newNodePath = substitute(newNodePath, '\/$', '', '') 171 | 172 | let confirmed = 1 173 | if currentNode.path.copyingWillOverwrite(newNodePath) 174 | call s:echo("Warning: copying may overwrite files! Continue? (yN)") 175 | let choice = nr2char(getchar()) 176 | let confirmed = choice ==# 'y' 177 | endif 178 | 179 | if confirmed 180 | try 181 | let newNode = currentNode.copy(newNodePath) 182 | call NERDTreeRender() 183 | call newNode.putCursorHere(0, 0) 184 | catch /^NERDTree/ 185 | call s:echoWarning("Could not copy node") 186 | endtry 187 | endif 188 | else 189 | call s:echo("Copy aborted.") 190 | endif 191 | redraw 192 | endfunction 193 | 194 | " vim: set sw=4 sts=4 et fdm=marker: 195 | -------------------------------------------------------------------------------- /vim/syntax/rst.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: reStructuredText documentation format 3 | " Maintainer: Nikolai Weibull 4 | " Latest Revision: 2009-05-25 5 | 6 | if exists("b:current_syntax") 7 | finish 8 | endif 9 | 10 | let s:cpo_save = &cpo 11 | set cpo&vim 12 | 13 | syn case ignore 14 | 15 | syn match rstSections "^\%(\([=`:.'"~^_*+#-]\)\1\+\n\)\=.\+\n\([=`:.'"~^_*+#-]\)\2\+$" 16 | 17 | syn match rstTransition /^[=`:.'"~^_*+#-]\{4,}\s*$/ 18 | 19 | syn cluster rstCruft contains=rstEmphasis,rstStrongEmphasis, 20 | \ rstInterpretedText,rstInlineLiteral,rstSubstitutionReference, 21 | \ rstInlineInternalTargets,rstFootnoteReference,rstHyperlinkReference 22 | 23 | syn region rstLiteralBlock matchgroup=rstDelimiter 24 | \ start='::\_s*\n\ze\z(\s\+\)' skip='^$' end='^\z1\@!' 25 | \ contains=@NoSpell 26 | 27 | syn region rstQuotedLiteralBlock matchgroup=rstDelimiter 28 | \ start="::\_s*\n\ze\z([!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]\)" 29 | \ end='^\z1\@!' contains=@NoSpell 30 | 31 | syn region rstDoctestBlock oneline display matchgroup=rstDelimiter 32 | \ start='^>>>\s' end='^$' 33 | 34 | syn region rstTable transparent start='^\n\s*+[-=+]\+' end='^$' 35 | \ contains=rstTableLines,@rstCruft 36 | syn match rstTableLines contained display '|\|+\%(=\+\|-\+\)\=' 37 | 38 | syn region rstSimpleTable transparent 39 | \ start='^\n\%(\s*\)\@>\%(\%(=\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(=\+\)\@>\%(\s*\)\@>\)\+\)\@>$' 40 | \ end='^$' 41 | \ contains=rstSimpleTableLines,@rstCruft 42 | syn match rstSimpleTableLines contained display 43 | \ '^\%(\s*\)\@>\%(\%(=\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(=\+\)\@>\%(\s*\)\@>\)\+\)\@>$' 44 | syn match rstSimpleTableLines contained display 45 | \ '^\%(\s*\)\@>\%(\%(-\+\)\@>\%(\s\+\)\@>\)\%(\%(\%(-\+\)\@>\%(\s*\)\@>\)\+\)\@>$' 46 | 47 | syn cluster rstDirectives contains=rstFootnote,rstCitation, 48 | \ rstHyperlinkTarget,rstExDirective 49 | 50 | syn match rstExplicitMarkup '^\.\.\_s' 51 | \ nextgroup=@rstDirectives,rstComment,rstSubstitutionDefinition 52 | 53 | let s:ReferenceName = '[[:alnum:]]\+\%([_.-][[:alnum:]]\+\)*' 54 | 55 | syn keyword rstTodo contained FIXME TODO XXX NOTE 56 | 57 | execute 'syn region rstComment contained' . 58 | \ ' start=/.*/' 59 | \ ' end=/^\s\@!/ contains=rstTodo' 60 | 61 | execute 'syn region rstFootnote contained matchgroup=rstDirective' . 62 | \ ' start=+\[\%(\d\+\|#\%(' . s:ReferenceName . '\)\=\|\*\)\]\_s+' . 63 | \ ' skip=+^$+' . 64 | \ ' end=+^\s\@!+ contains=@rstCruft,@NoSpell' 65 | 66 | execute 'syn region rstCitation contained matchgroup=rstDirective' . 67 | \ ' start=+\[' . s:ReferenceName . '\]\_s+' . 68 | \ ' skip=+^$+' . 69 | \ ' end=+^\s\@!+ contains=@rstCruft,@NoSpell' 70 | 71 | syn region rstHyperlinkTarget contained matchgroup=rstDirective 72 | \ start='_\%(_\|[^:\\]*\%(\\.[^:\\]*\)*\):\_s' skip=+^$+ end=+^\s\@!+ 73 | 74 | syn region rstHyperlinkTarget contained matchgroup=rstDirective 75 | \ start='_`[^`\\]*\%(\\.[^`\\]*\)*`:\_s' skip=+^$+ end=+^\s\@!+ 76 | 77 | syn region rstHyperlinkTarget matchgroup=rstDirective 78 | \ start=+^__\_s+ skip=+^$+ end=+^\s\@!+ 79 | 80 | execute 'syn region rstExDirective contained matchgroup=rstDirective' . 81 | \ ' start=+' . s:ReferenceName . '::\_s+' . 82 | \ ' skip=+^$+' . 83 | \ ' end=+^\s\@!+ contains=@rstCruft' 84 | 85 | execute 'syn match rstSubstitutionDefinition contained' . 86 | \ ' /|' . s:ReferenceName . '|\_s\+/ nextgroup=@rstDirectives' 87 | 88 | function! s:DefineOneInlineMarkup(name, start, middle, end, char_left, char_right) 89 | execute 'syn region rst' . a:name . 90 | \ ' start=+' . a:char_left . '\zs' . a:start . 91 | \ '\ze[^[:space:]' . a:char_right . a:start[strlen(a:start) - 1] . ']+' . 92 | \ a:middle . 93 | \ ' end=+\S' . a:end . '\ze\%($\|\s\|[''")\]}>/:.,;!?\\-]\)+' 94 | endfunction 95 | 96 | function! s:DefineInlineMarkup(name, start, middle, end) 97 | let middle = a:middle != "" ? 98 | \ (' skip=+\\\\\|\\' . a:middle . '+') : 99 | \ "" 100 | 101 | call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, "'", "'") 102 | call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '"', '"') 103 | call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '(', ')') 104 | call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '\[', '\]') 105 | call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '{', '}') 106 | call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '<', '>') 107 | 108 | call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '\%(^\|\s\|[/:]\)', '') 109 | 110 | execute 'syn match rst' . a:name . 111 | \ ' +\%(^\|\s\|[''"([{/:.,;!?\\-]\)+' 114 | 115 | execute 'hi def link rst' . a:name . 'Delimiter' . ' rst' . a:name 116 | endfunction 117 | 118 | call s:DefineInlineMarkup('Emphasis', '\*', '\*', '\*') 119 | call s:DefineInlineMarkup('StrongEmphasis', '\*\*', '\*', '\*\*') 120 | call s:DefineInlineMarkup('InterpretedTextOrHyperlinkReference', '`', '`', '`_\{0,2}') 121 | call s:DefineInlineMarkup('InlineLiteral', '``', "", '``') 122 | call s:DefineInlineMarkup('SubstitutionReference', '|', '|', '|_\{0,2}') 123 | call s:DefineInlineMarkup('InlineInternalTargets', '_`', '`', '`') 124 | 125 | " TODO: Can’t remember why these two can’t be defined like the ones above. 126 | execute 'syn match rstFootnoteReference contains=@NoSpell' . 127 | \ ' +\[\%(\d\+\|#\%(' . s:ReferenceName . '\)\=\|\*\)\]_+' 128 | 129 | execute 'syn match rstCitationReference contains=@NoSpell' . 130 | \ ' +\[' . s:ReferenceName . '\]_\ze\%($\|\s\|[''")\]}>/:.,;!?\\-]\)+' 131 | 132 | execute 'syn match rstHyperlinkReference' . 133 | \ ' /\<' . s:ReferenceName . '__\=\ze\%($\|\s\|[''")\]}>/:.,;!?\\-]\)/' 134 | 135 | syn match rstStandaloneHyperlink contains=@NoSpell 136 | \ "\<\%(\%(\%(https\=\|file\|ftp\|gopher\)://\|\%(mailto\|news\):\)[^[:space:]'\"<>]\+\|www[[:alnum:]_-]*\.[[:alnum:]_-]\+\.[^[:space:]'\"<>]\+\)[[:alnum:]/]" 137 | 138 | " TODO: Use better syncing. I don’t know the specifics of syncing well enough, 139 | " though. 140 | syn sync minlines=50 141 | 142 | hi def link rstTodo Todo 143 | hi def link rstComment Comment 144 | hi def link rstSections Type 145 | hi def link rstTransition Type 146 | hi def link rstLiteralBlock String 147 | hi def link rstQuotedLiteralBlock String 148 | hi def link rstDoctestBlock PreProc 149 | hi def link rstTableLines rstDelimiter 150 | hi def link rstSimpleTableLines rstTableLines 151 | hi def link rstExplicitMarkup rstDirective 152 | hi def link rstDirective Keyword 153 | hi def link rstFootnote String 154 | hi def link rstCitation String 155 | hi def link rstHyperlinkTarget String 156 | hi def link rstExDirective String 157 | hi def link rstSubstitutionDefinition rstDirective 158 | hi def link rstDelimiter Delimiter 159 | " TODO: I dunno... 160 | hi def rstEmphasis term=italic cterm=italic gui=italic 161 | hi def link rstStrongEmphasis Special 162 | "term=bold cterm=bold gui=bold 163 | hi def link rstInterpretedTextOrHyperlinkReference Identifier 164 | hi def link rstInlineLiteral String 165 | hi def link rstSubstitutionReference PreProc 166 | hi def link rstInlineInternalTargets Identifier 167 | hi def link rstFootnoteReference Identifier 168 | hi def link rstCitationReference Identifier 169 | hi def link rstHyperLinkReference Identifier 170 | hi def link rstStandaloneHyperlink Identifier 171 | 172 | let b:current_syntax = "rst" 173 | 174 | let &cpo = s:cpo_save 175 | unlet s:cpo_save 176 | -------------------------------------------------------------------------------- /vim/plugin/snipMate.vim: -------------------------------------------------------------------------------- 1 | " File: snipMate.vim 2 | " Author: Michael Sanders 3 | " Last Updated: July 13, 2009 4 | " Version: 0.83 5 | " Description: snipMate.vim implements some of TextMate's snippets features in 6 | " Vim. A snippet is a piece of often-typed text that you can 7 | " insert into your document using a trigger word followed by a "". 8 | " 9 | " For more help see snipMate.txt; you can do this by using: 10 | " :helptags ~/.vim/doc 11 | " :h snipMate.txt 12 | 13 | if exists('loaded_snips') || &cp || version < 700 14 | finish 15 | endif 16 | let loaded_snips = 1 17 | if !exists('snips_author') | let snips_author = 'Me' | endif 18 | 19 | au BufRead,BufNewFile *.snippets\= set ft=snippet 20 | au FileType snippet setl noet fdm=indent 21 | 22 | let s:snippets = {} | let s:multi_snips = {} 23 | 24 | if !exists('snippets_dir') 25 | let snippets_dir = substitute(globpath(&rtp, 'snippets/'), "\n", ',', 'g') 26 | endif 27 | 28 | fun! MakeSnip(scope, trigger, content, ...) 29 | let multisnip = a:0 && a:1 != '' 30 | let var = multisnip ? 's:multi_snips' : 's:snippets' 31 | if !has_key({var}, a:scope) | let {var}[a:scope] = {} | endif 32 | if !has_key({var}[a:scope], a:trigger) 33 | let {var}[a:scope][a:trigger] = multisnip ? [[a:1, a:content]] : a:content 34 | elseif multisnip | let {var}[a:scope][a:trigger] += [[a:1, a:content]] 35 | else 36 | echom 'Warning in snipMate.vim: Snippet '.a:trigger.' is already defined.' 37 | \ .' See :h multi_snip for help on snippets with multiple matches.' 38 | endif 39 | endf 40 | 41 | fun! ExtractSnips(dir, ft) 42 | for path in split(globpath(a:dir, '*'), "\n") 43 | if isdirectory(path) 44 | let pathname = fnamemodify(path, ':t') 45 | for snipFile in split(globpath(path, '*.snippet'), "\n") 46 | call s:ProcessFile(snipFile, a:ft, pathname) 47 | endfor 48 | elseif fnamemodify(path, ':e') == 'snippet' 49 | call s:ProcessFile(path, a:ft) 50 | endif 51 | endfor 52 | endf 53 | 54 | " Processes a single-snippet file; optionally add the name of the parent 55 | " directory for a snippet with multiple matches. 56 | fun s:ProcessFile(file, ft, ...) 57 | let keyword = fnamemodify(a:file, ':t:r') 58 | if keyword == '' | return | endif 59 | try 60 | let text = join(readfile(a:file), "\n") 61 | catch /E484/ 62 | echom "Error in snipMate.vim: couldn't read file: ".a:file 63 | endtry 64 | return a:0 ? MakeSnip(a:ft, a:1, text, keyword) 65 | \ : MakeSnip(a:ft, keyword, text) 66 | endf 67 | 68 | fun! ExtractSnipsFile(file, ft) 69 | if !filereadable(a:file) | return | endif 70 | let text = readfile(a:file) 71 | let inSnip = 0 72 | for line in text + ["\n"] 73 | if inSnip && (line[0] == "\t" || line == '') 74 | let content .= strpart(line, 1)."\n" 75 | continue 76 | elseif inSnip 77 | call MakeSnip(a:ft, trigger, content[:-2], name) 78 | let inSnip = 0 79 | endif 80 | 81 | if line[:6] == 'snippet' 82 | let inSnip = 1 83 | let trigger = strpart(line, 8) 84 | let name = '' 85 | let space = stridx(trigger, ' ') + 1 86 | if space " Process multi snip 87 | let name = strpart(trigger, space) 88 | let trigger = strpart(trigger, 0, space - 1) 89 | endif 90 | let content = '' 91 | endif 92 | endfor 93 | endf 94 | 95 | fun! ResetSnippets() 96 | let s:snippets = {} | let s:multi_snips = {} | let g:did_ft = {} 97 | endf 98 | 99 | let g:did_ft = {} 100 | fun! GetSnippets(dir, filetypes) 101 | for ft in split(a:filetypes, '\.') 102 | if has_key(g:did_ft, ft) | continue | endif 103 | call s:DefineSnips(a:dir, ft, ft) 104 | if ft == 'objc' || ft == 'cpp' || ft == 'cs' 105 | call s:DefineSnips(a:dir, 'c', ft) 106 | elseif ft == 'xhtml' 107 | call s:DefineSnips(a:dir, 'html', 'xhtml') 108 | endif 109 | let g:did_ft[ft] = 1 110 | endfor 111 | endf 112 | 113 | " Define "aliasft" snippets for the filetype "realft". 114 | fun s:DefineSnips(dir, aliasft, realft) 115 | for path in split(globpath(a:dir, a:aliasft.'/')."\n". 116 | \ globpath(a:dir, a:aliasft.'-*/'), "\n") 117 | call ExtractSnips(path, a:realft) 118 | endfor 119 | for path in split(globpath(a:dir, a:aliasft.'.snippets')."\n". 120 | \ globpath(a:dir, a:aliasft.'-*.snippets'), "\n") 121 | call ExtractSnipsFile(path, a:realft) 122 | endfor 123 | endf 124 | 125 | fun! TriggerSnippet() 126 | if exists('g:SuperTabMappingForward') 127 | if g:SuperTabMappingForward == "" 128 | let SuperTabKey = "\" 129 | elseif g:SuperTabMappingBackward == "" 130 | let SuperTabKey = "\" 131 | endif 132 | endif 133 | 134 | if pumvisible() " Update snippet if completion is used, or deal with supertab 135 | if exists('SuperTabKey') 136 | call feedkeys(SuperTabKey) | return '' 137 | endif 138 | call feedkeys("\a", 'n') " Close completion menu 139 | call feedkeys("\") | return '' 140 | endif 141 | 142 | if exists('g:snipPos') | return snipMate#jumpTabStop(0) | endif 143 | 144 | let word = matchstr(getline('.'), '\S\+\%'.col('.').'c') 145 | for scope in [bufnr('%')] + split(&ft, '\.') + ['_'] 146 | let [trigger, snippet] = s:GetSnippet(word, scope) 147 | " If word is a trigger for a snippet, delete the trigger & expand 148 | " the snippet. 149 | if snippet != '' 150 | let col = col('.') - len(trigger) 151 | sil exe 's/\V'.escape(trigger, '/.').'\%#//' 152 | return snipMate#expandSnip(snippet, col) 153 | endif 154 | endfor 155 | 156 | if exists('SuperTabKey') 157 | call feedkeys(SuperTabKey) 158 | return '' 159 | endif 160 | return "\" 161 | endf 162 | 163 | fun! BackwardsSnippet() 164 | if exists('g:snipPos') | return snipMate#jumpTabStop(1) | endif 165 | 166 | if exists('g:SuperTabMappingForward') 167 | if g:SuperTabMappingBackward == "" 168 | let SuperTabKey = "\" 169 | elseif g:SuperTabMappingForward == "" 170 | let SuperTabKey = "\" 171 | endif 172 | endif 173 | if exists('SuperTabKey') 174 | call feedkeys(SuperTabKey) 175 | return '' 176 | endif 177 | return "\" 178 | endf 179 | 180 | " Check if word under cursor is snippet trigger; if it isn't, try checking if 181 | " the text after non-word characters is (e.g. check for "foo" in "bar.foo") 182 | fun s:GetSnippet(word, scope) 183 | let word = a:word | let snippet = '' 184 | while snippet == '' 185 | if exists('s:snippets["'.a:scope.'"]["'.escape(word, '\"').'"]') 186 | let snippet = s:snippets[a:scope][word] 187 | elseif exists('s:multi_snips["'.a:scope.'"]["'.escape(word, '\"').'"]') 188 | let snippet = s:ChooseSnippet(a:scope, word) 189 | if snippet == '' | break | endif 190 | else 191 | if match(word, '\W') == -1 | break | endif 192 | let word = substitute(word, '.\{-}\W', '', '') 193 | endif 194 | endw 195 | if word == '' && a:word != '.' && stridx(a:word, '.') != -1 196 | let [word, snippet] = s:GetSnippet('.', a:scope) 197 | endif 198 | return [word, snippet] 199 | endf 200 | 201 | fun s:ChooseSnippet(scope, trigger) 202 | let snippet = [] 203 | let i = 1 204 | for snip in s:multi_snips[a:scope][a:trigger] 205 | let snippet += [i.'. '.snip[0]] 206 | let i += 1 207 | endfor 208 | if i == 2 | return s:multi_snips[a:scope][a:trigger][0][1] | endif 209 | let num = inputlist(snippet) - 1 210 | return num == -1 ? '' : s:multi_snips[a:scope][a:trigger][num][1] 211 | endf 212 | 213 | fun! ShowAvailableSnips() 214 | let line = getline('.') 215 | let col = col('.') 216 | let word = matchstr(getline('.'), '\S\+\%'.col.'c') 217 | let words = [word] 218 | if stridx(word, '.') 219 | let words += split(word, '\.', 1) 220 | endif 221 | let matchlen = 0 222 | let matches = [] 223 | for scope in [bufnr('%')] + split(&ft, '\.') + ['_'] 224 | let triggers = has_key(s:snippets, scope) ? keys(s:snippets[scope]) : [] 225 | if has_key(s:multi_snips, scope) 226 | let triggers += keys(s:multi_snips[scope]) 227 | endif 228 | for trigger in triggers 229 | for word in words 230 | if word == '' 231 | let matches += [trigger] " Show all matches if word is empty 232 | elseif trigger =~ '^'.word 233 | let matches += [trigger] 234 | let len = len(word) 235 | if len > matchlen | let matchlen = len | endif 236 | endif 237 | endfor 238 | endfor 239 | endfor 240 | 241 | " This is to avoid a bug with Vim when using complete(col - matchlen, matches) 242 | " (Issue#46 on the Google Code snipMate issue tracker). 243 | call setline(line('.'), substitute(line, repeat('.', matchlen).'\%'.col.'c', '', '')) 244 | call complete(col, matches) 245 | return '' 246 | endf 247 | " vim:noet:sw=4:ts=4:ft=vim 248 | -------------------------------------------------------------------------------- /vimrc: -------------------------------------------------------------------------------- 1 | " Vim RC 2 | " 3 | " Maintainer: Łukasz Langa 4 | 5 | " Bootstrap settings: 6 | " - reset previously set environmental settings 7 | " - don't allow specific files to override settings from this file 8 | " 9 | autocmd! 10 | set nomodeline 11 | 12 | 13 | 14 | " 15 | " UI configuration 16 | " 17 | colorscheme ambv 18 | syntax on "highlight syntax with specific group for bad whitespace: 19 | highlight BadWhitespace ctermbg=red guibg=red 20 | set history=250 "number of commands to remember in the command line 21 | set wildmenu wildmode=full "show a list of possible values on Tab 22 | set showmode "show what mode you're in (Insert, Replace, Visual, etc.) 23 | set shortmess=aoO "abbreviate status line but don't truncate messages 24 | set showcmd "show combo command as you type it in the bottom right corner 25 | set ruler laststatus=2 "show rulers for buffers and the status line even if there's only 1 file 26 | set rulerformat=%30(%=\ %b\ 0x%B\ \ %l:%c\ %P%) "as the name says 27 | "set mouse=a "use the mouse wherever possible 28 | set title "change the terminal title according to the currently active buffer 29 | set number "always show line numbers unless otherwise specified 30 | "set clipboard+=unnamed "the same clipboard is used for Visual mode 31 | set ignorecase smartcase "when searching, match case only when at least one char is upper 32 | set incsearch "start searching while typing 33 | set gdefault "automatically add /g to searches; actually specifying /g now toggles the value 34 | set backspace=eol,start,indent "make backspace work between lines and with indentation 35 | set whichwrap=<,>,~,[,] "allow crossing line borders with cursors in every mode 36 | set winminheight=0 "Allow windows to get fully squashed 37 | set scrolloff=10 "start scrolling 10 lines before the end of the buffer 38 | set cursorline "highlight current line 39 | set cursorcolumn "highlight current column 40 | "set virtualedit=all "cursor can move anywhere (even beyond text boundaries) 41 | 42 | 43 | 44 | " 45 | " Default formatting and editing options 46 | " 47 | set shiftwidth=2 tabstop=2 softtabstop=2 "by default, Tab moves by 2 spaces 48 | set shiftround "tabbing and detabbing also uses shiftwidth 49 | set expandtab "use Space instead of Tab 50 | set autoindent "keep current indent state when starting a new line 51 | set matchpairs+=(:),{:},[:],<:> "join these pairs of characters; useful for highlighting 52 | "and jumping between with % 53 | set wrap textwidth=0 formatoptions=l "wrap text by default but don't insert additional 54 | "new lines on text input 55 | set hidden "don't destroy buffers that are hidden; think twice before using :q! or :qa! 56 | 57 | 58 | 59 | " 60 | " Filetype specific formatting and editing options 61 | " 62 | filetype on 63 | filetype plugin indent on 64 | 65 | function! Python_init() 66 | set shiftwidth=4 tabstop=4 softtabstop=4 "standard PEP8 Tab length 67 | set smartindent "use the keywords below to add additional indentation 68 | set cinwords=if,elif,else,for,while,try,except,finally,def,class 69 | "smartindent is OK but don't move # comments to the first column please: 70 | inoremap # X# 71 | set formatoptions=cq12 textwidth=79 "wrap lines longer than 79 characters 72 | set complete+=k~/.vim/pydiction "use auto-completion from the specified dictionary 73 | set nowrap "don't wrap source code, it's evil 74 | set noignorecase nosmartcase "avoid corrupting source code on search/replace operations 75 | "set smarttab "I don't really know what this does when sw == ts == sts 76 | "set isk+=.,( 77 | match ExtraWhitespace /\s\+\%#\@ 0 && line("'\"") <= line("$") | exe "normal g`\"" | endif "return to the last edited line in opened files: 109 | autocmd BufReadCmd *.egg,*.odp,*.ods,*.odt,*.jar,*.xmap,*.xmind,*.xpi call zip#Browse(expand("")) 110 | autocmd InsertLeave * redraw! 111 | 112 | " 113 | " Folding; closed by default because it caused confusion in the long run. 114 | " 115 | if has('folding') 116 | set foldlevelstart=999 foldopen=all "foldclose=all 117 | nnoremap @=(foldlevel('.')?'za':'l') 118 | vnoremap zf 119 | endif 120 | 121 | 122 | 123 | " 124 | " Keyboard shortcuts 125 | " 126 | 127 | "Tab/Shift-Tab controls indentation also in Visual and Insert mode 128 | vnoremap > 129 | vnoremap 130 | vmap 131 | vmap 132 | inoremap 133 | inoremap 134 | 135 | "Y works like D does 136 | noremap Y y$ 137 | 138 | nnoremap tt :NERDTreeToggle 139 | 140 | "F1 toggles highlighting search results 141 | nnoremap \th :set invhls hls? 142 | nmap \th 143 | imap \th 144 | 145 | "F2 toggles showing invisible characters 146 | nnoremap \tl :set invlist list? 147 | nmap \tl 148 | 149 | "F3 toggles autowrapping on Insert 150 | nnoremap \tf :if &fo =~ 't' set fo-=t else set fo+=t 151 | \ endif set fo? 152 | nmap \tf 153 | imap \tf 154 | 155 | "F4 handles paste toggling; works perfectly in Normal mode, Insert mode requires 156 | "two keystrokes to leave paste mode entirely 157 | nmap :call Paste_toggle(0) 158 | imap :call Paste_toggle(1) 159 | set pastetoggle= 160 | function Paste_toggle(insert_mode) 161 | """ toggling between paste mode and normal mode; includes removing 162 | """ mouse support and numbering (for terminal cut&paste purposes) 163 | if &paste || (a:insert_mode != 0 && !&number) 164 | set nopaste number cursorline mouse=a 165 | else 166 | set paste nonumber nocursorline mouse= 167 | endif 168 | endfunction 169 | command PasteToggle :call Paste_toggle(0) 170 | 171 | "F5 toggles taglist 172 | nnoremap :TlistToggle 173 | inoremap :TlistToggle 174 | 175 | "F6 toggles between windows 176 | nnoremap w 177 | nnoremap W 178 | 179 | "F9 forces file reload in CP-850 charset 180 | map :call SwitchToCP850() 181 | func! SwitchToCP850() 182 | e! ++enc=cp850 183 | endfunc 184 | 185 | "F10 forces file reload in CP-1250 charset 186 | map :call SwitchToCP1250() 187 | func! SwitchToCP1250() 188 | e! ++enc=cp1250 189 | endfunc 190 | 191 | "F11 forces file reload in ISO-8859-2 charset 192 | map :call SwitchToISO() 193 | func! SwitchToISO() 194 | e! ++enc=iso-8859-2 195 | endfunc 196 | 197 | "F12 forces file reload in UTF-8 charset 198 | map :call SwitchToUTF8() 199 | func! SwitchToUTF8() 200 | e! ++enc=utf-8 201 | endfunc 202 | 203 | nmap ,-1 yyp$r=yykP 204 | nmap ,-2 yyp$r- 205 | nmap ,-3 yyp$r~ 206 | 207 | "Ctrl+q as Insert/Normal mode toggle 208 | "ignoremap ii 209 | 210 | ":W command to "sudo & write" if you forget to sudo first 211 | "cmap W w !sudo tee % >/dev/null 212 | "Turned off because mapped each "W" typed. Gotta come up with something better. 213 | 214 | " 215 | " Specific plug-in configuration 216 | " 217 | let python_highlight_indent_errors=1 218 | let python_highlight_space_errors=1 219 | let python_highlight_string_formatting=1 220 | let python_highlight_string_format=1 221 | let python_highlight_string_templates=1 222 | let python_highlight_doctests=1 223 | let python_slow_sync=1 224 | 225 | let NERDTreeIgnore=['\~$', '^\~', '\.swp$', '\$$', 226 | \ '\.pyc$', '\.pyo$', '\.pyd$', 227 | \ '\.class$', '\.bak$', '\.bin$', 228 | \ '\.jpg$', '\.gif$', '\.png$', '\.bmp$', 229 | \ '\.mo$'] 230 | 231 | let Tlist_Use_Right_Window=1 232 | "let Tlist_Use_Horiz_Window=1 233 | let Tlist_Compact_Format=1 234 | 235 | let snips_author='Tomasz Zen Napierała' 236 | 237 | let bufExplorerFindActive=0 238 | let bufExplorerShowRelativePath=1 239 | "let bufExplorerSortBy="fullpath" 240 | -------------------------------------------------------------------------------- /vim/doc/chef.txt: -------------------------------------------------------------------------------- 1 | *chef.txt* plugin for opscode's chef. find attribute, open recipes etc. 2 | 3 | ______ __ ____ 4 | / ____/ / /_ ___ / __/ 5 | / / / __ ` / _ ` / /_ 6 | / /___ / / / / / __/ / __/ 7 | `____/ /_/ /_/ `___/ /_/ 8 | - easy jump to target!! 9 | 10 | Version: 1.0 11 | Author : t9md 12 | ============================================================================== 13 | 14 | CONTENTS *chef-contents* 15 | 16 | Introduction |chef-introduction| 17 | Commands |chef-commands| 18 | Usage |chef-usage| 19 | Finder |chef-finder| 20 | Hook |chef-hook| 21 | Configuration |chef-config| 22 | Variables |chef-variables| 23 | Notes |chef-notes| 24 | ToDo |chef-todo| 25 | Changelog |chef-changelog| 26 | 27 | ============================================================================== 28 | INTRODUCTION *chef-introduction* 29 | 30 | chef.vim is plugin which make it easy for 31 | 32 | * jump between `attributes` and `recipes` 33 | * open `recipes` by extract filename from `include_recipe` 34 | * open `templates` and `files` 35 | * jump to `attributes` file 36 | 37 | Latest Version: 38 | https://github.com/t9md/vim-chef 39 | 40 | 41 | ============================================================================== 42 | COMMANDS *chef-commands* 43 | 44 | * [Deprecated] ChefDoWhatIMean 45 | * [Deprecated] ChefDoWhatIMeanSplit 46 | * [Deprecated] ChefDoWhatIMeanVsplit 47 | 48 | :ChefFindAny *:ChefFindAny* 49 | :ChefFindAnySplit *:ChefFindAnySplit* 50 | :ChefFindAnyVsplit *:ChefFindAnyVsplit* 51 | 52 | Find target in appropriate order. 53 | You can customize order and targets by |configuration|. 54 | 55 | :ChefFindAttribute *:ChefFindAttribute* 56 | :ChefFindAttributeSplit *:ChefFindAttributeSplit* 57 | :ChefFindAttributeVsplit *:ChefFindAttributeVsplit* 58 | 59 | :ChefFindRecipe *:ChefFindRecipe* 60 | :ChefFindRecipeSplit *:ChefFindRecipeSplit* 61 | :ChefFindRecipeVsplit *:ChefFindRecipeVsplit* 62 | 63 | :ChefFindDefinition *:ChefFindDefinition* 64 | :ChefFindDefinitionSplit *:ChefFindDefinitionSplit* 65 | :ChefFindDefinitionVsplit *:ChefFindDefinitionVsplit* 66 | 67 | :ChefFindLWRP *:ChefFindLWRP* 68 | :ChefFindLWRPSplit *:ChefFindLWRPSplit* 69 | :ChefFindLWRPVSplit *:ChefFindLWRPVSplit* 70 | 71 | :ChefFindSource *:ChefFindSource* 72 | :ChefFindSourceSplit *:ChefFindSourceSplit* 73 | :ChefFindSourceVsplit *:ChefFindSourceVsplit* 74 | 75 | :ChefFindRelated *:ChefFindRelated* 76 | :ChefFindRelatedSplit *:ChefFindRelatedSplit* 77 | :ChefFindRelatedVsplit *:ChefFindRelatedVsplit* 78 | 79 | ============================================================================== 80 | USAGE *chef-usage* 81 | 82 | in following examples, assume~ 83 | 84 | * `` is mapped to |:ChefFindAny| 85 | * `^` indicate cursor position 86 | 87 | ## jump to node's attribute~ 88 | > 89 | node[:apache2][:address] = node[:nova][:my_ip] 90 | ^^^^^^^^^^^^^^^^^^^^^^^ 91 | < 92 | `` try to find that attribute appropriate order. 93 | 94 | ## open templates~ 95 | open in `recipes/default.rb' then position cursor to 96 | > 97 | source "grants.sql.erb" 98 | ^^^^^^^^^^^^^^ 99 | < 100 | ``, try to open file under `templates/default/grants.sql.erb` 101 | 102 | ## open files~ 103 | > 104 | source "grants.sql" 105 | ^^^^^^^^^^^^^^ 106 | < 107 | `` try to open file under `files/default/grants.sql` 108 | 109 | ## jump between attributes and recipes~ 110 | 111 | in buffer for file under `recipes/*` or `attributes/*` 112 | Press `` to jump *related* files. 113 | For examples, jump between `recipes/default.rb` and `attributes/default.rb` 114 | Jump between `resources/hoge.rb` and `providers/hoge.rb` is also supported. 115 | 116 | ## open recipe files~ 117 | > 118 | include_recipe "nova::mysql" 119 | ^^^^^^^^^^ 120 | < 121 | `` try to open `cookbooks/nova/recipes/mysql.rb` 122 | 123 | ## jump to definition 124 | 125 | > 126 | apache_module "authz_groupfile" 127 | ^^^^^^^^^^^^^ 128 | < 129 | 130 | apache_module is definition. so `` would find and jump to position where 131 | defined. 132 | When apache_module is LWRP, chef.vim can jump to `apache/providers/module.rb` 133 | 134 | ============================================================================== 135 | FINDEER *chef-finder* 136 | 137 | Customize Finding target and finding order~ 138 | 139 | You can customize what you want to find in `ChefFindAny` command. 140 | Following are default finder list. 141 | `ChefFindAny` try to find target in this order. 142 | > 143 | [ "Attribute", "Source", "Recipe", "Definition", "LWRP", "Related" ] 144 | < 145 | If you want to exclude `Related` finder from target, set following in your `.vimrc` 146 | > 147 | let g:chef = {} 148 | let g:chef.any_finders = [ "Attribute", "Source", "Recipe", "Definition", "LWRP" ] 149 | < 150 | It's OK to remove Finder from list, but I don't recommend changing *order*. 151 | 152 | ============================================================================== 153 | HOOK *chef-hook* 154 | 155 | Hook after finding success [experimental]~ 156 | 157 | After each finder success finding(return 1) 158 | Hook function is called if hook is defined. 159 | Hook take one argument 'env'. 160 | See "Configuration Example". 161 | 162 | ============================================================================== 163 | CONFIGURATION *chef-config* 164 | 165 | Requirement~ 166 | > 167 | au BufNewFile,BufRead */*cookbooks/* call s:SetupChef() 168 | < 169 | 170 | Basic~ 171 | > 172 | function! s:SetupChef() 173 | " Mouse: 174 | " Left mouse click to GO! 175 | nnoremap <2-LeftMouse> :ChefFindAny 176 | " Right mouse click to Back! 177 | nnoremap 178 | 179 | " Keyboard: 180 | nnoremap :ChefFindAny 181 | nnoremap :ChefFindAnySplit 182 | endfunction 183 | < 184 | 185 | Advanced~ 186 | > 187 | function! ChefNerdTreeFind(env) 188 | try 189 | :NERDTreeFind 190 | let scrolloff_orig = &scrolloff 191 | let &scrolloff = 15 192 | normal! jk 193 | wincmd p 194 | finally 195 | let &scrolloff = scrolloff_orig 196 | endtry 197 | endfunction 198 | 199 | let g:chef = {} 200 | let g:chef.hooks = ['ChefNerdTreeFind'] 201 | 202 | " remove 'Related' from default, I want to find 'Related' explicitly. 203 | let g:chef.any_finders = ['Attribute', 'Source', 'Recipe', 'Definition'] 204 | 205 | function! s:SetupChef() 206 | " Mouse: 207 | " Left mouse click to GO! 208 | nnoremap <2-LeftMouse> :ChefFindAny 209 | " Right mouse click to Back! 210 | nnoremap 211 | 212 | " Keyboard: 213 | nnoremap :ChefFindAny 214 | nnoremap :ChefFindAnySplit 215 | nnoremap :ChefFindRelated 216 | endfunction 217 | < 218 | 219 | ============================================================================== 220 | VARIABLES *chef-variables* 221 | 222 | g:chef = 223 | This dictionary is used as placeholder for other configuration. 224 | 225 | Default~ 226 | {} 227 | 228 | g:chef.any_finders = 229 | Finders |List| which is used for |ChefFindAny|. 230 | 231 | Default~ 232 | [ "Attribute", "Source", "Recipe", "Definition", "Related" ] 233 | 234 | 235 | g:chef.hooks = 236 | List of|Function|names, which is called when finding was successfully 237 | completed. 238 | 239 | Default~ 240 | [] 241 | 242 | ============================================================================== 243 | NOTES *chef-notes* 244 | 245 | chef.vim doesn't provide `DEFAULT_KEY_MAPPING` like many other plugins do. 246 | So check |chef-config| section and set keymap you like. 247 | 248 | chef.vim asume directory name end with '*cookbooks' as cookbooks root 249 | directory. 250 | > 251 | ex) site_cookbooks, cookbooks 252 | < 253 | ============================================================================== 254 | TODO *chef-todo* 255 | 256 | ============================================================================== 257 | CHANGELOG *chef-changelog* 258 | 2011-08-13: v1.0 259 | - new finder LWRP. 260 | - jump between resources and providers are introduced. 261 | 2011-08-11: 262 | - improve attribute finder 263 | 2011-06-15: v0.9 264 | - now able to find attribute whichever a[:attr] or a['attr'] 265 | - bugfix for search order of attribute 266 | - search all attribute files under /attribute/ directory. 267 | 2011-06-14: v0.8 268 | - Deprecated `ChefDoWhatIMean` for naming consistency. 269 | - Now use `ChefFindAny` for this purpose 270 | - Provide new command for each Finder. 271 | - Now order and targets to for `ChefFindAny` is customizable. 272 | - Support definition finding. 273 | - Improve debug capability and code consistency. 274 | - Suport hook function. 275 | - Improve finders information with color highlighted messages. 276 | 2011-06-12: v0.6 277 | - Make more fuzzy for attribute finding. 278 | 2011-06-12: v0.5 279 | - First release 280 | ============================================================================== 281 | vim:tw=78:ts=8:ft=help:norl: 282 | -------------------------------------------------------------------------------- /vim/ftplugin/python/jpythonfold.vim: -------------------------------------------------------------------------------- 1 | " Fold routines for python code, version 3.2 2 | " Source: http://www.vim.org/scripts/script.php?script_id=2527 3 | " Last Change: 2009 Feb 25 4 | " Author: Jurjen Bos 5 | " Bug fixes and helpful comments: Grissiom, David Froger, Andrew McNabb 6 | 7 | " Principles: 8 | " - a def/class starts a fold 9 | " a line with indent less than the previous def/class ends a fold 10 | " empty lines and comment lines are linked to the previous fold 11 | " comment lines outside a def/class are never folded 12 | " other lines outside a def/class are folded together as a group 13 | " for algorithm, see bottom of script 14 | 15 | " - optionally, you can get empty lines between folds, see (***) 16 | " - another option is to ignore non-python files see (**) 17 | " - you can also modify the def/class check, 18 | " allowing for multiline def and class definitions see (*) 19 | 20 | " Note for vim 7 users: 21 | " Vim 6 line numbers always take 8 columns, while vim 7 has a numberwidth variable 22 | " you can change the 8 below to &numberwidth if you have vim 7, 23 | " this is only really useful when you plan to use more than 8 columns (i.e. never) 24 | 25 | " Note for masochists trying to read this: 26 | " I wanted to keep the functions short, so I replaced occurences of 27 | " if condition 28 | " statement 29 | " by 30 | " if condition | statement 31 | " wherever I found that useful 32 | 33 | " (*) 34 | " class definitions are supposed to ontain a colon on the same line. 35 | " function definitions are *not* required to have a colon, to allow for multiline defs. 36 | " I you disagree, use instead of the pattern '^\s*\(class\s.*:\|def\s\)' 37 | " to enforce : for defs: '^\s*\(class\|def\)\s.*:' 38 | " you'll have to do this in two places. 39 | let s:defpat = '^\s*\(@\|class\s.*:\|def\s\)' 40 | 41 | " (**) Ignore non-python files 42 | " Commented out because some python files are not recognized by Vim 43 | "if &filetype != 'python' 44 | " finish 45 | "endif 46 | 47 | setlocal foldmethod=expr 48 | setlocal foldexpr=GetPythonFold(v:lnum) 49 | setlocal foldtext=PythonFoldText() 50 | 51 | function! PythonFoldText() 52 | let fs = v:foldstart 53 | while getline(fs) =~ '^\s*@' | let fs = nextnonblank(fs + 1) 54 | endwhile 55 | let line = getline(fs) 56 | let nnum = nextnonblank(fs + 1) 57 | let nextline = getline(nnum) 58 | "get the document string: next line is ''' or """ 59 | if nextline =~ "^\\s\\+[\"']\\{3}\\s*$" 60 | let line = line . " " . matchstr(getline(nextnonblank(nnum + 1)), '^\s*\zs.*\ze$') 61 | "next line starts with qoutes, and has text 62 | elseif nextline =~ "^\\s\\+[\"']\\{1,3}" 63 | let line = line." ".matchstr(nextline, "^\\s\\+[\"']\\{1,3}\\zs.\\{-}\\ze['\"]\\{0,3}$") 64 | elseif nextline =~ '^\s\+pass\s*$' 65 | let line = line . ' pass' 66 | endif 67 | "compute the width of the visible part of the window (see Note above) 68 | let w = winwidth(0) - &foldcolumn - (&number ? 8 : 0) 69 | let size = 1 + v:foldend - v:foldstart 70 | "compute expansion string 71 | let spcs = '................' 72 | while strlen(spcs) < w | let spcs = spcs . spcs 73 | endwhile 74 | "expand tabs (mail me if you have tabstop>10) 75 | let onetab = strpart(' ', 0, &tabstop) 76 | let line = substitute(line, '\t', onetab, 'g') 77 | return strpart(line.spcs, 0, w-strlen(size)-7).'.'.size.' lines' 78 | endfunction 79 | 80 | function! GetBlockIndent(lnum) 81 | " Auxiliary function; determines the indent level of the surrounding def/class 82 | " "global" lines are level 0, first def &shiftwidth, and so on 83 | " scan backwards for class/def that is shallower or equal 84 | let ind = 100 85 | let p = a:lnum+1 86 | while indent(p) >= 0 87 | let p = p - 1 88 | " skip empty and comment lines 89 | if getline(p) =~ '^$\|^\s*#' | continue 90 | " zero-level regular line 91 | elseif indent(p) == 0 | return 0 92 | " skip deeper or equal lines 93 | elseif indent(p) >= ind || getline(p) =~ '^$\|^\s*#' | continue 94 | " indent is strictly less at this point: check for def/class 95 | elseif getline(p) =~ s:defpat && getline(p) !~ '^\s*@' 96 | " level is one more than this def/class 97 | return indent(p) + &shiftwidth 98 | endif 99 | " shallower line that is neither class nor def: continue search at new level 100 | let ind = indent(p) 101 | endwhile 102 | "beginning of file 103 | return 0 104 | endfunction 105 | 106 | " Clever debug code, use as: call PrintIfCount(n,"Line: ".a:lnum.", value: ".x) 107 | let s:counter=0 108 | function! PrintIfCount(n,t) 109 | "Print text the nth time this function is called 110 | let s:counter = s:counter+1 111 | if s:counter==a:n | echo a:t 112 | endif 113 | endfunction 114 | 115 | function! GetPythonFold(lnum) 116 | " Determine folding level in Python source (see "higher foldlevel theory" below) 117 | let line = getline(a:lnum) 118 | let ind = indent(a:lnum) 119 | " Case D***: class and def start a fold 120 | " If previous line is @, it is not the first 121 | if line =~ s:defpat && getline(prevnonblank(a:lnum-1)) !~ '^\s*@' 122 | " let's see if this range of 0 or more @'s end in a class/def 123 | let n = a:lnum 124 | while getline(n) =~ '^\s*@' | let n = nextnonblank(n + 1) 125 | endwhile 126 | " yes, we have a match: this is the first of a real def/class with decorators 127 | if getline(n) =~ s:defpat 128 | return ">".(ind/&shiftwidth+1) 129 | endif 130 | " Case E***: empty lines fold with previous 131 | " (***) change '=' to -1 if you want empty lines/comment out of a fold 132 | elseif line == '' | return '=' 133 | endif 134 | " now we need the indent from previous 135 | let p = prevnonblank(a:lnum-1) 136 | while p>0 && getline(p) =~ '^\s*#' | let p = prevnonblank(p-1) 137 | endwhile 138 | let pind = indent(p) 139 | " If previous was definition: count as one level deeper 140 | if getline(p) =~ s:defpat && getline(prevnonblank(a:lnum - 1)) !~ '^\s*@' 141 | let pind = pind + &shiftwidth 142 | " if begin of file: take zero 143 | elseif p==0 | let pind = 0 144 | endif 145 | " Case S*=* and C*=*: indent equal 146 | if ind>0 && ind==pind | return '=' 147 | " Case S*>* and C*>*: indent increase 148 | elseif ind>pind | return '=' 149 | " All cases with 0 indent 150 | elseif ind==0 151 | " Case C*=0*: separate global code blocks 152 | if pind==0 && line =~ '^#' | return 0 153 | " Case S*<0* and S*=0*: global code 154 | elseif line !~'^#' 155 | " Case S*<0*: new global statement if/while/for/try/with 156 | if 01' 157 | " Case S*=0*, after level 0 comment 158 | elseif 0==pind && getline(prevnonblank(a:lnum-1)) =~ '^\s*#' | return '>1' 159 | " Case S*=0*, other, stay 1 160 | else | return '=' 161 | endif 162 | endif 163 | " Case C*<0= and C*<0<: compute next indent 164 | let n = nextnonblank(a:lnum+1) 165 | while n>0 && getline(n) =~'^\s*#' | let n = nextnonblank(n+1) 166 | endwhile 167 | " Case C*<0=: split definitions 168 | if indent(n)==0 | return 0 169 | " Case C*<0<: shallow comment 170 | else | return -1 171 | end 172 | endif 173 | " now we really need to compute the actual fold indent 174 | " do the hard computation 175 | let blockindent = GetBlockIndent(a:lnum) 176 | " Case SG<* and CG<*: global code, level 1 177 | if blockindent==0 | return 1 178 | endif 179 | " now we need the indent from next 180 | let n = nextnonblank(a:lnum+1) 181 | while n>0 && getline(n) =~'^\s*#' | let n = nextnonblank(n+1) 182 | endwhile 183 | let nind = indent(n) 184 | " Case CR<= and CR<> 185 | "if line !~ '^\s*#' | call PrintIfCount(4,"Line: ".a:lnum.", blockindent: ".blockindent.", n: ".n.", nind: ".nind.", p: ".p.", pind: ".pind) 186 | endif 187 | if line =~ '^\s*#' && ind>=nind | return -1 188 | " Case CR<<: return next indent 189 | elseif line =~ '^\s*#' | return nind / &shiftwidth 190 | " Case SR<*: return actual indent 191 | else | return blockindent / &shiftwidth 192 | endif 193 | endfunction 194 | 195 | " higher foldlevel theory 196 | " There are five kinds of statements: S (code), D (def/class), E (empty), C (comment) 197 | 198 | " Note that a decorator statement (beginning with @) counts as definition, 199 | " but that of a sequence of @,@,@,def only the first one counts 200 | " This means that a definiion only counts if not preceded by a decorator 201 | 202 | " There are two kinds of folds: R (regular), G (global statements) 203 | 204 | " There are five indent situations with respect to the previous non-emtpy non-comment line: 205 | " > (indent), < (dedent), = (same); < and = combine with 0 (indent is zero) 206 | " Note: if the previous line is class/def, its indent is interpreted as one higher 207 | 208 | " There are three indent situations with respect to the next (non-E non-C) line: 209 | " > (dedent), < (indent), = (same) 210 | 211 | " Situations (in order of the script): 212 | " stat fold prev next 213 | " SDEC RG ><=00 ><= 214 | " D * * * begin fold level if previous is not @: '>'.ind/&sw+1 215 | " E * * * keep with previous: '=' 216 | " S * = * stays the same: '=' 217 | " C * = * combine with previous: '=' 218 | " S * > * stays the same: '=' 219 | " C * > * combine with previous: '=' 220 | " C * =0 * separate blocks: 0 221 | " S * <0 * becomes new level 1: >1 (except except/else: 1) 222 | " S * =0 * stays 1: '=' (after level 0 comment: '>1') 223 | " C * <0 = split definitions: 0 224 | " C * <0 < shallow comment: -1 225 | " C * <0 > [never occurs] 226 | " S G < * global, not the first: 1 227 | " C G < * indent isn't 0: 1 228 | " C R < = foldlevel as computed for next line: -1 229 | " C R < > foldlevel as computed for next line: -1 230 | " S R < * compute foldlevel the hard way: use function 231 | " C R < < foldlevel as computed for this line: use function 232 | -------------------------------------------------------------------------------- /vim/doc/surround.txt: -------------------------------------------------------------------------------- 1 | *surround.txt* Plugin for deleting, changing, and adding "surroundings" 2 | 3 | Author: Tim Pope *surround-author* 4 | License: Same terms as Vim itself (see |license|) 5 | 6 | This plugin is only available if 'compatible' is not set. 7 | 8 | INTRODUCTION *surround* 9 | 10 | This plugin is a tool for dealing with pairs of "surroundings." Examples 11 | of surroundings include parentheses, quotes, and HTML tags. They are 12 | closely related to what Vim refers to as |text-objects|. Provided 13 | are mappings to allow for removing, changing, and adding surroundings. 14 | 15 | Details follow on the exact semantics, but first, consider the following 16 | examples. An asterisk (*) is used to denote the cursor position. 17 | 18 | Old text Command New text ~ 19 | "Hello *world!" ds" Hello world! 20 | [123+4*56]/2 cs]) (123+456)/2 21 | "Look ma, I'm *HTML!" cs" Look ma, I'm HTML! 22 | if *x>3 { ysW( if ( x>3 ) { 23 | my $str = *whee!; vlllls' my $str = 'whee!'; 24 | 25 | While a few features of this plugin will work in older versions of Vim, 26 | Vim 7 is recommended for full functionality. 27 | 28 | MAPPINGS *surround-mappings* 29 | 30 | Delete surroundings is *ds* . The next character given determines the target 31 | to delete. The exact nature of the target are explained in |surround-targets| 32 | but essentially it is the last character of a |text-object|. This mapping 33 | deletes the difference between the "inner" object and "an" object. This is 34 | easiest to understand with some examples: 35 | 36 | Old text Command New text ~ 37 | "Hello *world!" ds" Hello world! 38 | (123+4*56)/2 ds) 123+456/2 39 |
Yo!*
dst Yo! 40 | 41 | Change surroundings is *cs* . It takes two arguments, a target like with 42 | |ds|, and a replacement. Details about the second argument can be found 43 | below in |surround-replacements|. Once again, examples are in order. 44 | 45 | Old text Command New text ~ 46 | "Hello *world!" cs"' 'Hello world!' 47 | "Hello *world!" cs" Hello world! 48 | (123+4*56)/2 cs)] [123+456]/2 49 | (123+4*56)/2 cs)[ [ 123+456 ]/2 50 |
Yo!*
cst

Yo!

51 | 52 | *ys* takes an valid Vim motion or text object as the first object, and wraps 53 | it using the second argument as with |cs|. (Unfortunately there's no good 54 | mnemonic for "ys".) 55 | 56 | Old text Command New text ~ 57 | Hello w*orld! ysiw) Hello (world)! 58 | 59 | As a special case, *yss* operates on the current line, ignoring leading 60 | whitespace. 61 | 62 | Old text Command New text ~ 63 | Hello w*orld! yssB {Hello world!} 64 | 65 | There is also *yS* and *ySS* which indent the surrounded text and place it 66 | on a line of its own. 67 | 68 | In visual mode, a simple "s" with an argument wraps the selection. This is 69 | referred to as the *vs* mapping, although ordinarily there will be 70 | additional keystrokes between the v and s. In linewise visual mode, the 71 | surroundings are placed on separate lines. In blockwise visual mode, each 72 | line is surrounded. 73 | 74 | An "S" in visual mode (*vS*) behaves similarly but always places the 75 | surroundings on separate lines. Additionally, the surrounded text is 76 | indented. In blockwise visual mode, using "S" instead of "s" instead skips 77 | trailing whitespace. 78 | 79 | Note that "s" and "S" already have valid meaning in visual mode, but it is 80 | identical to "c". If you have muscle memory for "s" and would like to use a 81 | different key, add your own mapping and the existing one will be disabled. 82 | > 83 | vmap s Vsurround 84 | vmap S VSurround 85 | < 86 | *i_CTRL-G_s* *i_CTRL-G_S* 87 | Finally, there is an experimental insert mode mapping on s and . 88 | Beware that the latter won't work on terminals with flow control (if you 89 | accidentally freeze your terminal, use to unfreeze it). The mapping 90 | inserts the specified surroundings and puts the cursor between them. If, 91 | immediately after the mapping and before the replacement, a second or 92 | carriage return is pressed, the prefix, cursor, and suffix will be placed on 93 | three separate lines. S (not s) also exhibits this behavior. 94 | 95 | TARGETS *surround-targets* 96 | 97 | The |ds| and |cs| commands both take a target as their first argument. The 98 | possible targets are based closely on the |text-objects| provided by Vim. 99 | In order for a target to work, the corresponding text object must be 100 | supported in the version of Vim used (Vim 7 adds several text objects, and 101 | thus is highly recommended). All targets are currently just one character. 102 | 103 | Eight punctuation marks, (, ), {, }, [, ], <, and >, represent themselves 104 | and their counterpart. If the opening mark is used, contained whitespace is 105 | also trimmed. The targets b, B, r, and a are aliases for ), }, ], and > 106 | (the first two mirror Vim; the second two are completely arbitrary and 107 | subject to change). 108 | 109 | Three quote marks, ', ", `, represent themselves, in pairs. They are only 110 | searched for on the current line. 111 | 112 | A t is a pair of HTML or XML tags. See |tag-blocks| for details. Remember 113 | that you can specify a numerical argument if you want to get to a tag other 114 | than the innermost one. 115 | 116 | The letters w, W, and s correspond to a |word|, a |WORD|, and a |sentence|, 117 | respectively. These are special in that they have nothing to delete, and 118 | used with |ds| they are a no-op. With |cs|, one could consider them a 119 | slight shortcut for ysi (cswb == ysiwb, more or less). 120 | 121 | A p represents a |paragraph|. This behaves similarly to w, W, and s above; 122 | however, newlines are sometimes added and/or removed. 123 | 124 | REPLACEMENTS *surround-replacements* 125 | 126 | A replacement argument is a single character, and is required by |cs|, |ys|, 127 | and |vs|. Undefined replacement characters (with the exception of alphabetic 128 | characters) default to placing themselves at the beginning and end of the 129 | destination, which can be useful for characters like / and |. 130 | 131 | If either ), }, ], or > is used, the text is wrapped in the appropriate pair 132 | of characters. Similar behavior can be found with (, {, and [ (but not <), 133 | which append an additional space to the inside. Like with the targets above, 134 | b, B, r, and a are aliases for ), }, ], and >. To fulfill the common need for 135 | code blocks in C-style languages, (which is really ) adds braces on 136 | lines separate from the content. 137 | 138 | If t or < is used, Vim prompts for an HTML/XML tag to insert. You may specify 139 | attributes here and they will be stripped from the closing tag. End your 140 | input by pressing or >. If is used, the tags will appear on lines 141 | by themselves. 142 | 143 | A deprecated replacement of a LaTeX environment is provided on \ and l. The 144 | name of the environment and any arguments will be input from a prompt. This 145 | will be removed once a more fully functional customization system is 146 | implemented. The following shows the resulting environment from 147 | csp\tabular}{lc 148 | > 149 | \begin{tabular}{lc} 150 | \end{tabular} 151 | < 152 | CUSTOMIZING *surround-customizing* 153 | 154 | The following adds a potential replacement on "-" (ASCII 45) in PHP files. 155 | (To determine the ASCII code to use, :echo char2nr("-")). The carriage 156 | return will be replaced by the original text. 157 | > 158 | autocmd FileType php let b:surround_45 = "" 159 | < 160 | This can be used in a PHP file as in the following example. 161 | 162 | Old text Command New text ~ 163 | print "Hello *world!" yss- 164 | 165 | Additionally, one can use a global variable for globally available 166 | replacements. 167 | > 168 | let g:surround_45 = "<% \r %>" 169 | let g:surround_61 = "<%= \r %>" 170 | < 171 | Advanced, experimental, and subject to change: One can also prompt for 172 | replacement text. The syntax for this is to surround the replacement in pairs 173 | of low numbered control characters. If this sounds confusing, that's because 174 | it is (but it makes the parsing easy). Consider the following example for a 175 | LaTeX environment on the "l" replacement. 176 | > 177 | let g:surround_108 = "\\begin{\1environment: \1}\r\\end{\1\1}" 178 | < 179 | When this replacement is used, the user is prompted with an "environment: " 180 | prompt for input. This input is inserted between each set of \1's. 181 | Additional inputs up to \7 can be used. 182 | 183 | Furthermore, one can specify a regular expression substitution to apply. 184 | > 185 | let g:surround_108 = "\\begin{\1environment: \1}\r\\end{\1\r}.*\r\1}" 186 | < 187 | This will remove anything after the first } in the input when the text is 188 | placed within the \end{} slot. The first \r marks where the pattern begins, 189 | and the second where the replacement text begins. 190 | 191 | Here's a second example for creating an HTML
. The substitution cleverly 192 | prompts for an id, but only adds id="" if it is non-blank. You may have to 193 | read this one a few times slowly before you understand it. 194 | > 195 | let g:surround_{char2nr("d")} = "\r
" 196 | < 197 | Inputting text replacements is a proof of concept at this point. The ugly, 198 | unintuitive interface and the brevity of the documentation reflect this. 199 | 200 | Finally, It is possible to always append a string to surroundings in insert 201 | mode (and only insert mode). This is useful with certain plugins and mappings 202 | that allow you to jump to such markings. 203 | > 204 | let g:surround_insert_tail = "<++>" 205 | < 206 | ISSUES *surround-issues* 207 | 208 | Vim could potentially get confused when deleting/changing occurs at the very 209 | end of the line. Please report any repeatable instances of this. 210 | 211 | Do we need to use |inputsave()|/|inputrestore()| with the tag replacement? 212 | 213 | Indenting is handled haphazardly. Need to decide the most appropriate 214 | behavior and implement it. Right now one can do :let b:surround_indent = 1 215 | (or the global equivalent) to enable automatic re-indenting by Vim via |=|; 216 | should this be the default? 217 | 218 | vim:tw=78:ts=8:ft=help:norl: 219 | -------------------------------------------------------------------------------- /vim/snippets/ruby.snippets: -------------------------------------------------------------------------------- 1 | # #!/usr/bin/ruby 2 | snippet #! 3 | #!/usr/bin/ruby 4 | 5 | # New Block 6 | snippet =b 7 | =begin rdoc 8 | ${1} 9 | =end 10 | snippet y 11 | :yields: ${1:arguments} 12 | snippet rb 13 | #!/usr/bin/env ruby -wKU 14 | 15 | snippet req 16 | require "${1}"${2} 17 | snippet # 18 | # => 19 | snippet end 20 | __END__ 21 | snippet case 22 | case ${1:object} 23 | when ${2:condition} 24 | ${3} 25 | end 26 | snippet when 27 | when ${1:condition} 28 | ${2} 29 | snippet def 30 | def ${1:method_name} 31 | ${2} 32 | end 33 | snippet deft 34 | def test_${1:case_name} 35 | ${2} 36 | end 37 | snippet if 38 | if ${1:condition} 39 | ${2} 40 | end 41 | snippet ife 42 | if ${1:condition} 43 | ${2} 44 | else 45 | ${3} 46 | end 47 | snippet elsif 48 | elsif ${1:condition} 49 | ${2} 50 | snippet unless 51 | unless ${1:condition} 52 | ${2} 53 | end 54 | snippet while 55 | while ${1:condition} 56 | ${2} 57 | end 58 | snippet until 59 | until ${1:condition} 60 | ${2} 61 | end 62 | snippet cla class .. end 63 | class ${1:`substitute(Filename(), '^.', '\u&', '')`} 64 | ${2} 65 | end 66 | snippet cla class .. initialize .. end 67 | class ${1:`substitute(Filename(), '^.', '\u&', '')`} 68 | def initialize(${2:args}) 69 | ${3} 70 | end 71 | 72 | 73 | end 74 | snippet cla class .. < ParentClass .. initialize .. end 75 | class ${1:`substitute(Filename(), '^.', '\u&', '')`} < ${2:ParentClass} 76 | def initialize(${3:args}) 77 | ${4} 78 | end 79 | 80 | 81 | end 82 | snippet cla ClassName = Struct .. do .. end 83 | ${1:`substitute(Filename(), '^.', '\u&', '')`} = Struct.new(:${2:attr_names}) do 84 | def ${3:method_name} 85 | ${4} 86 | end 87 | 88 | 89 | end 90 | snippet cla class BlankSlate .. initialize .. end 91 | class ${1:BlankSlate} 92 | instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ } 93 | snippet cla class << self .. end 94 | class << ${1:self} 95 | ${2} 96 | end 97 | # class .. < DelegateClass .. initialize .. end 98 | snippet cla- 99 | class ${1:`substitute(Filename(), '^.', '\u&', '')`} < DelegateClass(${2:ParentClass}) 100 | def initialize(${3:args}) 101 | super(${4:del_obj}) 102 | 103 | ${5} 104 | end 105 | 106 | 107 | end 108 | snippet mod module .. end 109 | module ${1:`substitute(Filename(), '^.', '\u&', '')`} 110 | ${2} 111 | end 112 | snippet mod module .. module_function .. end 113 | module ${1:`substitute(Filename(), '^.', '\u&', '')`} 114 | module_function 115 | 116 | ${2} 117 | end 118 | snippet mod module .. ClassMethods .. end 119 | module ${1:`substitute(Filename(), '^.', '\u&', '')`} 120 | module ClassMethods 121 | ${2} 122 | end 123 | 124 | module InstanceMethods 125 | 126 | end 127 | 128 | def self.included(receiver) 129 | receiver.extend ClassMethods 130 | receiver.send :include, InstanceMethods 131 | end 132 | end 133 | # attr_reader 134 | snippet r 135 | attr_reader :${1:attr_names} 136 | # attr_writer 137 | snippet w 138 | attr_writer :${1:attr_names} 139 | # attr_accessor 140 | snippet rw 141 | attr_accessor :${1:attr_names} 142 | # include Enumerable 143 | snippet Enum 144 | include Enumerable 145 | 146 | def each(&block) 147 | ${1} 148 | end 149 | # include Comparable 150 | snippet Comp 151 | include Comparable 152 | 153 | def <=>(other) 154 | ${1} 155 | end 156 | # extend Forwardable 157 | snippet Forw- 158 | extend Forwardable 159 | # def self 160 | snippet defs 161 | def self.${1:class_method_name} 162 | ${2} 163 | end 164 | # def method_missing 165 | snippet defmm 166 | def method_missing(meth, *args, &blk) 167 | ${1} 168 | end 169 | snippet defd 170 | def_delegator :${1:@del_obj}, :${2:del_meth}, :${3:new_name} 171 | snippet defds 172 | def_delegators :${1:@del_obj}, :${2:del_methods} 173 | snippet am 174 | alias_method :${1:new_name}, :${2:old_name} 175 | snippet app 176 | if __FILE__ == $PROGRAM_NAME 177 | ${1} 178 | end 179 | # usage_if() 180 | snippet usai 181 | if ARGV.${1} 182 | abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3} 183 | end 184 | # usage_unless() 185 | snippet usau 186 | unless ARGV.${1} 187 | abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3} 188 | end 189 | snippet array 190 | Array.new(${1:10}) { |${2:i}| ${3} } 191 | snippet hash 192 | Hash.new { |${1:hash}, ${2:key}| $1[$2] = ${3} } 193 | snippet file File.foreach() { |line| .. } 194 | File.foreach(${1:"path/to/file"}) { |${2:line}| ${3} } 195 | snippet file File.read() 196 | File.read(${1:"path/to/file"})${2} 197 | snippet Dir Dir.global() { |file| .. } 198 | Dir.glob(${1:"dir/glob/*"}) { |${2:file}| ${3} } 199 | snippet Dir Dir[".."] 200 | Dir[${1:"glob/**/*.rb"}]${2} 201 | snippet dir 202 | Filename.dirname(__FILE__) 203 | snippet deli 204 | delete_if { |${1:e}| ${2} } 205 | snippet fil 206 | fill(${1:range}) { |${2:i}| ${3} } 207 | # flatten_once() 208 | snippet flao 209 | inject(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2)}${3} 210 | snippet zip 211 | zip(${1:enums}) { |${2:row}| ${3} } 212 | # downto(0) { |n| .. } 213 | snippet dow 214 | downto(${1:0}) { |${2:n}| ${3} } 215 | snippet ste 216 | step(${1:2}) { |${2:n}| ${3} } 217 | snippet tim 218 | times { |${1:n}| ${2} } 219 | snippet upt 220 | upto(${1:1.0/0.0}) { |${2:n}| ${3} } 221 | snippet loo 222 | loop { ${1} } 223 | snippet ea 224 | each { |${1:e}| ${2} } 225 | snippet eab 226 | each_byte { |${1:byte}| ${2} } 227 | snippet eac- each_char { |chr| .. } 228 | each_char { |${1:chr}| ${2} } 229 | snippet eac- each_cons(..) { |group| .. } 230 | each_cons(${1:2}) { |${2:group}| ${3} } 231 | snippet eai 232 | each_index { |${1:i}| ${2} } 233 | snippet eak 234 | each_key { |${1:key}| ${2} } 235 | snippet eal 236 | each_line { |${1:line}| ${2} } 237 | snippet eap 238 | each_pair { |${1:name}, ${2:val}| ${3} } 239 | snippet eas- 240 | each_slice(${1:2}) { |${2:group}| ${3} } 241 | snippet eav 242 | each_value { |${1:val}| ${2} } 243 | snippet eawi 244 | each_with_index { |${1:e}, ${2:i}| ${3} } 245 | snippet reve 246 | reverse_each { |${1:e}| ${2} } 247 | snippet inj 248 | inject(${1:init}) { |${2:mem}, ${3:var}| ${4} } 249 | snippet map 250 | map { |${1:e}| ${2} } 251 | snippet mapwi- 252 | enum_with_index.map { |${1:e}, ${2:i}| ${3} } 253 | snippet sor 254 | sort { |a, b| ${1} } 255 | snippet sorb 256 | sort_by { |${1:e}| ${2} } 257 | snippet ran 258 | sort_by { rand } 259 | snippet all 260 | all? { |${1:e}| ${2} } 261 | snippet any 262 | any? { |${1:e}| ${2} } 263 | snippet cl 264 | classify { |${1:e}| ${2} } 265 | snippet col 266 | collect { |${1:e}| ${2} } 267 | snippet det 268 | detect { |${1:e}| ${2} } 269 | snippet fet 270 | fetch(${1:name}) { |${2:key}| ${3} } 271 | snippet fin 272 | find { |${1:e}| ${2} } 273 | snippet fina 274 | find_all { |${1:e}| ${2} } 275 | snippet gre 276 | grep(${1:/pattern/}) { |${2:match}| ${3} } 277 | snippet sub 278 | ${1:g}sub(${2:/pattern/}) { |${3:match}| ${4} } 279 | snippet sca 280 | scan(${1:/pattern/}) { |${2:match}| ${3} } 281 | snippet max 282 | max { |a, b|, ${1} } 283 | snippet min 284 | min { |a, b|, ${1} } 285 | snippet par 286 | partition { |${1:e}|, ${2} } 287 | snippet rej 288 | reject { |${1:e}|, ${2} } 289 | snippet sel 290 | select { |${1:e}|, ${2} } 291 | snippet lam 292 | lambda { |${1:args}| ${2} } 293 | snippet do 294 | do |${1:variable}| 295 | ${2} 296 | end 297 | snippet : 298 | :${1:key} => ${2:"value"}${3} 299 | snippet ope 300 | open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${4} } 301 | # path_from_here() 302 | snippet patfh 303 | File.join(File.dirname(__FILE__), *%2[${1:rel path here}])${2} 304 | # unix_filter {} 305 | snippet unif 306 | ARGF.each_line${1} do |${2:line}| 307 | ${3} 308 | end 309 | # option_parse {} 310 | snippet optp 311 | require "optparse" 312 | 313 | options = {${1:default => "args"}} 314 | 315 | ARGV.options do |opts| 316 | opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} 317 | snippet opt 318 | opts.on( "-${1:o}", "--${2:long-option-name}", ${3:String}, 319 | "${4:Option description.}") do |${5:opt}| 320 | ${6} 321 | end 322 | snippet tc 323 | require "test/unit" 324 | 325 | require "${1:library_file_name}" 326 | 327 | class Test${2:$1} < Test::Unit::TestCase 328 | def test_${3:case_name} 329 | ${4} 330 | end 331 | end 332 | snippet ts 333 | require "test/unit" 334 | 335 | require "tc_${1:test_case_file}" 336 | require "tc_${2:test_case_file}"${3} 337 | snippet as 338 | assert(${1:test}, "${2:Failure message.}")${3} 339 | snippet ase 340 | assert_equal(${1:expected}, ${2:actual})${3} 341 | snippet asne 342 | assert_not_equal(${1:unexpected}, ${2:actual})${3} 343 | snippet asid 344 | assert_in_delta(${1:expected_float}, ${2:actual_float}, ${3:2 ** -20})${4} 345 | snippet asio 346 | assert_instance_of(${1:ExpectedClass}, ${2:actual_instance})${3} 347 | snippet asko 348 | assert_kind_of(${1:ExpectedKind}, ${2:actual_instance})${3} 349 | snippet asn 350 | assert_nil(${1:instance})${2} 351 | snippet asnn 352 | assert_not_nil(${1:instance})${2} 353 | snippet asm 354 | assert_match(/${1:expected_pattern}/, ${2:actual_string})${3} 355 | snippet asnm 356 | assert_no_match(/${1:unexpected_pattern}/, ${2:actual_string})${3} 357 | snippet aso 358 | assert_operator(${1:left}, :${2:operator}, ${3:right})${4} 359 | snippet asr 360 | assert_raise(${1:Exception}) { ${2} } 361 | snippet asnr 362 | assert_nothing_raised(${1:Exception}) { ${2} } 363 | snippet asrt 364 | assert_respond_to(${1:object}, :${2:method})${3} 365 | snippet ass assert_same(..) 366 | assert_same(${1:expected}, ${2:actual})${3} 367 | snippet ass assert_send(..) 368 | assert_send([${1:object}, :${2:message}, ${3:args}])${4} 369 | snippet asns 370 | assert_not_same(${1:unexpected}, ${2:actual})${3} 371 | snippet ast 372 | assert_throws(:${1:expected}) { ${2} } 373 | snippet asnt 374 | assert_nothing_thrown { ${1} } 375 | snippet fl 376 | flunk("${1:Failure message.}")${2} 377 | # Benchmark.bmbm do .. end 378 | snippet bm- 379 | TESTS = ${1:10_000} 380 | Benchmark.bmbm do |results| 381 | ${2} 382 | end 383 | snippet rep 384 | results.report("${1:name}:") { TESTS.times { ${2} }} 385 | # Marshal.dump(.., file) 386 | snippet Md 387 | File.open(${1:"path/to/file.dump"}, "wb") { |${2:file}| Marshal.dump(${3:obj}, $2) }${4} 388 | # Mashal.load(obj) 389 | snippet Ml 390 | File.open(${1:"path/to/file.dump"}, "rb") { |${2:file}| Marshal.load($2) }${3} 391 | # deep_copy(..) 392 | snippet deec 393 | Marshal.load(Marshal.dump(${1:obj_to_copy}))${2} 394 | snippet Pn- 395 | PStore.new(${1:"file_name.pstore"})${2} 396 | snippet tra 397 | transaction(${1:true}) { ${2} } 398 | # xmlread(..) 399 | snippet xml- 400 | REXML::Document.new(File.read(${1:"path/to/file"}))${2} 401 | # xpath(..) { .. } 402 | snippet xpa 403 | elements.each(${1:"//Xpath"}) do |${2:node}| 404 | ${3} 405 | end 406 | # class_from_name() 407 | snippet clafn 408 | split("::").inject(Object) { |par, const| par.const_get(const) } 409 | # singleton_class() 410 | snippet sinc 411 | class << self; self end 412 | snippet nam 413 | namespace :${1:`Filename()`} do 414 | ${2} 415 | end 416 | snippet tas 417 | desc "${1:Task description\}" 418 | task :${2:task_name => [:dependent, :tasks]} do 419 | ${3} 420 | end 421 | -------------------------------------------------------------------------------- /vim/doc/tags: -------------------------------------------------------------------------------- 1 | 'NERDChristmasTree' NERD_tree.txt /*'NERDChristmasTree'* 2 | 'NERDTreeAutoCenter' NERD_tree.txt /*'NERDTreeAutoCenter'* 3 | 'NERDTreeAutoCenterThreshold' NERD_tree.txt /*'NERDTreeAutoCenterThreshold'* 4 | 'NERDTreeBookmarksFile' NERD_tree.txt /*'NERDTreeBookmarksFile'* 5 | 'NERDTreeCaseSensitiveSort' NERD_tree.txt /*'NERDTreeCaseSensitiveSort'* 6 | 'NERDTreeChDirMode' NERD_tree.txt /*'NERDTreeChDirMode'* 7 | 'NERDTreeHighlightCursorline' NERD_tree.txt /*'NERDTreeHighlightCursorline'* 8 | 'NERDTreeHijackNetrw' NERD_tree.txt /*'NERDTreeHijackNetrw'* 9 | 'NERDTreeIgnore' NERD_tree.txt /*'NERDTreeIgnore'* 10 | 'NERDTreeMouseMode' NERD_tree.txt /*'NERDTreeMouseMode'* 11 | 'NERDTreeQuitOnOpen' NERD_tree.txt /*'NERDTreeQuitOnOpen'* 12 | 'NERDTreeShowBookmarks' NERD_tree.txt /*'NERDTreeShowBookmarks'* 13 | 'NERDTreeShowFiles' NERD_tree.txt /*'NERDTreeShowFiles'* 14 | 'NERDTreeShowHidden' NERD_tree.txt /*'NERDTreeShowHidden'* 15 | 'NERDTreeShowLineNumbers' NERD_tree.txt /*'NERDTreeShowLineNumbers'* 16 | 'NERDTreeSortOrder' NERD_tree.txt /*'NERDTreeSortOrder'* 17 | 'NERDTreeStatusline' NERD_tree.txt /*'NERDTreeStatusline'* 18 | 'NERDTreeWinPos' NERD_tree.txt /*'NERDTreeWinPos'* 19 | 'NERDTreeWinSize' NERD_tree.txt /*'NERDTreeWinSize'* 20 | 'Tlist_Auto_Highlight_Tag' taglist.txt /*'Tlist_Auto_Highlight_Tag'* 21 | 'Tlist_Auto_Open' taglist.txt /*'Tlist_Auto_Open'* 22 | 'Tlist_Auto_Update' taglist.txt /*'Tlist_Auto_Update'* 23 | 'Tlist_Close_On_Select' taglist.txt /*'Tlist_Close_On_Select'* 24 | 'Tlist_Compact_Format' taglist.txt /*'Tlist_Compact_Format'* 25 | 'Tlist_Ctags_Cmd' taglist.txt /*'Tlist_Ctags_Cmd'* 26 | 'Tlist_Display_Prototype' taglist.txt /*'Tlist_Display_Prototype'* 27 | 'Tlist_Display_Tag_Scope' taglist.txt /*'Tlist_Display_Tag_Scope'* 28 | 'Tlist_Enable_Fold_Column' taglist.txt /*'Tlist_Enable_Fold_Column'* 29 | 'Tlist_Exit_OnlyWindow' taglist.txt /*'Tlist_Exit_OnlyWindow'* 30 | 'Tlist_File_Fold_Auto_Close' taglist.txt /*'Tlist_File_Fold_Auto_Close'* 31 | 'Tlist_GainFocus_On_ToggleOpen' taglist.txt /*'Tlist_GainFocus_On_ToggleOpen'* 32 | 'Tlist_Highlight_Tag_On_BufEnter' taglist.txt /*'Tlist_Highlight_Tag_On_BufEnter'* 33 | 'Tlist_Inc_Winwidth' taglist.txt /*'Tlist_Inc_Winwidth'* 34 | 'Tlist_Max_Submenu_Items' taglist.txt /*'Tlist_Max_Submenu_Items'* 35 | 'Tlist_Max_Tag_Length' taglist.txt /*'Tlist_Max_Tag_Length'* 36 | 'Tlist_Process_File_Always' taglist.txt /*'Tlist_Process_File_Always'* 37 | 'Tlist_Show_Menu' taglist.txt /*'Tlist_Show_Menu'* 38 | 'Tlist_Show_One_File' taglist.txt /*'Tlist_Show_One_File'* 39 | 'Tlist_Sort_Type' taglist.txt /*'Tlist_Sort_Type'* 40 | 'Tlist_Use_Horiz_Window' taglist.txt /*'Tlist_Use_Horiz_Window'* 41 | 'Tlist_Use_Right_Window' taglist.txt /*'Tlist_Use_Right_Window'* 42 | 'Tlist_Use_SingleClick' taglist.txt /*'Tlist_Use_SingleClick'* 43 | 'Tlist_WinHeight' taglist.txt /*'Tlist_WinHeight'* 44 | 'Tlist_WinWidth' taglist.txt /*'Tlist_WinWidth'* 45 | 'loaded_nerd_tree' NERD_tree.txt /*'loaded_nerd_tree'* 46 | 'snippets' snipMate.txt /*'snippets'* 47 | .snippet snipMate.txt /*.snippet* 48 | .snippets snipMate.txt /*.snippets* 49 | :NERDTree NERD_tree.txt /*:NERDTree* 50 | :NERDTreeClose NERD_tree.txt /*:NERDTreeClose* 51 | :NERDTreeFind NERD_tree.txt /*:NERDTreeFind* 52 | :NERDTreeFromBookmark NERD_tree.txt /*:NERDTreeFromBookmark* 53 | :NERDTreeMirror NERD_tree.txt /*:NERDTreeMirror* 54 | :NERDTreeToggle NERD_tree.txt /*:NERDTreeToggle* 55 | :TlistAddFiles taglist.txt /*:TlistAddFiles* 56 | :TlistAddFilesRecursive taglist.txt /*:TlistAddFilesRecursive* 57 | :TlistClose taglist.txt /*:TlistClose* 58 | :TlistDebug taglist.txt /*:TlistDebug* 59 | :TlistHighlightTag taglist.txt /*:TlistHighlightTag* 60 | :TlistLock taglist.txt /*:TlistLock* 61 | :TlistMessages taglist.txt /*:TlistMessages* 62 | :TlistOpen taglist.txt /*:TlistOpen* 63 | :TlistSessionLoad taglist.txt /*:TlistSessionLoad* 64 | :TlistSessionSave taglist.txt /*:TlistSessionSave* 65 | :TlistShowPrototype taglist.txt /*:TlistShowPrototype* 66 | :TlistShowTag taglist.txt /*:TlistShowTag* 67 | :TlistToggle taglist.txt /*:TlistToggle* 68 | :TlistUndebug taglist.txt /*:TlistUndebug* 69 | :TlistUnlock taglist.txt /*:TlistUnlock* 70 | :TlistUpdate taglist.txt /*:TlistUpdate* 71 | ExtractSnips() snipMate.txt /*ExtractSnips()* 72 | ExtractSnipsFile() snipMate.txt /*ExtractSnipsFile()* 73 | Filename() snipMate.txt /*Filename()* 74 | NERDTree NERD_tree.txt /*NERDTree* 75 | NERDTree-? NERD_tree.txt /*NERDTree-?* 76 | NERDTree-A NERD_tree.txt /*NERDTree-A* 77 | NERDTree-B NERD_tree.txt /*NERDTree-B* 78 | NERDTree-C NERD_tree.txt /*NERDTree-C* 79 | NERDTree-C-J NERD_tree.txt /*NERDTree-C-J* 80 | NERDTree-C-K NERD_tree.txt /*NERDTree-C-K* 81 | NERDTree-D NERD_tree.txt /*NERDTree-D* 82 | NERDTree-F NERD_tree.txt /*NERDTree-F* 83 | NERDTree-I NERD_tree.txt /*NERDTree-I* 84 | NERDTree-J NERD_tree.txt /*NERDTree-J* 85 | NERDTree-K NERD_tree.txt /*NERDTree-K* 86 | NERDTree-O NERD_tree.txt /*NERDTree-O* 87 | NERDTree-P NERD_tree.txt /*NERDTree-P* 88 | NERDTree-R NERD_tree.txt /*NERDTree-R* 89 | NERDTree-T NERD_tree.txt /*NERDTree-T* 90 | NERDTree-U NERD_tree.txt /*NERDTree-U* 91 | NERDTree-X NERD_tree.txt /*NERDTree-X* 92 | NERDTree-cd NERD_tree.txt /*NERDTree-cd* 93 | NERDTree-contents NERD_tree.txt /*NERDTree-contents* 94 | NERDTree-e NERD_tree.txt /*NERDTree-e* 95 | NERDTree-f NERD_tree.txt /*NERDTree-f* 96 | NERDTree-gi NERD_tree.txt /*NERDTree-gi* 97 | NERDTree-go NERD_tree.txt /*NERDTree-go* 98 | NERDTree-gs NERD_tree.txt /*NERDTree-gs* 99 | NERDTree-i NERD_tree.txt /*NERDTree-i* 100 | NERDTree-m NERD_tree.txt /*NERDTree-m* 101 | NERDTree-o NERD_tree.txt /*NERDTree-o* 102 | NERDTree-p NERD_tree.txt /*NERDTree-p* 103 | NERDTree-q NERD_tree.txt /*NERDTree-q* 104 | NERDTree-r NERD_tree.txt /*NERDTree-r* 105 | NERDTree-s NERD_tree.txt /*NERDTree-s* 106 | NERDTree-t NERD_tree.txt /*NERDTree-t* 107 | NERDTree-u NERD_tree.txt /*NERDTree-u* 108 | NERDTree-x NERD_tree.txt /*NERDTree-x* 109 | NERDTreeAPI NERD_tree.txt /*NERDTreeAPI* 110 | NERDTreeAbout NERD_tree.txt /*NERDTreeAbout* 111 | NERDTreeAddKeyMap() NERD_tree.txt /*NERDTreeAddKeyMap()* 112 | NERDTreeAddMenuItem() NERD_tree.txt /*NERDTreeAddMenuItem()* 113 | NERDTreeAddMenuSeparator() NERD_tree.txt /*NERDTreeAddMenuSeparator()* 114 | NERDTreeAddSubmenu() NERD_tree.txt /*NERDTreeAddSubmenu()* 115 | NERDTreeBookmarkCommands NERD_tree.txt /*NERDTreeBookmarkCommands* 116 | NERDTreeBookmarkTable NERD_tree.txt /*NERDTreeBookmarkTable* 117 | NERDTreeBookmarks NERD_tree.txt /*NERDTreeBookmarks* 118 | NERDTreeChangelog NERD_tree.txt /*NERDTreeChangelog* 119 | NERDTreeCredits NERD_tree.txt /*NERDTreeCredits* 120 | NERDTreeFunctionality NERD_tree.txt /*NERDTreeFunctionality* 121 | NERDTreeGlobalCommands NERD_tree.txt /*NERDTreeGlobalCommands* 122 | NERDTreeInvalidBookmarks NERD_tree.txt /*NERDTreeInvalidBookmarks* 123 | NERDTreeKeymapAPI NERD_tree.txt /*NERDTreeKeymapAPI* 124 | NERDTreeLicense NERD_tree.txt /*NERDTreeLicense* 125 | NERDTreeMappings NERD_tree.txt /*NERDTreeMappings* 126 | NERDTreeMenu NERD_tree.txt /*NERDTreeMenu* 127 | NERDTreeMenuAPI NERD_tree.txt /*NERDTreeMenuAPI* 128 | NERDTreeOptionDetails NERD_tree.txt /*NERDTreeOptionDetails* 129 | NERDTreeOptionSummary NERD_tree.txt /*NERDTreeOptionSummary* 130 | NERDTreeOptions NERD_tree.txt /*NERDTreeOptions* 131 | NERDTreeRender() NERD_tree.txt /*NERDTreeRender()* 132 | NERD_tree.txt NERD_tree.txt /*NERD_tree.txt* 133 | ResetSnippets() snipMate.txt /*ResetSnippets()* 134 | Tlist_Get_Tag_Prototype_By_Line() taglist.txt /*Tlist_Get_Tag_Prototype_By_Line()* 135 | Tlist_Get_Tagname_By_Line() taglist.txt /*Tlist_Get_Tagname_By_Line()* 136 | Tlist_Set_App() taglist.txt /*Tlist_Set_App()* 137 | Tlist_Update_File_Tags() taglist.txt /*Tlist_Update_File_Tags()* 138 | bufexplorer bufexplorer.txt /*bufexplorer* 139 | bufexplorer-changelog bufexplorer.txt /*bufexplorer-changelog* 140 | bufexplorer-credits bufexplorer.txt /*bufexplorer-credits* 141 | bufexplorer-customization bufexplorer.txt /*bufexplorer-customization* 142 | bufexplorer-installation bufexplorer.txt /*bufexplorer-installation* 143 | bufexplorer-todo bufexplorer.txt /*bufexplorer-todo* 144 | bufexplorer-usage bufexplorer.txt /*bufexplorer-usage* 145 | bufexplorer.txt bufexplorer.txt /*bufexplorer.txt* 146 | buffer-explorer bufexplorer.txt /*buffer-explorer* 147 | cs surround.txt /*cs* 148 | ds surround.txt /*ds* 149 | g:bufExplorerDefaultHelp bufexplorer.txt /*g:bufExplorerDefaultHelp* 150 | g:bufExplorerDetailedHelp bufexplorer.txt /*g:bufExplorerDetailedHelp* 151 | g:bufExplorerFindActive bufexplorer.txt /*g:bufExplorerFindActive* 152 | g:bufExplorerReverseSort bufexplorer.txt /*g:bufExplorerReverseSort* 153 | g:bufExplorerShowDirectories bufexplorer.txt /*g:bufExplorerShowDirectories* 154 | g:bufExplorerShowRelativePath bufexplorer.txt /*g:bufExplorerShowRelativePath* 155 | g:bufExplorerShowUnlisted bufexplorer.txt /*g:bufExplorerShowUnlisted* 156 | g:bufExplorerSortBy bufexplorer.txt /*g:bufExplorerSortBy* 157 | g:bufExplorerSplitBelow bufexplorer.txt /*g:bufExplorerSplitBelow* 158 | g:bufExplorerSplitOutPathName bufexplorer.txt /*g:bufExplorerSplitOutPathName* 159 | g:bufExplorerSplitRight bufexplorer.txt /*g:bufExplorerSplitRight* 160 | g:snippets_dir snipMate.txt /*g:snippets_dir* 161 | g:snips_author snipMate.txt /*g:snips_author* 162 | i_CTRL-G_S surround.txt /*i_CTRL-G_S* 163 | i_CTRL-G_s surround.txt /*i_CTRL-G_s* 164 | i_CTRL-R_ snipMate.txt /*i_CTRL-R_* 165 | list-snippets snipMate.txt /*list-snippets* 166 | multi_snip snipMate.txt /*multi_snip* 167 | snipMate snipMate.txt /*snipMate* 168 | snipMate-$# snipMate.txt /*snipMate-$#* 169 | snipMate-${#:} snipMate.txt /*snipMate-${#:}* 170 | snipMate-${#} snipMate.txt /*snipMate-${#}* 171 | snipMate-author snipMate.txt /*snipMate-author* 172 | snipMate-commands snipMate.txt /*snipMate-commands* 173 | snipMate-contact snipMate.txt /*snipMate-contact* 174 | snipMate-description snipMate.txt /*snipMate-description* 175 | snipMate-disadvantages snipMate.txt /*snipMate-disadvantages* 176 | snipMate-expandtab snipMate.txt /*snipMate-expandtab* 177 | snipMate-features snipMate.txt /*snipMate-features* 178 | snipMate-filename snipMate.txt /*snipMate-filename* 179 | snipMate-indenting snipMate.txt /*snipMate-indenting* 180 | snipMate-placeholders snipMate.txt /*snipMate-placeholders* 181 | snipMate-remap snipMate.txt /*snipMate-remap* 182 | snipMate-settings snipMate.txt /*snipMate-settings* 183 | snipMate-usage snipMate.txt /*snipMate-usage* 184 | snipMate.txt snipMate.txt /*snipMate.txt* 185 | snippet snipMate.txt /*snippet* 186 | snippet-syntax snipMate.txt /*snippet-syntax* 187 | snippets snipMate.txt /*snippets* 188 | surround surround.txt /*surround* 189 | surround-author surround.txt /*surround-author* 190 | surround-customizing surround.txt /*surround-customizing* 191 | surround-issues surround.txt /*surround-issues* 192 | surround-mappings surround.txt /*surround-mappings* 193 | surround-replacements surround.txt /*surround-replacements* 194 | surround-targets surround.txt /*surround-targets* 195 | surround.txt surround.txt /*surround.txt* 196 | taglist-commands taglist.txt /*taglist-commands* 197 | taglist-debug taglist.txt /*taglist-debug* 198 | taglist-extend taglist.txt /*taglist-extend* 199 | taglist-faq taglist.txt /*taglist-faq* 200 | taglist-functions taglist.txt /*taglist-functions* 201 | taglist-install taglist.txt /*taglist-install* 202 | taglist-internet taglist.txt /*taglist-internet* 203 | taglist-intro taglist.txt /*taglist-intro* 204 | taglist-keys taglist.txt /*taglist-keys* 205 | taglist-license taglist.txt /*taglist-license* 206 | taglist-menu taglist.txt /*taglist-menu* 207 | taglist-options taglist.txt /*taglist-options* 208 | taglist-requirements taglist.txt /*taglist-requirements* 209 | taglist-session taglist.txt /*taglist-session* 210 | taglist-todo taglist.txt /*taglist-todo* 211 | taglist-using taglist.txt /*taglist-using* 212 | taglist.txt taglist.txt /*taglist.txt* 213 | vs surround.txt /*vs* 214 | yS surround.txt /*yS* 215 | ySS surround.txt /*ySS* 216 | ys surround.txt /*ys* 217 | yss surround.txt /*yss* 218 | -------------------------------------------------------------------------------- /vim/plugin/tasklist.vim: -------------------------------------------------------------------------------- 1 | "------------------------------------------------------------------------------ 2 | " Name Of File: tasklist.vim 3 | " 4 | " Description: Vim plugin to search for a list of tokens and display a 5 | " window with matches. 6 | " 7 | " Author: Juan Frias (juandfrias at gmail.com) 8 | " 9 | " Last Change: 2009 Apr 11 10 | " Version: 1.0.1 11 | " 12 | " Copyright: Permission is hereby granted to use and distribute this code, 13 | " with or without modifications, provided that this header 14 | " is included with it. 15 | " 16 | " This script is to be distributed freely in the hope that it 17 | " will be useful, but is provided 'as is' and without warranties 18 | " as to performance of merchantability or any other warranties 19 | " whether expressed or implied. Because of the various hardware 20 | " and software environments into which this script may be put, 21 | " no warranty of fitness for a particular purpose is offered. 22 | " 23 | " GOOD DATA PROCESSING PROCEDURE DICTATES THAT ANY SCRIPT BE 24 | " THOROUGHLY TESTED WITH NON-CRITICAL DATA BEFORE RELYING ON IT. 25 | " 26 | " THE USER MUST ASSUME THE ENTIRE RISK OF USING THE SCRIPT. 27 | " 28 | " The author does not retain any liability on any damage caused 29 | " through the use of this script. 30 | " 31 | " Install: 1. Read the section titled 'Options' 32 | " 2. Setup any variables need in your vimrc file 33 | " 3. Copy 'tasklist.vim' to your plugin directory. 34 | " 35 | " Mapped Keys: t Display list. 36 | " 37 | " Usage: Start the script with the mapped key, a new window appears 38 | " with the matches found, moving around the window will also 39 | " update the position of the current document. 40 | " 41 | " The following keys are mapped to the results window: 42 | " 43 | " q - Quit, and restore original cursor position. 44 | " 45 | " e - Exit, and keep results window open note that 46 | " movements on the result window will no longer be 47 | " updated. 48 | " 49 | " - Quit and place the cursor on the selected line. 50 | " 51 | " Aknowledgments: Many thanks to Zhang Shuhan for taking the time to beta 52 | " test and suggest many of the improvements and features 53 | " found in the script. I don't think I would have 54 | " implemented it wihout his help. Thanks! 55 | " 56 | "------------------------------------------------------------------------------ 57 | " Please send me any bugs you find, so I can keep the script up to date. 58 | "------------------------------------------------------------------------------ 59 | 60 | " History: {{{1 61 | "------------------------------------------------------------------------------ 62 | " 63 | " 1.00 Initial version. 64 | " 65 | " User Options: {{{1 66 | "------------------------------------------------------------------------------ 67 | " 68 | " t 69 | " This is the default key map to view the task list. 70 | " to overwrite use something like: 71 | " map v TaskList 72 | " in your vimrc file 73 | " 74 | " g:tlWindowPosition 75 | " This is specifies the position of the window to be opened. By 76 | " default it will open at on top. To overwrite use: 77 | " let g:tlWindowPosition = 1 78 | " in your vimrc file, options are as follows: 79 | " 0 = Open on top 80 | " 1 = Open on the bottom 81 | " 82 | " g:tlTokenList 83 | " This is the list of tokens to search for default is 84 | " 'FIXME TODO XXX'. The results are groupped and displayed in the 85 | " order that they appear. to overwrite use: 86 | " let g:tlTokenList = ['TOKEN1', 'TOKEN2', 'TOKEN3'] 87 | " in your vimrc file 88 | " 89 | " g:tlRememberPosition 90 | " If this is set to 1 then the script will try to get back to the 91 | " position where it last was closed. By default it will find the line 92 | " closest to the current cursor position. 93 | " to overwrite use: 94 | " let g:tlRememberPosition = 1 95 | " in your vimrc file 96 | " 97 | 98 | " Global variables: {{{1 99 | "------------------------------------------------------------------------------ 100 | 101 | " Load script once 102 | "------------------------------------------------------------------------------ 103 | if exists("g:loaded_tasklist") || &cp 104 | finish 105 | endif 106 | let g:loaded_tasklist = 1 107 | 108 | " Set where the window opens 109 | "------------------------------------------------------------------------------ 110 | if !exists('g:tlWindowPosition') 111 | " 0 = Open at top 112 | let g:tlWindowPosition = 0 113 | endif 114 | 115 | " Set the token list 116 | "------------------------------------------------------------------------------ 117 | if !exists('g:tlTokenList') 118 | " default list of tokens 119 | let g:tlTokenList = ["FIXME", "TODO", "XXX"] 120 | endif 121 | 122 | " Remember position 123 | "------------------------------------------------------------------------------ 124 | if !exists('g:tlRememberPosition') 125 | " 0 = Donot remember, find closest match 126 | let g:tlRememberPosition = 0 127 | endif 128 | 129 | " Script variables: {{{1 130 | "------------------------------------------------------------------------------ 131 | 132 | " Function: Open Window {{{1 133 | "-------------------------------------------------------------------------- 134 | function! s:OpenWindow(buffnr, lineno) 135 | " Open results window and place items there. 136 | if g:tlWindowPosition == 0 137 | execute 'sp -TaskList_'.a:buffnr.'-' 138 | else 139 | execute 'botright sp -TaskList_'.a:buffnr.'-' 140 | endif 141 | 142 | let b:original_buffnr = a:buffnr 143 | let b:original_line = a:lineno 144 | 145 | set noswapfile 146 | set modifiable 147 | normal! "zPGddgg 148 | set fde=getline(v:lnum)[0]=='L' 149 | set foldmethod=expr 150 | set foldlevel=0 151 | normal! zR 152 | set nonumber 153 | 154 | " Resize line if too big. 155 | let l:hits = line("$") 156 | if l:hits < winheight(0) 157 | sil! exe "resize ".l:hits 158 | endif 159 | 160 | " Clean up. 161 | let @z = "" 162 | set nomodified 163 | endfunction 164 | 165 | " Function: Search file {{{1 166 | "-------------------------------------------------------------------------- 167 | function! s:SearchFile(hits, word) 168 | " Search at the beginning and keep adding them to the register 169 | let l:match_count = 0 170 | normal! gg0 171 | let l:max = strlen(line('$')) 172 | let l:last_match = -1 173 | let l:div = 0 174 | while search(a:word, "Wc") > 0 175 | let l:curr_line = line('.') 176 | if l:last_match == l:curr_line 177 | if l:curr_line == line('$') 178 | break 179 | endif 180 | normal! j0 181 | continue 182 | endif 183 | let l:last_match = l:curr_line 184 | if foldlevel(l:curr_line) != 0 185 | normal! 99zo 186 | endif 187 | if l:div == 0 188 | if a:hits != 0 189 | let @z = @z."\n" 190 | endif 191 | let l:div = 1 192 | endif 193 | normal! 0 194 | let l:lineno = ' '.l:curr_line 195 | let @z = @z.'Ln '.strpart(l:lineno, strlen(l:lineno) - l:max).': ' 196 | let l:text = getline(".") 197 | let @z = @z.strpart(l:text, stridx(l:text, a:word)) 198 | let @z = @z."\n" 199 | normal! $ 200 | let l:match_count = l:match_count + 1 201 | endwhile 202 | return l:match_count 203 | endfunction 204 | 205 | " Function: Get line number {{{1 206 | "-------------------------------------------------------------------------- 207 | function! s:LineNumber() 208 | let l:text = getline(".") 209 | if strpart(l:text, 0, 5) == "File:" 210 | return 0 211 | endif 212 | if strlen(l:text) == 0 213 | return -1 214 | endif 215 | let l:num = matchstr(l:text, '[0-9]\+') 216 | if l:num == '' 217 | return -1 218 | endif 219 | return l:num 220 | endfunction 221 | 222 | " Function: Update document position {{{1 223 | "-------------------------------------------------------------------------- 224 | function! s:UpdateDoc() 225 | let l:line_hit = LineNumber() 226 | 227 | match none 228 | if l:line_hit == -1 229 | redraw 230 | return 231 | endif 232 | 233 | let l:buffnr = b:original_buffnr 234 | exe 'match Search /\%'.line(".").'l.*/' 235 | if line(".") < (line("$") - (winheight(0) / 2)) + 1 236 | normal! zz 237 | endif 238 | execute bufwinnr(l:buffnr)." wincmd w" 239 | match none 240 | if l:line_hit == 0 241 | normal! 1G 242 | else 243 | exe "normal! ".l:line_hit."Gzz" 244 | exe 'match Search /\%'.line(".").'l.*/' 245 | endif 246 | execute bufwinnr('-TaskList_'.l:buffnr.'-')." wincmd w" 247 | redraw 248 | endfunction 249 | 250 | " Function: Clean up on exit {{{1 251 | "-------------------------------------------------------------------------- 252 | function! s:Exit(key) 253 | 254 | call UpdateDoc() 255 | match none 256 | 257 | let l:original_line = b:original_line 258 | let l:last_position = line('.') 259 | 260 | if a:key == -1 261 | nunmap e 262 | nunmap q 263 | nunmap 264 | execute bufwinnr(b:original_buffnr)." wincmd w" 265 | else 266 | bd! 267 | endif 268 | 269 | let b:last_position = l:last_position 270 | 271 | if a:key == 0 272 | exe "normal! ".l:original_line."G" 273 | endif 274 | 275 | match none 276 | normal! zz 277 | 278 | execute "set updatetime=".s:old_updatetime 279 | endfunction 280 | 281 | " Function: Check for screen update {{{1 282 | "-------------------------------------------------------------------------- 283 | function! s:CheckForUpdate() 284 | if stridx(expand("%:t"), '-TaskList_') == -1 285 | return 286 | endif 287 | if b:selected_line != line(".") 288 | call UpdateDoc() 289 | let b:selected_line = line(".") 290 | endif 291 | endfunction 292 | 293 | " Function: Start the search. {{{1 294 | "-------------------------------------------------------------------------- 295 | function! s:TaskList() 296 | let l:original_buffnr = bufnr('%') 297 | let l:original_line = line(".") 298 | 299 | " last position 300 | if !exists('b:last_position') 301 | let b:last_position = 1 302 | endif 303 | let l:last_position = b:last_position 304 | 305 | 306 | " get file name 307 | let @z = "File:".expand("%:p")."\n\n" 308 | 309 | " search file 310 | let l:index = 0 311 | let l:count = 0 312 | let l:hits = 0 313 | while l:index < len(g:tlTokenList) 314 | let l:search_word = g:tlTokenList[l:index] 315 | let l:hits = s:SearchFile(l:hits, l:search_word) 316 | let l:count = l:count + l:hits 317 | let l:index = l:index + 1 318 | endwhile 319 | 320 | " Make sure we at least have one hit. 321 | if l:count == 0 322 | echohl Search 323 | echo "tasklist.vim: No task information found." 324 | echohl None 325 | execute 'normal! '.l:original_line.'G' 326 | return 327 | endif 328 | 329 | " display window 330 | call s:OpenWindow(l:original_buffnr, l:original_line) 331 | 332 | " restore the cursor position 333 | if g:tlRememberPosition != 0 334 | exec 'normal! '.l:last_position.'G' 335 | else 336 | normal! gg 337 | endif 338 | 339 | " Map exit keys 340 | nnoremap q :call Exit(0) 341 | nnoremap :call Exit(1) 342 | nnoremap e :call Exit(-1) 343 | 344 | " Setup syntax highlight {{{ 345 | syntax match tasklistFileDivider /^File:.*$/ 346 | syntax match tasklistLineNumber /^Ln\s\+\d\+:/ 347 | 348 | highlight def link tasklistFileDivider Title 349 | highlight def link tasklistLineNumber LineNr 350 | highlight def link tasklistSearchWord Search 351 | " }}} 352 | 353 | " Save globals and change updatetime 354 | let b:selected_line = line(".") 355 | let s:old_updatetime = &updatetime 356 | set updatetime=350 357 | 358 | " update the doc and hook the CheckForUpdate function. 359 | call UpdateDoc() 360 | au! CursorHold nested call CheckForUpdate() 361 | 362 | endfunction 363 | "}}} 364 | 365 | " Command 366 | command! TaskList call s:TaskList() 367 | 368 | " Default key map 369 | if !hasmapto('TaskList') 370 | map t TaskList 371 | endif 372 | 373 | " Key map to Command 374 | nnoremap