dotfiles

configuration files for different softwares
git clone git://z3bra.org/dotfiles
Log | Files | Refs

commit 06f31a6dfd44d5c22826e40ec9f68890542e9f8d
parent 0a277cdcacf8b99a2c15b0b6a845ea12acb0d3a6
Author: Willy Goiffon <w.goiffon@gmail.com>
Date:   Thu Jul 25 15:50:24 2013

removed last unused plugins. Freedom.

Diffstat:
 vim/autoload/pathogen.vim                                   |  326 +--
 vim/bundle/custom/colors/ambient.vim                        |   58 +-
 vim/bundle/custom/colors/sandstorm.vim                      |   69 +-
 vim/bundle/custom/colors/shadow.vim                         |   60 +-
 vim/bundle/custom/ftplugin/header.vim                       |   28 +-
 vim/bundle/custom/plugin/gpg.vim                            |   31 +-
 vim/bundle/matchit/.gitignore                               |    4 +-
 vim/bundle/matchit/doc/matchit.txt                          |  406 +---
 vim/bundle/matchit/plugin/matchit.vim                       |  812 +------
 vim/bundle/snipmate/README.markdown                         |    5 +-
 vim/bundle/snipmate/after/plugin/snipMate.vim               |   40 +-
 vim/bundle/snipmate/autoload/snipMate.vim                   |  435 +---
 vim/bundle/snipmate/doc/snipMate.txt                        |  322 +--
 vim/bundle/snipmate/ftplugin/html_snip_helper.vim           |   10 +-
 vim/bundle/snipmate/plugin-info.txt                         |    8 +-
 vim/bundle/snipmate/plugin/snipMate.vim                     |  271 +--
 vim/bundle/snipmate/snippets/_.snippets                     |    9 +-
 vim/bundle/snipmate/snippets/autoit.snippets                |   66 +-
 vim/bundle/snipmate/snippets/c.snippets                     |  113 +-
 vim/bundle/snipmate/snippets/cpp.snippets                   |   34 +-
 vim/bundle/snipmate/snippets/erlang.snippets                |   39 +-
 vim/bundle/snipmate/snippets/html.snippets                  |  190 +-
 vim/bundle/snipmate/snippets/java.snippets                  |   95 +-
 vim/bundle/snipmate/snippets/javascript.snippets            |   74 +-
 vim/bundle/snipmate/snippets/mako.snippets                  |   54 +-
 vim/bundle/snipmate/snippets/objc.snippets                  |  247 +--
 vim/bundle/snipmate/snippets/perl.snippets                  |   97 +-
 vim/bundle/snipmate/snippets/php.snippets                   |  216 +--
 vim/bundle/snipmate/snippets/python.snippets                |   86 +-
 vim/bundle/snipmate/snippets/ruby.snippets                  |  504 +----
 vim/bundle/snipmate/snippets/sh.snippets                    |   28 +-
 vim/bundle/snipmate/snippets/snippet.snippets               |    7 +-
 vim/bundle/snipmate/snippets/tcl.snippets                   |   92 +-
 vim/bundle/snipmate/snippets/tex.snippets                   |  115 +-
 vim/bundle/snipmate/snippets/vim.snippets                   |   32 +-
 vim/bundle/snipmate/snippets/zsh.snippets                   |   58 +-
 vim/bundle/snipmate/syntax/snippet.vim                      |   19 +-
 vim/bundle/tcomment/.gitignore                              |   10 +-
 vim/bundle/tcomment/CHANGES.TXT                             |  205 +-
 vim/bundle/tcomment/README                                  |  104 +-
 vim/bundle/tcomment/addon-info.json                         |    9 +-
 vim/bundle/tcomment/autoload/tcomment.vim                   | 1679 +------------
 vim/bundle/tcomment/doc/tcomment.txt                        |  495 +----
 vim/bundle/tcomment/plugin/tcomment.vim                     |  177 +-
 vim/bundle/tcomment/spec/tcomment/issue30.vim               |   12 +-
 vim/bundle/tcomment/spec/tcomment/issue30_sel=exclusive.vim |   14 +-
 vim/bundle/tcomment/spec/tcomment/issue30_sel=inclusive.vim |   11 +-
 vim/bundle/tcomment/spec/tcomment/issue30_test.c            |    4 +-
 vim/bundle/tcomment/spec/tcomment/issue30_test_1.c          |    6 +-
 vim/bundle/tcomment/spec/tcomment/issue30_test_2.c          |    4 +-
 vim/bundle/tcomment/spec/tcomment/issue30_test_3.c          |    4 +-
 vim/colors/ambient.vim                                      |   58 +-
 vim/colors/sandstorm.vim                                    |   69 +-
 vim/colors/shadow.vim                                       |   60 +-
 54 files changed, 187 insertions(+), 7794 deletions(-)

diff --git a/vim/autoload/pathogen.vim b/vim/autoload/pathogen.vim @@ -1,326 +0,0 @@ -" pathogen.vim - path option manipulation -" Maintainer: Tim Pope <http://tpo.pe/> -" Version: 2.2 - -" Install in ~/.vim/autoload (or ~\vimfiles\autoload). -" -" For management of individually installed plugins in ~/.vim/bundle (or -" ~\vimfiles\bundle), adding `call pathogen#infect()` to the top of your -" .vimrc is the only other setup necessary. -" -" The API is documented inline below. For maximum ease of reading, -" :set foldmethod=marker - -if exists("g:loaded_pathogen") || &cp - finish -endif -let g:loaded_pathogen = 1 - -function! s:warn(msg) - echohl WarningMsg - echomsg a:msg - echohl NONE -endfunction - -" Point of entry for basic default usage. Give a relative path to invoke -" pathogen#incubate() (defaults to "bundle/{}"), or an absolute path to invoke -" pathogen#surround(). For backwards compatibility purposes, a full path that -" does not end in {} or * is given to pathogen#runtime_prepend_subdirectories() -" instead. -function! pathogen#infect(...) abort " {{{1 - for path in a:0 ? reverse(copy(a:000)) : ['bundle/{}'] - if path =~# '^[^\\/]\+$' - call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')') - call pathogen#incubate(path . '/{}') - elseif path =~# '^[^\\/]\+[\\/]\%({}\|\*\)$' - call pathogen#incubate(path) - elseif path =~# '[\\/]\%({}\|\*\)$' - call pathogen#surround(path) - else - call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')') - call pathogen#surround(path . '/{}') - endif - endfor - call pathogen#cycle_filetype() - return '' -endfunction " }}}1 - -" Split a path into a list. -function! pathogen#split(path) abort " {{{1 - if type(a:path) == type([]) | return a:path | endif - let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,') - return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")') -endfunction " }}}1 - -" Convert a list to a path. -function! pathogen#join(...) abort " {{{1 - if type(a:1) == type(1) && a:1 - let i = 1 - let space = ' ' - else - let i = 0 - let space = '' - endif - let path = "" - while i < a:0 - if type(a:000[i]) == type([]) - let list = a:000[i] - let j = 0 - while j < len(list) - let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g') - let path .= ',' . escaped - let j += 1 - endwhile - else - let path .= "," . a:000[i] - endif - let i += 1 - endwhile - return substitute(path,'^,','','') -endfunction " }}}1 - -" Convert a list to a path with escaped spaces for 'path', 'tag', etc. -function! pathogen#legacyjoin(...) abort " {{{1 - return call('pathogen#join',[1] + a:000) -endfunction " }}}1 - -" Remove duplicates from a list. -function! pathogen#uniq(list) abort " {{{1 - let i = 0 - let seen = {} - while i < len(a:list) - if (a:list[i] ==# '' && exists('empty')) || has_key(seen,a:list[i]) - call remove(a:list,i) - elseif a:list[i] ==# '' - let i += 1 - let empty = 1 - else - let seen[a:list[i]] = 1 - let i += 1 - endif - endwhile - return a:list -endfunction " }}}1 - -" \ on Windows unless shellslash is set, / everywhere else. -function! pathogen#separator() abort " {{{1 - return !exists("+shellslash") || &shellslash ? '/' : '\' -endfunction " }}}1 - -" Convenience wrapper around glob() which returns a list. -function! pathogen#glob(pattern) abort " {{{1 - let files = split(glob(a:pattern),"\n") - return map(files,'substitute(v:val,"[".pathogen#separator()."/]$","","")') -endfunction "}}}1 - -" Like pathogen#glob(), only limit the results to directories. -function! pathogen#glob_directories(pattern) abort " {{{1 - return filter(pathogen#glob(a:pattern),'isdirectory(v:val)') -endfunction "}}}1 - -" Turn filetype detection off and back on again if it was already enabled. -function! pathogen#cycle_filetype() " {{{1 - if exists('g:did_load_filetypes') - filetype off - filetype on - endif -endfunction " }}}1 - -" Check if a bundle is disabled. A bundle is considered disabled if it ends -" in a tilde or its basename or full name is included in the list -" g:pathogen_disabled. -function! pathogen#is_disabled(path) " {{{1 - if a:path =~# '\~$' - return 1 - elseif !exists("g:pathogen_disabled") - return 0 - endif - let sep = pathogen#separator() - let blacklist = g:pathogen_disabled - return index(blacklist, strpart(a:path, strridx(a:path, sep)+1)) != -1 && index(blacklist, a:path) != 1 -endfunction "}}}1 - -" Prepend the given directory to the runtime path and append its corresponding -" after directory. If the directory is already included, move it to the -" outermost position. Wildcards are added as is. Ending a path in /{} causes -" all subdirectories to be added (except those in g:pathogen_disabled). -function! pathogen#surround(path) abort " {{{1 - let sep = pathogen#separator() - let rtp = pathogen#split(&rtp) - if a:path =~# '[\\/]{}$' - let path = fnamemodify(a:path[0:-4], ':p:s?[\\/]\=$??') - let before = filter(pathogen#glob_directories(path.sep.'*'), '!pathogen#is_disabled(v:val)') - let after = filter(reverse(pathogen#glob_directories(path.sep."*".sep."after")), '!pathogen#is_disabled(v:val[0:-7])') - call filter(rtp,'v:val[0:strlen(path)-1] !=# path') - else - let path = fnamemodify(a:path, ':p:s?[\\/]\=$??') - let before = [path] - let after = [path . sep . 'after'] - call filter(rtp, 'index(before + after, v:val) == -1') - endif - let &rtp = pathogen#join(before, rtp, after) - return &rtp -endfunction " }}}1 - -" Prepend all subdirectories of path to the rtp, and append all 'after' -" directories in those subdirectories. Deprecated. -function! pathogen#runtime_prepend_subdirectories(path) " {{{1 - call s:warn('Change pathogen#runtime_prepend_subdirectories('.string(a:path).') to pathogen#surround('.string(a:path.'/{}').')') - return pathogen#surround(a:path . pathogen#separator() . '{}') -endfunction " }}}1 - -" For each directory in the runtime path, add a second entry with the given -" argument appended. If the argument ends in '/{}', add a separate entry for -" each subdirectory. The default argument is 'bundle/{}', which means that -" .vim/bundle/*, $VIM/vimfiles/bundle/*, $VIMRUNTIME/bundle/*, -" $VIM/vim/files/bundle/*/after, and .vim/bundle/*/after will be added (on -" UNIX). -function! pathogen#incubate(...) abort " {{{1 - let sep = pathogen#separator() - let name = a:0 ? a:1 : 'bundle/{}' - if "\n".s:done_bundles =~# "\\M\n".name."\n" - return "" - endif - let s:done_bundles .= name . "\n" - let list = [] - for dir in pathogen#split(&rtp) - if dir =~# '\<after$' - if name =~# '{}$' - let list += filter(pathogen#glob_directories(substitute(dir,'after$',name[0:-3],'').'*'.sep.'after'), '!pathogen#is_disabled(v:val[0:-7])') + [dir] - else - let list += [dir, substitute(dir, 'after$', '', '') . name . sep . 'after'] - endif - else - if name =~# '{}$' - let list += [dir] + filter(pathogen#glob_directories(dir.sep.name[0:-3].'*'), '!pathogen#is_disabled(v:val)') - else - let list += [dir . sep . name, dir] - endif - endif - endfor - let &rtp = pathogen#join(pathogen#uniq(list)) - return 1 -endfunction " }}}1 - -" Deprecated alias for pathogen#incubate(). -function! pathogen#runtime_append_all_bundles(...) abort " {{{1 - if a:0 - call s:warn('Change pathogen#runtime_append_all_bundles('.string(a:1).') to pathogen#incubate('.string(a:1.'/{}').')') - else - call s:warn('Change pathogen#runtime_append_all_bundles() to pathogen#incubate()') - endif - return call('pathogen#incubate', map(copy(a:000),'v:val . "/{}"')) -endfunction - -let s:done_bundles = '' -" }}}1 - -" Invoke :helptags on all non-$VIM doc directories in runtimepath. -function! pathogen#helptags() abort " {{{1 - let sep = pathogen#separator() - for glob in pathogen#split(&rtp) - for dir in split(glob(glob), "\n") - if (dir.sep)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir.sep.'doc') == 2 && !empty(filter(split(glob(dir.sep.'doc'.sep.'*'),"\n>"),'!isdirectory(v:val)')) && (!filereadable(dir.sep.'doc'.sep.'tags') || filewritable(dir.sep.'doc'.sep.'tags')) - silent! execute 'helptags' pathogen#fnameescape(dir.'/doc') - endif - endfor - endfor -endfunction " }}}1 - -command! -bar Helptags :call pathogen#helptags() - -" Execute the given command. This is basically a backdoor for --remote-expr. -function! pathogen#execute(...) abort " {{{1 - for command in a:000 - execute command - endfor - return '' -endfunction " }}}1 - -" Like findfile(), but hardcoded to use the runtimepath. -function! pathogen#runtime_findfile(file,count) abort "{{{1 - let rtp = pathogen#join(1,pathogen#split(&rtp)) - let file = findfile(a:file,rtp,a:count) - if file ==# '' - return '' - else - return fnamemodify(file,':p') - endif -endfunction " }}}1 - -" Backport of fnameescape(). -function! pathogen#fnameescape(string) abort " {{{1 - if exists('*fnameescape') - return fnameescape(a:string) - elseif a:string ==# '-' - return '\-' - else - return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','') - endif -endfunction " }}}1 - -if exists(':Vedit') - finish -endif - -let s:vopen_warning = 0 - -function! s:find(count,cmd,file,lcd) " {{{1 - let rtp = pathogen#join(1,pathogen#split(&runtimepath)) - let file = pathogen#runtime_findfile(a:file,a:count) - if file ==# '' - return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'" - endif - if !s:vopen_warning - let s:vopen_warning = 1 - let warning = '|echohl WarningMsg|echo "Install scriptease.vim to continue using :V'.a:cmd.'"|echohl NONE' - else - let warning = '' - endif - if a:lcd - let path = file[0:-strlen(a:file)-2] - execute 'lcd `=path`' - return a:cmd.' '.pathogen#fnameescape(a:file) . warning - else - return a:cmd.' '.pathogen#fnameescape(file) . warning - endif -endfunction " }}}1 - -function! s:Findcomplete(A,L,P) " {{{1 - let sep = pathogen#separator() - let cheats = { - \'a': 'autoload', - \'d': 'doc', - \'f': 'ftplugin', - \'i': 'indent', - \'p': 'plugin', - \'s': 'syntax'} - if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0]) - let request = cheats[a:A[0]].a:A[1:-1] - else - let request = a:A - endif - let pattern = substitute(request,'/\|\'.sep,'*'.sep,'g').'*' - let found = {} - for path in pathogen#split(&runtimepath) - let path = expand(path, ':p') - let matches = split(glob(path.sep.pattern),"\n") - call map(matches,'isdirectory(v:val) ? v:val.sep : v:val') - call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]') - for match in matches - let found[match] = 1 - endfor - endfor - return sort(keys(found)) -endfunction " }}}1 - -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(<count>,'edit<bang>',<q-args>,0) -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(<count>,'edit<bang>',<q-args>,0) -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(<count>,'edit<bang>',<q-args>,1) -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(<count>,'split',<q-args>,<bang>1) -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(<count>,'vsplit',<q-args>,<bang>1) -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(<count>,'tabedit',<q-args>,<bang>1) -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(<count>,'pedit',<q-args>,<bang>1) -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(<count>,'read',<q-args>,<bang>1) - -" vim:set et sw=2: diff --git a/vim/bundle/custom/colors/ambient.vim b/vim/bundle/custom/colors/ambient.vim @@ -1,58 +0,0 @@ -" Maintainer: Kevin Hamer <kevin@imarc.net> -" Version: 1.2 -" Last Change: Fri Aug 12 16:53:40 EDT 2011 - -" Changes: -" 1.2 lightened the blue slightly -" 1.1 lightened both orange-reds - -"" Based off the colors for Ambiance, the 2011 Ubuntu dark human theme. -"" Derived from Mustang by Henrique C. Alves (hcarvalhoalves@gmail.com) -"" Offers 256 color support. - -set background=light - -hi clear - -if exists("syntax_on") - syntax reset -endif - -let colors_name = "ambient" - -" Vim >= 7.0 specific colors -if version >= 700 - " hi CursorLine cterm=underline - hi CursorLine cterm=underline - hi ColorColumn ctermfg=15 ctermbg=7 cterm=none - hi MatchParen ctermfg=15 ctermbg=8 cterm=bold - hi Pmenu ctermfg=15 ctermbg=8 - hi PmenuSel ctermfg=8 ctermbg=15 -endif -" General colors -hi Cursor ctermbg=12 -hi Normal ctermfg=8 -hi NonText ctermfg=237 -hi LineNr ctermfg=239 -hi StatusLine ctermfg=8 ctermbg=15 -hi StatusLineNC ctermfg=246 -hi VertSplit ctermfg=234 -hi Folded ctermfg=80 -hi Title ctermfg=8 -hi Visual ctermfg=15 -hi SpecialKey ctermfg=239 - -" Syntax highlight -hi Comment ctermfg=6 -hi Boolean ctermfg=5 -hi String ctermfg=13 -hi Identifier ctermfg=13 -hi Function ctermfg=8 -hi Type ctermfg=10 -hi Statement ctermfg=11 -hi Keyword ctermfg=4 -hi Constant ctermfg=5 -hi Number ctermfg=13 -hi Special ctermfg=5 -hi PreProc ctermfg=7 -hi Todo ctermfg=15 ctermbg=8 diff --git a/vim/bundle/custom/colors/sandstorm.vim b/vim/bundle/custom/colors/sandstorm.vim @@ -1,69 +0,0 @@ -" -" Terminal setup. -" -set background=dark -if version > 580 - highlight clear - if exists("g:syntax_on") - syntax reset - endif -endif -let g:colors_name="sandstorm" - -" -" Highlighting definitions. -" -if has("gui_running") || &t_Co == 256 - - " - " Actual colours and styles. - " - highlight Comment term=NONE cterm=NONE ctermfg=0 ctermbg=NONE - highlight Constant term=NONE cterm=NONE ctermfg=226 ctermbg=NONE - highlight Cursor term=NONE cterm=NONE ctermfg=66 ctermbg=222 - highlight CursorLine term=NONE cterm=NONE ctermfg=NONE ctermbg=233 - highlight DiffAdd term=NONE cterm=NONE ctermfg=NONE ctermbg=22 - highlight DiffChange term=NONE cterm=NONE ctermfg=NONE ctermbg=17 - highlight DiffDelete term=NONE cterm=NONE ctermfg=NONE ctermbg=52 - highlight DiffText term=NONE cterm=NONE ctermfg=NONE ctermbg=19 - highlight FoldColumn term=NONE cterm=NONE ctermfg=180 ctermbg=237 - highlight Folded term=NONE cterm=NONE ctermfg=250 ctermbg=237 - - highlight Function term=NONE cterm=NONE ctermfg=136 ctermbg=NONE - highlight Identifier term=NONE cterm=NONE ctermfg=220 ctermbg=NONE - highlight Ignore term=NONE cterm=NONE ctermfg=240 ctermbg=NONE - highlight IncSearch term=NONE cterm=NONE ctermfg=11 ctermbg=3 - highlight ModeMsg term=NONE cterm=NONE ctermfg=178 ctermbg=NONE - highlight MoreMsg term=NONE cterm=NONE ctermfg=240 ctermbg=NONE - highlight NonText term=NONE cterm=NONE ctermfg=237 ctermbg=NONE - highlight Normal term=NONE cterm=NONE ctermfg=7 ctermbg=NONE - highlight Pmenu term=NONE cterm=NONE ctermfg=231 ctermbg=237 - highlight PreProc term=NONE cterm=NONE ctermfg=178 ctermbg=NONE - highlight Question term=NONE cterm=NONE ctermfg=186 ctermbg=NONE - highlight Search term=NONE cterm=NONE ctermfg=0 ctermbg=11 - highlight Special term=NONE cterm=NONE ctermfg=222 ctermbg=NONE - highlight SpecialKey term=NONE cterm=NONE ctermfg=184 ctermbg=NONE - highlight Statement term=NONE cterm=NONE ctermfg=11 ctermbg=NONE - highlight StatusLine term=NONE cterm=NONE ctermfg=231 ctermbg=237 - highlight StatusLineNC term=NONE cterm=NONE ctermfg=16 ctermbg=237 - highlight String term=NONE cterm=NONE ctermfg=166 ctermbg=NONE - highlight Todo term=NONE cterm=NONE ctermfg=196 ctermbg=226 - highlight Type term=NONE cterm=NONE ctermfg=3 ctermbg=NONE - highlight Underlined term=NONE cterm=NONE ctermfg=186 ctermbg=NONE - highlight VertSplit term=NONE cterm=NONE ctermfg=243 ctermbg=237 - highlight Visual term=NONE cterm=NONE ctermfg=11 ctermbg=237 - highlight WarningMsg term=NONE cterm=NONE ctermfg=209 ctermbg=NONE - - " - " General highlighting group links. - " - highlight! link Title Normal - highlight! link LineNr NonText - highlight! link TabLine StatusLineNC - highlight! link TabLineFill StatusLineNC - highlight! link TabLineSel StatusLine - highlight! link VertSplit StatusLineNC - highlight! link VimHiGroup VimGroup - -endif - diff --git a/vim/bundle/custom/colors/shadow.vim b/vim/bundle/custom/colors/shadow.vim @@ -1,60 +0,0 @@ -" Vim colorscheme -" -" Focus on statements and values - -set background=dark - -hi clear -if exists("syntax_on") - syntax reset -endif - -let colors_name = "shadow" - -" Window elements -hi Cursor ctermfg=0 ctermbg=15 -hi Folded ctermfg=8 ctermbg=0 -hi LineNr ctermfg=7 -hi NonText ctermfg=7 -hi Normal ctermfg=7 -hi StatusLine ctermfg=15 ctermbg=0 cterm=none -hi Visual ctermfg=15 ctermbg=0 - -" Main groups -hi Comment ctermfg=15 -hi Constant ctermfg=11 cterm=none -hi Statement ctermfg=11 cterm=none -hi StatementU ctermfg=11 cterm=underline -hi Keyword ctermfg=8 -hi Underlined cterm=underline -hi Error ctermfg=15 ctermbg=1 - -hi! link String Constant -hi! link Character Constant -hi! link Number Constant -hi! link Boolean Constant -hi! link Float Constant - -hi! link Identifier Normal -hi! link Function Statement - -hi! link Operator Keyword -hi! link Preproc Keyword -hi! link Type Keyword - -hi! link Special Keyword -hi! link Ignore Normal -hi! link Todo Error - -hi! link Title Normal - -hi! link phpDefine StatementU - -hi! link HtmlArg Attribute -hi! link HtmlSpecialChar Statement - -hi! link xmlTagName Keyword -hi! link xmlEndTag Keyword -hi! link xmlEntity Statement -hi! link xmlCData Comment -hi! link xmlAttrib Attribute diff --git a/vim/bundle/custom/ftplugin/header.vim b/vim/bundle/custom/ftplugin/header.vim @@ -1,28 +0,0 @@ -fu! AddFileHeader() - let s:line=1 - call append(0, "\/*") - call append(s:line, " * ===== SOURCE FILE ==========================================") - call append(s:line+1, " *") - call append(s:line+2, " * Filename: " .expand("%")) - call append(s:line+3, " * Author: Willy Goiffon") - call append(s:line+4, " *") - call append(s:line+5, " * Creation Date: " .strftime("%d-%m-%Y %H:%M:%S")) - call append(s:line+6, " * Last Modified: ") - call append(s:line+7, " * Compiler: " .$CC) - call append(s:line+8, " *") - call append(s:line+9, " * Description: ") - call append(s:line+10, " *") - call append(s:line+11," * ============================================================") - call append(s:line+12, " */") - call append(s:line+13, "") - unlet s:line -endfunc - -fu! UpdateFileHeader() - normal ma - exe "8g/Last Modified/s/Last Modified:.*/Last Modified: " .strftime("%c") - normal `a -endfunc - -au BufNewFile *.c exe "call AddFileHeader()" -au BufWritePre *.c exe "call UpdateFileHeader()" diff --git a/vim/bundle/custom/plugin/gpg.vim b/vim/bundle/custom/plugin/gpg.vim @@ -1,31 +0,0 @@ -" Transparent editing of gpg encrypted files. -augroup encrypted -au! -" First make sure nothing is written to ~/.viminfo while editing -" an encrypted file. -autocmd BufReadPre,FileReadPre *.gpg set viminfo= -" We don't want a swap file, as it writes unencrypted data to disk -autocmd BufReadPre,FileReadPre *.gpg set noswapfile -" Switch to binary mode to read the encrypted file -autocmd BufReadPre,FileReadPre *.gpg set bin -autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2 -autocmd BufReadPre,FileReadPre *.gpg let shsave=&sh -autocmd BufReadPre,FileReadPre *.gpg let &sh='sh' -autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2 -autocmd BufReadPost,FileReadPost *.gpg '[,']!gpg --decrypt --default-recipient-self 2> /dev/null -autocmd BufReadPost,FileReadPost *.gpg let &sh=shsave -" Switch to normal mode for editing -autocmd BufReadPost,FileReadPost *.gpg set nobin -autocmd BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save -autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r") -" Convert all text to encrypted text before writing -autocmd BufWritePre,FileWritePre *.gpg set bin -autocmd BufWritePre,FileWritePre *.gpg let shsave=&sh -autocmd BufWritePre,FileWritePre *.gpg let &sh='sh' -autocmd BufWritePre,FileWritePre *.gpg '[,']!gpg --encrypt --default-recipient-self 2>/dev/null -autocmd BufWritePre,FileWritePre *.gpg let &sh=shsave -" Undo the encryption so we are back in the normal text, directly -" after the file has been written. -autocmd BufWritePost,FileWritePost *.gpg silent u -autocmd BufWritePost,FileWritePost *.gpg set nobin -augroup END diff --git a/vim/bundle/matchit/.gitignore b/vim/bundle/matchit/.gitignore @@ -1,4 +0,0 @@ -# File types to be ignored by our git repositories - -.DS_Store -doc/tags diff --git a/vim/bundle/matchit/doc/matchit.txt b/vim/bundle/matchit/doc/matchit.txt @@ -1,406 +0,0 @@ -*matchit.txt* Extended "%" matching - -For instructions on installing this file, type - :help matchit-install -inside Vim. - -For Vim version 6.3. Last change: 2007 Aug 29 - - - VIM REFERENCE MANUAL by Benji Fisher - -*matchit* *matchit.vim* - -1. Extended matching with "%" |matchit-intro| -2. Activation |matchit-activate| -3. Configuration |matchit-configure| -4. Supporting a New Language |matchit-newlang| -5. Known Bugs and Limitations |matchit-bugs| - -The functionality mentioned here is a plugin, see |add-plugin|. -This plugin is only available if 'compatible' is not set. -You can avoid loading this plugin by setting the "loaded_matchit" variable -in your |vimrc| file: > - :let loaded_matchit = 1 - -{Vi does not have any of this} - -============================================================================== -1. Extended matching with "%" *matchit-intro* - - *matchit-%* -% Cycle forward through matching groups, such as "if", "else", "endif", - as specified by |b:match_words|. - - *g%* *v_g%* *o_g%* -g% Cycle backwards through matching groups, as specified by - |b:match_words|. For example, go from "if" to "endif" to "else". - - *[%* *v_[%* *o_[%* -[% Go to [count] previous unmatched group, as specified by - |b:match_words|. Similar to |[{|. - - *]%* *v_]%* *o_]%* -]% Go to [count] next unmatched group, as specified by - |b:match_words|. Similar to |]}|. - - *v_a%* -a% In Visual mode, select the matching group, as specified by - |b:match_words|, containing the cursor. Similar to |v_a[|. - A [count] is ignored, and only the first character of the closing - pattern is selected. - -In Vim, as in plain vi, the percent key, |%|, jumps the cursor from a brace, -bracket, or paren to its match. This can be configured with the 'matchpairs' -option. The matchit plugin extends this in several ways: - - You can match whole words, such as "if" and "endif", not just - single characters. You can also specify a |regular-expression|. - You can define groups with more than two words, such as "if", - "else", "endif". Banging on the "%" key will cycle from the "if" to - the first "else", the next "else", ..., the closing "endif", and back - to the opening "if". Nested structures are skipped. Using |g%| goes - in the reverse direction. - By default, words inside comments and strings are ignored, unless - the cursor is inside a comment or string when you type "%". If the - only thing you want to do is modify the behavior of "%" so that it - behaves this way, you do not have to define |b:match_words|, since the - script uses the 'matchpairs' option as well as this variable. - -See |matchit-details| for details on what the script does, and |b:match_words| -for how to specify matching patterns. - -MODES: *matchit-modes* *matchit-v_%* *matchit-o_%* - -Mostly, % and related motions (|g%| and |[%| and |]%|) work just like built-in -|motion| commands in |Operator-pending| and |Visual| modes. However, you -cannot make these motions |linewise| or |characterwise|, since the |:omap|s -that define them start with "v" in order to make the default behavior -inclusive. (See |o_v|.) In other words, "dV%" will not work. The -work-around is to go through Visual mode: "V%d" will work. - -LANGUAGES: *matchit-languages* - -Currently, the following languages are supported: Ada, ASP with VBS, Csh, -DTD, Entity, Essbase, Fortran, HTML, JSP (same as HTML), LaTeX, Lua, Pascal, -SGML, Shell, Tcsh, Vim, XML. Other languages may already have support via -the default |filetype-plugin|s in the standard vim distribution. - -To support a new language, see |matchit-newlang| below. - -DETAILS: *matchit-details* *matchit-parse* - -Here is an outline of what matchit.vim does each time you hit the "%" key. If -there are |backref|s in |b:match_words| then the first step is to produce a -version in which these back references have been eliminated; if there are no -|backref|s then this step is skipped. This step is called parsing. For -example, "\(foo\|bar\):end\1" is parsed to yield -"\(foo\|bar\):end\(foo\|bar\)". This can get tricky, especially if there are -nested groups. If debugging is turned on, the parsed version is saved as -|b:match_pat|. - - *matchit-choose* -Next, the script looks for a word on the current line that matches the pattern -just constructed. It includes the patterns from the 'matchpairs' option. -The goal is to do what you expect, which turns out to be a little complicated. -The script follows these rules: - - Insist on a match that ends on or after the cursor. - Prefer a match that includes the cursor position (that is, one that - starts on or before the cursor). - Prefer a match that starts as close to the cursor as possible. - If more than one pattern in |b:match_words| matches, choose the one - that is listed first. - -Examples: - - Suppose you > - :let b:match_words = '<:>,<tag>:</tag>' -< and hit "%" with the cursor on or before the "<" in "a <tag> is born". - The pattern '<' comes first, so it is preferred over '<tag>', which - also matches. If the cursor is on the "t", however, then '<tag>' is - preferred, because this matches a bit of text containing the cursor. - If the two groups of patterns were reversed then '<' would never be - preferred. - - Suppose you > - :let b:match_words = 'if:end if' -< (Note the space!) and hit "%" with the cursor at the end of "end if". - Then "if" matches, which is probably not what you want, but if the - cursor starts on the "end " then "end if" is chosen. (You can avoid - this problem by using a more complicated pattern.) - -If there is no match, the cursor does not move. (Before version 1.13 of the -script, it would fall back on the usual behavior of |%|). If debugging is -turned on, the matched bit of text is saved as |b:match_match| and the cursor -column of the start of the match is saved as |b:match_col|. - -Next, the script looks through |b:match_words| (original and parsed versions) -for the group and pattern that match. If debugging is turned on, the group is -saved as |b:match_ini| (the first pattern) and |b:match_tail| (the rest). If -there are |backref|s then, in addition, the matching pattern is saved as -|b:match_word| and a table of translations is saved as |b:match_table|. If -there are |backref|s, these are determined from the matching pattern and -|b:match_match| and substituted into each pattern in the matching group. - -The script decides whether to search forwards or backwards and chooses -arguments for the |searchpair()| function. Then, the cursor is moved to the -start of the match, and |searchpair()| is called. By default, matching -structures inside strings and comments are ignored. This can be changed by -setting |b:match_skip|. - -============================================================================== -2. Activation *matchit-activate* - -You can use this script as a plugin, by copying it to your plugin directory. -See |add-global-plugin| for instructions. You can also add a line to your -|vimrc| file, such as > - :source $VIMRUNTIME/macros/matchit.vim -or > - :runtime macros/matchit.vim -Either way, the script should start working the next time you start up Vim. - -(Earlier versions of the script did nothing unless a |buffer-variable| named -|b:match_words| was defined. Even earlier versions contained autocommands -that set this variable for various file types. Now, |b:match_words| is -defined in many of the default |filetype-plugin|s instead.) - -For a new language, you can add autocommands to the script or to your vimrc -file, but the recommended method is to add a line such as > - let b:match_words = '\<foo\>:\<bar\>' -to the |filetype-plugin| for your language. See |b:match_words| below for how -this variable is interpreted. - -TROUBLESHOOTING *matchit-troubleshoot* - -The script should work in most installations of Vim. It may not work if Vim -was compiled with a minimal feature set, for example if the |+syntax| option -was not enabled. If your Vim has support for syntax compiled in, but you do -not have |syntax| highlighting turned on, matchit.vim should work, but it may -fail to skip matching groups in comments and strings. If the |filetype| -mechanism is turned off, the |b:match_words| variable will probably not be -defined automatically. - -============================================================================== -3. Configuration *matchit-configure* - -There are several variables that govern the behavior of matchit.vim. Note -that these are variables local to the buffer, not options, so use |:let| to -define them, not |:set|. Some of these variables have values that matter; for -others, it only matters whether the variable has been defined. All of these -can be defined in the |filetype-plugin| or autocommand that defines -|b:match_words| or "on the fly." - -The main variable is |b:match_words|. It is described in the section below on -supporting a new language. - - *MatchError* *matchit-hl* *matchit-highlight* -MatchError is the highlight group for error messages from the script. By -default, it is linked to WarningMsg. If you do not want to be bothered by -error messages, you can define this to be something invisible. For example, -if you use the GUI version of Vim and your command line is normally white, you -can do > - :hi MatchError guifg=white guibg=white -< - *b:match_ignorecase* -If you > - :let b:match_ignorecase = 1 -then matchit.vim acts as if 'ignorecase' is set: for example, "end" and "END" -are equivalent. If you > - :let b:match_ignorecase = 0 -then matchit.vim treats "end" and "END" differently. (There will be no -b:match_infercase option unless someone requests it.) - - *b:match_debug* -Define b:match_debug if you want debugging information to be saved. See -|matchit-debug|, below. - - *b:match_skip* -If b:match_skip is defined, it is passed as the skip argument to -|searchpair()|. This controls when matching structures are skipped, or -ignored. By default, they are ignored inside comments and strings, as -determined by the |syntax| mechanism. (If syntax highlighting is turned off, -nothing is skipped.) You can set b:match_skip to a string, which evaluates to -a non-zero, numerical value if the match is to be skipped or zero if the match -should not be skipped. In addition, the following special values are -supported by matchit.vim: - s:foo becomes (current syntax item) =~ foo - S:foo becomes (current syntax item) !~ foo - r:foo becomes (line before cursor) =~ foo - R:foo becomes (line before cursor) !~ foo -(The "s" is meant to suggest "syntax", and the "r" is meant to suggest -"regular expression".) - -Examples: - - You can get the default behavior with > - :let b:match_skip = 's:comment\|string' -< - If you want to skip matching structures unless they are at the start - of the line (ignoring whitespace) then you can > - :let b:match_skip = 'R:^\s*' -< Do not do this if strings or comments can span several lines, since - the normal syntax checking will not be done if you set b:match_skip. - - In LaTeX, since "%" is used as the comment character, you can > - :let b:match_skip = 'r:%' -< Unfortunately, this will skip anything after "\%", an escaped "%". To - allow for this, and also "\\%" (an excaped backslash followed by the - comment character) you can > - :let b:match_skip = 'r:\(^\|[^\\]\)\(\\\\\)*%' -< - See the $VIMRUNTIME/ftplugin/vim.vim for an example that uses both - syntax and a regular expression. - -============================================================================== -4. Supporting a New Language *matchit-newlang* - *b:match_words* -In order for matchit.vim to support a new language, you must define a suitable -pattern for |b:match_words|. You may also want to set some of the -|matchit-configure| variables, as described above. If your language has a -complicated syntax, or many keywords, you will need to know something about -Vim's |regular-expression|s. - -The format for |b:match_words| is similar to that of the 'matchpairs' option: -it is a comma (,)-separated list of groups; each group is a colon(:)-separated -list of patterns (regular expressions). Commas and backslashes that are part -of a pattern should be escaped with backslashes ('\:' and '\,'). It is OK to -have only one group; the effect is undefined if a group has only one pattern. -A simple example is > - :let b:match_words = '\<if\>:\<endif\>,' - \ . '\<while\>:\<continue\>:\<break\>:\<endwhile\>' -(In Vim regular expressions, |\<| and |\>| denote word boundaries. Thus "if" -matches the end of "endif" but "\<if\>" does not.) Then banging on the "%" -key will bounce the cursor between "if" and the matching "endif"; and from -"while" to any matching "continue" or "break", then to the matching "endwhile" -and back to the "while". It is almost always easier to use |literal-string|s -(single quotes) as above: '\<if\>' rather than "\\<if\\>" and so on. - -Exception: If the ":" character does not appear in b:match_words, then it is -treated as an expression to be evaluated. For example, > - :let b:match_words = 'GetMatchWords()' -allows you to define a function. This can return a different string depending -on the current syntax, for example. - -Once you have defined the appropriate value of |b:match_words|, you will -probably want to have this set automatically each time you edit the -appropriate file type. The recommended way to do this is by adding the -definition to a |filetype-plugin| file. - -Tips: Be careful that your initial pattern does not match your final pattern. -See the example above for the use of word-boundary expressions. It is usually -better to use ".\{-}" (as many as necessary) instead of ".*" (as many as -possible). See |\{-|. For example, in the string "<tag>label</tag>", "<.*>" -matches the whole string whereas "<.\{-}>" and "<[^>]*>" match "<tag>" and -"</tag>". - - *matchit-spaces* *matchit-s:notend* -If "if" is to be paired with "end if" (Note the space!) then word boundaries -are not enough. Instead, define a regular expression s:notend that will match -anything but "end" and use it as follows: > - :let s:notend = '\%(\<end\s\+\)\@<!' - :let b:match_words = s:notend . '\<if\>:\<end\s\+if\>' -< *matchit-s:sol* -This is a simplified version of what is done for Ada. The s:notend is a -|script-variable|. Similarly, you may want to define a start-of-line regular -expression > - :let s:sol = '\%(^\|;\)\s*' -if keywords are only recognized after the start of a line or after a -semicolon (;), with optional white space. - - *matchit-backref* *matchit-\1* -In any group, the expressions |\1|, |\2|, ..., |\9| refer to parts of the -INITIAL pattern enclosed in |\(|escaped parentheses|\)|. These are referred -to as back references, or backrefs. For example, > - :let b:match_words = '\<b\(o\+\)\>:\(h\)\1\>' -means that "bo" pairs with "ho" and "boo" pairs with "hoo" and so on. Note -that "\1" does not refer to the "\(h\)" in this example. If you have -"\(nested \(parentheses\)\) then "\d" refers to the d-th "\(" and everything -up to and including the matching "\)": in "\(nested\(parentheses\)\)", "\1" -refers to everything and "\2" refers to "\(parentheses\)". If you use a -variable such as |s:notend| or |s:sol| in the previous paragraph then remember -to count any "\(" patterns in this variable. You do not have to count groups -defined by |\%(\)|. - -It should be possible to resolve back references from any pattern in the -group. For example, > - :let b:match_words = '\(foo\)\(bar\):more\1:and\2:end\1\2' -would not work because "\2" cannot be determined from "morefoo" and "\1" -cannot be determined from "andbar". On the other hand, > - :let b:match_words = '\(\(foo\)\(bar\)\):\3\2:end\1' -should work (and have the same effect as "foobar:barfoo:endfoobar"), although -this has not been thoroughly tested. - -You can use |zero-width| patterns such as |\@<=| and |\zs|. (The latter has -not been thouroughly tested in matchit.vim.) For example, if the keyword "if" -must occur at the start of the line, with optional white space, you might use -the pattern "\(^\s*\)\@<=if" so that the cursor will end on the "i" instead of -at the start of the line. For another example, if HTML had only one tag then -one could > - :let b:match_words = '<:>,<\@<=tag>:<\@<=/tag>' -so that "%" can bounce between matching "<" and ">" pairs or (starting on -"tag" or "/tag") between matching tags. Without the |\@<=|, the script would -bounce from "tag" to the "<" in "</tag>", and another "%" would not take you -back to where you started. - -DEBUGGING *matchit-debug* *:MatchDebug* - -If you are having trouble figuring out the appropriate definition of -|b:match_words| then you can take advantage of the same information I use when -debugging the script. This is especially true if you are not sure whether -your patterns or my script are at fault! To make this more convenient, I have -made the command :MatchDebug, which defines the variable |b:match_debug| and -creates a Matchit menu. This menu makes it convenient to check the values of -the variables described below. You will probably also want to read -|matchit-details| above. - -Defining the variable |b:match_debug| causes the script to set the following -variables, each time you hit the "%" key. Several of these are only defined -if |b:match_words| includes |backref|s. - - *b:match_pat* -The b:match_pat variable is set to |b:match_words| with |backref|s parsed. - *b:match_match* -The b:match_match variable is set to the bit of text that is recognized as a -match. - *b:match_col* -The b:match_col variable is set to the cursor column of the start of the -matching text. - *b:match_wholeBR* -The b:match_wholeBR variable is set to the comma-separated group of patterns -that matches, with |backref|s unparsed. - *b:match_iniBR* -The b:match_iniBR variable is set to the first pattern in |b:match_wholeBR|. - *b:match_ini* -The b:match_ini variable is set to the first pattern in |b:match_wholeBR|, -with |backref|s resolved from |b:match_match|. - *b:match_tail* -The b:match_tail variable is set to the remaining patterns in -|b:match_wholeBR|, with |backref|s resolved from |b:match_match|. - *b:match_word* -The b:match_word variable is set to the pattern from |b:match_wholeBR| that -matches |b:match_match|. - *b:match_table* -The back reference '\'.d refers to the same thing as '\'.b:match_table[d] in -|b:match_word|. - -============================================================================== -5. Known Bugs and Limitations *matchit-bugs* - -Just because I know about a bug does not mean that it is on my todo list. I -try to respond to reports of bugs that cause real problems. If it does not -cause serious problems, or if there is a work-around, a bug may sit there for -a while. Moral: if a bug (known or not) bothers you, let me know. - -The various |:vmap|s defined in the script (%, |g%|, |[%|, |]%|, |a%|) may -have undesired effects in Select mode |Select-mode-mapping|. At least, if you -want to replace the selection with any character in "ag%[]" there will be a -pause of |'updatetime'| first. - -It would be nice if "\0" were recognized as the entire pattern. That is, it -would be nice if "foo:\end\0" had the same effect as "\(foo\):\end\1". I may -try to implement this in a future version. (This is not so easy to arrange as -you might think!) - -============================================================================== -vim:tw=78:fo=tcq2: diff --git a/vim/bundle/matchit/plugin/matchit.vim b/vim/bundle/matchit/plugin/matchit.vim @@ -1,812 +0,0 @@ -" matchit.vim: (global plugin) Extended "%" matching -" Last Change: Fri Jan 25 10:00 AM 2008 EST -" Maintainer: Benji Fisher PhD <benji@member.AMS.org> -" Version: 1.13.2, for Vim 6.3+ -" URL: http://www.vim.org/script.php?script_id=39 - -" Documentation: -" The documentation is in a separate file, matchit.txt . - -" Credits: -" Vim editor by Bram Moolenaar (Thanks, Bram!) -" Original script and design by Raul Segura Acevedo -" Support for comments by Douglas Potts -" Support for back references and other improvements by Benji Fisher -" Support for many languages by Johannes Zellner -" Suggestions for improvement, bug reports, and support for additional -" languages by Jordi-Albert Batalla, Neil Bird, Servatius Brandt, Mark -" Collett, Stephen Wall, Dany St-Amant, Yuheng Xie, and Johannes Zellner. - -" Debugging: -" If you'd like to try the built-in debugging commands... -" :MatchDebug to activate debugging for the current buffer -" This saves the values of several key script variables as buffer-local -" variables. See the MatchDebug() function, below, for details. - -" TODO: I should think about multi-line patterns for b:match_words. -" This would require an option: how many lines to scan (default 1). -" This would be useful for Python, maybe also for *ML. -" TODO: Maybe I should add a menu so that people will actually use some of -" the features that I have implemented. -" TODO: Eliminate the MultiMatch function. Add yet another argument to -" Match_wrapper() instead. -" TODO: Allow :let b:match_words = '\(\(foo\)\(bar\)\):\3\2:end\1' -" TODO: Make backrefs safer by using '\V' (very no-magic). -" TODO: Add a level of indirection, so that custom % scripts can use my -" work but extend it. - -" allow user to prevent loading -" and prevent duplicate loading -if exists("loaded_matchit") || &cp - finish -endif -let loaded_matchit = 1 -let s:last_mps = "" -let s:last_words = ":" - -let s:save_cpo = &cpo -set cpo&vim - -nnoremap <silent> % :<C-U>call <SID>Match_wrapper('',1,'n') <CR> -nnoremap <silent> g% :<C-U>call <SID>Match_wrapper('',0,'n') <CR> -vnoremap <silent> % :<C-U>call <SID>Match_wrapper('',1,'v') <CR>m'gv`` -vnoremap <silent> g% :<C-U>call <SID>Match_wrapper('',0,'v') <CR>m'gv`` -onoremap <silent> % v:<C-U>call <SID>Match_wrapper('',1,'o') <CR> -onoremap <silent> g% v:<C-U>call <SID>Match_wrapper('',0,'o') <CR> - -" Analogues of [{ and ]} using matching patterns: -nnoremap <silent> [% :<C-U>call <SID>MultiMatch("bW", "n") <CR> -nnoremap <silent> ]% :<C-U>call <SID>MultiMatch("W", "n") <CR> -vmap [% <Esc>[%m'gv`` -vmap ]% <Esc>]%m'gv`` -" vnoremap <silent> [% :<C-U>call <SID>MultiMatch("bW", "v") <CR>m'gv`` -" vnoremap <silent> ]% :<C-U>call <SID>MultiMatch("W", "v") <CR>m'gv`` -onoremap <silent> [% v:<C-U>call <SID>MultiMatch("bW", "o") <CR> -onoremap <silent> ]% v:<C-U>call <SID>MultiMatch("W", "o") <CR> - -" text object: -vmap a% <Esc>[%v]% - -" Auto-complete mappings: (not yet "ready for prime time") -" TODO Read :help write-plugin for the "right" way to let the user -" specify a key binding. -" let g:match_auto = '<C-]>' -" let g:match_autoCR = '<C-CR>' -" if exists("g:match_auto") -" execute "inoremap " . g:match_auto . ' x<Esc>"=<SID>Autocomplete()<CR>Pls' -" endif -" if exists("g:match_autoCR") -" execute "inoremap " . g:match_autoCR . ' <CR><C-R>=<SID>Autocomplete()<CR>' -" endif -" if exists("g:match_gthhoh") -" execute "inoremap " . g:match_gthhoh . ' <C-O>:call <SID>Gthhoh()<CR>' -" endif " gthhoh = "Get the heck out of here!" - -let s:notslash = '\\\@<!\%(\\\\\)*' - -function! s:Match_wrapper(word, forward, mode) range - " In s:CleanUp(), :execute "set" restore_options . - let restore_options = (&ic ? " " : " no") . "ignorecase" - if exists("b:match_ignorecase") - let &ignorecase = b:match_ignorecase - endif - let restore_options = " ve=" . &ve . restore_options - set ve= - " If this function was called from Visual mode, make sure that the cursor - " is at the correct end of the Visual range: - if a:mode == "v" - execute "normal! gv\<Esc>" - endif - " In s:CleanUp(), we may need to check whether the cursor moved forward. - let startline = line(".") - let startcol = col(".") - " Use default behavior if called with a count. - if v:count - exe "normal! " . v:count . "%" - return s:CleanUp(restore_options, a:mode, startline, startcol) - end - - " First step: if not already done, set the script variables - " s:do_BR flag for whether there are backrefs - " s:pat parsed version of b:match_words - " s:all regexp based on s:pat and the default groups - " - if !exists("b:match_words") || b:match_words == "" - let match_words = "" - " Allow b:match_words = "GetVimMatchWords()" . - elseif b:match_words =~ ":" - let match_words = b:match_words - else - execute "let match_words =" b:match_words - endif -" Thanks to Preben "Peppe" Guldberg and Bram Moolenaar for this suggestion! - if (match_words != s:last_words) || (&mps != s:last_mps) || - \ exists("b:match_debug") - let s:last_words = match_words - let s:last_mps = &mps - " The next several lines were here before - " BF started messing with this script. - " quote the special chars in 'matchpairs', replace [,:] with \| and then - " append the builtin pairs (/*, */, #if, #ifdef, #else, #elif, #endif) - " let default = substitute(escape(&mps, '[$^.*~\\/?]'), '[,:]\+', - " \ '\\|', 'g').'\|\/\*\|\*\/\|#if\>\|#ifdef\>\|#else\>\|#elif\>\|#endif\>' - let default = escape(&mps, '[$^.*~\\/?]') . (strlen(&mps) ? "," : "") . - \ '\/\*:\*\/,#if\%(def\)\=:#else\>:#elif\>:#endif\>' - " s:all = pattern with all the keywords - let match_words = match_words . (strlen(match_words) ? "," : "") . default - if match_words !~ s:notslash . '\\\d' - let s:do_BR = 0 - let s:pat = match_words - else - let s:do_BR = 1 - let s:pat = s:ParseWords(match_words) - endif - let s:all = substitute(s:pat, s:notslash . '\zs[,:]\+', '\\|', 'g') - let s:all = '\%(' . s:all . '\)' - " let s:all = '\%(' . substitute(s:all, '\\\ze[,:]', '', 'g') . '\)' - if exists("b:match_debug") - let b:match_pat = s:pat - endif - endif - - " Second step: set the following local variables: - " matchline = line on which the cursor started - " curcol = number of characters before match - " prefix = regexp for start of line to start of match - " suffix = regexp for end of match to end of line - " Require match to end on or after the cursor and prefer it to - " start on or before the cursor. - let matchline = getline(startline) - if a:word != '' - " word given - if a:word !~ s:all - echohl WarningMsg|echo 'Missing rule for word:"'.a:word.'"'|echohl NONE - return s:CleanUp(restore_options, a:mode, startline, startcol) - endif - let matchline = a:word - let curcol = 0 - let prefix = '^\%(' - let suffix = '\)$' - " Now the case when "word" is not given - else " Find the match that ends on or after the cursor and set curcol. - let regexp = s:Wholematch(matchline, s:all, startcol-1) - let curcol = match(matchline, regexp) - " If there is no match, give up. - if curcol == -1 - return s:CleanUp(restore_options, a:mode, startline, startcol) - endif - let endcol = matchend(matchline, regexp) - let suf = strlen(matchline) - endcol - let prefix = (curcol ? '^.*\%' . (curcol + 1) . 'c\%(' : '^\%(') - let suffix = (suf ? '\)\%' . (endcol + 1) . 'c.*$' : '\)$') - endif - if exists("b:match_debug") - let b:match_match = matchstr(matchline, regexp) - let b:match_col = curcol+1 - endif - - " Third step: Find the group and single word that match, and the original - " (backref) versions of these. Then, resolve the backrefs. - " Set the following local variable: - " group = colon-separated list of patterns, one of which matches - " = ini:mid:fin or ini:fin - " - " Reconstruct the version with unresolved backrefs. - let patBR = substitute(match_words.',', - \ s:notslash.'\zs[,:]*,[,:]*', ',', 'g') - let patBR = substitute(patBR, s:notslash.'\zs:\{2,}', ':', 'g') - " Now, set group and groupBR to the matching group: 'if:endif' or - " 'while:endwhile' or whatever. A bit of a kluge: s:Choose() returns - " group . "," . groupBR, and we pick it apart. - let group = s:Choose(s:pat, matchline, ",", ":", prefix, suffix, patBR) - let i = matchend(group, s:notslash . ",") - let groupBR = strpart(group, i) - let group = strpart(group, 0, i-1) - " Now, matchline =~ prefix . substitute(group,':','\|','g') . suffix - if s:do_BR " Do the hard part: resolve those backrefs! - let group = s:InsertRefs(groupBR, prefix, group, suffix, matchline) - endif - if exists("b:match_debug") - let b:match_wholeBR = groupBR - let i = matchend(groupBR, s:notslash . ":") - let b:match_iniBR = strpart(groupBR, 0, i-1) - endif - - " Fourth step: Set the arguments for searchpair(). - let i = matchend(group, s:notslash . ":") - let j = matchend(group, '.*' . s:notslash . ":") - let ini = strpart(group, 0, i-1) - let mid = substitute(strpart(group, i,j-i-1), s:notslash.'\zs:', '\\|', 'g') - let fin = strpart(group, j) - "Un-escape the remaining , and : characters. - let ini = substitute(ini, s:notslash . '\zs\\\(:\|,\)', '\1', 'g') - let mid = substitute(mid, s:notslash . '\zs\\\(:\|,\)', '\1', 'g') - let fin = substitute(fin, s:notslash . '\zs\\\(:\|,\)', '\1', 'g') - " searchpair() requires that these patterns avoid \(\) groups. - let ini = substitute(ini, s:notslash . '\zs\\(', '\\%(', 'g') - let mid = substitute(mid, s:notslash . '\zs\\(', '\\%(', 'g') - let fin = substitute(fin, s:notslash . '\zs\\(', '\\%(', 'g') - " Set mid. This is optimized for readability, not micro-efficiency! - if a:forward && matchline =~ prefix . fin . suffix - \ || !a:forward && matchline =~ prefix . ini . suffix - let mid = "" - endif - " Set flag. This is optimized for readability, not micro-efficiency! - if a:forward && matchline =~ prefix . fin . suffix - \ || !a:forward && matchline !~ prefix . ini . suffix - let flag = "bW" - else - let flag = "W" - endif - " Set skip. - if exists("b:match_skip") - let skip = b:match_skip - elseif exists("b:match_comment") " backwards compatibility and testing! - let skip = "r:" . b:match_comment - else - let skip = 's:comment\|string' - endif - let skip = s:ParseSkip(skip) - if exists("b:match_debug") - let b:match_ini = ini - let b:match_tail = (strlen(mid) ? mid.'\|' : '') . fin - endif - - " Fifth step: actually start moving the cursor and call searchpair(). - " Later, :execute restore_cursor to get to the original screen. - let restore_cursor = virtcol(".") . "|" - normal! g0 - let restore_cursor = line(".") . "G" . virtcol(".") . "|zs" . restore_cursor - normal! H - let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor - execute restore_cursor - call cursor(0, curcol + 1) - " normal! 0 - " if curcol - " execute "normal!" . curcol . "l" - " endif - if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on")) - let skip = "0" - else - execute "if " . skip . "| let skip = '0' | endif" - endif - let sp_return = searchpair(ini, mid, fin, flag, skip) - let final_position = "call cursor(" . line(".") . "," . col(".") . ")" - " Restore cursor position and original screen. - execute restore_cursor - normal! m' - if sp_return > 0 - execute final_position - endif - return s:CleanUp(restore_options, a:mode, startline, startcol, mid.'\|'.fin) -endfun - -" Restore options and do some special handling for Operator-pending mode. -" The optional argument is the tail of the matching group. -fun! s:CleanUp(options, mode, startline, startcol, ...) - execute "set" a:options - " Open folds, if appropriate. - if a:mode != "o" - if &foldopen =~ "percent" - normal! zv - endif - " In Operator-pending mode, we want to include the whole match - " (for example, d%). - " This is only a problem if we end up moving in the forward direction. - elseif (a:startline < line(".")) || - \ (a:startline == line(".") && a:startcol < col(".")) - if a:0 - " Check whether the match is a single character. If not, move to the - " end of the match. - let matchline = getline(".") - let currcol = col(".") - let regexp = s:Wholematch(matchline, a:1, currcol-1) - let endcol = matchend(matchline, regexp) - if endcol > currcol " This is NOT off by one! - execute "normal!" . (endcol - currcol) . "l" - endif - endif " a:0 - endif " a:mode != "o" && etc. - return 0 -endfun - -" Example (simplified HTML patterns): if -" a:groupBR = '<\(\k\+\)>:</\1>' -" a:prefix = '^.\{3}\(' -" a:group = '<\(\k\+\)>:</\(\k\+\)>' -" a:suffix = '\).\{2}$' -" a:matchline = "123<tag>12" or "123</tag>12" -" then extract "tag" from a:matchline and return "<tag>:</tag>" . -fun! s:InsertRefs(groupBR, prefix, group, suffix, matchline) - if a:matchline !~ a:prefix . - \ substitute(a:group, s:notslash . '\zs:', '\\|', 'g') . a:suffix - return a:group - endif - let i = matchend(a:groupBR, s:notslash . ':') - let ini = strpart(a:groupBR, 0, i-1) - let tailBR = strpart(a:groupBR, i) - let word = s:Choose(a:group, a:matchline, ":", "", a:prefix, a:suffix, - \ a:groupBR) - let i = matchend(word, s:notslash . ":") - let wordBR = strpart(word, i) - let word = strpart(word, 0, i-1) - " Now, a:matchline =~ a:prefix . word . a:suffix - if wordBR != ini - let table = s:Resolve(ini, wordBR, "table") - else - " let table = "----------" - let table = "" - let d = 0 - while d < 10 - if tailBR =~ s:notslash . '\\' . d - " let table[d] = d - let table = table . d - else - let table = table . "-" - endif - let d = d + 1 - endwhile - endif - let d = 9 - while d - if table[d] != "-" - let backref = substitute(a:matchline, a:prefix.word.a:suffix, - \ '\'.table[d], "") - " Are there any other characters that should be escaped? - let backref = escape(backref, '*,:') - execute s:Ref(ini, d, "start", "len") - let ini = strpart(ini, 0, start) . backref . strpart(ini, start+len) - let tailBR = substitute(tailBR, s:notslash . '\zs\\' . d, - \ escape(backref, '\\'), 'g') - endif - let d = d-1 - endwhile - if exists("b:match_debug") - if s:do_BR - let b:match_table = table - let b:match_word = word - else - let b:match_table = "" - let b:match_word = "" - endif - endif - return ini . ":" . tailBR -endfun - -" Input a comma-separated list of groups with backrefs, such as -" a:groups = '\(foo\):end\1,\(bar\):end\1' -" and return a comma-separated list of groups with backrefs replaced: -" return '\(foo\):end\(foo\),\(bar\):end\(bar\)' -fun! s:ParseWords(groups) - let groups = substitute(a:groups.",", s:notslash.'\zs[,:]*,[,:]*', ',', 'g') - let groups = substitute(groups, s:notslash . '\zs:\{2,}', ':', 'g') - let parsed = "" - while groups =~ '[^,:]' - let i = matchend(groups, s:notslash . ':') - let j = matchend(groups, s:notslash . ',') - let ini = strpart(groups, 0, i-1) - let tail = strpart(groups, i, j-i-1) . ":" - let groups = strpart(groups, j) - let parsed = parsed . ini - let i = matchend(tail, s:notslash . ':') - while i != -1 - " In 'if:else:endif', ini='if' and word='else' and then word='endif'. - let word = strpart(tail, 0, i-1) - let tail = strpart(tail, i) - let i = matchend(tail, s:notslash . ':') - let parsed = parsed . ":" . s:Resolve(ini, word, "word") - endwhile " Now, tail has been used up. - let parsed = parsed . "," - endwhile " groups =~ '[^,:]' - let parsed = substitute(parsed, ',$', '', '') - return parsed -endfun - -" TODO I think this can be simplified and/or made more efficient. -" TODO What should I do if a:start is out of range? -" Return a regexp that matches all of a:string, such that -" matchstr(a:string, regexp) represents the match for a:pat that starts -" as close to a:start as possible, before being preferred to after, and -" ends after a:start . -" Usage: -" let regexp = s:Wholematch(getline("."), 'foo\|bar', col(".")-1) -" let i = match(getline("."), regexp) -" let j = matchend(getline("."), regexp) -" let match = matchstr(getline("."), regexp) -fun! s:Wholematch(string, pat, start) - let group = '\%(' . a:pat . '\)' - let prefix = (a:start ? '\(^.*\%<' . (a:start + 2) . 'c\)\zs' : '^') - let len = strlen(a:string) - let suffix = (a:start+1 < len ? '\(\%>'.(a:start+1).'c.*$\)\@=' : '$') - if a:string !~ prefix . group . suffix - let prefix = '' - endif - return prefix . group . suffix -endfun - -" No extra arguments: s:Ref(string, d) will -" find the d'th occurrence of '\(' and return it, along with everything up -" to and including the matching '\)'. -" One argument: s:Ref(string, d, "start") returns the index of the start -" of the d'th '\(' and any other argument returns the length of the group. -" Two arguments: s:Ref(string, d, "foo", "bar") returns a string to be -" executed, having the effect of -" :let foo = s:Ref(string, d, "start") -" :let bar = s:Ref(string, d, "len") -fun! s:Ref(string, d, ...) - let len = strlen(a:string) - if a:d == 0 - let start = 0 - else - let cnt = a:d - let match = a:string - while cnt - let cnt = cnt - 1 - let index = matchend(match, s:notslash . '\\(') - if index == -1 - return "" - endif - let match = strpart(match, index) - endwhile - let start = len - strlen(match) - if a:0 == 1 && a:1 == "start" - return start - 2 - endif - let cnt = 1 - while cnt - let index = matchend(match, s:notslash . '\\(\|\\)') - 1 - if index == -2 - return "" - endif - " Increment if an open, decrement if a ')': - let cnt = cnt + (match[index]=="(" ? 1 : -1) " ')' - " let cnt = stridx('0(', match[index]) + cnt - let match = strpart(match, index+1) - endwhile - let start = start - 2 - let len = len - start - strlen(match) - endif - if a:0 == 1 - return len - elseif a:0 == 2 - return "let " . a:1 . "=" . start . "| let " . a:2 . "=" . len - else - return strpart(a:string, start, len) - endif -endfun - -" Count the number of disjoint copies of pattern in string. -" If the pattern is a literal string and contains no '0' or '1' characters -" then s:Count(string, pattern, '0', '1') should be faster than -" s:Count(string, pattern). -fun! s:Count(string, pattern, ...) - let pat = escape(a:pattern, '\\') - if a:0 > 1 - let foo = substitute(a:string, '[^'.a:pattern.']', "a:1", "g") - let foo = substitute(a:string, pat, a:2, "g") - let foo = substitute(foo, '[^' . a:2 . ']', "", "g") - return strlen(foo) - endif - let result = 0 - let foo = a:string - let index = matchend(foo, pat) - while index != -1 - let result = result + 1 - let foo = strpart(foo, index) - let index = matchend(foo, pat) - endwhile - return result -endfun - -" s:Resolve('\(a\)\(b\)', '\(c\)\2\1\1\2') should return table.word, where -" word = '\(c\)\(b\)\(a\)\3\2' and table = '-32-------'. That is, the first -" '\1' in target is replaced by '\(a\)' in word, table[1] = 3, and this -" indicates that all other instances of '\1' in target are to be replaced -" by '\3'. The hard part is dealing with nesting... -" Note that ":" is an illegal character for source and target, -" unless it is preceded by "\". -fun! s:Resolve(source, target, output) - let word = a:target - let i = matchend(word, s:notslash . '\\\d') - 1 - let table = "----------" - while i != -2 " There are back references to be replaced. - let d = word[i] - let backref = s:Ref(a:source, d) - " The idea is to replace '\d' with backref. Before we do this, - " replace any \(\) groups in backref with :1, :2, ... if they - " correspond to the first, second, ... group already inserted - " into backref. Later, replace :1 with \1 and so on. The group - " number w+b within backref corresponds to the group number - " s within a:source. - " w = number of '\(' in word before the current one - let w = s:Count( - \ substitute(strpart(word, 0, i-1), '\\\\', '', 'g'), '\(', '1') - let b = 1 " number of the current '\(' in backref - let s = d " number of the current '\(' in a:source - while b <= s:Count(substitute(backref, '\\\\', '', 'g'), '\(', '1') - \ && s < 10 - if table[s] == "-" - if w + b < 10 - " let table[s] = w + b - let table = strpart(table, 0, s) . (w+b) . strpart(table, s+1) - endif - let b = b + 1 - let s = s + 1 - else - execute s:Ref(backref, b, "start", "len") - let ref = strpart(backref, start, len) - let backref = strpart(backref, 0, start) . ":". table[s] - \ . strpart(backref, start+len) - let s = s + s:Count(substitute(ref, '\\\\', '', 'g'), '\(', '1') - endif - endwhile - let word = strpart(word, 0, i-1) . backref . strpart(word, i+1) - let i = matchend(word, s:notslash . '\\\d') - 1 - endwhile - let word = substitute(word, s:notslash . '\zs:', '\\', 'g') - if a:output == "table" - return table - elseif a:output == "word" - return word - else - return table . word - endif -endfun - -" Assume a:comma = ",". Then the format for a:patterns and a:1 is -" a:patterns = "<pat1>,<pat2>,..." -" a:1 = "<alt1>,<alt2>,..." -" If <patn> is the first pattern that matches a:string then return <patn> -" if no optional arguments are given; return <patn>,<altn> if a:1 is given. -fun! s:Choose(patterns, string, comma, branch, prefix, suffix, ...) - let tail = (a:patterns =~ a:comma."$" ? a:patterns : a:patterns . a:comma) - let i = matchend(tail, s:notslash . a:comma) - if a:0 - let alttail = (a:1 =~ a:comma."$" ? a:1 : a:1 . a:comma) - let j = matchend(alttail, s:notslash . a:comma) - endif - let current = strpart(tail, 0, i-1) - if a:branch == "" - let currpat = current - else - let currpat = substitute(current, s:notslash . a:branch, '\\|', 'g') - endif - while a:string !~ a:prefix . currpat . a:suffix - let tail = strpart(tail, i) - let i = matchend(tail, s:notslash . a:comma) - if i == -1 - return -1 - endif - let current = strpart(tail, 0, i-1) - if a:branch == "" - let currpat = current - else - let currpat = substitute(current, s:notslash . a:branch, '\\|', 'g') - endif - if a:0 - let alttail = strpart(alttail, j) - let j = matchend(alttail, s:notslash . a:comma) - endif - endwhile - if a:0 - let current = current . a:comma . strpart(alttail, 0, j-1) - endif - return current -endfun - -" Call this function to turn on debugging information. Every time the main -" script is run, buffer variables will be saved. These can be used directly -" or viewed using the menu items below. -if !exists(":MatchDebug") - command! -nargs=0 MatchDebug call s:Match_debug() -endif - -fun! s:Match_debug() - let b:match_debug = 1 " Save debugging information. - " pat = all of b:match_words with backrefs parsed - amenu &Matchit.&pat :echo b:match_pat<CR> - " match = bit of text that is recognized as a match - amenu &Matchit.&match :echo b:match_match<CR> - " curcol = cursor column of the start of the matching text - amenu &Matchit.&curcol :echo b:match_col<CR> - " wholeBR = matching group, original version - amenu &Matchit.wh&oleBR :echo b:match_wholeBR<CR> - " iniBR = 'if' piece, original version - amenu &Matchit.ini&BR :echo b:match_iniBR<CR> - " ini = 'if' piece, with all backrefs resolved from match - amenu &Matchit.&ini :echo b:match_ini<CR> - " tail = 'else\|endif' piece, with all backrefs resolved from match - amenu &Matchit.&tail :echo b:match_tail<CR> - " fin = 'endif' piece, with all backrefs resolved from match - amenu &Matchit.&word :echo b:match_word<CR> - " '\'.d in ini refers to the same thing as '\'.table[d] in word. - amenu &Matchit.t&able :echo '0:' . b:match_table . ':9'<CR> -endfun - -" Jump to the nearest unmatched "(" or "if" or "<tag>" if a:spflag == "bW" -" or the nearest unmatched "</tag>" or "endif" or ")" if a:spflag == "W". -" Return a "mark" for the original position, so that -" let m = MultiMatch("bW", "n") ... execute m -" will return to the original position. If there is a problem, do not -" move the cursor and return "", unless a count is given, in which case -" go up or down as many levels as possible and again return "". -" TODO This relies on the same patterns as % matching. It might be a good -" idea to give it its own matching patterns. -fun! s:MultiMatch(spflag, mode) - if !exists("b:match_words") || b:match_words == "" - return "" - end - let restore_options = (&ic ? "" : "no") . "ignorecase" - if exists("b:match_ignorecase") - let &ignorecase = b:match_ignorecase - endif - let startline = line(".") - let startcol = col(".") - - " First step: if not already done, set the script variables - " s:do_BR flag for whether there are backrefs - " s:pat parsed version of b:match_words - " s:all regexp based on s:pat and the default groups - " This part is copied and slightly modified from s:Match_wrapper(). - let default = escape(&mps, '[$^.*~\\/?]') . (strlen(&mps) ? "," : "") . - \ '\/\*:\*\/,#if\%(def\)\=:#else\>:#elif\>:#endif\>' - " Allow b:match_words = "GetVimMatchWords()" . - if b:match_words =~ ":" - let match_words = b:match_words - else - execute "let match_words =" b:match_words - endif - if (match_words != s:last_words) || (&mps != s:last_mps) || - \ exists("b:match_debug") - let s:last_words = match_words - let s:last_mps = &mps - if match_words !~ s:notslash . '\\\d' - let s:do_BR = 0 - let s:pat = match_words - else - let s:do_BR = 1 - let s:pat = s:ParseWords(match_words) - endif - let s:all = '\%(' . substitute(s:pat . (strlen(s:pat)?",":"") . default, - \ '[,:]\+','\\|','g') . '\)' - if exists("b:match_debug") - let b:match_pat = s:pat - endif - endif - - " Second step: figure out the patterns for searchpair() - " and save the screen, cursor position, and 'ignorecase'. - " - TODO: A lot of this is copied from s:Match_wrapper(). - " - maybe even more functionality should be split off - " - into separate functions! - let cdefault = (s:pat =~ '[^,]$' ? "," : "") . default - let open = substitute(s:pat . cdefault, - \ s:notslash . '\zs:.\{-}' . s:notslash . ',', '\\),\\(', 'g') - let open = '\(' . substitute(open, s:notslash . '\zs:.*$', '\\)', '') - let close = substitute(s:pat . cdefault, - \ s:notslash . '\zs,.\{-}' . s:notslash . ':', '\\),\\(', 'g') - let close = substitute(close, '^.\{-}' . s:notslash . ':', '\\(', '') . '\)' - if exists("b:match_skip") - let skip = b:match_skip - elseif exists("b:match_comment") " backwards compatibility and testing! - let skip = "r:" . b:match_comment - else - let skip = 's:comment\|string' - endif - let skip = s:ParseSkip(skip) - " let restore_cursor = line(".") . "G" . virtcol(".") . "|" - " normal! H - " let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor - let restore_cursor = virtcol(".") . "|" - normal! g0 - let restore_cursor = line(".") . "G" . virtcol(".") . "|zs" . restore_cursor - normal! H - let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor - execute restore_cursor - - " Third step: call searchpair(). - " Replace '\('--but not '\\('--with '\%(' and ',' with '\|'. - let openpat = substitute(open, '\(\\\@<!\(\\\\\)*\)\@<=\\(', '\\%(', 'g') - let openpat = substitute(openpat, ',', '\\|', 'g') - let closepat = substitute(close, '\(\\\@<!\(\\\\\)*\)\@<=\\(', '\\%(', 'g') - let closepat = substitute(closepat, ',', '\\|', 'g') - if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on")) - let skip = '0' - else - execute "if " . skip . "| let skip = '0' | endif" - endif - mark ' - let level = v:count1 - while level - if searchpair(openpat, '', closepat, a:spflag, skip) < 1 - call s:CleanUp(restore_options, a:mode, startline, startcol) - return "" - endif - let level = level - 1 - endwhile - - " Restore options and return a string to restore the original position. - call s:CleanUp(restore_options, a:mode, startline, startcol) - return restore_cursor -endfun - -" Search backwards for "if" or "while" or "<tag>" or ... -" and return "endif" or "endwhile" or "</tag>" or ... . -" For now, this uses b:match_words and the same script variables -" as s:Match_wrapper() . Later, it may get its own patterns, -" either from a buffer variable or passed as arguments. -" fun! s:Autocomplete() -" echo "autocomplete not yet implemented :-(" -" if !exists("b:match_words") || b:match_words == "" -" return "" -" end -" let startpos = s:MultiMatch("bW") -" -" if startpos == "" -" return "" -" endif -" " - TODO: figure out whether 'if' or '<tag>' matched, and construct -" " - the appropriate closing. -" let matchline = getline(".") -" let curcol = col(".") - 1 -" " - TODO: Change the s:all argument if there is a new set of match pats. -" let regexp = s:Wholematch(matchline, s:all, curcol) -" let suf = strlen(matchline) - matchend(matchline, regexp) -" let prefix = (curcol ? '^.\{' . curcol . '}\%(' : '^\%(') -" let suffix = (suf ? '\).\{' . suf . '}$' : '\)$') -" " Reconstruct the version with unresolved backrefs. -" let patBR = substitute(b:match_words.',', '[,:]*,[,:]*', ',', 'g') -" let patBR = substitute(patBR, ':\{2,}', ':', "g") -" " Now, set group and groupBR to the matching group: 'if:endif' or -" " 'while:endwhile' or whatever. -" let group = s:Choose(s:pat, matchline, ",", ":", prefix, suffix, patBR) -" let i = matchend(group, s:notslash . ",") -" let groupBR = strpart(group, i) -" let group = strpart(group, 0, i-1) -" " Now, matchline =~ prefix . substitute(group,':','\|','g') . suffix -" if s:do_BR -" let group = s:InsertRefs(groupBR, prefix, group, suffix, matchline) -" endif -" " let g:group = group -" -" " - TODO: Construct the closing from group. -" let fake = "end" . expand("<cword>") -" execute startpos -" return fake -" endfun - -" Close all open structures. "Get the heck out of here!" -" fun! s:Gthhoh() -" let close = s:Autocomplete() -" while strlen(close) -" put=close -" let close = s:Autocomplete() -" endwhile -" endfun - -" Parse special strings as typical skip arguments for searchpair(): -" s:foo becomes (current syntax item) =~ foo -" S:foo becomes (current syntax item) !~ foo -" r:foo becomes (line before cursor) =~ foo -" R:foo becomes (line before cursor) !~ foo -fun! s:ParseSkip(str) - let skip = a:str - if skip[1] == ":" - if skip[0] == "s" - let skip = "synIDattr(synID(line('.'),col('.'),1),'name') =~? '" . - \ strpart(skip,2) . "'" - elseif skip[0] == "S" - let skip = "synIDattr(synID(line('.'),col('.'),1),'name') !~? '" . - \ strpart(skip,2) . "'" - elseif skip[0] == "r" - let skip = "strpart(getline('.'),0,col('.'))=~'" . strpart(skip,2). "'" - elseif skip[0] == "R" - let skip = "strpart(getline('.'),0,col('.'))!~'" . strpart(skip,2). "'" - endif - endif - return skip -endfun - -let &cpo = s:save_cpo - -" vim:sts=2:sw=2: diff --git a/vim/bundle/snipmate/README.markdown b/vim/bundle/snipmate/README.markdown @@ -1,5 +0,0 @@ -Quickly install with: - - git clone git://github.com/msanders/snipmate.vim.git - cd snipmate.vim - cp -R * ~/.vim diff --git a/vim/bundle/snipmate/after/plugin/snipMate.vim b/vim/bundle/snipmate/after/plugin/snipMate.vim @@ -1,40 +0,0 @@ -" These are the mappings for snipMate.vim. Putting it here ensures that it -" will be mapped after other plugins such as supertab.vim. -if !exists('loaded_snips') || exists('s:did_snips_mappings') - finish -endif -let s:did_snips_mappings = 1 - -" This is put here in the 'after' directory in order for snipMate to override -" other plugin mappings (e.g., supertab). -" -" You can safely adjust these mappings to your preferences (as explained in -" :help snipMate-remap). -ino <silent> <tab> <c-r>=TriggerSnippet()<cr> -snor <silent> <tab> <esc>i<right><c-r>=TriggerSnippet()<cr> -ino <silent> <s-tab> <c-r>=BackwardsSnippet()<cr> -snor <silent> <s-tab> <esc>i<right><c-r>=BackwardsSnippet()<cr> -ino <silent> <c-r><tab> <c-r>=ShowAvailableSnips()<cr> - -" The default mappings for these are annoying & sometimes break snipMate. -" You can change them back if you want, I've put them here for convenience. -snor <bs> b<bs> -snor <right> <esc>a -snor <left> <esc>bi -snor ' b<bs>' -snor ` b<bs>` -snor % b<bs>% -snor U b<bs>U -snor ^ b<bs>^ -snor \ b<bs>\ -snor <c-x> b<bs><c-x> - -" By default load snippets in snippets_dir -if empty(snippets_dir) - finish -endif - -call GetSnippets(snippets_dir, '_') " Get global snippets - -au FileType * if &ft != 'help' | call GetSnippets(snippets_dir, &ft) | endif -" vim:noet:sw=4:ts=4:ft=vim diff --git a/vim/bundle/snipmate/autoload/snipMate.vim b/vim/bundle/snipmate/autoload/snipMate.vim @@ -1,435 +0,0 @@ -fun! Filename(...) - let filename = expand('%:t:r') - if filename == '' | return a:0 == 2 ? a:2 : '' | endif - return !a:0 || a:1 == '' ? filename : substitute(a:1, '$1', filename, 'g') -endf - -fun s:RemoveSnippet() - unl! g:snipPos s:curPos s:snipLen s:endCol s:endLine s:prevLen - \ s:lastBuf s:oldWord - if exists('s:update') - unl s:startCol s:origWordLen s:update - if exists('s:oldVars') | unl s:oldVars s:oldEndCol | endif - endif - aug! snipMateAutocmds -endf - -fun snipMate#expandSnip(snip, col) - let lnum = line('.') | let col = a:col - - let snippet = s:ProcessSnippet(a:snip) - " Avoid error if eval evaluates to nothing - if snippet == '' | return '' | endif - - " Expand snippet onto current position with the tab stops removed - let snipLines = split(substitute(snippet, '$\d\+\|${\d\+.\{-}}', '', 'g'), "\n", 1) - - let line = getline(lnum) - let afterCursor = strpart(line, col - 1) - " Keep text after the cursor - if afterCursor != "\t" && afterCursor != ' ' - let line = strpart(line, 0, col - 1) - let snipLines[-1] .= afterCursor - else - let afterCursor = '' - " For some reason the cursor needs to move one right after this - if line != '' && col == 1 && &ve != 'all' && &ve != 'onemore' - let col += 1 - endif - endif - - call setline(lnum, line.snipLines[0]) - - " Autoindent snippet according to previous indentation - let indent = matchend(line, '^.\{-}\ze\(\S\|$\)') + 1 - call append(lnum, map(snipLines[1:], "'".strpart(line, 0, indent - 1)."'.v:val")) - - " Open any folds snippet expands into - if &fen | sil! exe lnum.','.(lnum + len(snipLines) - 1).'foldopen' | endif - - let [g:snipPos, s:snipLen] = s:BuildTabStops(snippet, lnum, col - indent, indent) - - if s:snipLen - aug snipMateAutocmds - au CursorMovedI * call s:UpdateChangedSnip(0) - au InsertEnter * call s:UpdateChangedSnip(1) - aug END - let s:lastBuf = bufnr(0) " Only expand snippet while in current buffer - let s:curPos = 0 - let s:endCol = g:snipPos[s:curPos][1] - let s:endLine = g:snipPos[s:curPos][0] - - call cursor(g:snipPos[s:curPos][0], g:snipPos[s:curPos][1]) - let s:prevLen = [line('$'), col('$')] - if g:snipPos[s:curPos][2] != -1 | return s:SelectWord() | endif - else - unl g:snipPos s:snipLen - " Place cursor at end of snippet if no tab stop is given - let newlines = len(snipLines) - 1 - call cursor(lnum + newlines, indent + len(snipLines[-1]) - len(afterCursor) - \ + (newlines ? 0: col - 1)) - endif - return '' -endf - -" Prepare snippet to be processed by s:BuildTabStops -fun s:ProcessSnippet(snip) - let snippet = a:snip - " Evaluate eval (`...`) expressions. - " Backquotes prefixed with a backslash "\" are ignored. - " Using a loop here instead of a regex fixes a bug with nested "\=". - if stridx(snippet, '`') != -1 - while match(snippet, '\(^\|[^\\]\)`.\{-}[^\\]`') != -1 - let snippet = substitute(snippet, '\(^\|[^\\]\)\zs`.\{-}[^\\]`\ze', - \ substitute(eval(matchstr(snippet, '\(^\|[^\\]\)`\zs.\{-}[^\\]\ze`')), - \ "\n\\%$", '', ''), '') - endw - let snippet = substitute(snippet, "\r", "\n", 'g') - let snippet = substitute(snippet, '\\`', '`', 'g') - endif - - " Place all text after a colon in a tab stop after the tab stop - " (e.g. "${#:foo}" becomes "${:foo}foo"). - " This helps tell the position of the tab stops later. - let snippet = substitute(snippet, '${\d\+:\(.\{-}\)}', '&\1', 'g') - - " Update the a:snip so that all the $# become the text after - " the colon in their associated ${#}. - " (e.g. "${1:foo}" turns all "$1"'s into "foo") - let i = 1 - while stridx(snippet, '${'.i) != -1 - let s = matchstr(snippet, '${'.i.':\zs.\{-}\ze}') - if s != '' - let snippet = substitute(snippet, '$'.i, s.'&', 'g') - endif - let i += 1 - endw - - if &et " Expand tabs to spaces if 'expandtab' is set. - return substitute(snippet, '\t', repeat(' ', &sts ? &sts : &sw), 'g') - endif - return snippet -endf - -" Counts occurences of haystack in needle -fun s:Count(haystack, needle) - let counter = 0 - let index = stridx(a:haystack, a:needle) - while index != -1 - let index = stridx(a:haystack, a:needle, index+1) - let counter += 1 - endw - return counter -endf - -" Builds a list of a list of each tab stop in the snippet containing: -" 1.) The tab stop's line number. -" 2.) The tab stop's column number -" (by getting the length of the string between the last "\n" and the -" tab stop). -" 3.) The length of the text after the colon for the current tab stop -" (e.g. "${1:foo}" would return 3). If there is no text, -1 is returned. -" 4.) If the "${#:}" construct is given, another list containing all -" the matches of "$#", to be replaced with the placeholder. This list is -" composed the same way as the parent; the first item is the line number, -" and the second is the column. -fun s:BuildTabStops(snip, lnum, col, indent) - let snipPos = [] - let i = 1 - let withoutVars = substitute(a:snip, '$\d\+', '', 'g') - while stridx(a:snip, '${'.i) != -1 - let beforeTabStop = matchstr(withoutVars, '^.*\ze${'.i.'\D') - let withoutOthers = substitute(withoutVars, '${\('.i.'\D\)\@!\d\+.\{-}}', '', 'g') - - let j = i - 1 - call add(snipPos, [0, 0, -1]) - let snipPos[j][0] = a:lnum + s:Count(beforeTabStop, "\n") - let snipPos[j][1] = a:indent + len(matchstr(withoutOthers, '.*\(\n\|^\)\zs.*\ze${'.i.'\D')) - if snipPos[j][0] == a:lnum | let snipPos[j][1] += a:col | endif - - " Get all $# matches in another list, if ${#:name} is given - if stridx(withoutVars, '${'.i.':') != -1 - let snipPos[j][2] = len(matchstr(withoutVars, '${'.i.':\zs.\{-}\ze}')) - let dots = repeat('.', snipPos[j][2]) - call add(snipPos[j], []) - let withoutOthers = substitute(a:snip, '${\d\+.\{-}}\|$'.i.'\@!\d\+', '', 'g') - while match(withoutOthers, '$'.i.'\(\D\|$\)') != -1 - let beforeMark = matchstr(withoutOthers, '^.\{-}\ze'.dots.'$'.i.'\(\D\|$\)') - call add(snipPos[j][3], [0, 0]) - let snipPos[j][3][-1][0] = a:lnum + s:Count(beforeMark, "\n") - let snipPos[j][3][-1][1] = a:indent + (snipPos[j][3][-1][0] > a:lnum - \ ? len(matchstr(beforeMark, '.*\n\zs.*')) - \ : a:col + len(beforeMark)) - let withoutOthers = substitute(withoutOthers, '$'.i.'\ze\(\D\|$\)', '', '') - endw - endif - let i += 1 - endw - return [snipPos, i - 1] -endf - -fun snipMate#jumpTabStop(backwards) - let leftPlaceholder = exists('s:origWordLen') - \ && s:origWordLen != g:snipPos[s:curPos][2] - if leftPlaceholder && exists('s:oldEndCol') - let startPlaceholder = s:oldEndCol + 1 - endif - - if exists('s:update') - call s:UpdatePlaceholderTabStops() - else - call s:UpdateTabStops() - endif - - " Don't reselect placeholder if it has been modified - if leftPlaceholder && g:snipPos[s:curPos][2] != -1 - if exists('startPlaceholder') - let g:snipPos[s:curPos][1] = startPlaceholder - else - let g:snipPos[s:curPos][1] = col('.') - let g:snipPos[s:curPos][2] = 0 - endif - endif - - let s:curPos += a:backwards ? -1 : 1 - " Loop over the snippet when going backwards from the beginning - if s:curPos < 0 | let s:curPos = s:snipLen - 1 | endif - - if s:curPos == s:snipLen - let sMode = s:endCol == g:snipPos[s:curPos-1][1]+g:snipPos[s:curPos-1][2] - call s:RemoveSnippet() - return sMode ? "\<tab>" : TriggerSnippet() - endif - - call cursor(g:snipPos[s:curPos][0], g:snipPos[s:curPos][1]) - - let s:endLine = g:snipPos[s:curPos][0] - let s:endCol = g:snipPos[s:curPos][1] - let s:prevLen = [line('$'), col('$')] - - return g:snipPos[s:curPos][2] == -1 ? '' : s:SelectWord() -endf - -fun s:UpdatePlaceholderTabStops() - let changeLen = s:origWordLen - g:snipPos[s:curPos][2] - unl s:startCol s:origWordLen s:update - if !exists('s:oldVars') | return | endif - " Update tab stops in snippet if text has been added via "$#" - " (e.g., in "${1:foo}bar$1${2}"). - if changeLen != 0 - let curLine = line('.') - - for pos in g:snipPos - if pos == g:snipPos[s:curPos] | continue | endif - let changed = pos[0] == curLine && pos[1] > s:oldEndCol - let changedVars = 0 - let endPlaceholder = pos[2] - 1 + pos[1] - " Subtract changeLen from each tab stop that was after any of - " the current tab stop's placeholders. - for [lnum, col] in s:oldVars - if lnum > pos[0] | break | endif - if pos[0] == lnum - if pos[1] > col || (pos[2] == -1 && pos[1] == col) - let changed += 1 - elseif col < endPlaceholder - let changedVars += 1 - endif - endif - endfor - let pos[1] -= changeLen * changed - let pos[2] -= changeLen * changedVars " Parse variables within placeholders - " e.g., "${1:foo} ${2:$1bar}" - - if pos[2] == -1 | continue | endif - " Do the same to any placeholders in the other tab stops. - for nPos in pos[3] - let changed = nPos[0] == curLine && nPos[1] > s:oldEndCol - for [lnum, col] in s:oldVars - if lnum > nPos[0] | break | endif - if nPos[0] == lnum && nPos[1] > col - let changed += 1 - endif - endfor - let nPos[1] -= changeLen * changed - endfor - endfor - endif - unl s:endCol s:oldVars s:oldEndCol -endf - -fun s:UpdateTabStops() - let changeLine = s:endLine - g:snipPos[s:curPos][0] - let changeCol = s:endCol - g:snipPos[s:curPos][1] - if exists('s:origWordLen') - let changeCol -= s:origWordLen - unl s:origWordLen - endif - let lnum = g:snipPos[s:curPos][0] - let col = g:snipPos[s:curPos][1] - " Update the line number of all proceeding tab stops if <cr> has - " been inserted. - if changeLine != 0 - let changeLine -= 1 - for pos in g:snipPos - if pos[0] >= lnum - if pos[0] == lnum | let pos[1] += changeCol | endif - let pos[0] += changeLine - endif - if pos[2] == -1 | continue | endif - for nPos in pos[3] - if nPos[0] >= lnum - if nPos[0] == lnum | let nPos[1] += changeCol | endif - let nPos[0] += changeLine - endif - endfor - endfor - elseif changeCol != 0 - " Update the column of all proceeding tab stops if text has - " been inserted/deleted in the current line. - for pos in g:snipPos - if pos[1] >= col && pos[0] == lnum - let pos[1] += changeCol - endif - if pos[2] == -1 | continue | endif - for nPos in pos[3] - if nPos[0] > lnum | break | endif - if nPos[0] == lnum && nPos[1] >= col - let nPos[1] += changeCol - endif - endfor - endfor - endif -endf - -fun s:SelectWord() - let s:origWordLen = g:snipPos[s:curPos][2] - let s:oldWord = strpart(getline('.'), g:snipPos[s:curPos][1] - 1, - \ s:origWordLen) - let s:prevLen[1] -= s:origWordLen - if !empty(g:snipPos[s:curPos][3]) - let s:update = 1 - let s:endCol = -1 - let s:startCol = g:snipPos[s:curPos][1] - 1 - endif - if !s:origWordLen | return '' | endif - let l = col('.') != 1 ? 'l' : '' - if &sel == 'exclusive' - return "\<esc>".l.'v'.s:origWordLen."l\<c-g>" - endif - return s:origWordLen == 1 ? "\<esc>".l.'gh' - \ : "\<esc>".l.'v'.(s:origWordLen - 1)."l\<c-g>" -endf - -" This updates the snippet as you type when text needs to be inserted -" into multiple places (e.g. in "${1:default text}foo$1bar$1", -" "default text" would be highlighted, and if the user types something, -" UpdateChangedSnip() would be called so that the text after "foo" & "bar" -" are updated accordingly) -" -" It also automatically quits the snippet if the cursor is moved out of it -" while in insert mode. -fun s:UpdateChangedSnip(entering) - if exists('g:snipPos') && bufnr(0) != s:lastBuf - call s:RemoveSnippet() - elseif exists('s:update') " If modifying a placeholder - if !exists('s:oldVars') && s:curPos + 1 < s:snipLen - " Save the old snippet & word length before it's updated - " s:startCol must be saved too, in case text is added - " before the snippet (e.g. in "foo$1${2}bar${1:foo}"). - let s:oldEndCol = s:startCol - let s:oldVars = deepcopy(g:snipPos[s:curPos][3]) - endif - let col = col('.') - 1 - - if s:endCol != -1 - let changeLen = col('$') - s:prevLen[1] - let s:endCol += changeLen - else " When being updated the first time, after leaving select mode - if a:entering | return | endif - let s:endCol = col - 1 - endif - - " If the cursor moves outside the snippet, quit it - if line('.') != g:snipPos[s:curPos][0] || col < s:startCol || - \ col - 1 > s:endCol - unl! s:startCol s:origWordLen s:oldVars s:update - return s:RemoveSnippet() - endif - - call s:UpdateVars() - let s:prevLen[1] = col('$') - elseif exists('g:snipPos') - if !a:entering && g:snipPos[s:curPos][2] != -1 - let g:snipPos[s:curPos][2] = -2 - endif - - let col = col('.') - let lnum = line('.') - let changeLine = line('$') - s:prevLen[0] - - if lnum == s:endLine - let s:endCol += col('$') - s:prevLen[1] - let s:prevLen = [line('$'), col('$')] - endif - if changeLine != 0 - let s:endLine += changeLine - let s:endCol = col - endif - - " Delete snippet if cursor moves out of it in insert mode - if (lnum == s:endLine && (col > s:endCol || col < g:snipPos[s:curPos][1])) - \ || lnum > s:endLine || lnum < g:snipPos[s:curPos][0] - call s:RemoveSnippet() - endif - endif -endf - -" This updates the variables in a snippet when a placeholder has been edited. -" (e.g., each "$1" in "${1:foo} $1bar $1bar") -fun s:UpdateVars() - let newWordLen = s:endCol - s:startCol + 1 - let newWord = strpart(getline('.'), s:startCol, newWordLen) - if newWord == s:oldWord || empty(g:snipPos[s:curPos][3]) - return - endif - - let changeLen = g:snipPos[s:curPos][2] - newWordLen - let curLine = line('.') - let startCol = col('.') - let oldStartSnip = s:startCol - let updateTabStops = changeLen != 0 - let i = 0 - - for [lnum, col] in g:snipPos[s:curPos][3] - if updateTabStops - let start = s:startCol - if lnum == curLine && col <= start - let s:startCol -= changeLen - let s:endCol -= changeLen - endif - for nPos in g:snipPos[s:curPos][3][(i):] - " This list is in ascending order, so quit if we've gone too far. - if nPos[0] > lnum | break | endif - if nPos[0] == lnum && nPos[1] > col - let nPos[1] -= changeLen - endif - endfor - if lnum == curLine && col > start - let col -= changeLen - let g:snipPos[s:curPos][3][i][1] = col - endif - let i += 1 - endif - - " "Very nomagic" is used here to allow special characters. - call setline(lnum, substitute(getline(lnum), '\%'.col.'c\V'. - \ escape(s:oldWord, '\'), escape(newWord, '\&'), '')) - endfor - if oldStartSnip != s:startCol - call cursor(0, startCol + s:startCol - oldStartSnip) - endif - - let s:oldWord = newWord - let g:snipPos[s:curPos][2] = newWordLen -endf -" vim:noet:sw=4:ts=4:ft=vim diff --git a/vim/bundle/snipmate/doc/snipMate.txt b/vim/bundle/snipmate/doc/snipMate.txt @@ -1,322 +0,0 @@ -*snipMate.txt* Plugin for using TextMate-style snippets in Vim. - -snipMate *snippet* *snippets* *snipMate* -Last Change: December 27, 2009 - -|snipMate-description| Description -|snipMate-syntax| Snippet syntax -|snipMate-usage| Usage -|snipMate-settings| Settings -|snipMate-features| Features -|snipMate-disadvantages| Disadvantages to TextMate -|snipMate-contact| Contact -|snipMate-license| License - -For Vim version 7.0 or later. -This plugin only works if 'compatible' is not set. -{Vi does not have any of these features.} - -============================================================================== -DESCRIPTION *snipMate-description* - -snipMate.vim implements some of TextMate's snippets features in Vim. A -snippet is a piece of often-typed text that you can insert into your -document using a trigger word followed by a <tab>. - -For instance, in a C file using the default installation of snipMate.vim, if -you type "for<tab>" in insert mode, it will expand a typical for loop in C: > - - for (i = 0; i < count; i++) { - - } - - -To go to the next item in the loop, simply <tab> over to it; if there is -repeated code, such as the "i" variable in this example, you can simply -start typing once it's highlighted and all the matches specified in the -snippet will be updated. To go in reverse, use <shift-tab>. - -============================================================================== -SYNTAX *snippet-syntax* - -Snippets can be defined in two ways. They can be in their own file, named -after their trigger in 'snippets/<filetype>/<trigger>.snippet', or they can be -defined together in a 'snippets/<filetype>.snippets' file. Note that dotted -'filetype' syntax is supported -- e.g., you can use > - - :set ft=html.eruby - -to activate snippets for both HTML and eRuby for the current file. - -The syntax for snippets in *.snippets files is the following: > - - snippet trigger - expanded text - more expanded text - -Note that the first hard tab after the snippet trigger is required, and not -expanded in the actual snippet. The syntax for *.snippet files is the same, -only without the trigger declaration and starting indentation. - -Also note that snippets must be defined using hard tabs. They can be expanded -to spaces later if desired (see |snipMate-indenting|). - -"#" is used as a line-comment character in *.snippets files; however, they can -only be used outside of a snippet declaration. E.g.: > - - # this is a correct comment - snippet trigger - expanded text - snippet another_trigger - # this isn't a comment! - expanded text -< -This should hopefully be obvious with the included syntax highlighting. - - *snipMate-${#}* -Tab stops ~ - -By default, the cursor is placed at the end of a snippet. To specify where the -cursor is to be placed next, use "${#}", where the # is the number of the tab -stop. E.g., to place the cursor first on the id of a <div> tag, and then allow -the user to press <tab> to go to the middle of it: - > - snippet div - <div id="${1}"> - ${2} - </div> -< - *snipMate-placeholders* *snipMate-${#:}* *snipMate-$#* -Placeholders ~ - -Placeholder text can be supplied using "${#:text}", where # is the number of -the tab stop. This text then can be copied throughout the snippet using "$#", -given # is the same number as used before. So, to make a C for loop: > - - snippet for - for (${2:i}; $2 < ${1:count}; $1++) { - ${4} - } - -This will cause "count" to first be selected and change if the user starts -typing. When <tab> is pressed, the "i" in ${2}'s position will be selected; -all $2 variables will default to "i" and automatically be updated if the user -starts typing. -NOTE: "$#" syntax is used only for variables, not for tab stops as in TextMate. - -Variables within variables are also possible. For instance: > - - snippet opt - <option value="${1:option}">${2:$1}</option> - -Will, as usual, cause "option" to first be selected and update all the $1 -variables if the user starts typing. Since one of these variables is inside of -${2}, this text will then be used as a placeholder for the next tab stop, -allowing the user to change it if he wishes. - -To copy a value throughout a snippet without supplying default text, simply -use the "${#:}" construct without the text; e.g.: > - - snippet foo - ${1:}bar$1 -< *snipMate-commands* -Interpolated Vim Script ~ - -Snippets can also contain Vim script commands that are executed (via |eval()|) -when the snippet is inserted. Commands are given inside backticks (`...`); for -TextMates's functionality, use the |system()| function. E.g.: > - - snippet date - `system("date +%Y-%m-%d")` - -will insert the current date, assuming you are on a Unix system. Note that you -can also (and should) use |strftime()| for this example. - -Filename([{expr}] [, {defaultText}]) *snipMate-filename* *Filename()* - -Since the current filename is used often in snippets, a default function -has been defined for it in snipMate.vim, appropriately called Filename(). - -With no arguments, the default filename without an extension is returned; -the first argument specifies what to place before or after the filename, -and the second argument supplies the default text to be used if the file -has not been named. "$1" in the first argument is replaced with the filename; -if you only want the filename to be returned, the first argument can be left -blank. Examples: > - - snippet filename - `Filename()` - snippet filename_with_default - `Filename('', 'name')` - snippet filename_foo - `filename('$1_foo')` - -The first example returns the filename if it the file has been named, and an -empty string if it hasn't. The second returns the filename if it's been named, -and "name" if it hasn't. The third returns the filename followed by "_foo" if -it has been named, and an empty string if it hasn't. - - *multi_snip* -To specify that a snippet can have multiple matches in a *.snippets file, use -this syntax: > - - snippet trigger A description of snippet #1 - expand this text - snippet trigger A description of snippet #2 - expand THIS text! - -In this example, when "trigger<tab>" is typed, a numbered menu containing all -of the descriptions of the "trigger" will be shown; when the user presses the -corresponding number, that snippet will then be expanded. - -To create a snippet with multiple matches using *.snippet files, -simply place all the snippets in a subdirectory with the trigger name: -'snippets/<filetype>/<trigger>/<name>.snippet'. - -============================================================================== -USAGE *snipMate-usage* - - *'snippets'* *g:snippets_dir* -Snippets are by default looked for any 'snippets' directory in your -'runtimepath'. Typically, it is located at '~/.vim/snippets/' on *nix or -'$HOME\vimfiles\snippets\' on Windows. To change that location or add another -one, change the g:snippets_dir variable in your |.vimrc| to your preferred -directory, or use the |ExtractSnips()|function. This will be used by the -|globpath()| function, and so accepts the same syntax as it (e.g., -comma-separated paths). - -ExtractSnipsFile({directory}, {filetype}) *ExtractSnipsFile()* *.snippets* - -ExtractSnipsFile() extracts the specified *.snippets file for the given -filetype. A .snippets file contains multiple snippet declarations for the -filetype. It is further explained above, in |snippet-syntax|. - -ExtractSnips({directory}, {filetype}) *ExtractSnips()* *.snippet* - -ExtractSnips() extracts *.snippet files from the specified directory and -defines them as snippets for the given filetype. The directory tree should -look like this: 'snippets/<filetype>/<trigger>.snippet'. If the snippet has -multiple matches, it should look like this: -'snippets/<filetype>/<trigger>/<name>.snippet' (see |multi_snip|). - -ResetAllSnippets() *ResetAllSnippets()* -ResetAllSnippets() removes all snippets from memory. This is useful to put at -the top of a snippet setup file for if you would like to |:source| it multiple -times. - -ResetSnippets({filetype}) *ResetSnippets()* -ResetSnippets() removes all snippets from memory for the given filetype. - -ReloadAllSnippets() *ReloadAllSnippets()* -ReloadAllSnippets() reloads all snippets for all filetypes. This is useful for -testing and debugging. - -ReloadSnippets({filetype}) *ReloadSnippets()* -ReloadSnippets() reloads all snippets for the given filetype. - - *list-snippets* *i_CTRL-R_<Tab>* -If you would like to see what snippets are available, simply type <c-r><tab> -in the current buffer to show a list via |popupmenu-completion|. - -============================================================================== -SETTINGS *snipMate-settings* *g:snips_author* - -The g:snips_author string (similar to $TM_FULLNAME in TextMate) should be set -to your name; it can then be used in snippets to automatically add it. E.g.: > - - let g:snips_author = 'Hubert Farnsworth' - snippet name - `g:snips_author` -< - *snipMate-expandtab* *snipMate-indenting* -If you would like your snippets to be expanded using spaces instead of tabs, -just enable 'expandtab' and set 'softtabstop' to your preferred amount of -spaces. If 'softtabstop' is not set, 'shiftwidth' is used instead. - - *snipMate-remap* -snipMate does not come with a setting to customize the trigger key, but you -can remap it easily in the two lines it's defined in the 'after' directory -under 'plugin/snipMate.vim'. For instance, to change the trigger key -to CTRL-J, just change this: > - - ino <tab> <c-r>=TriggerSnippet()<cr> - snor <tab> <esc>i<right><c-r>=TriggerSnippet()<cr> - -to this: > - ino <c-j> <c-r>=TriggerSnippet()<cr> - snor <c-j> <esc>i<right><c-r>=TriggerSnippet()<cr> - -============================================================================== -FEATURES *snipMate-features* - -snipMate.vim has the following features among others: - - The syntax of snippets is very similar to TextMate's, allowing - easy conversion. - - The position of the snippet is kept transparently (i.e. it does not use - markers/placeholders written to the buffer), which allows you to escape - out of an incomplete snippet, something particularly useful in Vim. - - Variables in snippets are updated as-you-type. - - Snippets can have multiple matches. - - Snippets can be out of order. For instance, in a do...while loop, the - condition can be added before the code. - - [New] File-based snippets are supported. - - [New] Triggers after non-word delimiters are expanded, e.g. "foo" - in "bar.foo". - - [New] <shift-tab> can now be used to jump tab stops in reverse order. - -============================================================================== -DISADVANTAGES *snipMate-disadvantages* - -snipMate.vim currently has the following disadvantages to TextMate's snippets: - - There is no $0; the order of tab stops must be explicitly stated. - - Placeholders within placeholders are not possible. E.g.: > - - '<div${1: id="${2:some_id}}">${3}</div>' -< - In TextMate this would first highlight ' id="some_id"', and if - you hit delete it would automatically skip ${2} and go to ${3} - on the next <tab>, but if you didn't delete it it would highlight - "some_id" first. You cannot do this in snipMate.vim. - - Regex cannot be performed on variables, such as "${1/.*/\U&}" - - Placeholders cannot span multiple lines. - - Activating snippets in different scopes of the same file is - not possible. - -Perhaps some of these features will be added in a later release. - -============================================================================== -CONTACT *snipMate-contact* *snipMate-author* - -To contact the author (Michael Sanders), please email: - msanders42+snipmate <at> gmail <dot> com - -I greatly appreciate any suggestions or improvements offered for the script. - -============================================================================== -LICENSE *snipMate-license* - -snipMate is released under the MIT license: - -Copyright 2009-2010 Michael Sanders. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The software is provided "as is", without warranty of any kind, express or -implied, including but not limited to the warranties of merchantability, -fitness for a particular purpose and noninfringement. In no event shall the -authors or copyright holders be liable for any claim, damages or other -liability, whether in an action of contract, tort or otherwise, arising from, -out of or in connection with the software or the use or other dealings in the -software. - -============================================================================== - -vim:tw=78:ts=8:ft=help:norl: diff --git a/vim/bundle/snipmate/ftplugin/html_snip_helper.vim b/vim/bundle/snipmate/ftplugin/html_snip_helper.vim @@ -1,10 +0,0 @@ -" Helper function for (x)html snippets -if exists('s:did_snip_helper') || &cp || !exists('loaded_snips') - finish -endif -let s:did_snip_helper = 1 - -" Automatically closes tag if in xhtml -fun! Close() - return stridx(&ft, 'xhtml') == -1 ? '' : ' /' -endf diff --git a/vim/bundle/snipmate/plugin-info.txt b/vim/bundle/snipmate/plugin-info.txt @@ -1,8 +0,0 @@ -{ - "name" : "snipmate", - "version" : "dev", - "author" : "Michael Sanders <msanders42@gmail.com>", - "repository" : {"type": "git", "url": "git://github.com/msanders/snipmate.vim.git"}, - "dependencies" : {}, - "description" : "snipMate.vim aims to be a concise vim script that implements some of TextMate's snippets features in Vim." -} diff --git a/vim/bundle/snipmate/plugin/snipMate.vim b/vim/bundle/snipmate/plugin/snipMate.vim @@ -1,271 +0,0 @@ -" File: snipMate.vim -" Author: Michael Sanders -" Version: 0.84 -" Description: snipMate.vim implements some of TextMate's snippets features in -" Vim. A snippet is a piece of often-typed text that you can -" insert into your document using a trigger word followed by a "<tab>". -" -" For more help see snipMate.txt; you can do this by using: -" :helptags ~/.vim/doc -" :h snipMate.txt - -if exists('loaded_snips') || &cp || version < 700 - finish -endif -let loaded_snips = 1 -if !exists('snips_author') | let snips_author = 'Me' | endif - -au BufRead,BufNewFile *.snippets\= set ft=snippet -au FileType snippet setl noet fdm=indent - -let s:snippets = {} | let s:multi_snips = {} - -if !exists('snippets_dir') - let snippets_dir = substitute(globpath(&rtp, 'snippets/'), "\n", ',', 'g') -endif - -fun! MakeSnip(scope, trigger, content, ...) - let multisnip = a:0 && a:1 != '' - let var = multisnip ? 's:multi_snips' : 's:snippets' - if !has_key({var}, a:scope) | let {var}[a:scope] = {} | endif - if !has_key({var}[a:scope], a:trigger) - let {var}[a:scope][a:trigger] = multisnip ? [[a:1, a:content]] : a:content - elseif multisnip | let {var}[a:scope][a:trigger] += [[a:1, a:content]] - else - echom 'Warning in snipMate.vim: Snippet '.a:trigger.' is already defined.' - \ .' See :h multi_snip for help on snippets with multiple matches.' - endif -endf - -fun! ExtractSnips(dir, ft) - for path in split(globpath(a:dir, '*'), "\n") - if isdirectory(path) - let pathname = fnamemodify(path, ':t') - for snipFile in split(globpath(path, '*.snippet'), "\n") - call s:ProcessFile(snipFile, a:ft, pathname) - endfor - elseif fnamemodify(path, ':e') == 'snippet' - call s:ProcessFile(path, a:ft) - endif - endfor -endf - -" Processes a single-snippet file; optionally add the name of the parent -" directory for a snippet with multiple matches. -fun s:ProcessFile(file, ft, ...) - let keyword = fnamemodify(a:file, ':t:r') - if keyword == '' | return | endif - try - let text = join(readfile(a:file), "\n") - catch /E484/ - echom "Error in snipMate.vim: couldn't read file: ".a:file - endtry - return a:0 ? MakeSnip(a:ft, a:1, text, keyword) - \ : MakeSnip(a:ft, keyword, text) -endf - -fun! ExtractSnipsFile(file, ft) - if !filereadable(a:file) | return | endif - let text = readfile(a:file) - let inSnip = 0 - for line in text + ["\n"] - if inSnip && (line[0] == "\t" || line == '') - let content .= strpart(line, 1)."\n" - continue - elseif inSnip - call MakeSnip(a:ft, trigger, content[:-2], name) - let inSnip = 0 - endif - - if line[:6] == 'snippet' - let inSnip = 1 - let trigger = strpart(line, 8) - let name = '' - let space = stridx(trigger, ' ') + 1 - if space " Process multi snip - let name = strpart(trigger, space) - let trigger = strpart(trigger, 0, space - 1) - endif - let content = '' - endif - endfor -endf - -" Reset snippets for filetype. -fun! ResetSnippets(ft) - let ft = a:ft == '' ? '_' : a:ft - for dict in [s:snippets, s:multi_snips, g:did_ft] - if has_key(dict, ft) - unlet dict[ft] - endif - endfor -endf - -" Reset snippets for all filetypes. -fun! ResetAllSnippets() - let s:snippets = {} | let s:multi_snips = {} | let g:did_ft = {} -endf - -" Reload snippets for filetype. -fun! ReloadSnippets(ft) - let ft = a:ft == '' ? '_' : a:ft - call ResetSnippets(ft) - call GetSnippets(g:snippets_dir, ft) -endf - -" Reload snippets for all filetypes. -fun! ReloadAllSnippets() - for ft in keys(g:did_ft) - call ReloadSnippets(ft) - endfor -endf - -let g:did_ft = {} -fun! GetSnippets(dir, filetypes) - for ft in split(a:filetypes, '\.') - if has_key(g:did_ft, ft) | continue | endif - call s:DefineSnips(a:dir, ft, ft) - if ft == 'objc' || ft == 'cpp' || ft == 'cs' - call s:DefineSnips(a:dir, 'c', ft) - elseif ft == 'xhtml' - call s:DefineSnips(a:dir, 'html', 'xhtml') - endif - let g:did_ft[ft] = 1 - endfor -endf - -" Define "aliasft" snippets for the filetype "realft". -fun s:DefineSnips(dir, aliasft, realft) - for path in split(globpath(a:dir, a:aliasft.'/')."\n". - \ globpath(a:dir, a:aliasft.'-*/'), "\n") - call ExtractSnips(path, a:realft) - endfor - for path in split(globpath(a:dir, a:aliasft.'.snippets')."\n". - \ globpath(a:dir, a:aliasft.'-*.snippets'), "\n") - call ExtractSnipsFile(path, a:realft) - endfor -endf - -fun! TriggerSnippet() - if exists('g:SuperTabMappingForward') - if g:SuperTabMappingForward == "<tab>" - let SuperTabKey = "\<c-n>" - elseif g:SuperTabMappingBackward == "<tab>" - let SuperTabKey = "\<c-p>" - endif - endif - - if pumvisible() " Update snippet if completion is used, or deal with supertab - if exists('SuperTabKey') - call feedkeys(SuperTabKey) | return '' - endif - call feedkeys("\<esc>a", 'n') " Close completion menu - call feedkeys("\<tab>") | return '' - endif - - if exists('g:snipPos') | return snipMate#jumpTabStop(0) | endif - - let word = matchstr(getline('.'), '\S\+\%'.col('.').'c') - for scope in [bufnr('%')] + split(&ft, '\.') + ['_'] - let [trigger, snippet] = s:GetSnippet(word, scope) - " If word is a trigger for a snippet, delete the trigger & expand - " the snippet. - if snippet != '' - let col = col('.') - len(trigger) - sil exe 's/\V'.escape(trigger, '/\.').'\%#//' - return snipMate#expandSnip(snippet, col) - endif - endfor - - if exists('SuperTabKey') - call feedkeys(SuperTabKey) - return '' - endif - return "\<tab>" -endf - -fun! BackwardsSnippet() - if exists('g:snipPos') | return snipMate#jumpTabStop(1) | endif - - if exists('g:SuperTabMappingForward') - if g:SuperTabMappingBackward == "<s-tab>" - let SuperTabKey = "\<c-p>" - elseif g:SuperTabMappingForward == "<s-tab>" - let SuperTabKey = "\<c-n>" - endif - endif - if exists('SuperTabKey') - call feedkeys(SuperTabKey) - return '' - endif - return "\<s-tab>" -endf - -" Check if word under cursor is snippet trigger; if it isn't, try checking if -" the text after non-word characters is (e.g. check for "foo" in "bar.foo") -fun s:GetSnippet(word, scope) - let word = a:word | let snippet = '' - while snippet == '' - if exists('s:snippets["'.a:scope.'"]["'.escape(word, '\"').'"]') - let snippet = s:snippets[a:scope][word] - elseif exists('s:multi_snips["'.a:scope.'"]["'.escape(word, '\"').'"]') - let snippet = s:ChooseSnippet(a:scope, word) - if snippet == '' | break | endif - else - if match(word, '\W') == -1 | break | endif - let word = substitute(word, '.\{-}\W', '', '') - endif - endw - if word == '' && a:word != '.' && stridx(a:word, '.') != -1 - let [word, snippet] = s:GetSnippet('.', a:scope) - endif - return [word, snippet] -endf - -fun s:ChooseSnippet(scope, trigger) - let snippet = [] - let i = 1 - for snip in s:multi_snips[a:scope][a:trigger] - let snippet += [i.'. '.snip[0]] - let i += 1 - endfor - if i == 2 | return s:multi_snips[a:scope][a:trigger][0][1] | endif - let num = inputlist(snippet) - 1 - return num == -1 ? '' : s:multi_snips[a:scope][a:trigger][num][1] -endf - -fun! ShowAvailableSnips() - let line = getline('.') - let col = col('.') - let word = matchstr(getline('.'), '\S\+\%'.col.'c') - let words = [word] - if stridx(word, '.') - let words += split(word, '\.', 1) - endif - let matchlen = 0 - let matches = [] - for scope in [bufnr('%')] + split(&ft, '\.') + ['_'] - let triggers = has_key(s:snippets, scope) ? keys(s:snippets[scope]) : [] - if has_key(s:multi_snips, scope) - let triggers += keys(s:multi_snips[scope]) - endif - for trigger in triggers - for word in words - if word == '' - let matches += [trigger] " Show all matches if word is empty - elseif trigger =~ '^'.word - let matches += [trigger] - let len = len(word) - if len > matchlen | let matchlen = len | endif - endif - endfor - endfor - endfor - - " This is to avoid a bug with Vim when using complete(col - matchlen, matches) - " (Issue#46 on the Google Code snipMate issue tracker). - call setline(line('.'), substitute(line, repeat('.', matchlen).'\%'.col.'c', '', '')) - call complete(col, matches) - return '' -endf -" vim:noet:sw=4:ts=4:ft=vim diff --git a/vim/bundle/snipmate/snippets/_.snippets b/vim/bundle/snipmate/snippets/_.snippets @@ -1,9 +0,0 @@ -# Global snippets - -# (c) holds no legal value ;) -snippet c) - Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${1:`g:snips_author`}. All Rights Reserved.${2} -snippet date - `strftime("%Y-%m-%d")` -snippet ddate - `strftime("%B %d, %Y")` diff --git a/vim/bundle/snipmate/snippets/autoit.snippets b/vim/bundle/snipmate/snippets/autoit.snippets @@ -1,66 +0,0 @@ -snippet if - If ${1:condition} Then - ${2:; True code} - EndIf -snippet el - Else - ${1} -snippet elif - ElseIf ${1:condition} Then - ${2:; True code} -# If/Else block -snippet ifel - If ${1:condition} Then - ${2:; True code} - Else - ${3:; Else code} - EndIf -# If/ElseIf/Else block -snippet ifelif - If ${1:condition 1} Then - ${2:; True code} - ElseIf ${3:condition 2} Then - ${4:; True code} - Else - ${5:; Else code} - EndIf -# Switch block -snippet switch - Switch (${1:condition}) - Case {$2:case1}: - {$3:; Case 1 code} - Case Else: - {$4:; Else code} - EndSwitch -# Select block -snippet select - Select (${1:condition}) - Case {$2:case1}: - {$3:; Case 1 code} - Case Else: - {$4:; Else code} - EndSelect -# While loop -snippet while - While (${1:condition}) - ${2:; code...} - WEnd -# For loop -snippet for - For ${1:n} = ${3:1} to ${2:count} - ${4:; code...} - Next -# New Function -snippet func - Func ${1:fname}(${2:`indent('.') ? 'self' : ''`}): - ${4:Return} - EndFunc -# Message box -snippet msg - MsgBox(${3:MsgType}, ${1:"Title"}, ${2:"Message Text"}) -# Debug Message -snippet debug - MsgBox(0, "Debug", ${1:"Debug Message"}) -# Show Variable Debug Message -snippet showvar - MsgBox(0, "${1:VarName}", $1) diff --git a/vim/bundle/snipmate/snippets/c.snippets b/vim/bundle/snipmate/snippets/c.snippets @@ -1,113 +0,0 @@ -# main() -snippet main - int main(int argc, const char *argv[]) - { - ${1} - return 0; - } -snippet mainn - int main(void) - { - ${1} - return 0; - } -# #include <...> -snippet inc - #include <${1:stdio}.h>${2} -# #include "..." -snippet Inc - #include "${1:`Filename("$1.h")`}"${2} -# #ifndef ... #define ... #endif -snippet Def - #ifndef $1 - #define ${1:SYMBOL} ${2:value} - #endif${3} -snippet def - #define -snippet ifdef - #ifdef ${1:FOO} - ${2:#define } - #endif -snippet #if - #if ${1:FOO} - ${2} - #endif -# Header Include-Guard -snippet once - #ifndef ${1:`toupper(Filename('$1_H', 'UNTITLED_H'))`} - - #define $1 - - ${2} - - #endif /* end of include guard: $1 */ -# If Condition -snippet if - if (${1:/* condition */}) { - ${2:/* code */} - } -snippet el - else { - ${1} - } -# Ternary conditional -snippet t - ${1:/* condition */} ? ${2:a} : ${3:b} -# Do While Loop -snippet do - do { - ${2:/* code */} - } while (${1:/* condition */}); -# While Loop -snippet wh - while (${1:/* condition */}) { - ${2:/* code */} - } -# For Loop -snippet for - for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) { - ${4:/* code */} - } -# Custom For Loop -snippet forr - for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) { - ${5:/* code */} - } -# Function -snippet fun - ${1:void} ${2:function_name}(${3}) - { - ${4:/* code */} - } -# Function Declaration -snippet fund - ${1:void} ${2:function_name}(${3});${4} -# Typedef -snippet td - typedef ${1:int} ${2:MyCustomType};${3} -# Struct -snippet st - struct ${1:`Filename('$1_t', 'name')`} { - ${2:/* data */} - }${3: /* optional variable list */};${4} -# Typedef struct -snippet tds - typedef struct ${2:_$1 }{ - ${3:/* data */} - } ${1:`Filename('$1_t', 'name')`}; -# Typdef enum -snippet tde - typedef enum { - ${1:/* data */} - } ${2:foo}; -# printf -# unfortunately version this isn't as nice as TextMates's, given the lack of a -# dynamic `...` -snippet pr - printf("${1:%s}\n"${2});${3} -# fprintf (again, this isn't as nice as TextMate's version, but it works) -snippet fpr - fprintf(${1:stderr}, "${2:%s}\n"${3});${4} -# This is kind of convenient -snippet . - [${1}]${2} diff --git a/vim/bundle/snipmate/snippets/cpp.snippets b/vim/bundle/snipmate/snippets/cpp.snippets @@ -1,34 +0,0 @@ -# Read File Into Vector -snippet readfile - std::vector<char> v; - if (FILE *${2:fp} = fopen(${1:"filename"}, "r")) { - char buf[1024]; - while (size_t len = fread(buf, 1, sizeof(buf), $2)) - v.insert(v.end(), buf, buf + len); - fclose($2); - }${3} -# std::map -snippet map - std::map<${1:key}, ${2:value}> map${3}; -# std::vector -snippet vector - std::vector<${1:char}> v${2}; -# Namespace -snippet ns - namespace ${1:`Filename('', 'my')`} { - ${2} - } /* $1 */ -# Class -snippet cl - class ${1:`Filename('$1_t', 'name')`} { - public: - $1 (${2:arguments}); - virtual ~$1 (); - - private: - ${3:/* data */} - }; -snippet fori - for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) { - ${4:/* code */} - } diff --git a/vim/bundle/snipmate/snippets/erlang.snippets b/vim/bundle/snipmate/snippets/erlang.snippets @@ -1,39 +0,0 @@ -# module and export all -snippet mod - -module(${1:`Filename('', 'my')`}). - - -compile([export_all]). - - start() -> - ${2} - - stop() -> - ok. -# define directive -snippet def - -define(${1:macro}, ${2:body}).${3} -# export directive -snippet exp - -export([${1:function}/${2:arity}]). -# include directive -snippet inc - -include("${1:file}").${2} -# behavior directive -snippet beh - -behaviour(${1:behaviour}).${2} -# if expression -snippet if - if - ${1:guard} -> - ${2:body} - end -# case expression -snippet case - case ${1:expression} of - ${2:pattern} -> - ${3:body}; - end -# record directive -snippet rec - -record(${1:record}, { - ${2:field}=${3:value}}).${4} diff --git a/vim/bundle/snipmate/snippets/html.snippets b/vim/bundle/snipmate/snippets/html.snippets @@ -1,190 +0,0 @@ -# Some useful Unicode entities -# Non-Breaking Space -snippet nbs - &nbsp; -# ← -snippet left - &#x2190; -# → -snippet right - &#x2192; -# ↑ -snippet up - &#x2191; -# ↓ -snippet down - &#x2193; -# ↩ -snippet return - &#x21A9; -# ⇤ -snippet backtab - &#x21E4; -# ⇥ -snippet tab - &#x21E5; -# ⇧ -snippet shift - &#x21E7; -# ⌃ -snippet control - &#x2303; -# ⌅ -snippet enter - &#x2305; -# ⌘ -snippet command - &#x2318; -# ⌥ -snippet option - &#x2325; -# ⌦ -snippet delete - &#x2326; -# ⌫ -snippet backspace - &#x232B; -# ⎋ -snippet escape - &#x238B; -# Generic Doctype -snippet doctype HTML 4.01 Strict - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" - "http://www.w3.org/TR/html4/strict.dtd"> -snippet doctype HTML 4.01 Transitional - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" - "http://www.w3.org/TR/html4/loose.dtd"> -snippet doctype HTML 5 - <!DOCTYPE HTML> -snippet doctype XHTML 1.0 Frameset - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -snippet doctype XHTML 1.0 Strict - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -snippet doctype XHTML 1.0 Transitional - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -snippet doctype XHTML 1.1 - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" - "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> -# HTML Doctype 4.01 Strict -snippet docts - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" - "http://www.w3.org/TR/html4/strict.dtd"> -# HTML Doctype 4.01 Transitional -snippet doct - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" - "http://www.w3.org/TR/html4/loose.dtd"> -# HTML Doctype 5 -snippet doct5 - <!DOCTYPE HTML> -# XHTML Doctype 1.0 Frameset -snippet docxf - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> -# XHTML Doctype 1.0 Strict -snippet docxs - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -# XHTML Doctype 1.0 Transitional -snippet docxt - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -# XHTML Doctype 1.1 -snippet docx - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" - "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> -snippet html - <html> - ${1} - </html> -snippet xhtml - <html xmlns="http://www.w3.org/1999/xhtml"> - ${1} - </html> -snippet body - <body> - ${1} - </body> -snippet head - <head> - <meta http-equiv="content-type" content="text/html; charset=utf-8"`Close()`> - - <title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title> - ${2} - </head> -snippet title - <title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title>${2} -snippet script - <script type="text/javascript" charset="utf-8"> - ${1} - </script>${2} -snippet scriptsrc - <script src="${1}.js" type="text/javascript" charset="utf-8"></script>${2} -snippet style - <style type="text/css" media="${1:screen}"> - ${2} - </style>${3} -snippet base - <base href="${1}" target="${2}"`Close()`> -snippet r - <br`Close()[1:]`> -snippet div - <div id="${1:name}"> - ${2} - </div> -# Embed QT Movie -snippet movie - <object width="$2" height="$3" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" - codebase="http://www.apple.com/qtactivex/qtplugin.cab"> - <param name="src" value="$1"`Close()`> - <param name="controller" value="$4"`Close()`> - <param name="autoplay" value="$5"`Close()`> - <embed src="${1:movie.mov}" - width="${2:320}" height="${3:240}" - controller="${4:true}" autoplay="${5:true}" - scale="tofit" cache="true" - pluginspage="http://www.apple.com/quicktime/download/" - `Close()[1:]`> - </object>${6} -snippet fieldset - <fieldset id="$1"> - <legend>${1:name}</legend> - - ${3} - </fieldset> -snippet form - <form action="${1:`Filename('$1_submit')`}" method="${2:get}" accept-charset="utf-8"> - ${3} - - - <p><input type="submit" value="Continue &rarr;"`Close()`></p> - </form> -snippet h1 - <h1 id="${1:heading}">${2:$1}</h1> -snippet input - <input type="${1:text/submit/hidden/button}" name="${2:some_name}" value="${3}"`Close()`>${4} -snippet label - <label for="${2:$1}">${1:name}</label><input type="${3:text/submit/hidden/button}" name="${4:$2}" value="${5}" id="${6:$2}"`Close()`>${7} -snippet link - <link rel="${1:stylesheet}" href="${2:/css/master.css}" type="text/css" media="${3:screen}" charset="utf-8"`Close()`>${4} -snippet mailto - <a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${3:email me}</a> -snippet meta - <meta name="${1:name}" content="${2:content}"`Close()`>${3} -snippet opt - <option value="${1:option}">${2:$1}</option>${3} -snippet optt - <option>${1:option}</option>${2} -snippet select - <select name="${1:some_name}" id="${2:$1}"> - <option value="${3:option}">${4:$3}</option> - </select>${5} -snippet table - <table border="${1:0}"> - <tr><th>${2:Header}</th></tr> - <tr><th>${3:Data}</th></tr> - </table>${4} -snippet textarea - <textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">${4}</textarea>${5} diff --git a/vim/bundle/snipmate/snippets/java.snippets b/vim/bundle/snipmate/snippets/java.snippets @@ -1,95 +0,0 @@ -snippet main - public static void main (String [] args) - { - ${1:/* code */} - } -snippet pu - public -snippet po - protected -snippet pr - private -snippet st - static -snippet fi - final -snippet ab - abstract -snippet re - return -snippet br - break; -snippet de - default: - ${1} -snippet ca - catch(${1:Exception} ${2:e}) ${3} -snippet th - throw -snippet sy - synchronized -snippet im - import -snippet imp - implements -snippet ext - extends -snippet j.u - java.util -snippet j.i - java.io. -snippet j.b - java.beans. -snippet j.n - java.net. -snippet j.m - java.math. -snippet if - if (${1}) ${2} -snippet el - else -snippet elif - else if (${1}) ${2} -snippet wh - while (${1}) ${2} -snippet for - for (${1}; ${2}; ${3}) ${4} -snippet fore - for (${1} : ${2}) ${3} -snippet sw - switch (${1}) ${2} -snippet cs - case ${1}: - ${2} - ${3} -snippet tc - public class ${1:`Filename()`} extends ${2:TestCase} -snippet t - public void test${1:Name}() throws Exception ${2} -snippet cl - class ${1:`Filename("", "untitled")`} ${2} -snippet in - interface ${1:`Filename("", "untitled")`} ${2:extends Parent}${3} -snippet m - ${1:void} ${2:method}(${3}) ${4:throws }${5} -snippet v - ${1:String} ${2:var}${3: = null}${4};${5} -snippet co - static public final ${1:String} ${2:var} = ${3};${4} -snippet cos - static public final String ${1:var} = "${2}";${3} -snippet as - assert ${1:test} : "${2:Failure message}";${3} -snippet try - try { - ${3} - } catch(${1:Exception} ${2:e}) { - } -snippet tryf - try { - ${3} - } catch(${1:Exception} ${2:e}) { - } finally { - } -snippet rst - ResultSet ${1:rst}${2: = null}${3};${4} diff --git a/vim/bundle/snipmate/snippets/javascript.snippets b/vim/bundle/snipmate/snippets/javascript.snippets @@ -1,74 +0,0 @@ -# Prototype -snippet proto - ${1:class_name}.prototype.${2:method_name} = - function(${3:first_argument}) { - ${4:// body...} - }; -# Function -snippet fun - function ${1:function_name} (${2:argument}) { - ${3:// body...} - } -# Anonymous Function -snippet f - function(${1}) {${2}}; -# if -snippet if - if (${1:true}) {${2}} -# if ... else -snippet ife - if (${1:true}) {${2}} - else{${3}} -# tertiary conditional -snippet t - ${1:/* condition */} ? ${2:a} : ${3:b} -# switch -snippet switch - switch(${1:expression}) { - case '${3:case}': - ${4:// code} - break; - ${5} - default: - ${2:// code} - } -# case -snippet case - case '${1:case}': - ${2:// code} - break; - ${3} -# for (...) {...} -snippet for - for (var ${2:i} = 0; $2 < ${1:Things}.length; $2${3:++}) { - ${4:$1[$2]} - }; -# for (...) {...} (Improved Native For-Loop) -snippet forr - for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2${3:--}) { - ${4:$1[$2]} - }; -# while (...) {...} -snippet wh - while (${1:/* condition */}) { - ${2:/* code */} - } -# do...while -snippet do - do { - ${2:/* code */} - } while (${1:/* condition */}); -# Object Method -snippet :f - ${1:method_name}: function(${2:attribute}) { - ${4} - }${3:,} -# setTimeout function -snippet timeout - setTimeout(function() {${3}}${2}, ${1:10}; -# Get Elements -snippet get - getElementsBy${1:TagName}('${2}')${3} -# Get Element -snippet gett - getElementBy${1:Id}('${2}')${3} diff --git a/vim/bundle/snipmate/snippets/mako.snippets b/vim/bundle/snipmate/snippets/mako.snippets @@ -1,54 +0,0 @@ -snippet def - <%def name="${1:name}"> - ${2:} - </%def> -snippet call - <%call expr="${1:name}"> - ${2:} - </%call> -snippet doc - <%doc> - ${1:} - </%doc> -snippet text - <%text> - ${1:} - </%text> -snippet for - % for ${1:i} in ${2:iter}: - ${3:} - % endfor -snippet if if - % if ${1:condition}: - ${2:} - % endif -snippet if if/else - % if ${1:condition}: - ${2:} - % else: - ${3:} - % endif -snippet try - % try: - ${1:} - % except${2:}: - ${3:pass} - % endtry -snippet wh - % while ${1:}: - ${2:} - % endwhile -snippet $ - ${ ${1:} } -snippet <% - <% ${1:} %> -snippet <!% - <!% ${1:} %> -snippet inherit - <%inherit file="${1:filename}" /> -snippet include - <%include file="${1:filename}" /> -snippet namespace - <%namespace file="${1:name}" /> -snippet page - <%page args="${1:}" /> diff --git a/vim/bundle/snipmate/snippets/objc.snippets b/vim/bundle/snipmate/snippets/objc.snippets @@ -1,247 +0,0 @@ -# #import <...> -snippet Imp - #import <${1:Cocoa/Cocoa.h}>${2} -# #import "..." -snippet imp - #import "${1:`Filename()`.h}"${2} -# @selector(...) -snippet sel - @selector(${1:method}:)${3} -# @"..." string -snippet s - @"${1}"${2} -# Object -snippet o - ${1:NSObject} *${2:foo} = [${3:$1 alloc}]${4};${5} -# NSLog(...) -snippet log - NSLog(@"${1:%@}"${2});${3} -# Class -snippet objc - @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject} - { - } - @end - - @implementation $1 - ${3} - @end -# Class Interface -snippet int - @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject} - {${3} - } - ${4} - @end -snippet @interface - @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject} - {${3} - } - ${4} - @end -# Class Implementation -snippet impl - @implementation ${1:`Filename('', 'someClass')`} - ${2} - @end -snippet @implementation - @implementation ${1:`Filename('', 'someClass')`} - ${2} - @end -# Protocol -snippet pro - @protocol ${1:`Filename('$1Delegate', 'MyProtocol')`} ${2:<NSObject>} - ${3} - @end -snippet @protocol - @protocol ${1:`Filename('$1Delegate', 'MyProtocol')`} ${2:<NSObject>} - ${3} - @end -# init Definition -snippet init - - (id)init - { - if (self = [super init]) { - ${1} - } - return self; - } -# dealloc Definition -snippet dealloc - - (void) dealloc - { - ${1:deallocations} - [super dealloc]; - } -snippet su - [super ${1:init}]${2} -snippet ibo - IBOutlet ${1:NSSomeClass} *${2:$1};${3} -# Category -snippet cat - @interface ${1:NSObject} (${2:MyCategory}) - @end - - @implementation $1 ($2) - ${3} - @end -# Category Interface -snippet cath - @interface ${1:`Filename('$1', 'NSObject')`} (${2:MyCategory}) - ${3} - @end -# Method -snippet m - - (${1:id})${2:method} - { - ${3} - } -# Method declaration -snippet md - - (${1:id})${2:method};${3} -# IBAction declaration -snippet ibad - - (IBAction)${1:method}:(${2:id})sender;${3} -# IBAction method -snippet iba - - (IBAction)${1:method}:(${2:id})sender - { - ${3} - } -# awakeFromNib method -snippet wake - - (void)awakeFromNib - { - ${1} - } -# Class Method -snippet M - + (${1:id})${2:method} - { - ${3:return nil;} - } -# Sub-method (Call super) -snippet sm - - (${1:id})${2:method} - { - [super $2];${3} - return self; - } -# Accessor Methods For: -# Object -snippet objacc - - (${1:id})${2:thing} - { - return $2; - } - - - (void)set$2:($1)${3:new$2} - { - [$3 retain]; - [$2 release]; - $2 = $3; - }${4} -# for (object in array) -snippet forin - for (${1:Class} *${2:some$1} in ${3:array}) { - ${4} - } -snippet fore - for (${1:object} in ${2:array}) { - ${3:statements} - } -snippet forarray - unsigned int ${1:object}Count = [${2:array} count]; - - for (unsigned int index = 0; index < $1Count; index++) { - ${3:id} $1 = [$2 $1AtIndex:index]; - ${4} - } -snippet fora - unsigned int ${1:object}Count = [${2:array} count]; - - for (unsigned int index = 0; index < $1Count; index++) { - ${3:id} $1 = [$2 $1AtIndex:index]; - ${4} - } -# Try / Catch Block -snippet @try - @try { - ${1:statements} - } - @catch (NSException * e) { - ${2:handler} - } - @finally { - ${3:statements} - } -snippet @catch - @catch (${1:exception}) { - ${2:handler} - } -snippet @finally - @finally { - ${1:statements} - } -# IBOutlet -# @property (Objective-C 2.0) -snippet prop - @property (${1:retain}) ${2:NSSomeClass} ${3:*$2};${4} -# @synthesize (Objective-C 2.0) -snippet syn - @synthesize ${1:property};${2} -# [[ alloc] init] -snippet alloc - [[${1:foo} alloc] init${2}];${3} -snippet a - [[${1:foo} alloc] init${2}];${3} -# retain -snippet ret - [${1:foo} retain];${2} -# release -snippet rel - [${1:foo} release]; -# autorelease -snippet arel - [${1:foo} autorelease]; -# autorelease pool -snippet pool - NSAutoreleasePool *${1:pool} = [[NSAutoreleasePool alloc] init]; - ${2:/* code */} - [$1 drain]; -# Throw an exception -snippet except - NSException *${1:badness}; - $1 = [NSException exceptionWithName:@"${2:$1Name}" - reason:@"${3}" - userInfo:nil]; - [$1 raise]; -snippet prag - #pragma mark ${1:-} -snippet cl - @class ${1:Foo};${2} -snippet color - [[NSColor ${1:blackColor}] set]; -# NSArray -snippet array - NSMutableArray *${1:array} = [NSMutable array];${2} -snippet nsa - NSArray ${1} -snippet nsma - NSMutableArray ${1} -snippet aa - NSArray * array;${1} -snippet ma - NSMutableArray * array;${1} -# NSDictionary -snippet dict - NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];${2} -snippet nsd - NSDictionary ${1} -snippet nsmd - NSMutableDictionary ${1} -# NSString -snippet nss - NSString ${1} -snippet nsms - NSMutableString ${1} diff --git a/vim/bundle/snipmate/snippets/perl.snippets b/vim/bundle/snipmate/snippets/perl.snippets @@ -1,97 +0,0 @@ -# #!/usr/bin/perl -snippet #! - #!/usr/bin/perl - -# Hash Pointer -snippet . - => -# Function -snippet sub - sub ${1:function_name} { - ${2:#body ...} - } -# Conditional -snippet if - if (${1}) { - ${2:# body...} - } -# Conditional if..else -snippet ife - if (${1}) { - ${2:# body...} - } - else { - ${3:# else...} - } -# Conditional if..elsif..else -snippet ifee - if (${1}) { - ${2:# body...} - } - elsif (${3}) { - ${4:# elsif...} - } - else { - ${5:# else...} - } -# Conditional One-line -snippet xif - ${1:expression} if ${2:condition};${3} -# Unless conditional -snippet unless - unless (${1}) { - ${2:# body...} - } -# Unless conditional One-line -snippet xunless - ${1:expression} unless ${2:condition};${3} -# Try/Except -snippet eval - eval { - ${1:# do something risky...} - }; - if ($@) { - ${2:# handle failure...} - } -# While Loop -snippet wh - while (${1}) { - ${2:# body...} - } -# While Loop One-line -snippet xwh - ${1:expression} while ${2:condition};${3} -# C-style For Loop -snippet cfor - for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) { - ${4:# body...} - } -# For loop one-line -snippet xfor - ${1:expression} for @${2:array};${3} -# Foreach Loop -snippet for - foreach my $${1:x} (@${2:array}) { - ${3:# body...} - } -# Foreach Loop One-line -snippet fore - ${1:expression} foreach @${2:array};${3} -# Package -snippet cl - package ${1:ClassName}; - - use base qw(${2:ParentClass}); - - sub new { - my $class = shift; - $class = ref $class if ref $class; - my $self = bless {}, $class; - $self; - } - - 1;${3} -# Read File -snippet slurp - my $${1:var}; - { local $/ = undef; local *FILE; open FILE, "<${2:file}"; $$1 = <FILE>; close FILE }${3} diff --git a/vim/bundle/snipmate/snippets/php.snippets b/vim/bundle/snipmate/snippets/php.snippets @@ -1,216 +0,0 @@ -snippet php - <?php - ${1} - ?> -snippet ec - echo "${1:string}"${2}; -snippet inc - include '${1:file}';${2} -snippet inc1 - include_once '${1:file}';${2} -snippet req - require '${1:file}';${2} -snippet req1 - require_once '${1:file}';${2} -# $GLOBALS['...'] -snippet globals - $GLOBALS['${1:variable}']${2: = }${3:something}${4:;}${5} -snippet $_ COOKIE['...'] - $_COOKIE['${1:variable}']${2} -snippet $_ ENV['...'] - $_ENV['${1:variable}']${2} -snippet $_ FILES['...'] - $_FILES['${1:variable}']${2} -snippet $_ Get['...'] - $_GET['${1:variable}']${2} -snippet $_ POST['...'] - $_POST['${1:variable}']${2} -snippet $_ REQUEST['...'] - $_REQUEST['${1:variable}']${2} -snippet $_ SERVER['...'] - $_SERVER['${1:variable}']${2} -snippet $_ SESSION['...'] - $_SESSION['${1:variable}']${2} -# Start Docblock -snippet /* - /** - * ${1} - **/ -# Class - post doc -snippet doc_cp - /** - * ${1:undocumented class} - * - * @package ${2:default} - * @author ${3:`g:snips_author`} - **/${4} -# Class Variable - post doc -snippet doc_vp - /** - * ${1:undocumented class variable} - * - * @var ${2:string} - **/${3} -# Class Variable -snippet doc_v - /** - * ${3:undocumented class variable} - * - * @var ${4:string} - **/ - ${1:var} $${2};${5} -# Class -snippet doc_c - /** - * ${3:undocumented class} - * - * @packaged ${4:default} - * @author ${5:`g:snips_author`} - **/ - ${1:}class ${2:} - {${6} - } // END $1class $2 -# Constant Definition - post doc -snippet doc_dp - /** - * ${1:undocumented constant} - **/${2} -# Constant Definition -snippet doc_d - /** - * ${3:undocumented constant} - **/ - define(${1}, ${2});${4} -# Function - post doc -snippet doc_fp - /** - * ${1:undocumented function} - * - * @return ${2:void} - * @author ${3:`g:snips_author`} - **/${4} -# Function signature -snippet doc_s - /** - * ${4:undocumented function} - * - * @return ${5:void} - * @author ${6:`g:snips_author`} - **/ - ${1}function ${2}(${3});${7} -# Function -snippet doc_f - /** - * ${4:undocumented function} - * - * @return ${5:void} - * @author ${6:`g:snips_author`} - **/ - ${1}function ${2}(${3}) - {${7} - } -# Header -snippet doc_h - /** - * ${1} - * - * @author ${2:`g:snips_author`} - * @version ${3:$Id$} - * @copyright ${4:$2}, `strftime('%d %B, %Y')` - * @package ${5:default} - **/ - - /** - * Define DocBlock - *// -# Interface -snippet doc_i - /** - * ${2:undocumented class} - * - * @package ${3:default} - * @author ${4:`g:snips_author`} - **/ - interface ${1:} - {${5} - } // END interface $1 -# class ... -snippet class - /** - * ${1} - **/ - class ${2:ClassName} - { - ${3} - function ${4:__construct}(${5:argument}) - { - ${6:// code...} - } - } -# define(...) -snippet def - define('${1}'${2});${3} -# defined(...) -snippet def? - ${1}defined('${2}')${3} -snippet wh - while (${1:/* condition */}) { - ${2:// code...} - } -# do ... while -snippet do - do { - ${2:// code... } - } while (${1:/* condition */}); -snippet if - if (${1:/* condition */}) { - ${2:// code...} - } -snippet ife - if (${1:/* condition */}) { - ${2:// code...} - } else { - ${3:// code...} - } - ${4} -snippet else - else { - ${1:// code...} - } -snippet elseif - elseif (${1:/* condition */}) { - ${2:// code...} - } -# Tertiary conditional -snippet t - $${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5} -snippet switch - switch ($${1:variable}) { - case '${2:value}': - ${3:// code...} - break; - ${5} - default: - ${4:// code...} - break; - } -snippet case - case '${1:value}': - ${2:// code...} - break;${3} -snippet for - for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) { - ${4: // code...} - } -snippet foreach - foreach ($${1:variable} as $${2:key}) { - ${3:// code...} - } -snippet fun - ${1:public }function ${2:FunctionName}(${3}) - { - ${4:// code...} - } -# $... = array (...) -snippet array - $${1:arrayName} = array('${2}' => ${3});${4} diff --git a/vim/bundle/snipmate/snippets/python.snippets b/vim/bundle/snipmate/snippets/python.snippets @@ -1,86 +0,0 @@ -snippet #! - #!/usr/bin/env python - -snippet imp - import ${1:module} -# Module Docstring -snippet docs - ''' - File: ${1:`Filename('$1.py', 'foo.py')`} - Author: ${2:`g:snips_author`} - Description: ${3} - ''' -snippet wh - while ${1:condition}: - ${2:# code...} -snippet for - for ${1:needle} in ${2:haystack}: - ${3:# code...} -# New Class -snippet cl - class ${1:ClassName}(${2:object}): - """${3:docstring for $1}""" - def __init__(self, ${4:arg}): - ${5:super($1, self).__init__()} - self.$4 = $4 - ${6} -# New Function -snippet def - def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): - """${3:docstring for $1}""" - ${4:pass} -snippet deff - def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): - ${3} -# New Method -snippet defs - def ${1:mname}(self, ${2:arg}): - ${3:pass} -# New Property -snippet property - def ${1:foo}(): - doc = "${2:The $1 property.}" - def fget(self): - ${3:return self._$1} - def fset(self, value): - ${4:self._$1 = value} -# Lambda -snippet ld - ${1:var} = lambda ${2:vars} : ${3:action} -snippet . - self. -snippet try Try/Except - try: - ${1:pass} - except ${2:Exception}, ${3:e}: - ${4:raise $3} -snippet try Try/Except/Else - try: - ${1:pass} - except ${2:Exception}, ${3:e}: - ${4:raise $3} - else: - ${5:pass} -snippet try Try/Except/Finally - try: - ${1:pass} - except ${2:Exception}, ${3:e}: - ${4:raise $3} - finally: - ${5:pass} -snippet try Try/Except/Else/Finally - try: - ${1:pass} - except ${2:Exception}, ${3:e}: - ${4:raise $3} - else: - ${5:pass} - finally: - ${6:pass} -# if __name__ == '__main__': -snippet ifmain - if __name__ == '__main__': - ${1:main()} -# __magic__ -snippet _ - __${1:init}__${2} diff --git a/vim/bundle/snipmate/snippets/ruby.snippets b/vim/bundle/snipmate/snippets/ruby.snippets @@ -1,504 +0,0 @@ -# #!/usr/bin/env ruby -snippet #! - #!/usr/bin/env ruby - -# New Block -snippet =b - =begin rdoc - ${1} - =end -snippet y - :yields: ${1:arguments} -snippet rb - #!/usr/bin/env ruby -wKU -snippet beg - begin - ${3} - rescue ${1:Exception} => ${2:e} - end - -snippet req - require "${1}"${2} -snippet # - # => -snippet end - __END__ -snippet case - case ${1:object} - when ${2:condition} - ${3} - end -snippet when - when ${1:condition} - ${2} -snippet def - def ${1:method_name} - ${2} - end -snippet deft - def test_${1:case_name} - ${2} - end -snippet if - if ${1:condition} - ${2} - end -snippet ife - if ${1:condition} - ${2} - else - ${3} - end -snippet elsif - elsif ${1:condition} - ${2} -snippet unless - unless ${1:condition} - ${2} - end -snippet while - while ${1:condition} - ${2} - end -snippet for - for ${1:e} in ${2:c} - ${3} - end -snippet until - until ${1:condition} - ${2} - end -snippet cla class .. end - class ${1:`substitute(Filename(), '^.', '\u&', '')`} - ${2} - end -snippet cla class .. initialize .. end - class ${1:`substitute(Filename(), '^.', '\u&', '')`} - def initialize(${2:args}) - ${3} - end - - - end -snippet cla class .. < ParentClass .. initialize .. end - class ${1:`substitute(Filename(), '^.', '\u&', '')`} < ${2:ParentClass} - def initialize(${3:args}) - ${4} - end - - - end -snippet cla ClassName = Struct .. do .. end - ${1:`substitute(Filename(), '^.', '\u&', '')`} = Struct.new(:${2:attr_names}) do - def ${3:method_name} - ${4} - end - - - end -snippet cla class BlankSlate .. initialize .. end - class ${1:BlankSlate} - instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ } -snippet cla class << self .. end - class << ${1:self} - ${2} - end -# class .. < DelegateClass .. initialize .. end -snippet cla- - class ${1:`substitute(Filename(), '^.', '\u&', '')`} < DelegateClass(${2:ParentClass}) - def initialize(${3:args}) - super(${4:del_obj}) - - ${5} - end - - - end -snippet mod module .. end - module ${1:`substitute(Filename(), '^.', '\u&', '')`} - ${2} - end -snippet mod module .. module_function .. end - module ${1:`substitute(Filename(), '^.', '\u&', '')`} - module_function - - ${2} - end -snippet mod module .. ClassMethods .. end - module ${1:`substitute(Filename(), '^.', '\u&', '')`} - module ClassMethods - ${2} - end - - module InstanceMethods - - end - - def self.included(receiver) - receiver.extend ClassMethods - receiver.send :include, InstanceMethods - end - end -# attr_reader -snippet r - attr_reader :${1:attr_names} -# attr_writer -snippet w - attr_writer :${1:attr_names} -# attr_accessor -snippet rw - attr_accessor :${1:attr_names} -# include Enumerable -snippet Enum - include Enumerable - - def each(&block) - ${1} - end -# include Comparable -snippet Comp - include Comparable - - def <=>(other) - ${1} - end -# extend Forwardable -snippet Forw- - extend Forwardable -# def self -snippet defs - def self.${1:class_method_name} - ${2} - end -# def method_missing -snippet defmm - def method_missing(meth, *args, &blk) - ${1} - end -snippet defd - def_delegator :${1:@del_obj}, :${2:del_meth}, :${3:new_name} -snippet defds - def_delegators :${1:@del_obj}, :${2:del_methods} -snippet am - alias_method :${1:new_name}, :${2:old_name} -snippet app - if __FILE__ == $PROGRAM_NAME - ${1} - end -# usage_if() -snippet usai - if ARGV.${1} - abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3} - end -# usage_unless() -snippet usau - unless ARGV.${1} - abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3} - end -snippet array - Array.new(${1:10}) { |${2:i}| ${3} } -snippet hash - Hash.new { |${1:hash}, ${2:key}| $1[$2] = ${3} } -snippet file File.foreach() { |line| .. } - File.foreach(${1:"path/to/file"}) { |${2:line}| ${3} } -snippet file File.read() - File.read(${1:"path/to/file"})${2} -snippet Dir Dir.global() { |file| .. } - Dir.glob(${1:"dir/glob/*"}) { |${2:file}| ${3} } -snippet Dir Dir[".."] - Dir[${1:"glob/**/*.rb"}]${2} -snippet dir - Filename.dirname(__FILE__) -snippet deli - delete_if { |${1:e}| ${2} } -snippet fil - fill(${1:range}) { |${2:i}| ${3} } -# flatten_once() -snippet flao - inject(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2)}${3} -snippet zip - zip(${1:enums}) { |${2:row}| ${3} } -# downto(0) { |n| .. } -snippet dow - downto(${1:0}) { |${2:n}| ${3} } -snippet ste - step(${1:2}) { |${2:n}| ${3} } -snippet tim - times { |${1:n}| ${2} } -snippet upt - upto(${1:1.0/0.0}) { |${2:n}| ${3} } -snippet loo - loop { ${1} } -snippet ea - each { |${1:e}| ${2} } -snippet ead - each do |${1:e}| - ${2} - end -snippet eab - each_byte { |${1:byte}| ${2} } -snippet eac- each_char { |chr| .. } - each_char { |${1:chr}| ${2} } -snippet eac- each_cons(..) { |group| .. } - each_cons(${1:2}) { |${2:group}| ${3} } -snippet eai - each_index { |${1:i}| ${2} } -snippet eaid - each_index do |${1:i}| - end -snippet eak - each_key { |${1:key}| ${2} } -snippet eakd - each_key do |${1:key}| - ${2} - end -snippet eal - each_line { |${1:line}| ${2} } -snippet eald - each_line do |${1:line}| - ${2} - end -snippet eap - each_pair { |${1:name}, ${2:val}| ${3} } -snippet eapd - each_pair do |${1:name}, ${2:val}| - ${3} - end -snippet eas- - each_slice(${1:2}) { |${2:group}| ${3} } -snippet easd- - each_slice(${1:2}) do |${2:group}| - ${3} - end -snippet eav - each_value { |${1:val}| ${2} } -snippet eavd - each_value do |${1:val}| - ${2} - end -snippet eawi - each_with_index { |${1:e}, ${2:i}| ${3} } -snippet eawid - each_with_index do |${1:e},${2:i}| - ${3} - end -snippet reve - reverse_each { |${1:e}| ${2} } -snippet reved - reverse_each do |${1:e}| - ${2} - end -snippet inj - inject(${1:init}) { |${2:mem}, ${3:var}| ${4} } -snippet injd - inject(${1:init}) do |${2:mem}, ${3:var}| - ${4} - end -snippet map - map { |${1:e}| ${2} } -snippet mapd - map do |${1:e}| - ${2} - end -snippet mapwi- - enum_with_index.map { |${1:e}, ${2:i}| ${3} } -snippet sor - sort { |a, b| ${1} } -snippet sorb - sort_by { |${1:e}| ${2} } -snippet ran - sort_by { rand } -snippet all - all? { |${1:e}| ${2} } -snippet any - any? { |${1:e}| ${2} } -snippet cl - classify { |${1:e}| ${2} } -snippet col - collect { |${1:e}| ${2} } -snippet cold - collect do |${1:e}| - ${2} - end -snippet det - detect { |${1:e}| ${2} } -snippet detd - detect do |${1:e}| - ${2} - end -snippet fet - fetch(${1:name}) { |${2:key}| ${3} } -snippet fin - find { |${1:e}| ${2} } -snippet find - find do |${1:e}| - ${2} - end -snippet fina - find_all { |${1:e}| ${2} } -snippet finad - find_all do |${1:e}| - ${2} - end -snippet gre - grep(${1:/pattern/}) { |${2:match}| ${3} } -snippet sub - ${1:g}sub(${2:/pattern/}) { |${3:match}| ${4} } -snippet sca - scan(${1:/pattern/}) { |${2:match}| ${3} } -snippet scad - scan(${1:/pattern/}) do |${2:match}| - ${3} - end -snippet max - max { |a, b| ${1} } -snippet min - min { |a, b| ${1} } -snippet par - partition { |${1:e}| ${2} } -snippet pard - partition do |${1:e}| - ${2} - end -snippet rej - reject { |${1:e}| ${2} } -snippet rejd - reject do |${1:e}| - ${2} - end -snippet sel - select { |${1:e}| ${2} } -snippet seld - select do |${1:e}| - ${2} - end -snippet lam - lambda { |${1:args}| ${2} } -snippet do - do |${1:variable}| - ${2} - end -snippet : - :${1:key} => ${2:"value"}${3} -snippet ope - open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${4} } -# path_from_here() -snippet patfh - File.join(File.dirname(__FILE__), *%2[${1:rel path here}])${2} -# unix_filter {} -snippet unif - ARGF.each_line${1} do |${2:line}| - ${3} - end -# option_parse {} -snippet optp - require "optparse" - - options = {${1:default => "args"}} - - ARGV.options do |opts| - opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} -snippet opt - opts.on( "-${1:o}", "--${2:long-option-name}", ${3:String}, - "${4:Option description.}") do |${5:opt}| - ${6} - end -snippet tc - require "test/unit" - - require "${1:library_file_name}" - - class Test${2:$1} < Test::Unit::TestCase - def test_${3:case_name} - ${4} - end - end -snippet ts - require "test/unit" - - require "tc_${1:test_case_file}" - require "tc_${2:test_case_file}"${3} -snippet as - assert(${1:test}, "${2:Failure message.}")${3} -snippet ase - assert_equal(${1:expected}, ${2:actual})${3} -snippet asne - assert_not_equal(${1:unexpected}, ${2:actual})${3} -snippet asid - assert_in_delta(${1:expected_float}, ${2:actual_float}, ${3:2 ** -20})${4} -snippet asio - assert_instance_of(${1:ExpectedClass}, ${2:actual_instance})${3} -snippet asko - assert_kind_of(${1:ExpectedKind}, ${2:actual_instance})${3} -snippet asn - assert_nil(${1:instance})${2} -snippet asnn - assert_not_nil(${1:instance})${2} -snippet asm - assert_match(/${1:expected_pattern}/, ${2:actual_string})${3} -snippet asnm - assert_no_match(/${1:unexpected_pattern}/, ${2:actual_string})${3} -snippet aso - assert_operator(${1:left}, :${2:operator}, ${3:right})${4} -snippet asr - assert_raise(${1:Exception}) { ${2} } -snippet asnr - assert_nothing_raised(${1:Exception}) { ${2} } -snippet asrt - assert_respond_to(${1:object}, :${2:method})${3} -snippet ass assert_same(..) - assert_same(${1:expected}, ${2:actual})${3} -snippet ass assert_send(..) - assert_send([${1:object}, :${2:message}, ${3:args}])${4} -snippet asns - assert_not_same(${1:unexpected}, ${2:actual})${3} -snippet ast - assert_throws(:${1:expected}) { ${2} } -snippet asnt - assert_nothing_thrown { ${1} } -snippet fl - flunk("${1:Failure message.}")${2} -# Benchmark.bmbm do .. end -snippet bm- - TESTS = ${1:10_000} - Benchmark.bmbm do |results| - ${2} - end -snippet rep - results.report("${1:name}:") { TESTS.times { ${2} }} -# Marshal.dump(.., file) -snippet Md - File.open(${1:"path/to/file.dump"}, "wb") { |${2:file}| Marshal.dump(${3:obj}, $2) }${4} -# Mashal.load(obj) -snippet Ml - File.open(${1:"path/to/file.dump"}, "rb") { |${2:file}| Marshal.load($2) }${3} -# deep_copy(..) -snippet deec - Marshal.load(Marshal.dump(${1:obj_to_copy}))${2} -snippet Pn- - PStore.new(${1:"file_name.pstore"})${2} -snippet tra - transaction(${1:true}) { ${2} } -# xmlread(..) -snippet xml- - REXML::Document.new(File.read(${1:"path/to/file"}))${2} -# xpath(..) { .. } -snippet xpa - elements.each(${1:"//Xpath"}) do |${2:node}| - ${3} - end -# class_from_name() -snippet clafn - split("::").inject(Object) { |par, const| par.const_get(const) } -# singleton_class() -snippet sinc - class << self; self end -snippet nam - namespace :${1:`Filename()`} do - ${2} - end -snippet tas - desc "${1:Task description\}" - task :${2:task_name => [:dependent, :tasks]} do - ${3} - end diff --git a/vim/bundle/snipmate/snippets/sh.snippets b/vim/bundle/snipmate/snippets/sh.snippets @@ -1,28 +0,0 @@ -# #!/bin/bash -snippet #! - #!/bin/bash - -snippet if - if [[ ${1:condition} ]]; then - ${2:#statements} - fi -snippet elif - elif [[ ${1:condition} ]]; then - ${2:#statements} -snippet for - for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do - ${3:#statements} - done -snippet wh - while [[ ${1:condition} ]]; do - ${2:#statements} - done -snippet until - until [[ ${1:condition} ]]; do - ${2:#statements} - done -snippet case - case ${1:word} in - ${2:pattern}) - ${3};; - esac diff --git a/vim/bundle/snipmate/snippets/snippet.snippets b/vim/bundle/snipmate/snippets/snippet.snippets @@ -1,7 +0,0 @@ -# snippets for making snippets :) -snippet snip - snippet ${1:trigger} - ${2} -snippet msnip - snippet ${1:trigger} ${2:description} - ${3} diff --git a/vim/bundle/snipmate/snippets/tcl.snippets b/vim/bundle/snipmate/snippets/tcl.snippets @@ -1,92 +0,0 @@ -# #!/usr/bin/env tclsh -snippet #! - #!/usr/bin/env tclsh - -# Process -snippet pro - proc ${1:function_name} {${2:args}} { - ${3:#body ...} - } -#xif -snippet xif - ${1:expr}? ${2:true} : ${3:false} -# Conditional -snippet if - if {${1}} { - ${2:# body...} - } -# Conditional if..else -snippet ife - if {${1}} { - ${2:# body...} - } else { - ${3:# else...} - } -# Conditional if..elsif..else -snippet ifee - if {${1}} { - ${2:# body...} - } elseif {${3}} { - ${4:# elsif...} - } else { - ${5:# else...} - } -# If catch then -snippet ifc - if { [catch {${1:#do something...}} ${2:err}] } { - ${3:# handle failure...} - } -# Catch -snippet catch - catch {${1}} ${2:err} ${3:options} -# While Loop -snippet wh - while {${1}} { - ${2:# body...} - } -# For Loop -snippet for - for {set ${2:var} 0} {$$2 < ${1:count}} {${3:incr} $2} { - ${4:# body...} - } -# Foreach Loop -snippet fore - foreach ${1:x} {${2:#list}} { - ${3:# body...} - } -# after ms script... -snippet af - after ${1:ms} ${2:#do something} -# after cancel id -snippet afc - after cancel ${1:id or script} -# after idle -snippet afi - after idle ${1:script} -# after info id -snippet afin - after info ${1:id} -# Expr -snippet exp - expr {${1:#expression here}} -# Switch -snippet sw - switch ${1:var} { - ${3:pattern 1} { - ${4:#do something} - } - default { - ${2:#do something} - } - } -# Case -snippet ca - ${1:pattern} { - ${2:#do something} - }${3} -# Namespace eval -snippet ns - namespace eval ${1:path} {${2:#script...}} -# Namespace current -snippet nsc - namespace current diff --git a/vim/bundle/snipmate/snippets/tex.snippets b/vim/bundle/snipmate/snippets/tex.snippets @@ -1,115 +0,0 @@ -# \begin{}...\end{} -snippet begin - \begin{${1:env}} - ${2} - \end{$1} -# Tabular -snippet tab - \begin{${1:tabular}}{${2:c}} - ${3} - \end{$1} -# Align(ed) -snippet ali - \begin{align${1:ed}} - ${2} - \end{align$1} -# Gather(ed) -snippet gat - \begin{gather${1:ed}} - ${2} - \end{gather$1} -# Equation -snippet eq - \begin{equation} - ${1} - \end{equation} -# Unnumbered Equation -snippet \ - \\[ - ${1} - \\] -# Enumerate -snippet enum - \begin{enumerate} - \item ${1} - \end{enumerate} -# Itemize -snippet item - \begin{itemize} - \item ${1} - \end{itemize} -# Description -snippet desc - \begin{description} - \item[${1}] ${2} - \end{description} -# Matrix -snippet mat - \begin{${1:p/b/v/V/B/small}matrix} - ${2} - \end{$1matrix} -# Cases -snippet cas - \begin{cases} - ${1:equation}, &\text{ if }${2:case}\\ - ${3} - \end{cases} -# Split -snippet spl - \begin{split} - ${1} - \end{split} -# Part -snippet part - \part{${1:part name}} % (fold) - \label{prt:${2:$1}} - ${3} - % part $2 (end) -# Chapter -snippet cha - \chapter{${1:chapter name}} % (fold) - \label{cha:${2:$1}} - ${3} - % chapter $2 (end) -# Section -snippet sec - \section{${1:section name}} % (fold) - \label{sec:${2:$1}} - ${3} - % section $2 (end) -# Sub Section -snippet sub - \subsection{${1:subsection name}} % (fold) - \label{sub:${2:$1}} - ${3} - % subsection $2 (end) -# Sub Sub Section -snippet subs - \subsubsection{${1:subsubsection name}} % (fold) - \label{ssub:${2:$1}} - ${3} - % subsubsection $2 (end) -# Paragraph -snippet par - \paragraph{${1:paragraph name}} % (fold) - \label{par:${2:$1}} - ${3} - % paragraph $2 (end) -# Sub Paragraph -snippet subp - \subparagraph{${1:subparagraph name}} % (fold) - \label{subp:${2:$1}} - ${3} - % subparagraph $2 (end) -snippet itd - \item[${1:description}] ${2:item} -snippet figure - ${1:Figure}~\ref{${2:fig:}}${3} -snippet table - ${1:Table}~\ref{${2:tab:}}${3} -snippet listing - ${1:Listing}~\ref{${2:list}}${3} -snippet section - ${1:Section}~\ref{${2:sec:}}${3} -snippet page - ${1:page}~\pageref{${2}}${3} diff --git a/vim/bundle/snipmate/snippets/vim.snippets b/vim/bundle/snipmate/snippets/vim.snippets @@ -1,32 +0,0 @@ -snippet header - " File: ${1:`expand('%:t')`} - " Author: ${2:`g:snips_author`} - " Description: ${3} - ${4:" Last Modified: `strftime("%B %d, %Y")`} -snippet guard - if exists('${1:did_`Filename()`}') || &cp${2: || version < 700} - finish - endif - let $1 = 1${3} -snippet f - fun ${1:function_name}(${2}) - ${3:" code} - endf -snippet for - for ${1:needle} in ${2:haystack} - ${3:" code} - endfor -snippet wh - while ${1:condition} - ${2:" code} - endw -snippet if - if ${1:condition} - ${2:" code} - endif -snippet ife - if ${1:condition} - ${2} - else - ${3} - endif diff --git a/vim/bundle/snipmate/snippets/zsh.snippets b/vim/bundle/snipmate/snippets/zsh.snippets @@ -1,58 +0,0 @@ -# #!/bin/zsh -snippet #! - #!/bin/zsh - -snippet if - if ${1:condition}; then - ${2:# statements} - fi -snippet ife - if ${1:condition}; then - ${2:# statements} - else - ${3:# statements} - fi -snippet elif - elif ${1:condition} ; then - ${2:# statements} -snippet for - for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do - ${3:# statements} - done -snippet fore - for ${1:item} in ${2:list}; do - ${3:# statements} - done -snippet wh - while ${1:condition}; do - ${2:# statements} - done -snippet until - until ${1:condition}; do - ${2:# statements} - done -snippet repeat - repeat ${1:integer}; do - ${2:# statements} - done -snippet case - case ${1:word} in - ${2:pattern}) - ${3};; - esac -snippet select - select ${1:answer} in ${2:choices}; do - ${3:# statements} - done -snippet ( - ( ${1:#statements} ) -snippet { - { ${1:#statements} } -snippet [ - [[ ${1:test} ]] -snippet always - { ${1:try} } always { ${2:always} } -snippet fun - function ${1:name} (${2:args}) { - ${3:# body} - } diff --git a/vim/bundle/snipmate/syntax/snippet.vim b/vim/bundle/snipmate/syntax/snippet.vim @@ -1,19 +0,0 @@ -" Syntax highlighting for snippet files (used for snipMate.vim) -" Hopefully this should make snippets a bit nicer to write! -syn match snipComment '^#.*' -syn match placeHolder '\${\d\+\(:.\{-}\)\=}' contains=snipCommand -syn match tabStop '\$\d\+' -syn match snipCommand '[^\\]`.\{-}`' -syn match snippet '^snippet.*' transparent contains=multiSnipText,snipKeyword -syn match multiSnipText '\S\+ \zs.*' contained -syn match snipKeyword '^snippet'me=s+8 contained -syn match snipError "^[^#s\t].*$" - -hi link snipComment Comment -hi link multiSnipText String -hi link snipKeyword Keyword -hi link snipComment Comment -hi link placeHolder Special -hi link tabStop Special -hi link snipCommand String -hi link snipError Error diff --git a/vim/bundle/tcomment/.gitignore b/vim/bundle/tcomment/.gitignore @@ -1,10 +0,0 @@ -tags -Makefile -TODO.TXT -TODO_archived.viki -*.vba -*.vmb -*.zip -.last_* -test -test_* diff --git a/vim/bundle/tcomment/CHANGES.TXT b/vim/bundle/tcomment/CHANGES.TXT @@ -1,205 +0,0 @@ -0.1 -- Initial release - -0.2 -- Fixed uncommenting of non-aligned comments -- improved support for block comments (with middle lines and indentation) -- using TCommentBlock for file types that don't have block comments creates -single line comments -- removed the TCommentAsBlock command (TCommentAs provides its functionality) -- removed g:tcommentSetCMS -- the default key bindings have slightly changed - -1.3 -- slightly improved recognition of embedded syntax -- if no commentstring is defined in whatever way, reconstruct one from -&comments -- The TComment... commands now have bang variants that don't act as toggles -but always comment out the selected text -- fixed problem with commentstrings containing backslashes -- comment as visual block (allows commenting text to the right of the main -text, i.e., this command doesn't work on whole lines but on the text to the -right of the cursor) -- enable multimode for dsl, vim filetypes -- added explicit support for some other file types I ran into - -1.4 -- Fixed problem when &commentstring was invalid (e.g. lua) -- perl_block by Kyosuke Takayama. -- <c-_>s mapped to :TCommentAs <c-r>=&ft<cr> - -1.5 -- "Inline" visual comments (uses the &filetype_inline style if -available; doesn't check if the filetype actually supports this kind of -comments); tComment can't currently deduce inline comment styles from -&comments or &commentstring (I personally hardly ever use them); default -map: <c-_>i or <c-_>I -- In visual mode: if the selection spans several lines, normal mode is -selected; if the selection covers only a part of one line, inline mode -is selected -- Fixed problem with lines containing ^M or ^@ characters. -- It's no longer necessary to call TCommentCollectFileTypes() after -defining a new filetype via TCommentDefineType() -- Disabled single <c-_> mappings -- Renamed TCommentVisualBlock to TCommentRight -- FIX: Forgot 'x' in ExtractCommentsPart() (thanks to Fredrik Acosta) - -1.6 -- Ignore sql when guessing the comment string in php files; tComment -sometimes chooses the wrong comment string because the use of sql syntax -is used too loosely in php files; if you want to comment embedded sql -code you have to use TCommentAs -- Use keepjumps in commands. -- Map <c-_>p & <L>_p to vip:TComment<cr> -- Made key maps configurable via g:tcommentMapLeader1 and -g:tcommentMapLeader2 - -1.7 -- gc{motion} (see g:tcommentMapLeaderOp1) functions as a comment toggle -operator (i.e., something like gcl... works, mostly); gC{motion} (see -g:tcommentMapLeaderOp2) will unconditionally comment the text. -- TCommentAs takes an optional second argument (the comment level) -- New "n" map: TCommentAs &filetype [COUNT] -- Defined mail comments/citations -- g:tcommentSyntaxMap: Map syntax names to filetypes for buffers with -mixed syntax groups that don't match the filetypeEmbeddedsyntax scheme (e.g. -'vimRubyRegion', which should be commented as ruby syntax, not as vim -syntax) -- FIX: Comments in vim*Region -- TComment: The use of the type argument has slightly changed (IG -> i, -new: >) - -1.8 -- Definitly require vim7 -- Split the plugin into autoload & plugin. -- g:TCommentFileTypes is a list -- Fixed some block comment strings -- Removed extraneous newline in some block comments. -- Maps for visal mode (thanks Krzysztof Goj) - -1.9 -- Fix left offset for inline comments (via operator binding) - -1.10 -- tcomment#Operator defines w:tcommentPos if invoked repeatedly -- s:GuessFileType: use len(getline()) instead of col() - -1.11 -- Support for erlang (thanks to Zhang Jinzhu) - -1.12 -- Moved the definition of some variables from plugin/tComment.vim to -autoload/tcomment.vim -- Changed comment string for eruby (proposed by Vinicius Baggio) -- Support for x86conf - -2.0 -- Enabled key=value pairs to configure commenting -- Renamed the file plugin/tComment.vim to plugin/tcomment.vim -- Renamed certain global functions to tcomment#... - -2.1 -- FIX - -version: "2.02" - - Support for matlab (contributed by D Fong) - MD5 checksum: 29a2742dfae32b52a7abcdfb4de553ad - -version: "2.03" - - s:PrintF(): Silently ignore malformed format strings - - Deal with major.minor pseudo-filetypes - - go-lang - - Remove s:SPrintF() since vim now has printf() - MD5 checksum: 4a13ffb1b1d46bbd2dc8dcee77507983 - -version: "2.04" - - Support for fstab - - g:tcommentOptions: Other key-value options used by |tcomment#Comment()|. - - Support for django (thanks to Jim Tinsky) - - g:tcomment#syntax_substitute: Rewrite syntax names - - django support: minor correction - MD5 checksum: 994e5886d185857848b5472d5457b232 - -version: "2.05" - - Explicit support for python (thanks to brendanarnold) - - Support for samba (thanks Dominic) - - .gitignore - - Define new types: debsources and debcontrol - - Removed some whitespace as proposed by blueyed - - Add config for typoscript filetype. - - EXPERIMENTAL commentstring_rx: Support for using regexps to uncomment code - - s:ProcessedLine: Don't substitute(rv, '\n', '\\\n', 'g') - - Try to handle char-type text objects (disabled by default) - - scss (SASS) filetype - - Add config for 'nginx' filetype. - MD5 checksum: 0e23f194638256fb4fa4a729df645966 - -version: "2.06" - - tcomment#Comment(): Remove last item in search history (reported by Raimond) - - Add config for conkyrc filetype. - - Add config for 'robots' filetype. - - tcomment#GetCommentDef(name) - - g:tcomment_types: override tcomment's default comment styles (fix #12) - - Fixed ft-guessing of htmldjango files - - Add definitions for dnsmasq, pac, resolv and squid. - - Avoid the problem reported in https://github.com/tomtom/tcomment_vim/pull/18 - - Handle nested comments in c mode (fix #19) - MD5 checksum: 0e23f194638256fb4fa4a729df645966 - -version: "2.07" - - Avoid duplicate tag in help file (reported by utkarshkukreti) - - add puppet type - - Use \r instead of ^M - - support for haml and coffeescript - - Support for gitignore - - Merge branch 'master' of https://github.com/ignovak/tcomment_vim - - Enable "filetype guessing" for eruby (fixes #25) - - g:tcommentModeExtra: Always modify how commenting works - - g:tcommentModeExtra: >> ... Like > but also move the cursor to the next line - - adding gnu smalltalk comment style - - Add comment definition for "smarty" - - Sort definition for "sql" - - Merge branch 'master' of https://github.com/clutt0n/tcomment_vim - - added support for jasmine.coffee (cf. https://github.com/claco/jasmine.vim) - - fixed jasmine (have to use syntax instead of filetype) - - Block comments: set &sel = exclusive (fixes #30; bug 1) - - Merge branch 'master' of https://github.com/paulwittmann/tcomment_vim - - spec files for issue 30 - - Inline comments: Include the current character if selection == inclusive (fixes #30 bug 2) - - gC in visual mode: call :TCommentMaybeInline! (fixes #30 bug 3) - - Added Clojure and Clojurescript support. Thou the comment is a single ';' it is a widely adopted convention to comment whole lines with ';;' - - command line completion: also offer rx*= arguments - - Merge branch 'master' of https://github.com/ssedano/tcomment_vim - - clojure: use ";" for inline comments - - TCommentRight used wrong column - - b:tcommentOptions: buffer-local options - - Deal with mode argument (concatenate with commentMode) - - Removed visual/selection maps for :TCommentRight - - <c-_>cc and <c-_>ca maps to temporary set options (count, as) on the fly - - <c-_>1 .. <c-_>9 maps to invoke :TComment count=N (repeat the comment string N times) - - clojure: use the "count" property instead of hardcoding the double semicolon (";;") - - Enable inline comments for insert & normal mode (create empty comments, which isn't always that useful; fixes #33) - - When guessing a filetype, make sure to use custom definitions when no syntax name is found - - gc<count>c maps that set the "count" attribute - - Make sure to ignore %%s in commentstrings - - gc<Count>c{motion} maps work as toggle - - Enable <c-_><Count> maps for insert mode - - Monkey language comment style - MD5 checksum: 0853c50ebdcd4c52a31b2ad2d514d1e0 - -version: "2.08" - - Enable count for gc operator maps (use e.g. 3gc2l instead of gc3c2l; maybe remove gc<count>c maps later on) - - <count>gc operator maps: use v:count instead of v:count1 - - fixed unlet - - Merge branch 'master' of https://github.com/grassofhust/tcomment_vim - - Added vhdl to tcomment#DefineType - - tcomment#GuessCommentType(): Make filetype guessing accessible for other plugins - - FIX: didn't guess filetype correctly for lines containing only one character - - Guess filetype: Improved handling of empty lines - - g:tcommentSyntaxMap: support additional info on how to handle empty lines - - g:tcommentSyntaxMap: support filetype key: explicitly map syntax name per filetype (fixes #39) - - Fix typo - - Add `g:tcommentGuessFileType_smarty = 1` - - Define/handle 'ini' file type (e.g. for php.ini) - MD5 checksum: 702082a857ddeaf75d3b4fd884363173 - diff --git a/vim/bundle/tcomment/README b/vim/bundle/tcomment/README @@ -1,104 +0,0 @@ -tcomment provides easy to use, file-type sensible comments for Vim. It -can handle embedded syntax. - -TComment works like a toggle, i.e., it will comment out text that -contains uncommented lines, and it will remove comment markup for -already commented text (i.e. text that contains no uncommented lines). - -If the file-type is properly defined, TComment will figure out which -comment string to use. Otherwise you use |tcomment#DefineType()| to -override the default choice. - -TComment can properly handle an embedded syntax, e.g., ruby/python/perl -regions in vim scripts, HTML or JavaScript in php code etc. - -tcomment favours the use of line-wise comment styles. This implies that usually -whole line will be commented out. tcomment also knows block-style and inline -comments that can be used via special maps (see below) or the |:TCommentAs| -command. - -Demo: -http://vimsomnia.blogspot.com/2010/11/tcomment-vim-plugin.html - - - *tcomment-maps* -Key bindings~ - -Most of the time the default toggle keys will do what you want (or to be -more precise: what I think you want it to do ;-). - - *tcomment-operator* -As operator (the prefix can be customized via |g:tcommentMapLeaderOp1| -and |g:tcommentMapLeaderOp2|): - - gc{motion} :: Toggle comments (for small comments within one line - the &filetype_inline style will be used, if - defined) - gc<Count>c{motion} :: Toggle comment text with count argument - (see |tcomment#Comment()|) - gcc :: Toggle comment for the current line - gC{motion} :: Comment region - gCc :: Comment the current line - -In visual mode: - - gc :: Toggle comments - gC :: Comment selected text - -CAVEAT: If you visually select text within a line, the visual mode map will -comment out the selected text. If you selected text across several lines, the -visual mode map will assume though that you wanted to comment out lines -- -since this is how many vim maps work. In order to make tcomment use e.g. inline -comments anyway, use the <c-_>i map -- see below. - -By default the cursor stays put. If you want the cursor to the end of -the commented text, set |g:tcommentOpModeExtra| to '>' (but this may not -work properly with exclusive motions). - -Primary key maps for normal and insert mode: - - <c-_><c-_> :: :TComment - <c-_><space> :: :TComment <QUERY COMMENT-BEGIN ?COMMENT-END> - <c-_>b :: :TCommentBlock - <c-_>a :: :TCommentAs <QUERY COMMENT TYPE> - <c-_>n :: :TCommentAs &filetype <QUERY COUNT> - <c-_>s :: :TCommentAs &filetype_<QUERY COMMENT SUBTYPE> - <c-_>i :: :TCommentInline (in normal and insert mode, this map will - create an empty inline comment, which isn't suitable for - all filetypes though) - <c-_>r :: :TCommentRight - <c-_>p :: Comment the current inner paragraph - <c-_><Count> :: :TComment with count argument (a number from 1 to 9) - (see |tcomment#Comment()|) - -Primary key maps for visual mode: - - <c-_><c-_> :: :TComment - <c-_>i :: :TCommentInline - <c-_><Count> :: :TComment with count argument (a number from 1 to 9) - (see |tcomment#Comment()|) - -A secondary set of key maps is defined for normal and insert mode: - - <Leader>__ :: :TComment - <Leader>_p :: Comment the current inner paragraph - <Leader>_<space> :: :TComment <QUERY COMMENT-BEGIN ?COMMENT-END> - <Leader>_i :: :TCommentInline - <Leader>_r :: :TCommentRight - <Leader>_b :: :TCommentBlock - <Leader>_a :: :TCommentAs <QUERY COMMENT TYPE> - <Leader>_n :: :TCommentAs &filetype <QUERY COUNT> - <Leader>_s :: :TCommentAs &filetype_<QUERY COMMENT SUBTYPE> - -... and for select mode: - - <Leader>__ :: :TComment - <Leader>_i :: :TCommentInline - - ------------------------------------------------------------------------ - -Status: Works for me (there may be some minor quirks) -Install: See http://github.com/tomtom/vimtlib/blob/master/INSTALL.TXT -See http://github.com/tomtom for related plugins. - diff --git a/vim/bundle/tcomment/addon-info.json b/vim/bundle/tcomment/addon-info.json @@ -1,9 +0,0 @@ -{ - "name" : "tcomment", - "version" : "dev", - "author" : "Tom Link <micathom at gmail com>", - "maintainer" : "Tom Link <micathom at gmail com>", - "repository" : {"type": "git", "url": "git://github.com/tomtom/tcomment_vim.git"}, - "dependencies" : {}, - "description" : "An easily extensible & universal comment plugin" -} diff --git a/vim/bundle/tcomment/autoload/tcomment.vim b/vim/bundle/tcomment/autoload/tcomment.vim @@ -1,1679 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2007-09-17. -" @Last Change: 2013-03-07. -" @Revision: 1010 - -" call tlog#Log('Load: '. expand('<sfile>')) " vimtlib-sfile - -if !exists("g:tcommentBlankLines") - " If true, comment blank lines too - let g:tcommentBlankLines = 1 "{{{2 -endif - -if !exists("g:tcommentModeExtra") - " Modifies how commenting works. - " > ... Move the cursor to the end of the comment - " >> ... Like above but move the cursor to the next line - " # ... Move the cursor to the position of the commented text - " (NOTE: this only works when creating empty comments using - " |:TCommentInline| from normal or insert mode and should - " not be set here as a global option.) - let g:tcommentModeExtra = '' "{{{2 -endif - -if !exists("g:tcommentOpModeExtra") - " Modifies how the operator works. - " See |g:tcommentModeExtra| for a list of possible values. - let g:tcommentOpModeExtra = '' "{{{2 -endif - -if !exists('g:tcommentOptions') - " Other key-value options used by |tcomment#Comment()|. - " - " Example: If you want to put the opening comment marker always in - " the first column regardless of the block's indentation, put this - " into your |vimrc| file: > - " let g:tcommentOptions = {'col': 1} - let g:tcommentOptions = {} "{{{2 -endif - -if !exists('g:tcomment#ignore_char_type') - " |text-objects| for use with |tcomment#Operator| can have different - " types: line, block, char etc. Text objects like aB, it, at etc. - " have type char but this may not work reliably. By default, - " tcomment handles those text objects most often as if they were of - " type line. Set this variable to 0 in order to change this - " behaviour. Be prepared that the result may not always match your - " intentions. - let g:tcomment#ignore_char_type = 1 "{{{2 -endif - -if !exists("g:tcommentGuessFileType") - " Guess the file type based on syntax names always or for some fileformat only - " If non-zero, try to guess filetypes. - " tcomment also checks g:tcommentGuessFileType_{&filetype} for - " filetype specific values. - " - " Values: - " 0 ... don't guess - " 1 ... guess - " FILETYPE ... assume this filetype - let g:tcommentGuessFileType = 0 "{{{2 -endif -if !exists("g:tcommentGuessFileType_dsl") - " For dsl documents, assume filetype = xml. - let g:tcommentGuessFileType_dsl = 'xml' "{{{2 -endif -if !exists("g:tcommentGuessFileType_php") - " In php documents, the php part is usually marked as phpRegion. We - " thus assume that the buffers default comment style isn't php but - " html. - let g:tcommentGuessFileType_php = 'html' "{{{2 -endif -if !exists("g:tcommentGuessFileType_html") - let g:tcommentGuessFileType_html = 1 "{{{2 -endif -if !exists("g:tcommentGuessFileType_tskeleton") - let g:tcommentGuessFileType_tskeleton = 1 "{{{2 -endif -if !exists("g:tcommentGuessFileType_vim") - let g:tcommentGuessFileType_vim = 1 "{{{2 -endif -if !exists("g:tcommentGuessFileType_django") - let g:tcommentGuessFileType_django = 1 "{{{2 -endif -if !exists("g:tcommentGuessFileType_eruby") - let g:tcommentGuessFileType_eruby = 1 "{{{2 -endif -if !exists("g:tcommentGuessFileType_smarty") - let g:tcommentGuessFileType_smarty = 1 "{{{2 -endif - -if !exists("g:tcommentIgnoreTypes_php") - " In php files, some syntax regions are wrongly highlighted as sql - " markup. We thus ignore sql syntax when guessing the filetype in - " php files. - let g:tcommentIgnoreTypes_php = 'sql' "{{{2 -endif - -if !exists('g:tcomment#syntax_substitute') - " :read: let g:tcomment#syntax_substitute = {...} "{{{2 - " Perform replacements on the syntax name. - let g:tcomment#syntax_substitute = { - \ '\C^javaScript': {'sub': 'javascript'} - \ } -endif - -if !exists('g:tcomment#filetype_map') - " Keys must match the full |filetype|. Regexps must be |magic|. No - " regexp modifiers (like |\V|) are allowed. - " let g:tcomment#filetype_map = {...} "{{{2 - let g:tcomment#filetype_map = { - \ 'rails-views': 'html', - \ 'mkd': 'html', - \ } -endif - -if !exists('g:tcommentSyntaxMap') - " tcomment guesses filetypes based on the name of the current syntax - " region. This works well if the syntax names match - " /filetypeSomeName/. Other syntax names have to be explicitly - " mapped onto the corresponding filetype. - " :read: let g:tcommentSyntaxMap = {...} "{{{2 - let g:tcommentSyntaxMap = { - \ 'erubyExpression': 'ruby', - \ 'vimMzSchemeRegion': 'scheme', - \ 'vimPerlRegion': 'perl', - \ 'vimPythonRegion': 'python', - \ 'vimRubyRegion': 'ruby', - \ 'vimTclRegion': 'tcl', - \ 'Delimiter': { - \ 'filetype': { - \ 'php': 'php', - \ }, - \ }, - \ 'phpRegionDelimiter': { - \ 'prevnonblank': [ - \ {'match': '<?php', 'filetype': 'php'}, - \ {'match': '?>', 'filetype': 'html'}, - \ ], - \ 'nextnonblank': [ - \ {'match': '?>', 'filetype': 'php'}, - \ {'match': '<?php', 'filetype': 'html'}, - \ ], - \ }, - \ } -endif - -if !exists('g:tcomment#replacements_c') - " Replacements for c filetype. - " :read: let g:tcomment#replacements_c = {...} "{{{2 - let g:tcomment#replacements_c = { - \ '/*': '#<{(|', - \ '*/': '|)}>#', - \ } -endif - -if !exists("g:tcommentInlineC") - " Generic c-like comments. - " :read: let g:tcommentInlineC = {...} "{{{2 - let g:tcommentInlineC = { - \ 'commentstring': '/* %s */', - \ 'replacements': g:tcomment#replacements_c - \ } -endif -if !exists("g:tcommentLineC") - " Generic c-like block comments. - let g:tcommentLineC = g:tcommentInlineC -endif -if !exists("g:tcommentBlockC") - let g:tcommentBlockC = { - \ 'commentstring': '/*%s */', - \ 'middle': ' * ', - \ 'rxbeg': '\*\+', - \ 'rxend': '\*\+', - \ 'rxmid': '\*\+', - \ 'replacements': g:tcomment#replacements_c - \ } -endif -if !exists("g:tcommentBlockC2") - " Generic c-like block comments (alternative markup). - " :read: let g:tcommentBlockC2 = {...} "{{{2 - let g:tcommentBlockC2 = { - \ 'commentstring': '/**%s */', - \ 'middle': ' * ', - \ 'rxbeg': '\*\+', - \ 'rxend': '\*\+', - \ 'rxmid': '\*\+', - \ 'replacements': g:tcomment#replacements_c - \ } -endif - -if !exists('g:tcomment#replacements_xml') - " Replacements for xml filetype. - " :read: let g:tcomment#replacements_xml = {...} "{{{2 - let g:tcomment#replacements_xml = { - \ '-': '&#45;', - \ '&': '&#38;', - \ } -endif - -if !exists("g:tcommentBlockXML") - " Generic xml-like block comments. - " :read: let g:tcommentBlockXML = {...} "{{{2 - let g:tcommentBlockXML = { - \ 'commentstring': "<!--%s-->\n ", - \ 'replacements': g:tcomment#replacements_xml - \ } -endif -if !exists("g:tcommentInlineXML") - " Generic xml-like comments. - " :read: let g:tcommentInlineXML = {...} "{{{2 - let g:tcommentInlineXML = { - \ 'commentstring': "<!-- %s -->", - \ 'replacements': g:tcomment#replacements_xml - \ } -endif - -let s:typesDirty = 1 - -let s:definitions = {} - -" If you don't explicitly define a comment style, |:TComment| will use -" 'commentstring' instead. We override the default values here in order -" to have a blank after the comment marker. Block comments work only if -" we explicitly define the markup. -" -" NAME usually is a 'filetype'. You can use special suffixes to define -" special comment types. E.g. the name "FILETYPE_block" is used for -" block comments for 'filetype'. The name "FILETYPE_inline" is used for -" inline comments. If no specialized comment definition exists, the -" normal one with name "FILETYPE" is used. -" -" The comment definition can be either a string or a dictionary. -" -" If it is a string: -" The format for block comments is similar to 'commentstrings' with the -" exception that the format strings for blocks can contain a second line -" that defines how "middle lines" (see :h format-comments) should be -" displayed. -" -" Example: If the string is "--%s--\n-- ", lines will be commented as -" "--%s--" but the middle lines in block comments will be commented as -" "--%s". -" -" If it is a dictionary: -" See the help on the args argument of |tcomment#Comment| (see item 1, -" args is a list of key=value pairs) to find out which fields can be -" used. -" :display: tcomment#DefineType(name, commentdef, ?cdef={}, ?anyway=0) -function! tcomment#DefineType(name, commentdef, ...) - let use = a:0 >= 2 ? a:2 : !has_key(s:definitions, a:name) - if use - if type(a:commentdef) == 4 - let cdef = copy(a:commentdef) - else - let cdef = a:0 >= 1 ? a:1 : {} - let cdef.commentstring = a:commentdef - endif - let s:definitions[a:name] = cdef - endif - let s:typesDirty = 1 -endf - -" :nodoc: -" Return comment definition -function! tcomment#GetCommentDef(name) - return get(s:definitions, a:name, "") -endf - -" :nodoc: -" Return 1 if a comment type is defined. -function! tcomment#TypeExists(name) - return has_key(s:definitions, a:name) -endf - -" :doc: -" A dictionary of NAME => COMMENT DEFINITION (see |tcomment#DefineType|) -" that can be set in vimrc to override tcomment's default comment -" styles. -" :read: let g:tcomment_types = {} "{{{2 -if exists('g:tcomment_types') - for [s:name, s:def] in items(g:tcomment_types) - call tcomment#DefineType(s:name, s:def) - endfor - unlet! s:name s:def -endif - -call tcomment#DefineType('aap', '# %s' ) -call tcomment#DefineType('ada', '-- %s' ) -call tcomment#DefineType('apache', '# %s' ) -call tcomment#DefineType('autoit', '; %s' ) -call tcomment#DefineType('asm', '; %s' ) -call tcomment#DefineType('awk', '# %s' ) -call tcomment#DefineType('catalog', '-- %s --' ) -call tcomment#DefineType('catalog_block', "--%s--\n " ) -call tcomment#DefineType('cpp', '// %s' ) -call tcomment#DefineType('cpp_inline', g:tcommentInlineC ) -call tcomment#DefineType('cpp_block', g:tcommentBlockC ) -call tcomment#DefineType('css', '/* %s */' ) -call tcomment#DefineType('css_inline', g:tcommentInlineC ) -call tcomment#DefineType('css_block', g:tcommentBlockC ) -call tcomment#DefineType('c', g:tcommentLineC ) -call tcomment#DefineType('c_inline', g:tcommentInlineC ) -call tcomment#DefineType('c_block', g:tcommentBlockC ) -call tcomment#DefineType('cfg', '# %s' ) -call tcomment#DefineType('chromemanifest', '# %s' ) -call tcomment#DefineType('clojure', {'commentstring': '; %s', 'count': 2}) -call tcomment#DefineType('clojure_inline', '; %s' ) -call tcomment#DefineType('clojurescript', ';; %s' ) -call tcomment#DefineType('clojurescript_inline', '; %s' ) -call tcomment#DefineType('cmake', '# %s' ) -call tcomment#DefineType('coffee', '# %s' ) -call tcomment#DefineType('conf', '# %s' ) -call tcomment#DefineType('conkyrc', '# %s' ) -call tcomment#DefineType('crontab', '# %s' ) -call tcomment#DefineType('cs', '// %s' ) -call tcomment#DefineType('cs_inline', g:tcommentInlineC ) -call tcomment#DefineType('cs_block', g:tcommentBlockC ) -call tcomment#DefineType('debsources', '# %s' ) -call tcomment#DefineType('debcontrol', '# %s' ) -call tcomment#DefineType('desktop', '# %s' ) -call tcomment#DefineType('dnsmasq', '# %s' ) -call tcomment#DefineType('docbk', g:tcommentInlineXML) -call tcomment#DefineType('docbk_inline', g:tcommentInlineXML) -call tcomment#DefineType('docbk_block', g:tcommentBlockXML ) -call tcomment#DefineType('dosbatch', 'rem %s' ) -call tcomment#DefineType('dosini', '; %s' ) -call tcomment#DefineType('dsl', '; %s' ) -call tcomment#DefineType('dylan', '// %s' ) -call tcomment#DefineType('eiffel', '-- %s' ) -call tcomment#DefineType('erlang', '%%%% %s' ) -call tcomment#DefineType('eruby', '<%%# %s' ) -call tcomment#DefineType('esmtprc', '# %s' ) -call tcomment#DefineType('fstab', '# %s' ) -call tcomment#DefineType('gitcommit', '# %s' ) -call tcomment#DefineType('gitignore', '# %s' ) -call tcomment#DefineType('gnuplot', '# %s' ) -call tcomment#DefineType('gtkrc', '# %s' ) -call tcomment#DefineType('go', '// %s' ) -call tcomment#DefineType('go_inline', g:tcommentInlineC ) -call tcomment#DefineType('go_block', g:tcommentBlockC ) -call tcomment#DefineType('groovy', '// %s' ) -call tcomment#DefineType('groovy_inline', g:tcommentInlineC ) -call tcomment#DefineType('groovy_block', g:tcommentBlockC ) -call tcomment#DefineType('groovy_doc_block', g:tcommentBlockC2 ) -call tcomment#DefineType('haml', '-# %s' ) -call tcomment#DefineType('haskell', '-- %s' ) -call tcomment#DefineType('haskell_block', "{-%s-}\n " ) -call tcomment#DefineType('haskell_inline', '{- %s -}' ) -call tcomment#DefineType('html', g:tcommentInlineXML) -call tcomment#DefineType('html_inline', g:tcommentInlineXML) -call tcomment#DefineType('html_block', g:tcommentBlockXML ) -call tcomment#DefineType('htmldjango', '{# %s #}' ) -call tcomment#DefineType('htmldjango_block', "{%% comment %%}%s{%% endcomment %%}\n ") -call tcomment#DefineType('ini', '; %s' ) " php ini (/etc/php5/...) -call tcomment#DefineType('io', '// %s' ) -call tcomment#DefineType('jasmine', '# %s' ) -call tcomment#DefineType('javaScript', '// %s' ) -call tcomment#DefineType('javaScript_inline', g:tcommentInlineC ) -call tcomment#DefineType('javaScript_block', g:tcommentBlockC ) -call tcomment#DefineType('javascript', '// %s' ) -call tcomment#DefineType('javascript_inline', g:tcommentInlineC ) -call tcomment#DefineType('javascript_block', g:tcommentBlockC ) -call tcomment#DefineType('java', '/* %s */' ) -call tcomment#DefineType('java_inline', g:tcommentInlineC ) -call tcomment#DefineType('java_block', g:tcommentBlockC ) -call tcomment#DefineType('java_doc_block', g:tcommentBlockC2 ) -call tcomment#DefineType('jproperties', '# %s' ) -call tcomment#DefineType('lisp', '; %s' ) -call tcomment#DefineType('lynx', '# %s' ) -call tcomment#DefineType('matlab', '%% %s' ) -call tcomment#DefineType('m4', 'dnl %s' ) -call tcomment#DefineType('mail', '> %s' ) -call tcomment#DefineType('monkey', ''' %s' ) -call tcomment#DefineType('msidl', '// %s' ) -call tcomment#DefineType('msidl_block', g:tcommentBlockC ) -call tcomment#DefineType('nginx', '# %s' ) -call tcomment#DefineType('nroff', '.\\" %s' ) -call tcomment#DefineType('nsis', '# %s' ) -call tcomment#DefineType('objc', '/* %s */' ) -call tcomment#DefineType('objc_inline', g:tcommentInlineC ) -call tcomment#DefineType('objc_block', g:tcommentBlockC ) -call tcomment#DefineType('ocaml', '(* %s *)' ) -call tcomment#DefineType('ocaml_inline', '(* %s *)' ) -call tcomment#DefineType('ocaml_block', "(*%s*)\n " ) -call tcomment#DefineType('pac', '// %s' ) -call tcomment#DefineType('pascal', '(* %s *)' ) -call tcomment#DefineType('pascal_inline', '(* %s *)' ) -call tcomment#DefineType('pascal_block', "(*%s*)\n " ) -call tcomment#DefineType('perl', '# %s' ) -call tcomment#DefineType('perl_block', "=cut%s=cut" ) -call tcomment#DefineType('pfmain', '# %s' ) -call tcomment#DefineType('php', {'commentstring_rx': '\%%(//\|#\) %s', 'commentstring': '// %s'}) -call tcomment#DefineType('php_inline', g:tcommentInlineC ) -call tcomment#DefineType('php_block', g:tcommentBlockC ) -call tcomment#DefineType('php_2_block', g:tcommentBlockC2 ) -call tcomment#DefineType('po', '# %s' ) -call tcomment#DefineType('prolog', '%% %s' ) -call tcomment#DefineType('puppet', '# %s' ) -call tcomment#DefineType('python', '# %s' ) -call tcomment#DefineType('racket', '; %s' ) -call tcomment#DefineType('racket_block', '#|%s|#' ) -call tcomment#DefineType('rc', '// %s' ) -call tcomment#DefineType('readline', '# %s' ) -call tcomment#DefineType('resolv', '# %s' ) -call tcomment#DefineType('robots', '# %s' ) -call tcomment#DefineType('ruby', '# %s' ) -call tcomment#DefineType('ruby_3', '### %s' ) -call tcomment#DefineType('ruby_block', "=begin rdoc%s=end") -call tcomment#DefineType('ruby_nodoc_block', "=begin%s=end" ) -call tcomment#DefineType('r', '# %s' ) -call tcomment#DefineType('samba', '# %s' ) -call tcomment#DefineType('sbs', "' %s" ) -call tcomment#DefineType('scala', '// %s' ) -call tcomment#DefineType('scala_inline', g:tcommentInlineC ) -call tcomment#DefineType('scala_block', g:tcommentBlockC ) -call tcomment#DefineType('scheme', '; %s' ) -call tcomment#DefineType('scheme_block', '#|%s|#' ) -" call tcomment#DefineType('scheme_s', '#;%s' ) -call tcomment#DefineType('scss', '// %s' ) -call tcomment#DefineType('scss_inline', g:tcommentInlineC ) -call tcomment#DefineType('scss_block', g:tcommentBlockC ) -call tcomment#DefineType('sed', '# %s' ) -call tcomment#DefineType('sgml', g:tcommentInlineXML) -call tcomment#DefineType('sgml_inline', g:tcommentInlineXML) -call tcomment#DefineType('sgml_block', g:tcommentBlockXML ) -call tcomment#DefineType('sh', '# %s' ) -call tcomment#DefineType('slim', '/%s' ) -call tcomment#DefineType('smarty', '{* %s *}' ) -call tcomment#DefineType('spec', '# %s' ) -call tcomment#DefineType('sps', '* %s.' ) -call tcomment#DefineType('sps_block', "* %s." ) -call tcomment#DefineType('spss', '* %s.' ) -call tcomment#DefineType('spss_block', "* %s." ) -call tcomment#DefineType('sql', '-- %s' ) -call tcomment#DefineType('squid', '# %s' ) -call tcomment#DefineType('sshconfig', '# %s' ) -call tcomment#DefineType('sshdconfig', '# %s' ) -call tcomment#DefineType('st', '" %s "' ) -call tcomment#DefineType('tcl', '# %s' ) -call tcomment#DefineType('tex', '%% %s' ) -call tcomment#DefineType('tpl', '<!-- %s -->' ) -call tcomment#DefineType('typoscript', '# %s' ) -call tcomment#DefineType('upstart', '# %s' ) -call tcomment#DefineType('vhdl', '-- %s' ) -call tcomment#DefineType('viki', '%% %s' ) -call tcomment#DefineType('viki_3', '%%%%%% %s' ) -call tcomment#DefineType('viki_inline', '{cmt: %s}' ) -call tcomment#DefineType('vim', '" %s' ) -call tcomment#DefineType('vim_3', '""" %s' ) -call tcomment#DefineType('websec', '# %s' ) -call tcomment#DefineType('x86conf', '# %s' ) -call tcomment#DefineType('xml', g:tcommentInlineXML) -call tcomment#DefineType('xml_inline', g:tcommentInlineXML) -call tcomment#DefineType('xml_block', g:tcommentBlockXML ) -call tcomment#DefineType('xs', '// %s' ) -call tcomment#DefineType('xs_block', g:tcommentBlockC ) -call tcomment#DefineType('xslt', g:tcommentInlineXML) -call tcomment#DefineType('xslt_inline', g:tcommentInlineXML) -call tcomment#DefineType('xslt_block', g:tcommentBlockXML ) -call tcomment#DefineType('yaml', '# %s' ) - - -function! s:DefaultValue(option) - exec 'let '. a:option .' = &'. a:option - exec 'set '. a:option .'&' - exec 'let default = &'. a:option - exec 'let &'. a:option .' = '. a:option - return default -endf - -let s:defaultComments = s:DefaultValue('comments') -let s:defaultCommentString = s:DefaultValue('commentstring') -let s:nullCommentString = '%s' - -" tcomment#Comment(line1, line2, ?commentMode, ?commentAnyway, ?args...) -" args... are either: -" 1. a list of key=value pairs where known keys are (see also -" |g:tcommentOptions|): -" as=STRING ... Use a specific comment definition -" count=N ... Repeat the comment string N times -" col=N ... Start the comment at column N (in block -" mode; must be smaller than |indent()|) -" mode=STRING ... See the notes below on the "commentMode" argument -" mode_extra=STRING ... Add to commentMode -" begin=STRING ... Comment prefix -" end=STRING ... Comment postfix -" middle=STRING ... Middle line comments in block mode -" rxbeg=N ... Regexp to find the substring of "begin" -" that should be multiplied by "count" -" rxend=N ... The above for "end" -" rxmid=N ... The above for "middle" -" mixedindent=BOOL ... If true, allow use of mixed -" characters for indentation -" commentstring_rx ... A regexp format string that matches -" commented lines (no new groups may be -" introduced, the |regexp| is |\V|; % have -" to be doubled); "commentstring", "begin" -" and optionally "end" must be defined or -" deducible. -" whitespace ... Define whether commented text is -" surrounded with whitespace; if -" both ... surround with whitespace (default) -" no ... don't use whitespace -" strip_whitespace ... Strip trailing whitespace: if 1, strip -" from empty lines only, if 2, always strip -" whitespace -" 2. 1-2 values for: ?commentPrefix, ?commentPostfix -" 3. a dictionary (internal use only) -" -" commentMode (see also ¦g:tcommentModeExtra¦): -" G ... guess the value of commentMode -" B ... block (use extra lines for the comment markers) -" i ... maybe inline, guess -" I ... inline -" R ... right (comment the line right of the cursor) -" v ... visual -" o ... operator -" By default, each line in range will be commented by adding the comment -" prefix and postfix. -function! tcomment#Comment(beg, end, ...) - let commentMode = s:AddModeExtra((a:0 >= 1 ? a:1 : 'G'), g:tcommentModeExtra, a:beg, a:end) - let commentAnyway = a:0 >= 2 ? (a:2 == '!') : 0 - " TLogVAR a:beg, a:end, commentMode, commentAnyway - " save the cursor position - if exists('w:tcommentPos') - let s:current_pos = copy(w:tcommentPos) - else - let s:current_pos = getpos('.') - endif - " echom "DBG current_pos=" string(s:current_pos) - let cursor_pos = getpos("'>") - " TLogVAR cursor_pos - let s:cursor_pos = [] - if commentMode =~# 'i' - let commentMode = substitute(commentMode, '\Ci', line("'<") == line("'>") ? 'I' : 'G', 'g') - " TLogVAR 1, commentMode - endif - let [lbeg, cbeg, lend, cend] = s:GetStartEnd(a:beg, a:end, commentMode) - if exists('s:temp_options') && has_key(s:temp_options, 'mode_extra') - let commentMode = s:AddModeExtra(commentMode, s:temp_options.mode_extra, lbeg, lend) - unlet s:temp_options.mode_extra - endif - " TLogVAR commentMode, lbeg, cbeg, lend, cend - " get the correct commentstring - let cdef = copy(g:tcommentOptions) - " TLogVAR 1, cdef - if exists('b:tcommentOptions') - let cdef = extend(cdef, copy(b:tcommentOptions)) - " TLogVAR 2, cdef - endif - if a:0 >= 3 && type(a:3) == 4 - call extend(cdef, a:3) - " TLogVAR 3, cdef - else - let cdef0 = s:GetCommentDefinition(lbeg, lend, commentMode) - " TLogVAR 4.1, cdef, cdef0 - call extend(cdef, cdef0) - " TLogVAR 4.2, cdef - let ax = 3 - if a:0 >= 3 && a:3 != '' && stridx(a:3, '=') == -1 - let ax = 4 - let cdef.begin = a:3 - if a:0 >= 4 && a:4 != '' && stridx(a:4, '=') == -1 - let ax = 5 - let cdef.end = a:4 - endif - endif - " TLogVAR ax, a:0, a:000 - if a:0 >= ax - let cdef = extend(cdef, s:ParseArgs(lbeg, lend, commentMode, a:000[ax - 1 : -1])) - " TLogVAR 5, cdef - endif - if !empty(get(cdef, 'begin', '')) || !empty(get(cdef, 'end', '')) - let cdef.commentstring = s:EncodeCommentPart(get(cdef, 'begin', '')) - \ . '%s' - \ . s:EncodeCommentPart(get(cdef, 'end', '')) - endif - let commentMode = cdef.mode - " TLogVAR 2, commentMode - endif - if exists('s:temp_options') - let cdef = s:ExtendCDef(lbeg, lend, commentMode, cdef, s:temp_options) - " TLogVAR 6, cdef - " echom "DBG s:temp_options" string(s:temp_options) - unlet s:temp_options - endif - " TLogVAR 7, cdef - if has_key(cdef, 'whitespace') - call s:SetWhitespaceMode(cdef) - endif - if !empty(filter(['count', 'cbeg', 'cend', 'cmid'], 'has_key(cdef, v:val)')) - call s:RepeatCommentstring(cdef) - endif - " echom "DBG" string(a:000) - let cms0 = s:BlockGetCommentRx(cdef) - " TLogVAR cms0 - " make whitespace optional; this conflicts with comments that require some - " whitespace - let cmtCheck = substitute(cms0, '\([ ]\)', '\1\\?', 'g') - " turn commentstring into a search pattern - " TLogVAR cmtCheck - let cmtCheck = printf(cmtCheck, '\(\_.\{-}\)') - " TLogVAR cdef, cmtCheck - let s:cdef = cdef - " set commentMode and indentStr - let [lbeg, lend, indentStr, uncomment] = s:CommentDef(lbeg, lend, cmtCheck, commentMode, cbeg, cend) - " TLogVAR lbeg, lend, indentStr, uncomment - let col = get(s:cdef, 'col', -1) - if col >= 0 - let col -= 1 - let indent = len(indentStr) - if col > indent - let cms0 = repeat(' ', col - indent) . cms0 - " TLogVAR cms0 - else - let indentStr = repeat(' ', col) - endif - endif - if commentAnyway - let uncomment = 0 - endif - " go - " TLogVAR commentMode - if commentMode =~# 'B' - " We want a comment block - call s:CommentBlock(lbeg, lend, commentMode, uncomment, cmtCheck, s:cdef, indentStr) - else - " call s:CommentLines(lbeg, lend, cbeg, cend, uncomment, cmtCheck, cms0, indentStr) - " We want commented lines - " final search pattern for uncommenting - let cmtCheck = escape('\V\^\(\s\{-}\)'. cmtCheck .'\$', '"/\') - " final pattern for commenting - let cmtReplace = s:GetCommentReplace(s:cdef, cms0) - " TLogVAR cmtReplace - if get(s:cdef, 'mixedindent', 0) && !empty(indentStr) - let cbeg = strdisplaywidth(indentStr, cbeg) - let indentStr = '' - endif - " TLogVAR commentMode, lbeg, cbeg, lend, cend - let s:processline_lnum = lbeg - let cmd = lbeg .','. lend .'s/\V'. - \ s:StartPosRx(commentMode, lbeg, cbeg) . indentStr .'\zs\(\_.\{-}\)'. s:EndPosRx(commentMode, lend, cend) .'/'. - \ '\=s:ProcessLine('. uncomment .', submatch(0), "'. cmtCheck .'", "'. cmtReplace .'")/ge' - " TLogVAR cmd - exec cmd - call histdel('search', -1) - endif - " reposition cursor - " TLogVAR 3, commentMode - " echom "DBG s:cursor_pos" string(s:cursor_pos) - if !empty(s:cursor_pos) - let cursor_pos = s:cursor_pos - endif - if commentMode =~ '>' - call setpos('.', cursor_pos) - if commentMode !~ 'i' && commentMode =~ '>>' - norm! l^ - endif - elseif commentMode =~ '#' - call setpos('.', cursor_pos) - if exists('w:tcommentPos') - let w:tcommentPos = cursor_pos - endif - else - call setpos('.', s:current_pos) - endif - unlet! s:cursor_pos s:current_pos s:cdef -endf - - -function! tcomment#SetOption(name, arg) "{{{3 - " TLogVAR a:name, a:arg - if !exists('s:temp_options') - let s:temp_options = {} - endif - " if index(['count', 'as'], a:name) != -1 - if empty(a:arg) - if has_key(s:temp_options, a:name) - call remove(s:temp_options, a:name) - endif - else - let s:temp_options[a:name] = a:arg - endif - " endif -endf - - -function! s:GetStartEnd(beg, end, commentMode) "{{{3 - " TLogVAR a:beg, a:end, a:commentMode - if type(a:beg) == 3 - let [lbeg, cbeg] = a:beg - let [lend, cend] = a:end - else - let lbeg = a:beg - let lend = a:end - let commentMode = a:commentMode - " TLogVAR commentMode - if commentMode =~# 'R' - let cbeg = col('.') - let cend = 0 - let commentMode = substitute(commentMode, '\CR', 'G', 'g') - elseif commentMode =~# 'I' - let cbeg = col("'<") - if cbeg == 0 - let cbeg = col('.') - endif - let cend = col("'>") - if cend < col('$') && (commentMode =~# 'o' || &selection == 'inclusive') - let cend += 1 - " TLogVAR cend, col('$') - endif - else - let cbeg = 0 - let cend = 0 - endif - endif - " TLogVAR lbeg, cbeg, lend, cend - return [lbeg, cbeg, lend, cend] -endf - - -function! s:SetWhitespaceMode(cdef) "{{{3 - let mode = a:cdef.whitespace - let cms = s:BlockGetCommentString(a:cdef) - let mid = s:BlockGetMiddleString(a:cdef) - let cms0 = cms - let mid0 = mid - " TLogVAR mode, cms, mid - if mode =~ '^\(n\%[o]\|l\%[eft]\|r\%[ight]\)$' - if mode == 'no' || mode == 'right' - let cms = substitute(cms, '\s\+\ze%\@<!%s', '', 'g') - let mid = substitute(mid, '\s\+\ze%\@<!%s', '', 'g') - endif - if mode == 'no' || mode == 'left' - let cms = substitute(cms, '%\@<!%s\zs\s\+', '', 'g') - let mid = substitute(mid, '%\@<!%s\zs\s\+', '', 'g') - endif - elseif mode =~ '^\(b\%[oth]\)$' - let cms = substitute(cms, '\S\zs\ze%\@<!%s', ' ', 'g') - let mid = substitute(mid, '\S\zs\ze%\@<!%s', ' ', 'g') - let cms = substitute(cms, '%\@<!%s\zs\ze\S', ' ', 'g') - let mid = substitute(mid, '%\@<!%s\zs\ze\S', ' ', 'g') - endif - if cms != cms0 - " TLogVAR cms - let a:cdef.commentstring = cms - endif - if mid != mid0 - " TLogVAR mid - let a:cdef.middle = mid - endif - return a:cdef -endf - - -function! s:RepeatCommentstring(cdef) "{{{3 - " TLogVAR a:cdef - let cms = s:BlockGetCommentString(a:cdef) - let mid = s:BlockGetMiddleString(a:cdef) - let cms_fbeg = match(cms, '\s*%\@<!%s') - let cms_fend = matchend(cms, '%\@<!%s\s*') - let rxbeg = get(a:cdef, 'rxbeg', '^.*$') - let rxend = get(a:cdef, 'rxend', '^.*$') - let rpbeg = repeat('&', get(a:cdef, 'cbeg', get(a:cdef, 'count', 1))) - let rpend = repeat('&', get(a:cdef, 'cend', get(a:cdef, 'count', 1))) - let a:cdef.commentstring = substitute(cms[0 : cms_fbeg - 1], rxbeg, rpbeg, '') - \. cms[cms_fbeg : cms_fend - 1] - \. substitute(cms[cms_fend : -1], rxend, rpend, '') - " TLogVAR cms, a:cdef.commentstring - if !empty(mid) - let rxmid = get(a:cdef, 'rxmid', '^.*$') - let rpmid = repeat('&', get(a:cdef, 'cmid', get(a:cdef, 'count', 1))) - let a:cdef.middle = substitute(mid, rxmid, rpmid, '') - " TLogVAR mid, a:cdef.middle - endif - return a:cdef -endf - - -function! s:ParseArgs(beg, end, commentMode, arglist) "{{{3 - let args = {} - for arg in a:arglist - let key = matchstr(arg, '^[^=]\+') - let value = matchstr(arg, '=\zs.*$') - if !empty(key) - let args[key] = value - endif - endfor - return s:ExtendCDef(a:beg, a:end, a:commentMode, {}, args) -endf - - -function! s:ExtendCDef(beg, end, commentMode, cdef, args) - for [key, value] in items(a:args) - if key == 'as' - call extend(a:cdef, s:GetCommentDefinitionForType(a:beg, a:end, a:commentMode, value)) - elseif key == 'mode' - let a:cdef[key] = a:commentMode . value - elseif key == 'count' - let a:cdef[key] = str2nr(value) - else - let a:cdef[key] = value - endif - endfor - return a:cdef -endf - - -function! tcomment#Operator(type, ...) "{{{3 - let commentMode = a:0 >= 1 ? a:1 : '' - let bang = a:0 >= 2 ? a:2 : '' - " TLogVAR a:type, commentMode, bang - if !exists('w:tcommentPos') - let w:tcommentPos = getpos(".") - endif - let sel_save = &selection - set selection=inclusive - let reg_save = @@ - try - if a:type == 'line' - silent exe "normal! '[V']" - let commentMode1 = 'G' - elseif a:type == 'block' - silent exe "normal! `[\<C-V>`]" - let commentMode1 = 'I' - elseif a:type == 'char' && !g:tcomment#ignore_char_type - silent exe "normal! `[v`]" - let commentMode1 = 'I' - else - silent exe "normal! `[v`]" - let commentMode1 = 'i' - endif - if empty(commentMode) - let commentMode = commentMode1 - endif - let lbeg = line("'[") - let lend = line("']") - let cbeg = col("'[") - let cend = col("']") - " TLogVAR lbeg, lend, cbeg, cend - " echom "DBG tcomment#Operator" lbeg col("'[") col("'<") lend col("']") col("'>") - norm!  - let commentMode = s:AddModeExtra(commentMode, g:tcommentOpModeExtra, lbeg, lend) - if a:type =~ 'line\|block' || g:tcomment#ignore_char_type - call tcomment#Comment(lbeg, lend, commentMode.'o', bang) - else - call tcomment#Comment([lbeg, cbeg], [lend, cend], commentMode.'o', bang) - endif - finally - let &selection = sel_save - let @@ = reg_save - " TLogVAR g:tcommentOpModeExtra - if g:tcommentOpModeExtra !~ '[#>]' - if exists('w:tcommentPos') - " TLogVAR w:tcommentPos - if w:tcommentPos != getpos('.') - call setpos('.', w:tcommentPos) - endif - unlet! w:tcommentPos - else - echohl WarningMsg - echom "TComment: w:tcommentPos wasn't set. Please report this to the plugin author" - echohl NONE - endif - endif - endtry -endf - - -function! tcomment#OperatorLine(type) "{{{3 - call tcomment#Operator(a:type, 'G') -endf - - -function! tcomment#OperatorAnyway(type) "{{{3 - call tcomment#Operator(a:type, '', '!') -endf - - -function! tcomment#OperatorLineAnyway(type) "{{{3 - call tcomment#Operator(a:type, 'G', '!') -endf - - -" :display: tcomment#CommentAs(beg, end, commentAnyway, filetype, ?args...) -" Where args is either: -" 1. A count NUMBER -" 2. An args list (see the notes on the "args" argument of -" |tcomment#Comment()|) -" comment text as if it were of a specific filetype -function! tcomment#CommentAs(beg, end, commentAnyway, filetype, ...) - if a:filetype =~ '_block$' - let commentMode = 'B' - let ft = substitute(a:filetype, '_block$', '', '') - elseif a:filetype =~ '_inline$' - let commentMode = 'I' - let ft = substitute(a:filetype, '_inline$', '', '') - else - let commentMode = 'G' - let ft = a:filetype - endif - if a:0 >= 1 - if type(a:1) == 0 - let cdef = {'count': a:0 >= 1 ? a:1 : 1} - else - let cdef = s:ParseArgs(a:beg, a:end, commentMode, a:000) - endif - else - let cdef = {} - endif - " echom "DBG" string(cdef) - call extend(cdef, s:GetCommentDefinitionForType(a:beg, a:end, commentMode, ft)) - keepjumps call tcomment#Comment(a:beg, a:end, commentMode, a:commentAnyway, cdef) -endf - - -" collect all known comment types -" :nodoc: -function! tcomment#CollectFileTypes() - if s:typesDirty - let s:types = keys(s:definitions) - let s:typesRx = '\V\^\('. join(s:types, '\|') .'\)\(\u\.\*\)\?\$' - let s:typesDirty = 0 - endif -endf - -call tcomment#CollectFileTypes() - - -" return a list of filetypes for which a tcomment_{&ft} is defined -" :nodoc: -function! tcomment#Complete(ArgLead, CmdLine, CursorPos) "{{{3 - call tcomment#CollectFileTypes() - let completions = copy(s:types) - let filetype = s:Filetype() - if index(completions, filetype) != -1 - " TLogVAR filetype - call insert(completions, filetype) - endif - if !empty(a:ArgLead) - call filter(completions, 'v:val =~ ''\V\^''.a:ArgLead') - endif - let completions += tcomment#CompleteArgs(a:ArgLead, a:CmdLine, a:CursorPos) - return completions -endf - - -let s:first_completion = 0 - -" :nodoc: -function! tcomment#CompleteArgs(ArgLead, CmdLine, CursorPos) "{{{3 - if v:version < 703 && !s:first_completion - redraw - let s:first_completion = 1 - endif - let completions = ['as=', 'col=', 'count=', 'mode=', 'begin=', 'end=', 'rxbeg=', 'rxend=', 'rxmid='] - if !empty(a:ArgLead) - if a:ArgLead =~ '^as=' - call tcomment#CollectFileTypes() - let completions += map(copy(s:types), '"as=". v:val') - endif - call filter(completions, 'v:val =~ ''\V\^''.a:ArgLead') - endif - return completions -endf - - -function! s:EncodeCommentPart(string) - return substitute(a:string, '%', '%%', 'g') -endf - - -function! s:GetCommentDefinitionForType(beg, end, commentMode, filetype) "{{{3 - let cdef = s:GetCommentDefinition(a:beg, a:end, a:commentMode, a:filetype) - " TLogVAR cdef - let cms = cdef.commentstring - let commentMode = cdef.mode - let pre = substitute(cms, '%\@<!%s.*$', '', '') - let pre = substitute(pre, '%%', '%', 'g') - let post = substitute(cms, '^.\{-}%\@<!%s', '', '') - let post = substitute(post, '%%', '%', 'g') - let cdef.begin = pre - let cdef.end = post - return cdef -endf - - -" s:GetCommentDefinition(beg, end, commentMode, ?filetype="") -function! s:GetCommentDefinition(beg, end, commentMode, ...) - let ft = a:0 >= 1 ? a:1 : '' - " TLogVAR ft - if ft != '' - let cdef = s:GetCustomCommentString(ft, a:commentMode) - else - let cdef = {'mode': a:commentMode} - endif - " TLogVAR cdef - let cms = get(cdef, 'commentstring', '') - if empty(cms) - let filetype = s:Filetype(ft) - if exists('b:commentstring') - let cms = b:commentstring - " TLogVAR 1, cms - return s:GetCustomCommentString(filetype, a:commentMode, cms) - elseif exists('b:commentStart') && b:commentStart != '' - let cms = s:EncodeCommentPart(b:commentStart) .' %s' - " TLogVAR 2, cms - if exists('b:commentEnd') && b:commentEnd != '' - let cms = cms .' '. s:EncodeCommentPart(b:commentEnd) - endif - return s:GetCustomCommentString(filetype, a:commentMode, cms) - else - let [use_guess_ft, altFiletype] = s:AltFiletype(ft) - " TLogVAR use_guess_ft, altFiletype - if use_guess_ft - return s:GuessFileType(a:beg, a:end, a:commentMode, filetype, altFiletype) - else - return s:GetCustomCommentString(filetype, a:commentMode, s:GuessCurrentCommentString(a:commentMode)) - endif - endif - let cdef.commentstring = cms - endif - return cdef -endf - -function! s:StartPosRx(mode, line, col) - " TLogVAR a:mode, a:line, a:col - if a:mode =~# 'I' - let col = get(s:cdef, 'mixedindent', 0) ? a:col - 1 : a:col - return s:StartLineRx(a:line) . s:StartColRx(col) - else - return s:StartColRx(a:col) - endif -endf - -function! s:EndPosRx(mode, line, col) - if a:mode =~# 'I' - return s:EndLineRx(a:line) . s:EndColRx(a:col) - else - return s:EndColRx(a:col) - endif -endf - -function! s:StartLineRx(pos) - return '\%'. a:pos .'l' -endf - -function! s:EndLineRx(pos) - return '\%'. a:pos .'l' -endf - -function! s:StartColRx(pos) - if a:pos <= 1 - return '\^' - elseif get(s:cdef, 'mixedindent', 0) - return '\%>'. a:pos .'v' - else - return '\%'. a:pos .'c' - endif -endf - -function! s:EndColRx(pos) - if a:pos == 0 - return '\$' - else - return '\%'. a:pos .'c' - endif -endf - -function! s:GetIndentString(line, start) - let start = a:start > 0 ? a:start - 1 : 0 - return substitute(strpart(getline(a:line), start), '\V\^\s\*\zs\.\*\$', '', '') -endf - -function! s:CommentDef(beg, end, checkRx, commentMode, cstart, cend) - " TLogVAR a:beg, a:end, a:checkRx, a:commentMode, a:cstart, a:cend - let beg = a:beg - let end = a:end - let mdrx = '\V'. s:StartColRx(a:cstart) .'\s\*'. a:checkRx .'\s\*'. s:EndColRx(0) - " let mdrx = '\V'. s:StartPosRx(a:commentMode, beg, a:cstart) .'\s\*'. a:checkRx .'\s\*'. s:EndPosRx(a:commentMode, end, 0) - let line = getline(beg) - if a:cstart != 0 && a:cend != 0 - let line = strpart(line, 0, a:cend - 1) - endif - let uncomment = (line =~ mdrx) - " TLogVAR 1, uncomment - let indentStr = s:GetIndentString(beg, a:cstart) - let il = indent(beg) - let n = beg + 1 - while n <= end - if getline(n) =~ '\S' - let jl = indent(n) - if jl < il - let indentStr = s:GetIndentString(n, a:cstart) - let il = jl - endif - if a:commentMode =~# 'G' - if !(getline(n) =~ mdrx) - let uncomment = 0 - " TLogVAR 2, uncomment - endif - endif - endif - let n = n + 1 - endwh - if a:commentMode =~# 'B' - let t = @t - try - silent exec 'norm! '. beg.'G1|v'.end.'G$"ty' - if &selection == 'inclusive' && @t =~ '\n$' && len(@t) > 1 - let @t = @t[0 : -2] - endif - " TLogVAR @t, mdrx - let uncomment = (@t =~ mdrx) - " TLogVAR 3, uncomment - if !uncomment && a:commentMode =~ 'o' - let mdrx1 = substitute(mdrx, '\\$$', '\\n\\$', '') - " TLogVAR mdrx1 - if @t =~ mdrx1 - let uncomment = 1 - " TLogVAR 4, uncomment - " let end -= 1 - endif - endif - finally - let @t = t - endtry - endif - " TLogVAR 5, uncomment - return [beg, end, indentStr, uncomment] -endf - -function! s:ProcessLine(uncomment, match, checkRx, replace) - " TLogVAR a:uncomment, a:match, a:checkRx, a:replace - try - if !(a:match =~ '\S' || g:tcommentBlankLines) - return a:match - endif - let ml = len(a:match) - if a:uncomment - let rv = substitute(a:match, a:checkRx, '\1\2', '') - let rv = s:UnreplaceInLine(rv) - else - let rv = s:ReplaceInLine(a:match) - let rv = printf(a:replace, rv) - let strip_whitespace = get(s:cdef, 'strip_whitespace', 0) - if strip_whitespace == 2 || (strip_whitespace == 1 && ml == 0) - let rv = substitute(rv, '\s\+$', '', '') - endif - endif - " TLogVAR rv - " echom "DBG s:cdef.mode=" string(s:cdef.mode) "s:cursor_pos=" string(s:cursor_pos) - " let md = len(rv) - ml - if s:cdef.mode =~ '>' - let s:cursor_pos = getpos('.') - let s:cursor_pos[2] += len(rv) - elseif s:cdef.mode =~ '#' - if empty(s:cursor_pos) || s:current_pos[1] == s:processline_lnum - let prefix = matchstr(a:replace, '^.*%\@<!\ze%s') - let prefix = substitute(prefix, '%\(.\)', '\1', 'g') - let prefix_len = strdisplaywidth(prefix) - " TLogVAR a:replace, prefix_len - if prefix_len != -1 - let s:cursor_pos = copy(s:current_pos) - if a:uncomment - let s:cursor_pos[2] -= prefix_len - if s:cursor_pos[2] < 1 - let s:cursor_pos[2] = 1 - endif - else - let s:cursor_pos[2] += prefix_len - endif - " echom "DBG s:current_pos=" string(s:current_pos) "s:cursor_pos=" string(s:cursor_pos) - endif - endif - endif - " TLogVAR pe, md, a:match - " TLogVAR rv - if v:version > 702 || (v:version == 702 && has('patch407')) - let rv = escape(rv, "\r") - else - let rv = escape(rv, "\\r") - endif - " TLogVAR rv - " let rv = substitute(rv, '\n', '\\\n', 'g') - " TLogVAR rv - return rv - finally - let s:processline_lnum += 1 - endtry -endf - - -function! s:ReplaceInLine(text) "{{{3 - if has_key(s:cdef, 'replacements') - let replacements = s:cdef.replacements - return s:DoReplacements(a:text, keys(replacements), values(replacements)) - else - return a:text - endif -endf - - -function! s:UnreplaceInLine(text) "{{{3 - if has_key(s:cdef, 'replacements') - let replacements = s:cdef.replacements - return s:DoReplacements(a:text, values(replacements), keys(replacements)) - else - return a:text - endif -endf - - -function! s:DoReplacements(text, tokens, replacements) "{{{3 - if empty(a:tokens) - return a:text - else - let rx = '\V\('. join(map(a:tokens, 'escape(v:val, ''\'')'), '\|') .'\)' - let texts = split(a:text, rx .'\zs', 1) - let texts = map(texts, 's:InlineReplacement(v:val, rx, a:tokens, a:replacements)') - let text = join(texts, '') - return text - endif -endf - - -function! s:InlineReplacement(text, rx, tokens, replacements) "{{{3 - " TLogVAR a:text, a:rx, a:replacements - let matches = split(a:text, '\ze'. a:rx .'\$', 1) - if len(matches) == 1 - return a:text - else - let match = matches[-1] - let idx = index(a:tokens, match) - " TLogVAR matches, match, idx - if idx != -1 - let matches[-1] = a:replacements[idx] - " TLogVAR matches - return join(matches, '') - else - throw 'TComment: Internal error: cannot find '. string(match) .' in '. string(a:tokens) - endif - endif -endf - - -function! s:CommentBlock(beg, end, commentMode, uncomment, checkRx, cdef, indentStr) - " TLogVAR a:beg, a:end, a:uncomment, a:checkRx, a:cdef, a:indentStr - let t = @t - let sel_save = &selection - set selection=exclusive - try - silent exec 'norm! '. a:beg.'G1|v'.a:end.'G$"td' - " TLogVAR @t - let ms = s:BlockGetMiddleString(a:cdef) - let mx = escape(ms, '\') - let cs = s:BlockGetCommentString(a:cdef) - let prefix = substitute(matchstr(cs, '^.*%\@<!\ze%s'), '%\(.\)', '\1', 'g') - let postfix = substitute(matchstr(cs, '%\@<!%s\zs.*$'), '%\(.\)', '\1', 'g') - if a:uncomment - let @t = substitute(@t, '\V\^\s\*'. a:checkRx .'\$', '\1', '') - " TLogVAR 1, @t - if ms != '' - let @t = substitute(@t, '\V\n'. a:indentStr . mx, '\n'. a:indentStr, 'g') - " TLogVAR 2, @t - endif - let @t = substitute(@t, '^\n', '', '') - let @t = substitute(@t, '\n\s*$', '', '') - if a:commentMode =~ '#' - let s:cursor_pos = copy(s:current_pos) - let prefix_lines = len(substitute(prefix, "[^\n]", '', 'g')) + 1 - let postfix_lines = len(substitute(postfix, "[^\n]", '', 'g')) + 1 - " TODO: more precise solution (when cursor is placed on - " postfix or prefix - if s:cursor_pos[1] > a:beg - let s:cursor_pos[1] -= prefix_lines - if s:cursor_pos[1] > a:end - postfix_lines - let s:cursor_pos[1] -= postfix_lines - endif - if s:cursor_pos[1] < 1 - let s:cursor_pos[1] = 1 - endif - endif - let prefix_len = strdisplaywidth(mx) - let s:cursor_pos[2] -= prefix_len - if s:cursor_pos[2] < 1 - let s:cursor_pos[2] = 1 - endif - endif - else - let cs = a:indentStr . substitute(cs, '%\@<!%s', '%s'. a:indentStr, '') - if ms != '' - let ms = a:indentStr . ms - let mx = a:indentStr . mx - let @t = substitute(@t, '^'. a:indentStr, '', 'g') - let @t = ms . substitute(@t, '\n'. a:indentStr, '\n'. mx, 'g') - endif - let @t = printf(cs, "\n". @t ."\n") - if a:commentMode =~ '#' - let s:cursor_pos = copy(s:current_pos) - let s:cursor_pos[1] += len(substitute(prefix, "[^\n]", '', 'g')) + 1 - let prefix_len = strdisplaywidth(mx) - let s:cursor_pos[2] += prefix_len - " echom "DBG s:current_pos=" string(s:current_pos) "s:cursor_pos=" string(s:cursor_pos) - endif - endif - silent norm! "tP - finally - let &selection = sel_save - let @t = t - endtry -endf - - -function! s:Filetype(...) "{{{3 - let ft = a:0 >= 1 && !empty(a:1) ? a:1 : &filetype - let pos = a:0 >= 2 ? a:2 : 0 - " TLogVAR ft, pos - let fts = split(ft, '^\@!\.') - " TLogVAR fts - " let ft = substitute(ft, '\..*$', '', '') - let rv = get(fts, pos, ft) - " TLogVAR fts, rv - if !exists('s:filetype_map_rx') - let fts_rx = '^'. join(map(keys(g:tcomment#filetype_map), 'escape(v:val, ''\'')'), '\|') .'$' - endif - " TLogVAR fts_rx - if rv =~ fts_rx - for [ft_rx, ftrv] in items(g:tcomment#filetype_map) - " TLogVAR ft_rx, ftrv - if rv =~ ft_rx - let rv = substitute(rv, ft_rx, ftrv, '') - " TLogVAR rv - break - endif - endfor - endif - return rv -endf - - -function! s:AltFiletype(filetype) "{{{3 - let filetype = empty(a:filetype) ? &filetype : a:filetype - " TLogVAR a:filetype, filetype - if g:tcommentGuessFileType || (exists('g:tcommentGuessFileType_'. filetype) - \ && g:tcommentGuessFileType_{filetype} =~ '[^0]') - if g:tcommentGuessFileType_{filetype} == 1 - if filetype =~ '^.\{-}\..\+$' - let altFiletype = s:Filetype(filetype, 1) - else - let altFiletype = '' - endif - else - let altFiletype = g:tcommentGuessFileType_{filetype} - endif - " TLogVAR 1, altFiletype - return [1, altFiletype] - elseif filetype =~ '^.\{-}\..\+$' - let altFiletype = s:Filetype(filetype, 1) - " TLogVAR 2, altFiletype - return [1, altFiletype] - else - " TLogVAR 3, '' - return [0, ''] - endif -endf - - -" A function that makes the s:GuessFileType() function usable for other -" library developers. -" -" The argument is a dictionary with the following keys: -" -" beg ................ (default = line(".")) -" end ................ (default = line(".")) -" commentMode ........ (default = "G") -" filetype ........... (default = &filetype) -" fallbackFiletype ... (default = "") -" -" This function return a dictionary that contains information about how -" to make comments. The information about the filetype of the text -" between lines "beg" and "end" is in the "filetype" key of the return -" value. It returns the first discernible filetype it encounters. -" :display: tcomment#GuessFileType(?options={}) -function! tcomment#GuessCommentType(...) "{{{3 - let options = a:0 >= 1 ? a:1 : {} - let beg = get(options, 'beg', line('.')) - let end = get(options, 'end', line('.')) - let commentMode = get(options, 'commentMode', '') - let filetype = get(options, 'filetype', &filetype) - let fallbackFiletype = get(options, 'filetype', '') - return s:GuessFileType(beg, end, commentMode, filetype, fallbackFiletype) -endf - - -" inspired by Meikel Brandmeyer's EnhancedCommentify.vim -" this requires that a syntax names are prefixed by the filetype name -" s:GuessFileType(beg, end, commentMode, filetype, ?fallbackFiletype) -function! s:GuessFileType(beg, end, commentMode, filetype, ...) - " TLogVAR a:beg, a:end, a:commentMode, a:filetype, a:000 - " TLogVAR cdef - let cdef0 = s:GetCustomCommentString(a:filetype, a:commentMode) - if a:0 >= 1 && a:1 != '' - let cdef = s:GetCustomCommentString(a:1, a:commentMode) - " TLogVAR 0, cdef - let cdef = extend(cdef, cdef0, 'keep') - " TLogVAR 1, cdef - if empty(get(cdef, 'commentstring', '')) - let cdef.commentstring = s:GuessCurrentCommentString(a:commentMode) - endif - " TLogVAR 2, cdef - else - let cdef = cdef0 - if !has_key(cdef, 'commentstring') - let cdef = {'commentstring': s:GuessCurrentCommentString(0), 'mode': s:GuessCommentMode(a:commentMode)} - endif - endif - let beg = a:beg - let end = nextnonblank(a:end) - if end == 0 - let end = a:end - let beg = prevnonblank(a:beg) - if beg == 0 - let beg = a:beg - endif - endif - let n = beg - " TLogVAR n, beg, end - while n <= end - let m = indent(n) + 1 - let text = getline(n) - let le = len(text) - " TLogVAR m, le - while m <= le - let syntaxName = s:GetSyntaxName(n, m) - " TLogVAR syntaxName, n, m - let ftypeMap = get(g:tcommentSyntaxMap, syntaxName, '') - " TLogVAR ftypeMap - if !empty(ftypeMap) && type(ftypeMap) == 4 - if n < a:beg - let key = 'prevnonblank' - elseif n > a:end - let key = 'nextnonblank' - else - let key = '' - endif - if empty(key) || !has_key(ftypeMap, key) - let ftypeftype = get(ftypeMap, 'filetype', {}) - " TLogVAR ftypeMap, ftypeftype - unlet! ftypeMap - let ftypeMap = get(ftypeftype, a:filetype, '') - else - let mapft = '' - for mapdef in ftypeMap[key] - if strpart(text, m - 1) =~ '^'. mapdef.match - let mapft = mapdef.filetype - break - endif - endfor - unlet! ftypeMap - if empty(mapft) - let ftypeMap = '' - else - let ftypeMap = mapft - endif - endif - endif - if !empty(ftypeMap) - " TLogVAR ftypeMap - return s:GetCustomCommentString(ftypeMap, a:commentMode, cdef.commentstring) - elseif syntaxName =~ s:typesRx - let ft = substitute(syntaxName, s:typesRx, '\1', '') - " TLogVAR ft - if exists('g:tcommentIgnoreTypes_'. a:filetype) && g:tcommentIgnoreTypes_{a:filetype} =~ '\<'.ft.'\>' - let m += 1 - else - return s:GetCustomCommentString(ft, a:commentMode, cdef.commentstring) - endif - elseif syntaxName == '' || syntaxName == 'None' || syntaxName =~ '^\u\+$' || syntaxName =~ '^\u\U*$' - let m += 1 - else - break - endif - endwh - let n += 1 - endwh - " TLogVAR cdef - return cdef -endf - - -function! s:GetSyntaxName(lnum, col) "{{{3 - let syntaxName = synIDattr(synID(a:lnum, a:col, 1), 'name') - if !empty(g:tcomment#syntax_substitute) - for [rx, subdef] in items(g:tcomment#syntax_substitute) - if !has_key(subdef, 'if') || eval(subdef.if) - let syntaxName = substitute(syntaxName, rx, subdef.sub, 'g') - endif - endfor - endif - " TLogVAR syntaxName - return syntaxName -endf - - -function! s:AddModeExtra(mode, extra, beg, end) "{{{3 - if a:beg == a:end - let extra = substitute(a:extra, '\C[B]', '', 'g') - else - let extra = substitute(a:extra, '\C[IR]', '', 'g') - endif - let mode = a:mode - if extra =~# 'B' - let mode = substitute(mode, '\c[gir]', '', 'g') - endif - if extra =~# '[IR]' - let mode = substitute(mode, '\c[gb]', '', 'g') - endif - let rv = mode . extra - " TLogVAR a:mode, a:extra, mode, extra, rv - return rv -endf - - -function! s:GuessCommentMode(commentMode) "{{{3 - if a:commentMode =~# '[IRB]' - return a:commentMode - else - return substitute(a:commentMode, '\w\+', 'G', 'g') - endif -endf - -function! s:GuessCurrentCommentString(commentMode) - " TLogVAR a:commentMode - let valid_cms = (match(&commentstring, '%\@<!%s') != -1) - if &commentstring != s:defaultCommentString && valid_cms - " The &commentstring appears to have been set and to be valid - return &commentstring - endif - if &comments != s:defaultComments - " the commentstring is the default one, so we assume that it wasn't - " explicitly set; we then try to reconstruct &cms from &comments - let cms = s:ConstructFromComments(a:commentMode) - if cms != s:nullCommentString - return cms - endif - endif - if valid_cms - " Before &commentstring appeared not to be set. As we don't know - " better we return it anyway if it is valid - return &commentstring - else - " &commentstring is invalid. So we return the identity string. - return s:nullCommentString - endif -endf - -function! s:ConstructFromComments(commentMode) - exec s:ExtractCommentsPart('') - if a:commentMode =~# 'G' && line != '' - return line .' %s' - endif - exec s:ExtractCommentsPart('s') - if s != '' - exec s:ExtractCommentsPart('e') - return s.' %s '.e - endif - if line != '' - return line .' %s' - else - return s:nullCommentString - endif -endf - -function! s:ExtractCommentsPart(key) - " let key = a:key != "" ? a:key .'[^:]*' : "" - let key = a:key . '[bnflrxO0-9-]*' - let val = substitute(&comments, '^\(.\{-},\)\{-}'. key .':\([^,]\+\).*$', '\2', '') - if val == &comments - let val = '' - else - let val = substitute(val, '%', '%%', 'g') - endif - let var = a:key == '' ? 'line' : a:key - return 'let '. var .'="'. escape(val, '"') .'"' -endf - -" s:GetCustomCommentString(ft, commentMode, ?default="") -function! s:GetCustomCommentString(ft, commentMode, ...) - " TLogVAR a:ft, a:commentMode, a:000 - let commentMode = a:commentMode - let customComment = tcomment#TypeExists(a:ft) - if commentMode =~# 'B' && tcomment#TypeExists(a:ft .'_block') - let def = s:definitions[a:ft .'_block'] - " TLogVAR 1, def - elseif commentMode =~? 'I' && tcomment#TypeExists(a:ft .'_inline') - let def = s:definitions[a:ft .'_inline'] - " TLogVAR 2, def - elseif customComment - let def = s:definitions[a:ft] - let commentMode = s:GuessCommentMode(commentMode) - " TLogVAR 3, def - elseif a:0 >= 1 - let def = {'commentstring': a:1} - let commentMode = s:GuessCommentMode(commentMode) - " TLogVAR 4, def - else - let def = {} - let commentMode = s:GuessCommentMode(commentMode) - " TLogVAR 5, def - endif - let cdef = copy(def) - let cdef.mode = commentMode - let cdef.filetype = a:ft - " TLogVAR cdef - return cdef -endf - -function! s:GetCommentReplace(cdef, cms0) - if has_key(a:cdef, 'commentstring_rx') - let rs = s:BlockGetCommentString(a:cdef) - else - let rs = a:cms0 - endif - return escape(rs, '"/') -endf - -function! s:BlockGetCommentRx(cdef) - if has_key(a:cdef, 'commentstring_rx') - return a:cdef.commentstring_rx - else - let cms0 = s:BlockGetCommentString(a:cdef) - let cms0 = escape(cms0, '\') - return cms0 - endif -endf - -function! s:BlockGetCommentString(cdef) - if has_key(a:cdef, 'middle') - return a:cdef.commentstring - else - return matchstr(a:cdef.commentstring, '^.\{-}\ze\(\n\|$\)') - endif -endf - -function! s:BlockGetMiddleString(cdef) - if has_key(a:cdef, 'middle') - return a:cdef.middle - else - return matchstr(a:cdef.commentstring, '\n\zs.*') - endif -endf - - -function! tcomment#TextObjectInlineComment() "{{{3 - let cdef = tcomment#GuessCommentType({'commentMode': 'I'}) - let cms = escape(cdef.commentstring, '\') - let pos = getpos('.') - let lnum = pos[1] - let col = pos[2] - let cmtf = '\V'. printf(cms, '\.\{-}\%'. lnum .'l\%'. col .'c\.\{-}') - " TLogVAR cmtf, search(cmtf,'cwn') - if search(cmtf, 'cw') > 0 - let pos0 = getpos('.') - if search(cmtf, 'cwe') > 0 - let pos1 = getpos('.') - exec 'norm!' - \ pos0[1].'gg'.pos0[2].'|v'. - \ pos1[1].'gg'.pos1[2].'|'. - \ (&sel == 'exclusive' ? 'l' : '') - endif - endif -endf - - -" vi: ft=vim:tw=72:ts=4:fo=w2croql diff --git a/vim/bundle/tcomment/doc/tcomment.txt b/vim/bundle/tcomment/doc/tcomment.txt @@ -1,495 +0,0 @@ -*tcomment.txt* An easily extensible & universal comment plugin - Author: Thomas Link, micathom AT gmail com?subject=vim - -tcomment provides easy to use, file-type sensible comments for Vim. It -can handle embedded syntax. - -TComment works like a toggle, i.e., it will comment out text that -contains uncommented lines, and it will remove comment markup for -already commented text (i.e. text that contains no uncommented lines). - -If the file-type is properly defined, TComment will figure out which -comment string to use. Otherwise you use |tcomment#DefineType()| to -override the default choice. - -TComment can properly handle an embedded syntax, e.g., ruby/python/perl -regions in vim scripts, HTML or JavaScript in php code etc. - -tcomment favours the use of line-wise comment styles. This implies that usually -whole line will be commented out. tcomment also knows block-style and inline -comments that can be used via special maps (see below) or the |:TCommentAs| -command. - -Demo: -http://vimsomnia.blogspot.com/2010/11/tcomment-vim-plugin.html - - - *tcomment-maps* -Key bindings~ - -Most of the time the default toggle keys will do what you want (or to be -more precise: what I think you want it to do ;-). - - *tcomment-operator* -As operator (the prefix can be customized via |g:tcommentMapLeaderOp1| -and |g:tcommentMapLeaderOp2|): - - gc{motion} :: Toggle comments (for small comments within one line - the &filetype_inline style will be used, if - defined) - gc<Count>c{motion} :: Toggle comment text with count argument - (see |tcomment#Comment()|) - gcc :: Toggle comment for the current line - gC{motion} :: Comment region - gCc :: Comment the current line - -In visual mode: - - gc :: Toggle comments - gC :: Comment selected text - -CAVEAT: If you visually select text within a line, the visual mode map will -comment out the selected text. If you selected text across several lines, the -visual mode map will assume though that you wanted to comment out lines -- -since this is how many vim maps work. In order to make tcomment use e.g. inline -comments anyway, use the <c-_>i map -- see below. - -By default the cursor stays put. If you want the cursor to the end of -the commented text, set |g:tcommentOpModeExtra| to '>' (but this may not -work properly with exclusive motions). - -Primary key maps for normal and insert mode: - - <c-_><c-_> :: :TComment - <c-_><space> :: :TComment <QUERY COMMENT-BEGIN ?COMMENT-END> - <c-_>b :: :TCommentBlock - <c-_>a :: :TCommentAs <QUERY COMMENT TYPE> - <c-_>n :: :TCommentAs &filetype <QUERY COUNT> - <c-_>s :: :TCommentAs &filetype_<QUERY COMMENT SUBTYPE> - <c-_>i :: :TCommentInline (in normal and insert mode, this map will - create an empty inline comment, which isn't suitable for - all filetypes though) - <c-_>r :: :TCommentRight - <c-_>p :: Comment the current inner paragraph - <c-_><Count> :: :TComment with count argument (a number from 1 to 9) - (see |tcomment#Comment()|) - -Primary key maps for visual mode: - - <c-_><c-_> :: :TComment - <c-_>i :: :TCommentInline - <c-_><Count> :: :TComment with count argument (a number from 1 to 9) - (see |tcomment#Comment()|) - -A secondary set of key maps is defined for normal and insert mode: - - <Leader>__ :: :TComment - <Leader>_p :: Comment the current inner paragraph - <Leader>_<space> :: :TComment <QUERY COMMENT-BEGIN ?COMMENT-END> - <Leader>_i :: :TCommentInline - <Leader>_r :: :TCommentRight - <Leader>_b :: :TCommentBlock - <Leader>_a :: :TCommentAs <QUERY COMMENT TYPE> - <Leader>_n :: :TCommentAs &filetype <QUERY COUNT> - <Leader>_s :: :TCommentAs &filetype_<QUERY COMMENT SUBTYPE> - -... and for select mode: - - <Leader>__ :: :TComment - <Leader>_i :: :TCommentInline - - ------------------------------------------------------------------------ -Install~ - -Edit the vba file and type: > - - :so % - -See :help vimball for details. If you have difficulties or use vim 7.0, -please make sure, you have the current version of vimball (vimscript -#1502) installed or update your runtime. - - -======================================================================== -Contents~ - - g:tcommentMaps ...................... |g:tcommentMaps| - g:tcommentMapLeader1 ................ |g:tcommentMapLeader1| - g:tcommentMapLeader2 ................ |g:tcommentMapLeader2| - g:tcommentMapLeaderOp1 .............. |g:tcommentMapLeaderOp1| - g:tcommentMapLeaderOp2 .............. |g:tcommentMapLeaderOp2| - :TComment ........................... |:TComment| - :TCommentAs ......................... |:TCommentAs| - :TCommentRight ...................... |:TCommentRight| - :TCommentBlock ...................... |:TCommentBlock| - :TCommentInline ..................... |:TCommentInline| - :TCommentMaybeInline ................ |:TCommentMaybeInline| - g:tcommentBlankLines ................ |g:tcommentBlankLines| - g:tcommentModeExtra ................. |g:tcommentModeExtra| - g:tcommentOpModeExtra ............... |g:tcommentOpModeExtra| - g:tcommentOptions ................... |g:tcommentOptions| - g:tcomment#ignore_char_type ......... |g:tcomment#ignore_char_type| - g:tcommentGuessFileType ............. |g:tcommentGuessFileType| - g:tcommentGuessFileType_dsl ......... |g:tcommentGuessFileType_dsl| - g:tcommentGuessFileType_php ......... |g:tcommentGuessFileType_php| - g:tcommentGuessFileType_html ........ |g:tcommentGuessFileType_html| - g:tcommentGuessFileType_tskeleton ... |g:tcommentGuessFileType_tskeleton| - g:tcommentGuessFileType_vim ......... |g:tcommentGuessFileType_vim| - g:tcommentGuessFileType_django ...... |g:tcommentGuessFileType_django| - g:tcommentGuessFileType_eruby ....... |g:tcommentGuessFileType_eruby| - g:tcommentGuessFileType_smarty ...... |g:tcommentGuessFileType_smarty| - g:tcommentIgnoreTypes_php ........... |g:tcommentIgnoreTypes_php| - g:tcomment#syntax_substitute ........ |g:tcomment#syntax_substitute| - g:tcommentSyntaxMap ................. |g:tcommentSyntaxMap| - g:tcomment#replacements_c ........... |g:tcomment#replacements_c| - g:tcommentInlineC ................... |g:tcommentInlineC| - g:tcommentBlockC2 ................... |g:tcommentBlockC2| - g:tcomment#replacements_xml ......... |g:tcomment#replacements_xml| - g:tcommentBlockXML .................. |g:tcommentBlockXML| - g:tcommentInlineXML ................. |g:tcommentInlineXML| - tcomment#DefineType ................. |tcomment#DefineType()| - g:tcomment_types .................... |g:tcomment_types| - tcomment#Comment .................... |tcomment#Comment()| - tcomment#SetOption .................. |tcomment#SetOption()| - tcomment#Operator ................... |tcomment#Operator()| - tcomment#OperatorLine ............... |tcomment#OperatorLine()| - tcomment#OperatorAnyway ............. |tcomment#OperatorAnyway()| - tcomment#OperatorLineAnyway ......... |tcomment#OperatorLineAnyway()| - tcomment#CommentAs .................. |tcomment#CommentAs()| - tcomment#GuessCommentType ........... |tcomment#GuessCommentType()| - - -======================================================================== -plugin/tcomment.vim~ - - *g:tcommentMaps* -g:tcommentMaps (default: 1) - If true, set maps. - - *g:tcommentMapLeader1* -g:tcommentMapLeader1 (default: '<c-_>') - g:tcommentMapLeader1 should be a shortcut that can be used with - map, imap, vmap. - - *g:tcommentMapLeader2* -g:tcommentMapLeader2 (default: '<Leader>_') - g:tcommentMapLeader2 should be a shortcut that can be used with - map, xmap. - - *g:tcommentMapLeaderOp1* -g:tcommentMapLeaderOp1 (default: 'gc') - See |tcomment-operator|. - - *g:tcommentMapLeaderOp2* -g:tcommentMapLeaderOp2 (default: 'gC') - See |tcomment-operator|. - - *:TComment* -:[range]TComment[!] ?ARGS... - If there is a visual selection that begins and ends in the same line, - then |:TCommentInline| is used instead. - The optional range defaults to the current line. With a bang '!', - always comment the line. - - ARGS... are either (see also |tcomment#Comment()|): - 1. a list of key=value pairs - 2. 1-2 values for: ?commentBegin, ?commentEnd - - *:TCommentAs* -:[range]TCommentAs[!] commenttype ?ARGS... - TCommentAs requires g:tcomment_{filetype} to be defined. - With a bang '!', always comment the line. - - ARGS... are either (see also |tcomment#Comment()|): - 1. a list of key=value pairs - 2. 1-2 values for: ?commentBegin, ?commentEnd - - *:TCommentRight* -:[range]TCommentRight[!] ?ARGS... - Comment the text to the right of the cursor. If a visual selection was - made (be it block-wise or not), all lines are commented out at from - the current cursor position downwards. - With a bang '!', always comment the line. - - ARGS... are either (see also |tcomment#Comment()|): - 1. a list of key=value pairs - 2. 1-2 values for: ?commentBegin, ?commentEnd - - *:TCommentBlock* -:[range]TCommentBlock[!] ?ARGS... - Comment as "block", e.g. use the {&ft}_block comment style. The - commented text isn't indented or reformated. - With a bang '!', always comment the line. - - ARGS... are either (see also |tcomment#Comment()|): - 1. a list of key=value pairs - 2. 1-2 values for: ?commentBegin, ?commentEnd - - *:TCommentInline* -:[range]TCommentInline[!] ?ARGS... - Use the {&ft}_inline comment style. - With a bang '!', always comment the line. - - ARGS... are either (see also |tcomment#Comment()|): - 1. a list of key=value pairs - 2. 1-2 values for: ?commentBegin, ?commentEnd - - *:TCommentMaybeInline* -:[range]TCommentMaybeInline[!] ?ARGS... - With a bang '!', always comment the line. - - ARGS... are either (see also |tcomment#Comment()|): - 1. a list of key=value pairs - 2. 1-2 values for: ?commentBegin, ?commentEnd - - -======================================================================== -autoload/tcomment.vim~ - - *g:tcommentBlankLines* -g:tcommentBlankLines (default: 1) - If true, comment blank lines too - - *g:tcommentModeExtra* -g:tcommentModeExtra (default: '') - Modifies how commenting works. - > ... Move the cursor to the end of the comment - >> ... Like above but move the cursor to the next line - # ... Move the cursor to the position of the commented text - (NOTE: this only works when creating empty comments using - |:TCommentInline| from normal or insert mode and should - not be set here as a global option.) - - *g:tcommentOpModeExtra* -g:tcommentOpModeExtra (default: '') - Modifies how the operator works. - See |g:tcommentModeExtra| for a list of possible values. - - *g:tcommentOptions* -g:tcommentOptions (default: {}) - Other key-value options used by |tcomment#Comment()|. - - Example: If you want to put the opening comment marker always in - the first column regardless of the block's indentation, put this - into your |vimrc| file: > - let g:tcommentOptions = {'col': 1} -< - - *g:tcomment#ignore_char_type* -g:tcomment#ignore_char_type (default: 1) - |text-objects| for use with |tcomment#Operator| can have different - types: line, block, char etc. Text objects like aB, it, at etc. - have type char but this may not work reliably. By default, - tcomment handles those text objects most often as if they were of - type line. Set this variable to 0 in order to change this - behaviour. Be prepared that the result may not always match your - intentions. - - *g:tcommentGuessFileType* -g:tcommentGuessFileType (default: 0) - Guess the file type based on syntax names always or for some fileformat only - If non-zero, try to guess filetypes. - tcomment also checks g:tcommentGuessFileType_{&filetype} for - filetype specific values. - - Values: - 0 ... don't guess - 1 ... guess - FILETYPE ... assume this filetype - - *g:tcommentGuessFileType_dsl* -g:tcommentGuessFileType_dsl (default: 'xml') - For dsl documents, assume filetype = xml. - - *g:tcommentGuessFileType_php* -g:tcommentGuessFileType_php (default: 'html') - In php documents, the php part is usually marked as phpRegion. We - thus assume that the buffers default comment style isn't php but - html. - - *g:tcommentGuessFileType_html* -g:tcommentGuessFileType_html (default: 1) - - *g:tcommentGuessFileType_tskeleton* -g:tcommentGuessFileType_tskeleton (default: 1) - - *g:tcommentGuessFileType_vim* -g:tcommentGuessFileType_vim (default: 1) - - *g:tcommentGuessFileType_django* -g:tcommentGuessFileType_django (default: 1) - - *g:tcommentGuessFileType_eruby* -g:tcommentGuessFileType_eruby (default: 1) - - *g:tcommentGuessFileType_smarty* -g:tcommentGuessFileType_smarty (default: 1) - - *g:tcommentIgnoreTypes_php* -g:tcommentIgnoreTypes_php (default: 'sql') - In php files, some syntax regions are wrongly highlighted as sql - markup. We thus ignore sql syntax when guessing the filetype in - php files. - - *g:tcomment#syntax_substitute* -g:tcomment#syntax_substitute (default: {...}) - - *g:tcommentSyntaxMap* -g:tcommentSyntaxMap (default: {...}) - tcomment guesses filetypes based on the name of the current syntax - region. This works well if the syntax names match - /filetypeSomeName/. Other syntax names have to be explicitly - mapped onto the corresponding filetype. - - *g:tcomment#replacements_c* -g:tcomment#replacements_c (default: {...}) - Replacements for c filetype. - - *g:tcommentInlineC* -g:tcommentInlineC (default: {...}) - Generic c-like comments. - - *g:tcommentBlockC2* -g:tcommentBlockC2 (default: {...}) - Generic c-like block comments. - Generic c-like block comments (alternative markup). - - *g:tcomment#replacements_xml* -g:tcomment#replacements_xml (default: {...}) - Replacements for xml filetype. - - *g:tcommentBlockXML* -g:tcommentBlockXML (default: {...}) - Generic xml-like block comments. - - *g:tcommentInlineXML* -g:tcommentInlineXML (default: {...}) - Generic xml-like comments. - - *tcomment#DefineType()* -tcomment#DefineType(name, commentdef) - If you don't explicitly define a comment style, |:TComment| will use - 'commentstring' instead. We override the default values here in order - to have a blank after the comment marker. Block comments work only if - we explicitly define the markup. - - NAME usually is a 'filetype'. You can use special suffixes to define - special comment types. E.g. the name "FILETYPE_block" is used for - block comments for 'filetype'. The name "FILETYPE_inline" is used for - inline comments. If no specialized comment definition exists, the - normal one with name "FILETYPE" is used. - - The comment definition can be either a string or a dictionary. - - If it is a string: - The format for block comments is similar to 'commentstrings' with the - exception that the format strings for blocks can contain a second line - that defines how "middle lines" (see :h format-comments) should be - displayed. - - Example: If the string is "--%s--\n-- ", lines will be commented as - "--%s--" but the middle lines in block comments will be commented as - "--%s". - - If it is a dictionary: - See the help on the args argument of |tcomment#Comment| (see item 1, - args is a list of key=value pairs) to find out which fields can be - used. - - *g:tcomment_types* -g:tcomment_types (default: {}) - A dictionary of NAME => COMMENT DEFINITION (see |tcomment#DefineType|) - that can be set in vimrc to override tcomment's default comment - styles. - - - - *tcomment#Comment()* -tcomment#Comment(beg, end, ...) - tcomment#Comment(line1, line2, ?commentMode, ?commentAnyway, ?args...) - args... are either: - 1. a list of key=value pairs where known keys are (see also - |g:tcommentOptions|): - as=STRING ... Use a specific comment definition - count=N ... Repeat the comment string N times - col=N ... Start the comment at column N (in block - mode; must be smaller than |indent()|) - mode=STRING ... See the notes below on the "commentMode" argument - mode_extra=STRING ... Add to commentMode - begin=STRING ... Comment prefix - end=STRING ... Comment postfix - middle=STRING ... Middle line comments in block mode - rxbeg=N ... Regexp to find the substring of "begin" - that should be multiplied by "count" - rxend=N ... The above for "end" - rxmid=N ... The above for "middle" - mixedindent=BOOL ... If true, allow use of mixed - characters for indentation - commentstring_rx ... A regexp format string that matches - commented lines (no new groups may be - introduced, the |regexp| is |\V|; % have - to be doubled); "commentstring", "begin" - and optionally "end" must be defined or - deducible. - strip_whitespace ... Strip trailing whitespace: if 1, strip - from empty lines only, if 2, always strip - whitespace - 2. 1-2 values for: ?commentPrefix, ?commentPostfix - 3. a dictionary (internal use only) - - commentMode (see also ¦g:tcommentModeExtra¦): - G ... guess the value of commentMode - B ... block (use extra lines for the comment markers) - i ... maybe inline, guess - I ... inline - R ... right (comment the line right of the cursor) - v ... visual - o ... operator - By default, each line in range will be commented by adding the comment - prefix and postfix. - - *tcomment#SetOption()* -tcomment#SetOption(name, arg) - - *tcomment#Operator()* -tcomment#Operator(type, ...) - - *tcomment#OperatorLine()* -tcomment#OperatorLine(type) - - *tcomment#OperatorAnyway()* -tcomment#OperatorAnyway(type) - - *tcomment#OperatorLineAnyway()* -tcomment#OperatorLineAnyway(type) - - *tcomment#CommentAs()* -tcomment#CommentAs(beg, end, commentAnyway, filetype, ?args...) - Where args is either: - 1. A count NUMBER - 2. An args list (see the notes on the "args" argument of - |tcomment#Comment()|) - comment text as if it were of a specific filetype - - *tcomment#GuessCommentType()* -tcomment#GuessFileType(?options={}) - A function that makes the s:GuessFileType() function usable for other - library developers. - - The argument is a dictionary with the following keys: - - beg ................ (default = line(".")) - end ................ (default = line(".")) - commentMode ........ (default = "G") - filetype ........... (default = &filetype) - fallbackFiletype ... (default = "") - - This function return a dictionary that contains information about how - to make comments. The information about the filetype of the text - between lines "beg" and "end" is in the "filetype" key of the return - value. It returns the first discernible filetype it encounters. - - - -vim:tw=78:fo=tcq2:isk=!-~,^*,^|,^":ts=8:ft=help:norl: diff --git a/vim/bundle/tcomment/plugin/tcomment.vim b/vim/bundle/tcomment/plugin/tcomment.vim @@ -1,177 +0,0 @@ -" tComment.vim -- An easily extensible & universal comment plugin -" @Author: Tom Link (micathom AT gmail com) -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 27-Dez-2004. -" @Last Change: 2012-11-26. -" @Revision: 777 -" GetLatestVimScripts: 1173 1 tcomment.vim - -if &cp || exists('loaded_tcomment') - finish -endif -let loaded_tcomment = 208 - -if !exists('g:tcommentMaps') - " If true, set maps. - let g:tcommentMaps = 1 "{{{2 -endif - -if !exists("g:tcommentMapLeader1") - " g:tcommentMapLeader1 should be a shortcut that can be used with - " map, imap, vmap. - let g:tcommentMapLeader1 = '<c-_>' "{{{2 -endif - -if !exists("g:tcommentMapLeader2") - " g:tcommentMapLeader2 should be a shortcut that can be used with - " map, xmap. - let g:tcommentMapLeader2 = '<Leader>_' "{{{2 -endif - -if !exists("g:tcommentMapLeaderOp1") - " See |tcomment-operator|. - let g:tcommentMapLeaderOp1 = 'gc' "{{{2 -endif - -if !exists("g:tcommentMapLeaderOp2") - " See |tcomment-operator|. - let g:tcommentMapLeaderOp2 = 'gC' "{{{2 -endif - -if !exists('g:tcommentTextObjectInlineComment') - let g:tcommentTextObjectInlineComment = 'ic' "{{{2 -endif - - -" :display: :[range]TComment[!] ?ARGS... -" If there is a visual selection that begins and ends in the same line, -" then |:TCommentInline| is used instead. -" The optional range defaults to the current line. With a bang '!', -" always comment the line. -" -" ARGS... are either (see also |tcomment#Comment()|): -" 1. a list of key=value pairs -" 2. 1-2 values for: ?commentBegin, ?commentEnd -command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TComment - \ keepjumps call tcomment#Comment(<line1>, <line2>, 'G', "<bang>", <f-args>) - -" :display: :[range]TCommentAs[!] commenttype ?ARGS... -" TCommentAs requires g:tcomment_{filetype} to be defined. -" With a bang '!', always comment the line. -" -" ARGS... are either (see also |tcomment#Comment()|): -" 1. a list of key=value pairs -" 2. 1-2 values for: ?commentBegin, ?commentEnd -command! -bang -complete=customlist,tcomment#Complete -range -nargs=+ TCommentAs - \ call tcomment#CommentAs(<line1>, <line2>, "<bang>", <f-args>) - -" :display: :[range]TCommentRight[!] ?ARGS... -" Comment the text to the right of the cursor. If a visual selection was -" made (be it block-wise or not), all lines are commented out at from -" the current cursor position downwards. -" With a bang '!', always comment the line. -" -" ARGS... are either (see also |tcomment#Comment()|): -" 1. a list of key=value pairs -" 2. 1-2 values for: ?commentBegin, ?commentEnd -command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TCommentRight - \ keepjumps call tcomment#Comment(<line1>, <line2>, 'R', "<bang>", <f-args>) - -" :display: :[range]TCommentBlock[!] ?ARGS... -" Comment as "block", e.g. use the {&ft}_block comment style. The -" commented text isn't indented or reformated. -" With a bang '!', always comment the line. -" -" ARGS... are either (see also |tcomment#Comment()|): -" 1. a list of key=value pairs -" 2. 1-2 values for: ?commentBegin, ?commentEnd -command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TCommentBlock - \ keepjumps call tcomment#Comment(<line1>, <line2>, 'B', "<bang>", <f-args>) - -" :display: :[range]TCommentInline[!] ?ARGS... -" Use the {&ft}_inline comment style. -" With a bang '!', always comment the line. -" -" ARGS... are either (see also |tcomment#Comment()|): -" 1. a list of key=value pairs -" 2. 1-2 values for: ?commentBegin, ?commentEnd -command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TCommentInline - \ keepjumps call tcomment#Comment(<line1>, <line2>, 'I', "<bang>", <f-args>) - -" :display: :[range]TCommentMaybeInline[!] ?ARGS... -" With a bang '!', always comment the line. -" -" ARGS... are either (see also |tcomment#Comment()|): -" 1. a list of key=value pairs -" 2. 1-2 values for: ?commentBegin, ?commentEnd -command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TCommentMaybeInline - \ keepjumps call tcomment#Comment(<line1>, <line2>, 'i', "<bang>", <f-args>) - - - -if g:tcommentMaps - if g:tcommentMapLeader1 != '' - exec 'noremap <silent> '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' :TComment<cr>' - exec 'vnoremap <silent> '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' :TCommentMaybeInline<cr>' - exec 'inoremap <silent> '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' <c-o>:TComment<cr>' - exec 'noremap <silent> '. g:tcommentMapLeader1 .'p m`vip:TComment<cr>``' - exec 'inoremap <silent> '. g:tcommentMapLeader1 .'p <c-o>:norm! m`vip<cr>:TComment<cr><c-o>``' - exec 'noremap '. g:tcommentMapLeader1 .'<space> :TComment ' - exec 'inoremap '. g:tcommentMapLeader1 .'<space> <c-o>:TComment ' - exec 'inoremap <silent> '. g:tcommentMapLeader1 .'r <c-o>:TCommentRight<cr>' - exec 'noremap <silent> '. g:tcommentMapLeader1 .'r :TCommentRight<cr>' - exec 'vnoremap <silent> '. g:tcommentMapLeader1 .'i :TCommentInline<cr>' - exec 'noremap <silent> '. g:tcommentMapLeader1 .'i v:TCommentInline mode=I#<cr>' - exec 'inoremap <silent> '. g:tcommentMapLeader1 .'i <c-\><c-o>v:TCommentInline mode=#<cr>' - exec 'noremap '. g:tcommentMapLeader1 .'b :TCommentBlock<cr>' - exec 'inoremap '. g:tcommentMapLeader1 .'b <c-o>:TCommentBlock<cr>' - exec 'noremap '. g:tcommentMapLeader1 .'a :TCommentAs ' - exec 'inoremap '. g:tcommentMapLeader1 .'a <c-o>:TCommentAs ' - exec 'noremap '. g:tcommentMapLeader1 .'n :TCommentAs <c-r>=&ft<cr> ' - exec 'inoremap '. g:tcommentMapLeader1 .'n <c-o>:TCommentAs <c-r>=&ft<cr> ' - exec 'noremap '. g:tcommentMapLeader1 .'s :TCommentAs <c-r>=&ft<cr>_' - exec 'inoremap '. g:tcommentMapLeader1 .'s <c-o>:TCommentAs <c-r>=&ft<cr>_' - exec 'noremap <silent> '. g:tcommentMapLeader1 .'cc :<c-u>call tcomment#SetOption("count", v:count1)<cr>' - exec 'noremap '. g:tcommentMapLeader1 .'ca :<c-u>call tcomment#SetOption("as", input("Comment as: ", &filetype, "customlist,tcomment#Complete"))<cr>' - for s:i in range(1, 9) - exec 'noremap <silent> '. g:tcommentMapLeader1 . s:i .' :TComment count='. s:i .'<cr>' - exec 'inoremap <silent> '. g:tcommentMapLeader1 . s:i .' <c-\><c-o>:TComment count='. s:i .'<cr>' - exec 'vnoremap <silent> '. g:tcommentMapLeader1 . s:i .' :TCommentMaybeInline count='. s:i .'<cr>' - endfor - unlet s:i - endif - if g:tcommentMapLeader2 != '' - exec 'noremap <silent> '. g:tcommentMapLeader2 .'_ :TComment<cr>' - exec 'xnoremap <silent> '. g:tcommentMapLeader2 .'_ :TCommentMaybeInline<cr>' - exec 'noremap <silent> '. g:tcommentMapLeader2 .'p vip:TComment<cr>' - exec 'noremap '. g:tcommentMapLeader2 .'<space> :TComment ' - exec 'xnoremap <silent> '. g:tcommentMapLeader2 .'i :TCommentInline<cr>' - exec 'noremap <silent> '. g:tcommentMapLeader2 .'r :TCommentRight<cr>' - exec 'noremap '. g:tcommentMapLeader2 .'b :TCommentBlock<cr>' - exec 'noremap '. g:tcommentMapLeader2 .'a :TCommentAs ' - exec 'noremap '. g:tcommentMapLeader2 .'n :TCommentAs <c-r>=&ft<cr> ' - exec 'noremap '. g:tcommentMapLeader2 .'s :TCommentAs <c-r>=&ft<cr>_' - endif - if g:tcommentMapLeaderOp1 != '' - exec 'nnoremap <silent> '. g:tcommentMapLeaderOp1 .' :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#Operator<cr>g@' - for s:i in range(1, 9) - exec 'nnoremap <silent> '. g:tcommentMapLeaderOp1 . s:i .'c :let w:tcommentPos = getpos(".") \| call tcomment#SetOption("count", '. s:i .') \| set opfunc=tcomment#Operator<cr>g@' - endfor - unlet s:i - exec 'nnoremap <silent> '. g:tcommentMapLeaderOp1 .'c :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLine<cr>g@$' - exec 'nnoremap <silent> '. g:tcommentMapLeaderOp1 .'b :let w:tcommentPos = getpos(".") \| call tcomment#SetOption("mode_extra", "B") \| set opfunc=tcomment#OperatorLine<cr>g@' - exec 'xnoremap <silent> '. g:tcommentMapLeaderOp1 .' :TCommentMaybeInline<cr>' - endif - if g:tcommentMapLeaderOp2 != '' - exec 'nnoremap <silent> '. g:tcommentMapLeaderOp2 .' :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorAnyway<cr>g@' - exec 'nnoremap <silent> '. g:tcommentMapLeaderOp2 .'c :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLineAnyway<cr>g@$' - exec 'nnoremap <silent> '. g:tcommentMapLeaderOp2 .'b :let w:tcommentPos = getpos(".") \| call tcomment#SetOption("mode_extra", "B") \| set opfunc=tcomment#OperatorLine<cr>g@' - exec 'xnoremap <silent> '. g:tcommentMapLeaderOp2 .' :TCommentMaybeInline!<cr>' - endif - if g:tcommentTextObjectInlineComment != '' - exec 'vnoremap' g:tcommentTextObjectInlineComment ':<c-U>silent call tcomment#TextObjectInlineComment()<cr>' - exec 'omap' g:tcommentTextObjectInlineComment ':normal v'. g:tcommentTextObjectInlineComment .'<cr>' - endif -endif - -" vi: ft=vim:tw=72:ts=4:fo=w2croql diff --git a/vim/bundle/tcomment/spec/tcomment/issue30.vim b/vim/bundle/tcomment/spec/tcomment/issue30.vim @@ -1,12 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 32 - - -SpecBegin 'title': 'issue30' - \, 'options': ['vim', {'&selection': 'inclusive'}, {'&selection': 'exclusive'}] - \, 'scratch': 'issue30_test.c' - -It should block comment a single line with <c-_>b. -Should yield Buffer ':norm 2ggb', 'issue30_test_1.c' - diff --git a/vim/bundle/tcomment/spec/tcomment/issue30_sel=exclusive.vim b/vim/bundle/tcomment/spec/tcomment/issue30_sel=exclusive.vim @@ -1,14 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 11 - -SpecBegin 'title': 'issue30 - bug 2 exclusive' - \, 'options': [{'&selection': 'exclusive'}] - \, 'scratch': 'issue30_test.c' - -It should comment last character selected by v$ with gc. -Should yield Buffer ':norm 3gg$v$gc', 'issue30_test_2.c' - -It should not comment empty space after typing v with gc. -Should yield Buffer ':norm 3gg$vgc', 'issue30_test_3.c' - diff --git a/vim/bundle/tcomment/spec/tcomment/issue30_sel=inclusive.vim b/vim/bundle/tcomment/spec/tcomment/issue30_sel=inclusive.vim @@ -1,11 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 10 - -SpecBegin 'title': 'issue30 - bug 2 inclusive' - \, 'options': [{'&selection': 'inclusive'}] - \, 'scratch': 'issue30_test.c' - -It should comment last character with gc. -Should yield Buffer ':norm 3gg$vgc', 'issue30_test_2.c' - diff --git a/vim/bundle/tcomment/spec/tcomment/issue30_test.c b/vim/bundle/tcomment/spec/tcomment/issue30_test.c @@ -1,4 +0,0 @@ -int main() -{ - return 0; -} diff --git a/vim/bundle/tcomment/spec/tcomment/issue30_test_1.c b/vim/bundle/tcomment/spec/tcomment/issue30_test_1.c @@ -1,6 +0,0 @@ -int main() -/* - * { - */ - return 0; -} diff --git a/vim/bundle/tcomment/spec/tcomment/issue30_test_2.c b/vim/bundle/tcomment/spec/tcomment/issue30_test_2.c @@ -1,4 +0,0 @@ -int main() -{ - return 0/* ; */ -} diff --git a/vim/bundle/tcomment/spec/tcomment/issue30_test_3.c b/vim/bundle/tcomment/spec/tcomment/issue30_test_3.c @@ -1,4 +0,0 @@ -int main() -{ - return 0/* */; -} diff --git a/vim/colors/ambient.vim b/vim/colors/ambient.vim @@ -0,0 +1,58 @@ +" Maintainer: Kevin Hamer <kevin@imarc.net> +" Version: 1.2 +" Last Change: Fri Aug 12 16:53:40 EDT 2011 + +" Changes: +" 1.2 lightened the blue slightly +" 1.1 lightened both orange-reds + +"" Based off the colors for Ambiance, the 2011 Ubuntu dark human theme. +"" Derived from Mustang by Henrique C. Alves (hcarvalhoalves@gmail.com) +"" Offers 256 color support. + +set background=light + +hi clear + +if exists("syntax_on") + syntax reset +endif + +let colors_name = "ambient" + +" Vim >= 7.0 specific colors +if version >= 700 + " hi CursorLine cterm=underline + hi CursorLine cterm=underline + hi ColorColumn ctermfg=15 ctermbg=7 cterm=none + hi MatchParen ctermfg=15 ctermbg=8 cterm=bold + hi Pmenu ctermfg=15 ctermbg=8 + hi PmenuSel ctermfg=8 ctermbg=15 +endif +" General colors +hi Cursor ctermbg=12 +hi Normal ctermfg=8 +hi NonText ctermfg=237 +hi LineNr ctermfg=239 +hi StatusLine ctermfg=8 ctermbg=15 +hi StatusLineNC ctermfg=246 +hi VertSplit ctermfg=234 +hi Folded ctermfg=80 +hi Title ctermfg=8 +hi Visual ctermfg=15 +hi SpecialKey ctermfg=239 + +" Syntax highlight +hi Comment ctermfg=6 +hi Boolean ctermfg=5 +hi String ctermfg=13 +hi Identifier ctermfg=13 +hi Function ctermfg=8 +hi Type ctermfg=10 +hi Statement ctermfg=11 +hi Keyword ctermfg=4 +hi Constant ctermfg=5 +hi Number ctermfg=13 +hi Special ctermfg=5 +hi PreProc ctermfg=7 +hi Todo ctermfg=15 ctermbg=8 diff --git a/vim/colors/sandstorm.vim b/vim/colors/sandstorm.vim @@ -0,0 +1,69 @@ +" +" Terminal setup. +" +set background=dark +if version > 580 + highlight clear + if exists("g:syntax_on") + syntax reset + endif +endif +let g:colors_name="sandstorm" + +" +" Highlighting definitions. +" +if has("gui_running") || &t_Co == 256 + + " + " Actual colours and styles. + " + highlight Comment term=NONE cterm=NONE ctermfg=0 ctermbg=NONE + highlight Constant term=NONE cterm=NONE ctermfg=226 ctermbg=NONE + highlight Cursor term=NONE cterm=NONE ctermfg=66 ctermbg=222 + highlight CursorLine term=NONE cterm=NONE ctermfg=NONE ctermbg=233 + highlight DiffAdd term=NONE cterm=NONE ctermfg=NONE ctermbg=22 + highlight DiffChange term=NONE cterm=NONE ctermfg=NONE ctermbg=17 + highlight DiffDelete term=NONE cterm=NONE ctermfg=NONE ctermbg=52 + highlight DiffText term=NONE cterm=NONE ctermfg=NONE ctermbg=19 + highlight FoldColumn term=NONE cterm=NONE ctermfg=180 ctermbg=237 + highlight Folded term=NONE cterm=NONE ctermfg=250 ctermbg=237 + + highlight Function term=NONE cterm=NONE ctermfg=136 ctermbg=NONE + highlight Identifier term=NONE cterm=NONE ctermfg=220 ctermbg=NONE + highlight Ignore term=NONE cterm=NONE ctermfg=240 ctermbg=NONE + highlight IncSearch term=NONE cterm=NONE ctermfg=11 ctermbg=3 + highlight ModeMsg term=NONE cterm=NONE ctermfg=178 ctermbg=NONE + highlight MoreMsg term=NONE cterm=NONE ctermfg=240 ctermbg=NONE + highlight NonText term=NONE cterm=NONE ctermfg=237 ctermbg=NONE + highlight Normal term=NONE cterm=NONE ctermfg=7 ctermbg=NONE + highlight Pmenu term=NONE cterm=NONE ctermfg=231 ctermbg=237 + highlight PreProc term=NONE cterm=NONE ctermfg=178 ctermbg=NONE + highlight Question term=NONE cterm=NONE ctermfg=186 ctermbg=NONE + highlight Search term=NONE cterm=NONE ctermfg=0 ctermbg=11 + highlight Special term=NONE cterm=NONE ctermfg=222 ctermbg=NONE + highlight SpecialKey term=NONE cterm=NONE ctermfg=184 ctermbg=NONE + highlight Statement term=NONE cterm=NONE ctermfg=11 ctermbg=NONE + highlight StatusLine term=NONE cterm=NONE ctermfg=231 ctermbg=237 + highlight StatusLineNC term=NONE cterm=NONE ctermfg=16 ctermbg=237 + highlight String term=NONE cterm=NONE ctermfg=166 ctermbg=NONE + highlight Todo term=NONE cterm=NONE ctermfg=196 ctermbg=226 + highlight Type term=NONE cterm=NONE ctermfg=3 ctermbg=NONE + highlight Underlined term=NONE cterm=NONE ctermfg=186 ctermbg=NONE + highlight VertSplit term=NONE cterm=NONE ctermfg=243 ctermbg=237 + highlight Visual term=NONE cterm=NONE ctermfg=11 ctermbg=237 + highlight WarningMsg term=NONE cterm=NONE ctermfg=209 ctermbg=NONE + + " + " General highlighting group links. + " + highlight! link Title Normal + highlight! link LineNr NonText + highlight! link TabLine StatusLineNC + highlight! link TabLineFill StatusLineNC + highlight! link TabLineSel StatusLine + highlight! link VertSplit StatusLineNC + highlight! link VimHiGroup VimGroup + +endif + diff --git a/vim/colors/shadow.vim b/vim/colors/shadow.vim @@ -0,0 +1,60 @@ +" Vim colorscheme +" +" Focus on statements and values + +set background=dark + +hi clear +if exists("syntax_on") + syntax reset +endif + +let colors_name = "shadow" + +" Window elements +hi Cursor ctermfg=0 ctermbg=15 +hi Folded ctermfg=8 ctermbg=0 +hi LineNr ctermfg=7 +hi NonText ctermfg=7 +hi Normal ctermfg=7 +hi StatusLine ctermfg=15 ctermbg=0 cterm=none +hi Visual ctermfg=15 ctermbg=0 + +" Main groups +hi Comment ctermfg=15 +hi Constant ctermfg=11 cterm=none +hi Statement ctermfg=11 cterm=none +hi StatementU ctermfg=11 cterm=underline +hi Keyword ctermfg=8 +hi Underlined cterm=underline +hi Error ctermfg=15 ctermbg=1 + +hi! link String Constant +hi! link Character Constant +hi! link Number Constant +hi! link Boolean Constant +hi! link Float Constant + +hi! link Identifier Normal +hi! link Function Statement + +hi! link Operator Keyword +hi! link Preproc Keyword +hi! link Type Keyword + +hi! link Special Keyword +hi! link Ignore Normal +hi! link Todo Error + +hi! link Title Normal + +hi! link phpDefine StatementU + +hi! link HtmlArg Attribute +hi! link HtmlSpecialChar Statement + +hi! link xmlTagName Keyword +hi! link xmlEndTag Keyword +hi! link xmlEntity Statement +hi! link xmlCData Comment +hi! link xmlAttrib Attribute