mirror of
https://github.com/kennethreitz-archive/dotfiles.git
synced 2026-06-05 07:26:12 +00:00
import vim config from krvim
This commit is contained in:
@@ -0,0 +1 @@
|
||||
rainbow_parenthsis-4.0.vba: call delete('/Users/kreitz/.vim/autoload/rainbow_parenthsis.vim')|call delete('/Users/kreitz/.vim/doc/rainbow_parenthsis.txt')|call delete('/Users/kreitz/.vim/plugin/rainbow_parenthsis.vim')|call delete('/Users/kreitz/.vim/rainbow_parenthsis_options.vim')
|
||||
@@ -0,0 +1 @@
|
||||
bundle/autojump.vim/
|
||||
@@ -0,0 +1,3 @@
|
||||
let g:netrw_dirhistmax =10
|
||||
let g:netrw_dirhist_cnt =1
|
||||
let g:netrw_dirhist_1='/Users/kreitz/repos/public/tablib'
|
||||
Binary file not shown.
@@ -0,0 +1,142 @@
|
||||
" pathogen.vim - path option manipulation
|
||||
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
|
||||
" Version: 1.2
|
||||
|
||||
" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
|
||||
"
|
||||
" API is documented below.
|
||||
|
||||
if exists("g:loaded_pathogen") || &cp
|
||||
finish
|
||||
endif
|
||||
let g:loaded_pathogen = 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 has_key(seen,a:list[i])
|
||||
call remove(a:list,i)
|
||||
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
|
||||
|
||||
" Checks if a bundle is 'disabled'. A bundle is considered 'disabled' if
|
||||
" its 'basename()' is included in g:pathogen_disabled[]'.
|
||||
function! pathogen#is_disabled(path) " {{{1
|
||||
if !exists("g:pathogen_disabled")
|
||||
return 0
|
||||
endif
|
||||
let sep = pathogen#separator()
|
||||
return index(g:pathogen_disabled, strpart(a:path, strridx(a:path, sep)+1)) != -1
|
||||
endfunction "}}}1
|
||||
|
||||
" Prepend all subdirectories of path to the rtp, and append all 'after'
|
||||
" directories in those subdirectories.
|
||||
function! pathogen#runtime_prepend_subdirectories(path) " {{{1
|
||||
let sep = pathogen#separator()
|
||||
let before = filter(pathogen#glob_directories(a:path.sep."*[^~]"), '!pathogen#is_disabled(v:val)')
|
||||
let after = filter(pathogen#glob_directories(a:path.sep."*[^~]".sep."after"), '!pathogen#is_disabled(v:val)')
|
||||
let rtp = pathogen#split(&rtp)
|
||||
let path = expand(a:path)
|
||||
call filter(rtp,'v:val[0:strlen(path)-1] !=# path')
|
||||
let &rtp = pathogen#join(pathogen#uniq(before + rtp + after))
|
||||
return &rtp
|
||||
endfunction " }}}1
|
||||
|
||||
" For each directory in rtp, check for a subdirectory named dir. If it
|
||||
" exists, add all subdirectories of that subdirectory to the rtp, immediately
|
||||
" after the original directory. If no argument is given, 'bundle' is used.
|
||||
" Repeated calls with the same arguments are ignored.
|
||||
function! pathogen#runtime_append_all_bundles(...) " {{{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$'
|
||||
let list += filter(pathogen#glob_directories(substitute(dir,'after$',name,'').sep.'*[^~]'.sep.'after'), '!pathogen#is_disabled(v:val)') + [dir]
|
||||
else
|
||||
let list += [dir] + filter(pathogen#glob_directories(dir.sep.name.sep.'*[^~]'), '!pathogen#is_disabled(v:val)')
|
||||
endif
|
||||
endfor
|
||||
let &rtp = pathogen#join(pathogen#uniq(list))
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
let s:done_bundles = ''
|
||||
" }}}1
|
||||
|
||||
" Invoke :helptags on all non-$VIM doc directories in runtimepath.
|
||||
function! pathogen#helptags() " {{{1
|
||||
for dir in pathogen#split(&rtp)
|
||||
if dir[0 : strlen($VIM)-1] !=# $VIM && isdirectory(dir.'/doc') && (!filereadable(dir.'/doc/tags') || filewritable(dir.'/doc/tags'))
|
||||
helptags `=dir.'/doc'`
|
||||
endif
|
||||
endfor
|
||||
endfunction " }}}1
|
||||
|
||||
" vim:set ft=vim ts=8 sw=2 sts=2:
|
||||
@@ -0,0 +1,172 @@
|
||||
"------------------------------------------------------------------------------
|
||||
" Description: Rainbow colors for parenthsis
|
||||
" $Id: rainbow_parenthsis.vim 50 2007-10-08 18:42:51Z krischik@users.sourceforge.net $
|
||||
" Copyright: Copyright (C) 2007 Martin Krischik
|
||||
" Maintainer: Martin Krischik (krischik@users.sourceforge.net)
|
||||
" John Gilmore
|
||||
" Luc Hermitte (hermitte@free.fr)
|
||||
" $Author: krischik@users.sourceforge.net $
|
||||
" $Date: 2007-10-08 20:42:51 +0200 (Mo, 08 Okt 2007) $
|
||||
" Version: 4.0
|
||||
" $Revision: 50 $
|
||||
" $HeadURL: https://vim-scripts.googlecode.com/svn/trunk/1561%20Rainbow%20Parenthsis%20Bundle/autoload/rainbow_parenthsis.vim $
|
||||
" History: 24.05.2006 MK Unified Headers
|
||||
" 15.10.2006 MK Bram's suggestion for runtime integration
|
||||
" 06.09.2007 LH Buffer friendly (can be used in different buffers),
|
||||
" can be toggled
|
||||
" 09.09.2007 MK Use on LH's suggestion but use autoload to
|
||||
" impove memory consumtion and startup performance
|
||||
" 09.10.2007 MK Now with round, square brackets, curly and angle
|
||||
" brackets.
|
||||
" Usage: copy to autoload directory.
|
||||
"------------------------------------------------------------------------------
|
||||
" This is a simple script. It extends the syntax highlighting to
|
||||
" highlight each matching set of parens in different colors, to make
|
||||
" it visually obvious what matches which.
|
||||
"
|
||||
" Obviously, most useful when working with lisp or Ada. But it's also nice other
|
||||
" times.
|
||||
"------------------------------------------------------------------------------
|
||||
|
||||
" Section: highlight {{{1
|
||||
|
||||
function rainbow_parenthsis#Activate()
|
||||
highlight default level1c ctermbg=LightGray ctermfg=brown guibg=WhiteSmoke guifg=RoyalBlue3
|
||||
highlight default level2c ctermbg=LightGray ctermfg=Darkblue guibg=WhiteSmoke guifg=SeaGreen3
|
||||
highlight default level3c ctermbg=LightGray ctermfg=darkgray guibg=WhiteSmoke guifg=DarkOrchid3
|
||||
highlight default level4c ctermbg=LightGray ctermfg=darkgreen guibg=WhiteSmoke guifg=firebrick3
|
||||
highlight default level5c ctermbg=LightGray ctermfg=darkcyan guibg=AntiqueWhite guifg=RoyalBlue3
|
||||
highlight default level6c ctermbg=LightGray ctermfg=darkred guibg=AntiqueWhite guifg=SeaGreen3
|
||||
highlight default level7c ctermbg=LightGray ctermfg=darkmagenta guibg=AntiqueWhite guifg=DarkOrchid3
|
||||
highlight default level8c ctermbg=LightGray ctermfg=brown guibg=AntiqueWhite guifg=firebrick3
|
||||
highlight default level9c ctermbg=LightGray ctermfg=gray guibg=LemonChiffon guifg=RoyalBlue3
|
||||
highlight default level10c ctermbg=LightGray ctermfg=black guibg=LemonChiffon guifg=SeaGreen3
|
||||
highlight default level11c ctermbg=LightGray ctermfg=darkmagenta guibg=LemonChiffon guifg=DarkOrchid3
|
||||
highlight default level12c ctermbg=LightGray ctermfg=Darkblue guibg=LemonChiffon guifg=firebrick3
|
||||
highlight default level13c ctermbg=LightGray ctermfg=darkgreen guibg=AliceBlue guifg=RoyalBlue3
|
||||
highlight default level14c ctermbg=LightGray ctermfg=darkcyan guibg=AliceBlue guifg=SeaGreen3
|
||||
highlight default level15c ctermbg=LightGray ctermfg=darkred guibg=AliceBlue guifg=DarkOrchid3
|
||||
highlight default level16c ctermbg=LightGray ctermfg=red guibg=AliceBlue guifg=firebrick3
|
||||
let rainbow_parenthesis#active = 1
|
||||
endfunction
|
||||
|
||||
function rainbow_parenthsis#Clear()
|
||||
let i = 0
|
||||
while i != 16
|
||||
let i = i + 1
|
||||
exe 'highlight clear level' . i . 'c'
|
||||
endwhile
|
||||
let rainbow_parenthesis#active = 0
|
||||
endfunction
|
||||
|
||||
function rainbow_parenthsis#Toggle ()
|
||||
if ! exists('rainbow_parenthesis#active')
|
||||
call rainbow_parenthsis#LoadRound ()
|
||||
endif
|
||||
if rainbow_parenthesis#active != 0
|
||||
call rainbow_parenthsis#Clear ()
|
||||
else
|
||||
call rainbow_parenthsis#Activate ()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Section: syntax {{{1
|
||||
"
|
||||
" Subsection: parentheses or round brackets: {{{2
|
||||
"
|
||||
function rainbow_parenthsis#LoadRound ()
|
||||
syntax region level1 matchgroup=level1c start=/(/ end=/)/ contains=TOP,level1,level2,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level2 matchgroup=level2c start=/(/ end=/)/ contains=TOP,level2,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level3 matchgroup=level3c start=/(/ end=/)/ contains=TOP,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level4 matchgroup=level4c start=/(/ end=/)/ contains=TOP,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level5 matchgroup=level5c start=/(/ end=/)/ contains=TOP,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level6 matchgroup=level6c start=/(/ end=/)/ contains=TOP,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level7 matchgroup=level7c start=/(/ end=/)/ contains=TOP,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level8 matchgroup=level8c start=/(/ end=/)/ contains=TOP,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level9 matchgroup=level9c start=/(/ end=/)/ contains=TOP,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level10 matchgroup=level10c start=/(/ end=/)/ contains=TOP,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level11 matchgroup=level11c start=/(/ end=/)/ contains=TOP,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level12 matchgroup=level12c start=/(/ end=/)/ contains=TOP,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level13 matchgroup=level13c start=/(/ end=/)/ contains=TOP,level13,level14,level15, level16,NoInParens
|
||||
syntax region level14 matchgroup=level14c start=/(/ end=/)/ contains=TOP,level14,level15, level16,NoInParens
|
||||
syntax region level15 matchgroup=level15c start=/(/ end=/)/ contains=TOP,level15, level16,NoInParens
|
||||
syntax region level16 matchgroup=level16c start=/(/ end=/)/ contains=TOP,level16,NoInParens
|
||||
let rainbow_parenthesis#active = 0
|
||||
endfunction
|
||||
|
||||
" Subsection: box brackets or square brackets: {{{2
|
||||
"
|
||||
function rainbow_parenthsis#LoadSquare ()
|
||||
syntax region level1 matchgroup=level1c start=/\[/ end=/\]/ contains=TOP,level1,level2,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level2 matchgroup=level2c start=/\[/ end=/\]/ contains=TOP,level2,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level3 matchgroup=level3c start=/\[/ end=/\]/ contains=TOP,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level4 matchgroup=level4c start=/\[/ end=/\]/ contains=TOP,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level5 matchgroup=level5c start=/\[/ end=/\]/ contains=TOP,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level6 matchgroup=level6c start=/\[/ end=/\]/ contains=TOP,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level7 matchgroup=level7c start=/\[/ end=/\]/ contains=TOP,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level8 matchgroup=level8c start=/\[/ end=/\]/ contains=TOP,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level9 matchgroup=level9c start=/\[/ end=/\]/ contains=TOP,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level10 matchgroup=level10c start=/\[/ end=/\]/ contains=TOP,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level11 matchgroup=level11c start=/\[/ end=/\]/ contains=TOP,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level12 matchgroup=level12c start=/\[/ end=/\]/ contains=TOP,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level13 matchgroup=level13c start=/\[/ end=/\]/ contains=TOP,level13,level14,level15, level16,NoInParens
|
||||
syntax region level14 matchgroup=level14c start=/\[/ end=/\]/ contains=TOP,level14,level15, level16,NoInParens
|
||||
syntax region level15 matchgroup=level15c start=/\[/ end=/\]/ contains=TOP,level15, level16,NoInParens
|
||||
syntax region level16 matchgroup=level16c start=/\[/ end=/\]/ contains=TOP,level16,NoInParens
|
||||
let rainbow_parenthesis#active = 0
|
||||
endfunction
|
||||
|
||||
" Subsection: curly brackets or braces: {{{2
|
||||
"
|
||||
function rainbow_parenthsis#LoadBraces ()
|
||||
syntax region level1 matchgroup=level1c start=/{/ end=/}/ contains=TOP,level1,level2,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level2 matchgroup=level2c start=/{/ end=/}/ contains=TOP,level2,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level3 matchgroup=level3c start=/{/ end=/}/ contains=TOP,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level4 matchgroup=level4c start=/{/ end=/}/ contains=TOP,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level5 matchgroup=level5c start=/{/ end=/}/ contains=TOP,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level6 matchgroup=level6c start=/{/ end=/}/ contains=TOP,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level7 matchgroup=level7c start=/{/ end=/}/ contains=TOP,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level8 matchgroup=level8c start=/{/ end=/}/ contains=TOP,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level9 matchgroup=level9c start=/{/ end=/}/ contains=TOP,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level10 matchgroup=level10c start=/{/ end=/}/ contains=TOP,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level11 matchgroup=level11c start=/{/ end=/}/ contains=TOP,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level12 matchgroup=level12c start=/{/ end=/}/ contains=TOP,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level13 matchgroup=level13c start=/{/ end=/}/ contains=TOP,level13,level14,level15, level16,NoInParens
|
||||
syntax region level14 matchgroup=level14c start=/{/ end=/}/ contains=TOP,level14,level15, level16,NoInParens
|
||||
syntax region level15 matchgroup=level15c start=/{/ end=/}/ contains=TOP,level15, level16,NoInParens
|
||||
syntax region level16 matchgroup=level16c start=/{/ end=/}/ contains=TOP,level16,NoInParens
|
||||
let rainbow_parenthesis#active = 0
|
||||
endfunction
|
||||
|
||||
" Subsection: angle brackets or chevrons: {{{2
|
||||
"
|
||||
function rainbow_parenthsis#LoadChevrons ()
|
||||
syntax region level1 matchgroup=level1c start=/</ end=/>/ contains=TOP,level1,level2,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level2 matchgroup=level2c start=/</ end=/>/ contains=TOP,level2,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level3 matchgroup=level3c start=/</ end=/>/ contains=TOP,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level4 matchgroup=level4c start=/</ end=/>/ contains=TOP,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level5 matchgroup=level5c start=/</ end=/>/ contains=TOP,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level6 matchgroup=level6c start=/</ end=/>/ contains=TOP,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level7 matchgroup=level7c start=/</ end=/>/ contains=TOP,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level8 matchgroup=level8c start=/</ end=/>/ contains=TOP,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level9 matchgroup=level9c start=/</ end=/>/ contains=TOP,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level10 matchgroup=level10c start=/</ end=/>/ contains=TOP,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level11 matchgroup=level11c start=/</ end=/>/ contains=TOP,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level12 matchgroup=level12c start=/</ end=/>/ contains=TOP,level12,level13,level14,level15, level16,NoInParens
|
||||
syntax region level13 matchgroup=level13c start=/</ end=/>/ contains=TOP,level13,level14,level15, level16,NoInParens
|
||||
syntax region level14 matchgroup=level14c start=/</ end=/>/ contains=TOP,level14,level15, level16,NoInParens
|
||||
syntax region level15 matchgroup=level15c start=/</ end=/>/ contains=TOP,level15, level16,NoInParens
|
||||
syntax region level16 matchgroup=level16c start=/</ end=/>/ contains=TOP,level16,NoInParens
|
||||
let rainbow_parenthesis#active = 0
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
finish
|
||||
|
||||
"------------------------------------------------------------------------------
|
||||
" Copyright (C) 2006 Martin Krischik
|
||||
"
|
||||
" Vim is Charityware - see ":help license" or uganda.txt for licence details.
|
||||
"------------------------------------------------------------------------------
|
||||
" vim: textwidth=78 wrap tabstop=8 shiftwidth=4 softtabstop=4 expandtab
|
||||
" vim: filetype=vim foldmethod=marker
|
||||
@@ -0,0 +1 @@
|
||||
tags
|
||||
@@ -0,0 +1,80 @@
|
||||
# ack.vim #
|
||||
|
||||
This plugin is a front for the Perl module
|
||||
[App::Ack](http://search.cpan.org/~petdance/ack/ack). Ack can be used as a
|
||||
replacement for 99% of the uses of _grep_. This plugin will allow you to run
|
||||
ack from vim, and shows the results in a split window.
|
||||
|
||||
The *Official Version* of this plugin is available at [vim.org](http://www.vim.org/scripts/script.php?script_id=2572).
|
||||
|
||||
## Installation ##
|
||||
|
||||
|
||||
### Ack
|
||||
|
||||
You have to install [ack](http://search.cpan.org/~petdance/ack/ack), of course.
|
||||
|
||||
Install on Debian / Ubuntu with:
|
||||
|
||||
sudo apt-get install ack-grep
|
||||
|
||||
For Debian / Ubuntu you can add this line into your .vimrc:
|
||||
|
||||
let g:ackprg="ack-grep -H --nocolor --nogroup --column"
|
||||
|
||||
Install on Gentoo with:
|
||||
|
||||
sudo emerge ack
|
||||
|
||||
Install with MacPorts:
|
||||
|
||||
sudo port install p5-app-ack
|
||||
|
||||
Install with Gentoo Prefix
|
||||
|
||||
emerge ack
|
||||
|
||||
Otherwise, you are on your own.
|
||||
|
||||
### The Plugin
|
||||
|
||||
If you have [Rake](http://rake.rubyforge.org/) installed, you can just run: `rake install`.
|
||||
|
||||
Otherwise, the file ack.vim goes in ~/.vim/plugin, and the ack.txt file belongs in ~/.vim/doc. Be sure to run
|
||||
|
||||
:helptags ~/.vim/doc
|
||||
|
||||
afterwards.
|
||||
|
||||
|
||||
## Usage ##
|
||||
|
||||
:Ack [options] {pattern} [{directory}]
|
||||
|
||||
Search recursively in {directory} (which defaults to the current directory) for the {pattern}.
|
||||
|
||||
Files containing the search term will be listed in the split window, along with
|
||||
the line number of the occurrence, once for each occurrence. [Enter] on a line
|
||||
in this window will open the file, and place the cursor on the matching line.
|
||||
|
||||
Just like where you use :grep, :grepadd, :lgrep, and :lgrepadd, you can use `:Ack`, `:AckAdd`, `:LAck`, and `:LAckAdd` respectively. (See `doc/ack.txt`, or install and `:h Ack` for more information.)
|
||||
|
||||
**From the [ack docs](http://search.cpan.org/~petdance/ack/ack)** (my favorite feature):
|
||||
|
||||
--type=TYPE, --type=noTYPE
|
||||
|
||||
Specify the types of files to include or exclude from a search. TYPE is a filetype, like perl or xml. --type=perl can also be specified as --perl, and --type=noperl can be done as --noperl.
|
||||
|
||||
If a file is of both type "foo" and "bar", specifying --foo and --nobar will exclude the file, because an exclusion takes precedence over an inclusion.
|
||||
|
||||
Type specifications can be repeated and are ORed together.
|
||||
|
||||
See ack --help=types for a list of valid types.
|
||||
|
||||
This Vim plugin is derived (and by derived, I mean copied, essentially) from
|
||||
Antoine Imbert's blog post [Ack and Vim
|
||||
Integration](http://blog.ant0ine.com/2007/03/ack_and_vim_integration.html) (in
|
||||
particular, the function at the bottom of the post). I added a help file that
|
||||
provides just enough reference to get you going. I also highly recommend you
|
||||
check out the docs for the Perl script 'ack', for obvious reasons: [ack -
|
||||
grep-like text finder](http://search.cpan.org/~petdance/ack/ack).
|
||||
@@ -0,0 +1,23 @@
|
||||
# Added by Josh Nichols, a.k.a. technicalpickles
|
||||
require 'rake'
|
||||
|
||||
files = ['doc/ack.txt', 'plugin/ack.vim']
|
||||
|
||||
desc 'Install plugin and documentation'
|
||||
task :install do
|
||||
vimfiles = if ENV['VIMFILES']
|
||||
ENV['VIMFILES']
|
||||
elsif RUBY_PLATFORM =~ /(win|w)32$/
|
||||
File.expand_path("~/vimfiles")
|
||||
else
|
||||
File.expand_path("~/.vim")
|
||||
end
|
||||
files.each do |file|
|
||||
target_file = File.join(vimfiles, file)
|
||||
FileUtils.mkdir_p File.dirname(target_file)
|
||||
FileUtils.cp file, target_file
|
||||
|
||||
puts " Copied #{file} to #{target_file}"
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,50 @@
|
||||
*ack.txt* Plugin that integrates ack with Vim
|
||||
|
||||
==============================================================================
|
||||
Author: Antoine Imbert <antoine.imbert+ackvim@gmail.com> *ack-author*
|
||||
License: Same terms as Vim itself (see |license|)
|
||||
|
||||
==============================================================================
|
||||
INTRODUCTION *ack*
|
||||
|
||||
This plugin is a front for the Perl module App::Ack. Ack can be used as a
|
||||
replacement for grep. This plugin will allow you to run ack from vim, and
|
||||
shows the results in a split window.
|
||||
|
||||
:Ack [options] {pattern} [{directory}] *:Ack*
|
||||
|
||||
Search recursively in {directory} (which defaults to the current
|
||||
directory) for the {pattern}. Behaves just like the |:grep| command, but
|
||||
will open the |Quickfix| window for you.
|
||||
|
||||
:AckAdd [options] {pattern} [{directory}] *:AckAdd*
|
||||
|
||||
Just like |:Ack|, but instead of making a new list, the matches are
|
||||
appended to the current |quickfix| list.
|
||||
|
||||
:AckFromSearch [{directory}] *:AckFromSearch*
|
||||
|
||||
Just like |:Ack| but the pattern is from previous search.
|
||||
|
||||
:LAck [options] {pattern} [{directory}] *:LAck*
|
||||
|
||||
Just like |:Ack| but instead of the |quickfix| list, matches are placed in
|
||||
the current |location-list|.
|
||||
|
||||
:LAckAdd [options] {pattern} [{directory}] *:LAckAdd*
|
||||
|
||||
Just like |:AckAdd| but instead of the |quickfix| list, matches are added
|
||||
to the current |location-list|
|
||||
|
||||
:AckFile [options] {pattern} [{directory}] *:AckFile*
|
||||
|
||||
Search recursively in {directory} (which defaults to the current
|
||||
directory) for filenames matching the {pattern}. Behaves just like the
|
||||
|:grep| command, but will open the |Quickfix| window for you.
|
||||
|
||||
Files containing the search term will be listed in the split window, along
|
||||
with the line number of the occurrence, once for each occurrence. <Enter> on
|
||||
a line in this window will open the file, and place the cursor on the matching
|
||||
line.
|
||||
|
||||
See http://search.cpan.org/~petdance/ack/ack for more information.
|
||||
@@ -0,0 +1,61 @@
|
||||
" NOTE: You must, of course, install the ack script
|
||||
" in your path.
|
||||
" On Debian / Ubuntu:
|
||||
" sudo apt-get install ack-grep
|
||||
" On your vimrc:
|
||||
" let g:ackprg="ack-grep -H --nocolor --nogroup --column"
|
||||
"
|
||||
" With MacPorts:
|
||||
" sudo port install p5-app-ack
|
||||
|
||||
" Location of the ack utility
|
||||
if !exists("g:ackprg")
|
||||
let g:ackprg="ack -H --nocolor --nogroup --column"
|
||||
endif
|
||||
|
||||
function! s:Ack(cmd, args)
|
||||
redraw
|
||||
echo "Searching ..."
|
||||
|
||||
" Format, used to manage column jump
|
||||
if a:cmd =~# '-g$'
|
||||
let g:ackformat="%f"
|
||||
else
|
||||
let g:ackformat="%f:%l:%c:%m"
|
||||
end
|
||||
|
||||
let grepprg_bak=&grepprg
|
||||
let grepformat_bak=&grepformat
|
||||
try
|
||||
let &grepprg=g:ackprg
|
||||
let &grepformat=g:ackformat
|
||||
silent execute a:cmd . " " . a:args
|
||||
finally
|
||||
let &grepprg=grepprg_bak
|
||||
let &grepformat=grepformat_bak
|
||||
endtry
|
||||
|
||||
if a:cmd =~# '^l'
|
||||
botright lopen
|
||||
else
|
||||
botright copen
|
||||
endif
|
||||
|
||||
exec "nnoremap <silent> <buffer> q :ccl<CR>"
|
||||
|
||||
redraw!
|
||||
endfunction
|
||||
|
||||
function! s:AckFromSearch(cmd, args)
|
||||
let search = getreg('/')
|
||||
" translate vim regular expression to perl regular expression.
|
||||
let search = substitute(search,'\(\\<\|\\>\)','\\b','g')
|
||||
call s:Ack(a:cmd, '"' . search .'" '. a:args)
|
||||
endfunction
|
||||
|
||||
command! -bang -nargs=* -complete=file Ack call s:Ack('grep<bang>',<q-args>)
|
||||
command! -bang -nargs=* -complete=file AckAdd call s:Ack('grepadd<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file AckFromSearch call s:AckFromSearch('grep<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file LAck call s:Ack('lgrep<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file LAckAdd call s:Ack('lgrepadd<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file AckFile call s:Ack('grep<bang> -g', <q-args>)
|
||||
@@ -0,0 +1,8 @@
|
||||
*.sw?
|
||||
*.un?
|
||||
*.vba
|
||||
*.zip
|
||||
*.gz
|
||||
vimball.txt
|
||||
*.orig
|
||||
tags
|
||||
@@ -0,0 +1,62 @@
|
||||
PLUGIN=$(shell basename "$$PWD")
|
||||
SCRIPT=$(wildcard plugin/*.vim)
|
||||
#AUTOL=$(wildcard autoload/*.vim)
|
||||
AUTOL=autoload/$(PLUGIN).vim
|
||||
DOC=$(wildcard doc/*.txt)
|
||||
TESTS=$(wildcard autoload/*Tests.vim)
|
||||
VERSION=$(shell perl -ne 'if (/\*\sCurrent\srelease:/) {s/^\s+(\d+\.\S+)\s.*$$/\1/;print}' $(DOC))
|
||||
VIMFOLDER=~/.vim/
|
||||
VIM=/usr/bin/vim
|
||||
|
||||
.PHONY: $(PLUGIN).vba README
|
||||
|
||||
all: vimball README zip gzip
|
||||
|
||||
vimball: $(PLUGIN).vba
|
||||
|
||||
clean:
|
||||
@echo clean
|
||||
rm -f *.vba */*.orig *.~* .VimballRecord *.zip *.gz
|
||||
|
||||
dist-clean: clean
|
||||
|
||||
undo:
|
||||
for i in */*.orig; do mv -f "$$i" "$${i%.*}"; done
|
||||
|
||||
README:
|
||||
@echo README
|
||||
cp -f $(DOC) README
|
||||
|
||||
$(PLUGIN).vba:
|
||||
@echo $(PLUGIN).vba
|
||||
rm -f $(PLUGIN)-$(VERSION).vba
|
||||
$(VIM) -N -c 'ru! vimballPlugin.vim' -c ':call append("0", [ "$(SCRIPT)", "$(AUTOL)", "$(DOC)"])' -c '$$d' -c ":%MkVimball $(PLUGIN)-$(VERSION) ." -c':q!'
|
||||
ln -f $(PLUGIN)-$(VERSION).vba $(PLUGIN).vba
|
||||
|
||||
zip:
|
||||
@echo zip
|
||||
rm -f *.zip
|
||||
zip -r $(PLUGIN).zip doc plugin autoload
|
||||
zip $(PLUGIN).zip -d \*.sw\? || echo 1
|
||||
zip $(PLUGIN).zip -d \*.un\? || echo 1
|
||||
zip $(PLUGIN).zip -d \*.orig || echo 1
|
||||
zip $(PLUGIN).zip -d \*tags || echo 1
|
||||
zip $(PLUGIN).zip -d $(TESTS)
|
||||
ln -f $(PLUGIN).zip $(PLUGIN)-$(VERSION).zip
|
||||
|
||||
gzip: vimball
|
||||
@echo vimball
|
||||
gzip -f $(PLUGIN).vba
|
||||
|
||||
release: version all
|
||||
|
||||
version:
|
||||
@echo version: $(VERSION)
|
||||
perl -i.orig -pne 'if (/^"\sVersion:/) {s/(\d+\.\S+)/$(VERSION)/}' $(SCRIPT) $(AUTOL)
|
||||
perl -i.orig -pne 'if (/let\sdelimitMate_version/) {s/"(\d+\.\S+)"/"$(VERSION)"/}' $(SCRIPT)
|
||||
perl -i.orig -pne 'if (/beasts/) {s/(v\d+\.\S+)/v$(VERSION)/}' $(DOC)
|
||||
perl -i.orig -MPOSIX -pne 'if (/^"\sModified:/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/e}' $(SCRIPT) $(AUTOL)
|
||||
perl -i.orig -MPOSIX -pne 'if (/^\s+$(VERSION)\s+\d+-\d+-\d+\s+\*/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/}' $(DOC)
|
||||
@echo Version: $(VERSION)
|
||||
|
||||
echo:
|
||||
@@ -0,0 +1,761 @@
|
||||
*delimitMate.txt* Trying to keep those beasts at bay! v2.5.1 *delimitMate*
|
||||
|
||||
|
||||
|
||||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
||||
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMMMM MMMMMMMMMMMMMMMMMMMMM ~
|
||||
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMM MMMMMMMMMMMMMMMMMMMMM
|
||||
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMM MMM M M MMMMMMMMMM MMMMMMMMM ~
|
||||
MMMM MMM MMM MM MM M M MMM MM MM MM MM MMM MMM MMM MM
|
||||
MM MM M MM MMMMMM MMMMMMM MMM MMMMM MM M MMM MMM M M ~
|
||||
M M MM MM MM MM M M MM MMM MMM MMMMM MMMMM MMM MMM M
|
||||
M M MM MMMMM MM MM M M MM MMM MMM MMMMM MMM MMM MMM MMMM ~
|
||||
M M MM M MM MM MM M M MM MMM MMM MMMMM MM M MMM MMM M M
|
||||
MM MMM MMM MM MM M M MM MMM MM MMMMM MMM MMM MMM MM ~
|
||||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
||||
|
||||
|
||||
|
||||
==============================================================================
|
||||
0.- CONTENTS *delimitMate-contents*
|
||||
|
||||
1. Introduction____________________________|delimitMateIntro|
|
||||
2. Customization___________________________|delimitMateOptions|
|
||||
2.1 Options summary____________________|delimitMateOptionSummary|
|
||||
2.2 Options details____________________|delimitMateOptionDetails|
|
||||
3. Functionality___________________________|delimitMateFunctionality|
|
||||
3.1 Automatic closing & exiting________|delimitMateAutoClose|
|
||||
3.2 Expansion of space and CR__________|delimitMateExpansion|
|
||||
3.3 Backspace__________________________|delimitMateBackspace|
|
||||
3.4 Smart Quotes_______________________|delimitMateSmartQuotes|
|
||||
3.5 Balancing matching pairs___________|delimitMateBalance|
|
||||
3.6 FileType based configuration_______|delimitMateFileType|
|
||||
3.7 Syntax awareness___________________|delimitMateSyntax|
|
||||
4. Commands________________________________|delimitMateCommands|
|
||||
5. Mappings________________________________|delimitMateMappings|
|
||||
6. Functions_______________________________|delimitMateFunctions|
|
||||
7. TODO list_______________________________|delimitMateTodo|
|
||||
8. Maintainer______________________________|delimitMateMaintainer|
|
||||
9. Credits_________________________________|delimitMateCredits|
|
||||
10. History_________________________________|delimitMateHistory|
|
||||
|
||||
==============================================================================
|
||||
1.- INTRODUCTION *delimitMateIntro*
|
||||
|
||||
This plug-in provides automatic closing of quotes, parenthesis, brackets,
|
||||
etc.; besides some other related features that should make your time in insert
|
||||
mode a little bit easier.
|
||||
|
||||
Most of the features can be modified or disabled permanently, using global
|
||||
variables, or on a FileType basis, using autocommands. With a couple of
|
||||
exceptions and limitations, this features don't brake undo, redo or history.
|
||||
|
||||
NOTE 1: If you have any trouble with this plugin, please run |:DelimitMateTest|
|
||||
in a new buffer to see what is not working.
|
||||
|
||||
NOTE 2: |'timeout'| needs to be set when working in the terminal, otherwise you
|
||||
might find weird behaviour with mappings including <Esc> or arrow keys.
|
||||
|
||||
NOTE 3: Abbreiations set with |:iabbrev| will not be expanded by delimiters
|
||||
used on delimitMate, you should use <C-]> (read |i_CTRL-]|) to expand them on
|
||||
the go.
|
||||
|
||||
==============================================================================
|
||||
2. CUSTOMIZATION *delimitMateOptions*
|
||||
|
||||
You can create your own mappings for some features using the global functions.
|
||||
Read |DelimitMateFunctions| for more info.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.1 OPTIONS SUMMARY *delimitMateOptionSummary*
|
||||
|
||||
The behaviour of this script can be customized setting the following options
|
||||
in your vimrc file. You can use local options to set the configuration for
|
||||
specific file types, see |delimitMateOptionDetails| for examples.
|
||||
|
||||
|'loaded_delimitMate'| Turns off the script.
|
||||
|
||||
|'delimitMate_autoclose'| Tells delimitMate whether to automagically
|
||||
insert the closing delimiter.
|
||||
|
||||
|'delimitMate_matchpairs'| Tells delimitMate which characters are
|
||||
matching pairs.
|
||||
|
||||
|'delimitMate_quotes'| Tells delimitMate which quotes should be
|
||||
used.
|
||||
|
||||
|'delimitMate_nesting_quotes'| Tells delimitMate which quotes should be
|
||||
allowed to be nested.
|
||||
|
||||
|'delimitMate_expand_cr'| Turns on/off the expansion of <CR>.
|
||||
|
||||
|'delimitMate_expand_space'| Turns on/off the expansion of <Space>.
|
||||
|
||||
|'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature.
|
||||
|
||||
|'delimitMate_balance_matchpairs'|Turns on/off the "balance matching pairs"
|
||||
feature.
|
||||
|
||||
|'delimitMate_excluded_regions'| Turns off the script for the given regions or
|
||||
syntax group names.
|
||||
|
||||
|'delimitMate_excluded_ft'| Turns off the script for the given file types.
|
||||
|
||||
|'delimitMate_apostrophes'| Tells delimitMate how it should "fix"
|
||||
balancing of single quotes when used as
|
||||
apostrophes. NOTE: Not needed any more, kept
|
||||
for compatibility with older versions.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2 OPTIONS DETAILS *delimitMateOptionDetails*
|
||||
|
||||
Add the shown lines to your vimrc file in order to set the below options.
|
||||
Buffer variables take precedence over global ones and can be used along with
|
||||
autocmd to modify delimitMate's behavior for specific file types, read more in
|
||||
|delimitMateFileType|.
|
||||
|
||||
Note: Use buffer variables only to set options for specific file types using
|
||||
:autocmd, use global variables to set options for every buffer. Read more in
|
||||
|g:var| and |b:var|.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'loaded_delimitMate'*
|
||||
*'b:loaded_delimitMate'*
|
||||
This option prevents delimitMate from loading.
|
||||
e.g.: >
|
||||
let loaded_delimitMate = 1
|
||||
au FileType mail let b:loaded_delimitMate = 1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_autoclose'*
|
||||
*'b:delimitMate_autoclose'*
|
||||
Values: 0 or 1. ~
|
||||
Default: 1 ~
|
||||
|
||||
If this option is set to 0, delimitMate will not add a closing delimiter
|
||||
automagically. See |delimitMateAutoClose| for details.
|
||||
e.g.: >
|
||||
let delimitMate_autoclose = 0
|
||||
au FileType mail let b:delimitMate_autoclose = 0
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_matchpairs'*
|
||||
*'b:delimitMate_matchpairs'*
|
||||
Values: A string with |'matchpairs'| syntax, plus support for multi-byte~
|
||||
characters.~
|
||||
Default: &matchpairs ~
|
||||
|
||||
Use this option to tell delimitMate which characters should be considered
|
||||
matching pairs. Read |delimitMateAutoClose| for details.
|
||||
e.g: >
|
||||
let delimitMate_matchpairs = "(:),[:],{:},<:>"
|
||||
au FileType vim,html let b:delimitMate_matchpairs = "(:),[:],{:},<:>"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_quotes'*
|
||||
*'b:delimitMate_quotes'*
|
||||
Values: A string of characters separated by spaces. ~
|
||||
Default: "\" ' `" ~
|
||||
|
||||
Use this option to tell delimitMate which characters should be considered as
|
||||
quotes. Read |delimitMateAutoClose| for details.
|
||||
e.g.: >
|
||||
let delimitMate_quotes = "\" ' ` *"
|
||||
au FileType html let b:delimitMate_quotes = "\" '"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_nesting_quotes'*
|
||||
*'b:delimitMate_nesting_quotes'*
|
||||
Values: A list of quotes. ~
|
||||
Default: [] ~
|
||||
|
||||
Quotes listed here will not be able to jump out of the empty pair, thus
|
||||
allowing the autoclosed quotes to be nested.
|
||||
e.g.: >
|
||||
let delimitMate_nesting_quotes = ['"','`']
|
||||
au FileType python let b:delimitMate_nesting_quotes = ['"']
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_expand_cr'*
|
||||
*'b:delimitMate_expand_cr'*
|
||||
Values: 1 or 0 ~
|
||||
Default: 0 ~
|
||||
|
||||
This option turns on/off the expansion of <CR>. Read |delimitMateExpansion|
|
||||
for details.
|
||||
e.g.: >
|
||||
let delimitMate_expand_cr = 1
|
||||
au FileType mail let b:delimitMate_expand_cr = 1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_expand_space'*
|
||||
*'b:delimitMate_expand_space'*
|
||||
Values: 1 or 0 ~
|
||||
Default: 0 ~
|
||||
|
||||
This option turns on/off the expansion of <Space>. Read |delimitMateExpansion|
|
||||
for details.
|
||||
e.g.: >
|
||||
let delimitMate_expand_space = 1
|
||||
au FileType tcl let b:delimitMate_expand_space = 1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_smart_quotes'*
|
||||
*'b:delimitMate_smart_quotes'*
|
||||
Values: 1 or 0 ~
|
||||
Default: 1 ~
|
||||
|
||||
This option turns on/off the smart quotes feature. Read
|
||||
|delimitMateSmartQuotes| for details.
|
||||
e.g.: >
|
||||
let delimitMate_smart_quotes = 0
|
||||
au FileType tcl let b:delimitMate_smart_quotes = 0
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_balance_matchpairs'*
|
||||
*'b:delimitMate_balance_matchpairs'*
|
||||
Values: 1 or 0 ~
|
||||
Default: 0 ~
|
||||
|
||||
This option turns on/off the balancing of matching pairs. Read
|
||||
|delimitMateBalance| for details.
|
||||
e.g.: >
|
||||
let delimitMate_balance_matchpairs = 1
|
||||
au FileType tcl let b:delimitMate_balance_matchpairs = 1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_excluded_regions'*
|
||||
Values: A string of syntax group names names separated by single commas. ~
|
||||
Default: Comment ~
|
||||
|
||||
This options turns delimitMate off for the listed regions, read |group-name|
|
||||
for more info about what is a region.
|
||||
e.g.: >
|
||||
let delimitMate_excluded_regions = "Comments,String"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_excluded_ft'*
|
||||
Values: A string of file type names separated by single commas. ~
|
||||
Default: Empty. ~
|
||||
|
||||
This options turns delimitMate off for the listed file types, use this option
|
||||
only if you don't want any of the features it provides on those file types.
|
||||
e.g.: >
|
||||
let delimitMate_excluded_ft = "mail,txt"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_apostrophes'*
|
||||
Values: Strings separated by ":". ~
|
||||
Default: No longer used. ~
|
||||
|
||||
NOTE: This feature is turned off by default, it's been kept for compatibility
|
||||
with older version, read |delimitMateSmartQuotes| for details.
|
||||
If auto-close is enabled, this option tells delimitMate how to try to fix the
|
||||
balancing of single quotes when used as apostrophes. The values of this option
|
||||
are strings of text where a single quote would be used as an apostrophe (e.g.:
|
||||
the "n't" of wouldn't or can't) separated by ":". Set it to an empty string to
|
||||
disable this feature.
|
||||
e.g.: >
|
||||
let delimitMate_apostrophes = ""
|
||||
au FileType tcl let delimitMate_apostrophes = ""
|
||||
<
|
||||
==============================================================================
|
||||
3. FUNCTIONALITY *delimitMateFunctionality*
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.1 AUTOMATIC CLOSING AND EXITING *delimitMateAutoClose*
|
||||
|
||||
With automatic closing enabled, if an opening delimiter is inserted the plugin
|
||||
inserts the closing delimiter and places the cursor between the pair. With
|
||||
automatic closing disabled, no closing delimiters is inserted by delimitMate,
|
||||
but when a pair of delimiters is typed, the cursor is placed in the middle.
|
||||
|
||||
When the cursor is inside an empty pair or located next to the left of a
|
||||
closing delimiter, the cursor is placed outside the pair to the right of the
|
||||
closing delimiter.
|
||||
|
||||
Unless |'delimitMate_matchpairs'| or |'delimitMate_quotes'|are set, this
|
||||
script uses the values in '&matchpairs' to identify the pairs, and ", ' and `
|
||||
for quotes respectively.
|
||||
|
||||
The following table shows the behaviour, this applies to quotes too (the final
|
||||
position of the cursor is represented by a "|"):
|
||||
|
||||
With auto-close: >
|
||||
Type | You get
|
||||
====================
|
||||
( | (|)
|
||||
–––––––––|––––––––––
|
||||
() | ()|
|
||||
–––––––––|––––––––––
|
||||
(<S-Tab> | ()|
|
||||
<
|
||||
Without auto-close: >
|
||||
|
||||
Type | You get
|
||||
=====================
|
||||
() | (|)
|
||||
–––––––––-|––––––––––
|
||||
()) | ()|
|
||||
–––––––––-|––––––––––
|
||||
()<S-Tab> | ()|
|
||||
<
|
||||
NOTE: Abbreviations will not be expanded by delimiters used on delimitMate,
|
||||
you should use <C-]> (read |i_CTRL-]|) to expand them on the go.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
|
||||
|
||||
When the cursor is inside an empty pair of delimiters, <Space> and <CR> can be
|
||||
expanded, see |'delimitMate_expand_space'| and
|
||||
|'delimitMate_expand_cr'|:
|
||||
|
||||
Expand <Space> to: >
|
||||
|
||||
<Space><Space><Left> | You get
|
||||
====================================
|
||||
(|) | ( | )
|
||||
<
|
||||
Expand <CR> to: >
|
||||
|
||||
<CR><CR><Up> | You get
|
||||
============================
|
||||
(|) | (
|
||||
| |
|
||||
| )
|
||||
<
|
||||
|
||||
NOTE that the expansion of <CR> will brake the redo command.
|
||||
|
||||
Since <Space> and <CR> are used everywhere, I have made the functions involved
|
||||
in expansions global, so they can be used to make custom mappings. Read
|
||||
|delimitMateFunctions| for more details.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.3 BACKSPACE *delimitMateBackspace*
|
||||
|
||||
If you press backspace inside an empty pair, both delimiters are deleted. When
|
||||
expansions are enabled, <BS> will also delete the expansions. NOTE that
|
||||
deleting <CR> expansions will brake the redo command.
|
||||
|
||||
If you type <S-BS> (shift + backspace) instead, only the closing delimiter
|
||||
will be deleted. NOTE that this will not usually work when using Vim from the
|
||||
terminal, see 'delimitMate#JumpAny()' below to see how to fix it.
|
||||
|
||||
e.g. typing at the "|": >
|
||||
|
||||
What | Before | After
|
||||
==============================================
|
||||
<BS> | call expand(|) | call expand|
|
||||
---------|-------------------|-----------------
|
||||
<BS> | call expand( | ) | call expand(|)
|
||||
---------|-------------------|-----------------
|
||||
<BS> | call expand( | call expand(|)
|
||||
| | |
|
||||
| ) |
|
||||
---------|-------------------|-----------------
|
||||
<S-BS> | call expand(|) | call expand(|
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.4 SMART QUOTES *delimitMateSmartQuotes*
|
||||
|
||||
Only one quote will be inserted following a quote, a "\" or, following or
|
||||
preceding an alphanumeric character. This should cover closing quotes after a
|
||||
string, opening quotes before a string, escaped quotes and apostrophes. Except
|
||||
for apostrophes, this feature can be disabled setting the option
|
||||
|'delimitMate_smart_quotes'| to 0.
|
||||
|
||||
e.g. typing at the "|": >
|
||||
|
||||
What | Before | After
|
||||
=======================================
|
||||
" | Text | | Text "|"
|
||||
" | "String| | "String"|
|
||||
" | let i = "| | let i = "|"
|
||||
'm | I| | I'm|
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
3.5 BALANCING MATCHING PAIRS *delimitMateBalance*
|
||||
|
||||
When inserting an opening paren and |'delimitMate_balance_matchpairs'| is
|
||||
enabled, delimitMate will try to balance the closing pairs in the current
|
||||
line.
|
||||
|
||||
e.g. typing at the "|": >
|
||||
|
||||
What | Before | After
|
||||
=======================================
|
||||
( | |) | (|)
|
||||
( | | | (|)
|
||||
( | (|) | ((|))
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
3.6 FILE TYPE BASED CONFIGURATION *delimitMateFileType*
|
||||
|
||||
delimitMate options can be set globally for all buffers using global
|
||||
("regular") variables in your |vimrc| file. But |:autocmd| can be used to set
|
||||
options for specific file types (see |'filetype'|) using buffer variables in
|
||||
the following way: >
|
||||
|
||||
au FileType mail,text let b:delimitMate_autoclose = 0
|
||||
^ ^ ^ ^ ^
|
||||
| | | | |
|
||||
| | | | - Option value.
|
||||
| | | - Option name.
|
||||
| | - Buffer variable.
|
||||
| - File types for which the option will be set.
|
||||
- Don't forget to put this event.
|
||||
<
|
||||
NOTE that you should use buffer variables (|b:var|) only to set options with
|
||||
|:autocmd|, for global options use regular variables (|g:var|) in your vimrc.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.7 SYNTAX AWARENESS *delimitMateSyntax*
|
||||
|
||||
The features of this plug-in might not be always helpful, comments and strings
|
||||
usualy don't need auto-completion. delimitMate monitors which region is being
|
||||
edited and if it detects that the cursor is in a comment it'll turn itself off
|
||||
until the cursor leaves the comment. The excluded regions can be set using the
|
||||
option |'delimitMate_excluded_regions'|. Read |group-name| for a list of
|
||||
regions or syntax group names.
|
||||
|
||||
NOTE that this feature relies on a proper syntax file for the current file
|
||||
type, if the appropiate syntax file doesn't define a region, delimitMate won't
|
||||
know about it.
|
||||
|
||||
==============================================================================
|
||||
4. COMMANDS *delimitMateCommands*
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
:DelimitMateReload *:DelimitMateReload*
|
||||
|
||||
Re-sets all the mappings used for this script, use it if any option has been
|
||||
changed or if the filetype option hasn't been set yet.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
:DelimitMateSwitch *:DelimitMateSwitch*
|
||||
|
||||
Switches the plug-in on and off.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
:DelimitMateTest *:DelimitMateTest*
|
||||
|
||||
This command tests every mapping set-up for this script, useful for testing
|
||||
custom configurations.
|
||||
|
||||
The following output corresponds to the default values, it will be different
|
||||
depending on your configuration. "Open & close:" represents the final result
|
||||
when the closing delimiter has been inserted, either manually or
|
||||
automatically, see |delimitMateExpansion|. "Delete:" typing backspace in an
|
||||
empty pair, see |delimitMateBackspace|. "Exit:" typing a closing delimiter
|
||||
inside a pair of delimiters, see |delimitMateAutoclose|. "Space:" the
|
||||
expansion, if any, of space, see |delimitMateExpansion|. "Visual-L",
|
||||
"Visual-R" and "Visual" shows visual wrapping, see
|
||||
|delimitMateVisualWrapping|. "Car return:" the expansion of car return, see
|
||||
|delimitMateExpansion|. The cursor's position at the end of every test is
|
||||
represented by an "|": >
|
||||
|
||||
* AUTOCLOSE:
|
||||
Open & close: (|)
|
||||
Delete: |
|
||||
Exit: ()|
|
||||
Space: ( |)
|
||||
Visual-L: (v)
|
||||
Visual-R: (v)
|
||||
Car return: (
|
||||
|)
|
||||
|
||||
Open & close: {|}
|
||||
Delete: |
|
||||
Exit: {}|
|
||||
Space: { |}
|
||||
Visual-L: {v}
|
||||
Visual-R: {v}
|
||||
Car return: {
|
||||
|}
|
||||
|
||||
Open & close: [|]
|
||||
Delete: |
|
||||
Exit: []|
|
||||
Space: [ |]
|
||||
Visual-L: [v]
|
||||
Visual-R: [v]
|
||||
Car return: [
|
||||
|]
|
||||
|
||||
Open & close: "|"
|
||||
Delete: |
|
||||
Exit: ""|
|
||||
Space: " |"
|
||||
Visual: "v"
|
||||
Car return: "
|
||||
|"
|
||||
|
||||
Open & close: '|'
|
||||
Delete: |
|
||||
Exit: ''|
|
||||
Space: ' |'
|
||||
Visual: 'v'
|
||||
Car return: '
|
||||
|'
|
||||
|
||||
Open & close: `|`
|
||||
Delete: |
|
||||
Exit: ``|
|
||||
Space: ` |`
|
||||
Visual: `v`
|
||||
Car return: `
|
||||
|`
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
5. MAPPINGS *delimitMateMappings*
|
||||
|
||||
delimitMate doesn't override any existing map, so you may encounter that it
|
||||
doesn't work as expected because a mapping is missing. In that case, the
|
||||
conflicting mappings should be resolved by either disabling the conflicting
|
||||
mapping or creating a custom mappings.
|
||||
|
||||
In order to make custom mappings easier and prevent overwritting existing
|
||||
ones, delimitMate uses the |<Plug>| + |hasmapto()| (|usr_41.txt|) construct
|
||||
for its mappings.
|
||||
|
||||
The following are the mappings alway set by delimitMate:
|
||||
|
||||
<BS> is mapped to <Plug>delimitMateBS
|
||||
<S-BS> is mapped to <Plug>delimitMateS-BS
|
||||
<S-Tab> is mapped to <Plug>delimitMateS-Tab
|
||||
<Del> is mapped to <Plug>delimitMateDel
|
||||
<Esc> is mapped to <Plug>delimitMateEsc
|
||||
<Left> is mapped to <Plug>delimitMateLeft
|
||||
<Right> is mapped to <Plug>delimitMateRight
|
||||
<Home> is mapped to <Plug>delimitMateHome
|
||||
<End> is mapped to <Plug>delimitMateEnd
|
||||
<Up> is mapped to <Plug>delimitMateUp
|
||||
<Down> is mapped to <Plug>delimitMateDown
|
||||
<PageUp> is mapped to <Plug>delimitMatePageUp
|
||||
<PageDown> is mapped to <Plug>delimitMatePageDown
|
||||
<S-Down> is mapped to <Plug>delimitMateS-Down
|
||||
<S-Up> is mapped to <Plug>delimitMateS-Up
|
||||
<LeftMouse> is mapped to <Plug>delimitMateMLeftMouse
|
||||
<RightMouse> is mapped to <Plug>delimitMateMRightMouse
|
||||
|
||||
The rest of the mappings correspond to parens, quotes, CR, Space, etc. and they
|
||||
depend on the values of the delimitMate options, they have the following form:
|
||||
|
||||
<Plug>delimitMate + char
|
||||
|
||||
e.g.: for "(":
|
||||
|
||||
( is mapped to <Plug>delimitMate(
|
||||
|
||||
e.g.: If you have <CR> expansion enabled, you might want to skip it on pop-up
|
||||
menus:
|
||||
|
||||
imap <expr> <CR> pumvisible() ?
|
||||
\"\<c-y>" :
|
||||
\ "<Plug>delimitMateCR"
|
||||
|
||||
|
||||
==============================================================================
|
||||
6. FUNCTIONS *delimitMateFunctions*
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair()*
|
||||
|
||||
Returns 1 if the cursor is inside an empty pair, 0 otherwise.
|
||||
e.g.: >
|
||||
|
||||
inoremap <expr> <CR> delimitMate#WithinEmptyPair() ?
|
||||
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>" :
|
||||
\ "external_mapping"
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
delimitMate#ShouldJump() *delimitMate#ShouldJump()*
|
||||
|
||||
Returns 1 if there is a closing delimiter or a quote to the right of the
|
||||
cursor, 0 otherwise.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
delimitMate#JumpAny(key) *delimitMate#JumpAny()*
|
||||
|
||||
This function returns a mapping that will make the cursor jump to the right
|
||||
when delimitMate#ShouldJump() returns 1, returns the argument "key" otherwise.
|
||||
e.g.: You can use this to create your own mapping to jump over any delimiter.
|
||||
>
|
||||
inoremap <C-Tab> <C-R>=delimitMate#JumpAny("\<C-Tab>")<CR>
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
7. TODO LIST *delimitMateTodo*
|
||||
|
||||
- Automatic set-up by file type.
|
||||
- Make block-wise visual wrapping work on un-even regions.
|
||||
|
||||
==============================================================================
|
||||
8. MAINTAINER *delimitMateMaintainer*
|
||||
|
||||
Hi there! My name is Israel Chauca F. and I can be reached at:
|
||||
mailto:israelchauca@gmail.com
|
||||
|
||||
Feel free to send me any suggestions and/or comments about this plugin, I'll
|
||||
be very pleased to read them.
|
||||
|
||||
==============================================================================
|
||||
9. CREDITS *delimitMateCredits*
|
||||
|
||||
Some of the code that make this script is modified or just shamelessly copied
|
||||
from the following sources:
|
||||
|
||||
- Ian McCracken
|
||||
Post titled: Vim, Part II: Matching Pairs:
|
||||
http://concisionandconcinnity.blogspot.com/
|
||||
|
||||
- Aristotle Pagaltzis
|
||||
From the comments on the previous blog post and from:
|
||||
http://gist.github.com/144619
|
||||
|
||||
- Karl Guertin
|
||||
AutoClose:
|
||||
http://www.vim.org/scripts/script.php?script_id=1849
|
||||
|
||||
- Thiago Alves
|
||||
AutoClose:
|
||||
http://www.vim.org/scripts/script.php?script_id=2009
|
||||
|
||||
- Edoardo Vacchi
|
||||
ClosePairs:
|
||||
http://www.vim.org/scripts/script.php?script_id=2373
|
||||
|
||||
This script was inspired by the auto-completion of delimiters on TextMate.
|
||||
|
||||
==============================================================================
|
||||
10. HISTORY *delimitMateHistory*
|
||||
|
||||
Version Date Release notes ~
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.5.1 2010-09-30 * Current release:
|
||||
- Remove visual wrapping. Surround.vim offers a much
|
||||
better implementation.
|
||||
- Minor mods to DelimitMateTest.
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.5 2010-09-22 * - Better handling of mappings.
|
||||
- Add report for mappings in |:DelimitMateTest|.
|
||||
- Allow the use of "|" and multi-byte characters in
|
||||
|'delimitMate_quotes'| and |'delimitMate_matchpairs'|.
|
||||
- Allow commands to be concatenated using |.
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.4.1 2010-07-31 * - Fix problem with <Home> and <End>.
|
||||
- Add missing doc on |'delimitMate_smart_quotes'|,
|
||||
|delimitMateBalance| and
|
||||
|'delimitMate_balance_matchpairs'|.
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.4 2010-07-29 * - Unbalanced parens: see :help delimitMateBalance.
|
||||
- Visual wrapping now works on block-wise visual
|
||||
with some limitations.
|
||||
- Arrow keys didn't work on terminal.
|
||||
- Added option to allow nested quotes.
|
||||
- Expand Smart Quotes to look for a string on the
|
||||
right of the cursor.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.3.1 2010-06-06 * - Fix: an extra <Space> is inserted after <Space>
|
||||
expansion.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.3 2010-06-06 * - Syntax aware: Will turn off when editing comments
|
||||
or other regions, customizable.
|
||||
- Changed format of most mappings.
|
||||
- Fix: <CR> expansion doesn't brake automatic
|
||||
indentation adjustments anymore.
|
||||
- Fix: Arrow keys would insert A, B, C or D instead
|
||||
of moving the cursor when using Vim on a terminal.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.2 2010-05-16 * - Added command to switch the plug-in on and off.
|
||||
- Fix: some problems with <Left>, <Right> and <CR>.
|
||||
- Fix: A small problem when inserting a delimiter at
|
||||
the beginning of the line.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.1 2010-05-10 * - Most of the functions have been moved to an
|
||||
autoload script to avoid loading unnecessary ones.
|
||||
- Fixed a problem with the redo command.
|
||||
- Many small fixes.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.0 2010-04-01 * New features:
|
||||
- All features are redo/undo-wise safe.
|
||||
- A single quote typed after an alphanumeric
|
||||
character is considered an apostrophe and one
|
||||
single quote is inserted.
|
||||
- A quote typed after another quote inserts a single
|
||||
quote and the cursor jumps to the middle.
|
||||
- <S-Tab> jumps out of any empty pair.
|
||||
- <CR> and <Space> expansions are fixed, but the
|
||||
functions used for it are global and can be used in
|
||||
custom mappings. The previous system is still
|
||||
active if you have any of the expansion options
|
||||
set.
|
||||
- <S-Backspace> deletes the closing delimiter.
|
||||
* Fixed bug:
|
||||
- s:vars were being used to store buffer options.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
1.6 2009-10-10 * Now delimitMate tries to fix the balancing of single
|
||||
quotes when used as apostrophes. You can read
|
||||
|delimitMate_apostrophes| for details.
|
||||
Fixed an error when |b:delimitMate_expand_space|
|
||||
wasn't set but |delimitMate_expand_space| wasn't.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
1.5 2009-10-05 * Fix: delimitMate should work correctly for files
|
||||
passed as arguments to Vim. Thanks to Ben Beuchler
|
||||
for helping to nail this bug.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
1.4 2009-09-27 * Fix: delimitMate is now enabled on new buffers even
|
||||
if they don't have set the file type option or were
|
||||
opened directly from the terminal.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
1.3 2009-09-24 * Now local options can be used along with autocmd
|
||||
for specific file type configurations.
|
||||
Fixes:
|
||||
- Unnamed register content is not lost on visual
|
||||
mode.
|
||||
- Use noremap where appropiate.
|
||||
- Wrapping a single empty line works as expected.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
1.2 2009-09-07 * Fixes:
|
||||
- When inside nested empty pairs, deleting the
|
||||
innermost left delimiter would delete all right
|
||||
contiguous delimiters.
|
||||
- When inside an empty pair, inserting a left
|
||||
delimiter wouldn't insert the right one, instead
|
||||
the cursor would jump to the right.
|
||||
- New buffer inside the current window wouldn't
|
||||
have the mappings set.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
1.1 2009-08-25 * Fixed an error that ocurred when mapleader wasn't
|
||||
set and added support for GetLatestScripts
|
||||
auto-detection.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
1.0 2009-08-23 * Initial upload.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
|
||||
|
||||
`\|||/´ MMM \|/ www __^__ ~
|
||||
(o o) (o o) @ @ (O-O) /(o o)\\ ~
|
||||
ooO_(_)_Ooo__ ooO_(_)_Ooo___oOO_(_)_OOo___oOO__(_)__OOo___oOO__(_)__OOo_____ ~
|
||||
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
||||
__|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_ ~
|
||||
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
||||
|
||||
vim:tw=78:et:ts=2:sw=2:ft=help:norl:formatoptions+=tcroqn:autoindent:
|
||||
@@ -0,0 +1,538 @@
|
||||
" ============================================================================
|
||||
" File: autoload/delimitMate.vim
|
||||
" Version: 2.5.1
|
||||
" Modified: 2010-09-30
|
||||
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
||||
" Manual: Read ":help delimitMate".
|
||||
|
||||
" Utilities {{{
|
||||
|
||||
let delimitMate_loaded = 1
|
||||
|
||||
function! delimitMate#ShouldJump() "{{{
|
||||
" Returns 1 if the next character is a closing delimiter.
|
||||
let col = col('.')
|
||||
let lcol = col('$')
|
||||
let char = getline('.')[col - 1]
|
||||
|
||||
" Closing delimiter on the right.
|
||||
for cdel in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
|
||||
if char == cdel
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
" Closing delimiter with space expansion.
|
||||
let nchar = getline('.')[col]
|
||||
if b:_l_delimitMate_expand_space && char == " "
|
||||
for cdel in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
|
||||
if nchar == cdel
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
" Closing delimiter with CR expansion.
|
||||
let uchar = getline(line('.') + 1)[0]
|
||||
if b:_l_delimitMate_expand_cr && char == ""
|
||||
for cdel in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
|
||||
if uchar == cdel
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#IsEmptyPair(str) "{{{
|
||||
for pair in b:_l_delimitMate_matchpairs_list
|
||||
if a:str == join( split( pair, ':' ),'' )
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
for quote in b:_l_delimitMate_quotes_list
|
||||
if a:str == quote . quote
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#IsCRExpansion() " {{{
|
||||
let nchar = getline(line('.')-1)[-1:]
|
||||
let schar = getline(line('.')+1)[:0]
|
||||
let isEmpty = getline('.') == ""
|
||||
if index(b:_l_delimitMate_left_delims, nchar) > -1 &&
|
||||
\ index(b:_l_delimitMate_left_delims, nchar) == index(b:_l_delimitMate_right_delims, schar) &&
|
||||
\ isEmpty
|
||||
return 1
|
||||
elseif index(b:_l_delimitMate_quotes_list, nchar) > -1 &&
|
||||
\ index(b:_l_delimitMate_quotes_list, nchar) == index(b:_l_delimitMate_quotes_list, schar) &&
|
||||
\ isEmpty
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
endfunction " }}} delimitMate#IsCRExpansion()
|
||||
|
||||
function! delimitMate#IsSpaceExpansion() " {{{
|
||||
let line = getline('.')
|
||||
let col = col('.')-2
|
||||
if col > 0
|
||||
let pchar = line[col - 1]
|
||||
let nchar = line[col + 2]
|
||||
let isSpaces = (line[col] == line[col+1] && line[col] == " ")
|
||||
|
||||
if index(b:_l_delimitMate_left_delims, pchar) > -1 &&
|
||||
\ index(b:_l_delimitMate_left_delims, pchar) == index(b:_l_delimitMate_right_delims, nchar) &&
|
||||
\ isSpaces
|
||||
return 1
|
||||
elseif index(b:_l_delimitMate_quotes_list, pchar) > -1 &&
|
||||
\ index(b:_l_delimitMate_quotes_list, pchar) == index(b:_l_delimitMate_quotes_list, nchar) &&
|
||||
\ isSpaces
|
||||
return 1
|
||||
endif
|
||||
endif
|
||||
return 0
|
||||
endfunction " }}} IsSpaceExpansion()
|
||||
|
||||
function! delimitMate#WithinEmptyPair() "{{{
|
||||
let cur = strpart( getline('.'), col('.')-2, 2 )
|
||||
return delimitMate#IsEmptyPair( cur )
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#WriteBefore(str) "{{{
|
||||
let len = len(a:str)
|
||||
let line = getline('.')
|
||||
let col = col('.')-2
|
||||
if col < 0
|
||||
call setline('.',line[(col+len+1):])
|
||||
else
|
||||
call setline('.',line[:(col)].line[(col+len+1):])
|
||||
endif
|
||||
return a:str
|
||||
endfunction " }}}
|
||||
|
||||
function! delimitMate#WriteAfter(str) "{{{
|
||||
let len = len(a:str)
|
||||
let line = getline('.')
|
||||
let col = col('.')-2
|
||||
if (col) < 0
|
||||
call setline('.',a:str.line)
|
||||
else
|
||||
call setline('.',line[:(col)].a:str.line[(col+len):])
|
||||
endif
|
||||
return ''
|
||||
endfunction " }}}
|
||||
|
||||
function! delimitMate#GetSyntaxRegion(line, col) "{{{
|
||||
return synIDattr(synIDtrans(synID(a:line, a:col, 1)), 'name')
|
||||
endfunction " }}}
|
||||
|
||||
function! delimitMate#GetCurrentSyntaxRegion() "{{{
|
||||
let col = col('.')
|
||||
if col == col('$')
|
||||
let col = col - 1
|
||||
endif
|
||||
return delimitMate#GetSyntaxRegion(line('.'), col)
|
||||
endfunction " }}}
|
||||
|
||||
function! delimitMate#GetCurrentSyntaxRegionIf(char) "{{{
|
||||
let col = col('.')
|
||||
let origin_line = getline('.')
|
||||
let changed_line = strpart(origin_line, 0, col - 1) . a:char . strpart(origin_line, col - 1)
|
||||
call setline('.', changed_line)
|
||||
let region = delimitMate#GetSyntaxRegion(line('.'), col)
|
||||
call setline('.', origin_line)
|
||||
return region
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#IsForbidden(char) "{{{
|
||||
if b:_l_delimitMate_excluded_regions_enabled == 0
|
||||
return 0
|
||||
endif
|
||||
"let result = index(b:_l_delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
|
||||
if index(b:_l_delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
|
||||
"echom "Forbidden 1!"
|
||||
return 1
|
||||
endif
|
||||
let region = delimitMate#GetCurrentSyntaxRegionIf(a:char)
|
||||
"let result = index(b:_l_delimitMate_excluded_regions_list, region) >= 0
|
||||
"return result || region == 'Comment'
|
||||
"echom "Forbidden 2!"
|
||||
return index(b:_l_delimitMate_excluded_regions_list, region) >= 0
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#FlushBuffer() " {{{
|
||||
let b:_l_delimitMate_buffer = []
|
||||
return ''
|
||||
endfunction " }}}
|
||||
|
||||
function! delimitMate#BalancedParens(char) "{{{
|
||||
" Returns:
|
||||
" = 0 => Parens balanced.
|
||||
" > 0 => More opening parens.
|
||||
" < 0 => More closing parens.
|
||||
|
||||
let line = getline('.')
|
||||
let col = col('.') - 2
|
||||
let col = col >= 0 ? col : 0
|
||||
let list = split(line, '\zs')
|
||||
let left = b:_l_delimitMate_left_delims[index(b:_l_delimitMate_right_delims, a:char)]
|
||||
let right = a:char
|
||||
let opening = 0
|
||||
let closing = 0
|
||||
|
||||
" If the cursor is not at the beginning, count what's behind it.
|
||||
if col > 0
|
||||
" Find the first opening paren:
|
||||
let start = index(list, left)
|
||||
" Must be before cursor:
|
||||
let start = start < col ? start : col - 1
|
||||
" Now count from the first opening until the cursor, this will prevent
|
||||
" extra closing parens from being counted.
|
||||
let opening = count(list[start : col - 1], left)
|
||||
let closing = count(list[start : col - 1], right)
|
||||
" I don't care if there are more closing parens than opening parens.
|
||||
let closing = closing > opening ? opening : closing
|
||||
endif
|
||||
|
||||
" Evaluate parens from the cursor to the end:
|
||||
let opening += count(list[col :], left)
|
||||
let closing += count(list[col :], right)
|
||||
|
||||
"echom "–––––––––"
|
||||
"echom line
|
||||
"echom col
|
||||
""echom left.":".a:char
|
||||
"echom string(list)
|
||||
"echom string(list[start : col - 1]) . " : " . string(list[col :])
|
||||
"echom opening . " - " . closing . " = " . (opening - closing)
|
||||
|
||||
" Return the found balance:
|
||||
return opening - closing
|
||||
endfunction "}}}
|
||||
|
||||
" }}}
|
||||
|
||||
" Doers {{{
|
||||
function! delimitMate#SkipDelim(char) "{{{
|
||||
if delimitMate#IsForbidden(a:char)
|
||||
return a:char
|
||||
endif
|
||||
let col = col('.') - 1
|
||||
let line = getline('.')
|
||||
if col > 0
|
||||
let cur = line[col]
|
||||
let pre = line[col-1]
|
||||
else
|
||||
let cur = line[col]
|
||||
let pre = ""
|
||||
endif
|
||||
if pre == "\\"
|
||||
" Escaped character
|
||||
return a:char
|
||||
elseif cur == a:char
|
||||
" Exit pair
|
||||
"return delimitMate#WriteBefore(a:char)
|
||||
return a:char . delimitMate#Del()
|
||||
elseif delimitMate#IsEmptyPair( pre . a:char )
|
||||
" Add closing delimiter and jump back to the middle.
|
||||
call insert(b:_l_delimitMate_buffer, a:char)
|
||||
return delimitMate#WriteAfter(a:char)
|
||||
else
|
||||
" Nothing special here, return the same character.
|
||||
return a:char
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#ParenDelim(char) " {{{
|
||||
if delimitMate#IsForbidden(a:char)
|
||||
return ''
|
||||
endif
|
||||
" Try to balance matchpairs
|
||||
if b:_l_delimitMate_balance_matchpairs &&
|
||||
\ delimitMate#BalancedParens(a:char) <= 0
|
||||
return ''
|
||||
endif
|
||||
let line = getline('.')
|
||||
let col = col('.')-2
|
||||
if b:_l_delimitMate_smart_matchpairs &&
|
||||
\ line[col+1] =~ '\S'
|
||||
return ''
|
||||
elseif (col) < 0
|
||||
call setline('.',a:char.line)
|
||||
call insert(b:_l_delimitMate_buffer, a:char)
|
||||
else
|
||||
"echom string(col).':'.line[:(col)].'|'.line[(col+1):]
|
||||
call setline('.',line[:(col)].a:char.line[(col+1):])
|
||||
call insert(b:_l_delimitMate_buffer, a:char)
|
||||
endif
|
||||
return ''
|
||||
endfunction " }}}
|
||||
|
||||
function! delimitMate#QuoteDelim(char) "{{{
|
||||
if delimitMate#IsForbidden(a:char)
|
||||
return a:char
|
||||
endif
|
||||
let line = getline('.')
|
||||
let col = col('.') - 2
|
||||
if line[col] == "\\"
|
||||
" Seems like a escaped character, insert one quotation mark.
|
||||
return a:char
|
||||
elseif line[col + 1] == a:char &&
|
||||
\ index(b:_l_delimitMate_nesting_quotes, a:char) < 0
|
||||
" Get out of the string.
|
||||
return a:char . delimitMate#Del()
|
||||
elseif (line[col] =~ '\w' && a:char == "'") ||
|
||||
\ (b:_l_delimitMate_smart_quotes &&
|
||||
\ (line[col] =~ '\w' ||
|
||||
\ line[col + 1] =~ '\w'))
|
||||
" Seems like an apostrophe or a smart quote case, insert a single quote.
|
||||
return a:char
|
||||
elseif (line[col] == a:char && line[col + 1 ] != a:char) && b:_l_delimitMate_smart_quotes
|
||||
" Seems like we have an unbalanced quote, insert one quotation mark and jump to the middle.
|
||||
call insert(b:_l_delimitMate_buffer, a:char)
|
||||
return delimitMate#WriteAfter(a:char)
|
||||
else
|
||||
" Insert a pair and jump to the middle.
|
||||
call insert(b:_l_delimitMate_buffer, a:char)
|
||||
call delimitMate#WriteAfter(a:char)
|
||||
return a:char
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#JumpOut(char) "{{{
|
||||
if delimitMate#IsForbidden(a:char)
|
||||
return a:char
|
||||
endif
|
||||
let line = getline('.')
|
||||
let col = col('.')-2
|
||||
if line[col+1] == a:char
|
||||
return a:char . delimitMate#Del()
|
||||
else
|
||||
return a:char
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
function! delimitMate#JumpAny(key) " {{{
|
||||
if delimitMate#IsForbidden('')
|
||||
return a:key
|
||||
endif
|
||||
if !delimitMate#ShouldJump()
|
||||
return a:key
|
||||
endif
|
||||
" Let's get the character on the right.
|
||||
let char = getline('.')[col('.')-1]
|
||||
if char == " "
|
||||
" Space expansion.
|
||||
"let char = char . getline('.')[col('.')] . delimitMate#Del()
|
||||
return char . getline('.')[col('.')] . delimitMate#Del() . delimitMate#Del()
|
||||
"call delimitMate#RmBuffer(1)
|
||||
elseif char == ""
|
||||
" CR expansion.
|
||||
"let char = "\<CR>" . getline(line('.') + 1)[0] . "\<Del>"
|
||||
let b:_l_delimitMate_buffer = []
|
||||
return "\<CR>" . getline(line('.') + 1)[0] . "\<Del>"
|
||||
else
|
||||
"call delimitMate#RmBuffer(1)
|
||||
return char . delimitMate#Del()
|
||||
endif
|
||||
endfunction " delimitMate#JumpAny() }}}
|
||||
|
||||
function! delimitMate#MapMsg(msg) "{{{
|
||||
redraw
|
||||
echomsg a:msg
|
||||
return ""
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#ExpandReturn() "{{{
|
||||
if delimitMate#IsForbidden("")
|
||||
return "\<CR>"
|
||||
endif
|
||||
if delimitMate#WithinEmptyPair()
|
||||
" Expand:
|
||||
call delimitMate#FlushBuffer()
|
||||
"return "\<Esc>a\<CR>x\<CR>\<Esc>k$\"_xa"
|
||||
return "\<CR>\<UP>\<Esc>o"
|
||||
else
|
||||
return "\<CR>"
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#ExpandSpace() "{{{
|
||||
if delimitMate#IsForbidden("\<Space>")
|
||||
return "\<Space>"
|
||||
endif
|
||||
if delimitMate#WithinEmptyPair()
|
||||
" Expand:
|
||||
call insert(b:_l_delimitMate_buffer, 's')
|
||||
return delimitMate#WriteAfter(' ') . "\<Space>"
|
||||
else
|
||||
return "\<Space>"
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#BS() " {{{
|
||||
if delimitMate#IsForbidden("")
|
||||
return "\<BS>"
|
||||
endif
|
||||
if delimitMate#WithinEmptyPair()
|
||||
"call delimitMate#RmBuffer(1)
|
||||
return "\<BS>" . delimitMate#Del()
|
||||
" return "\<Right>\<BS>\<BS>"
|
||||
elseif delimitMate#IsSpaceExpansion()
|
||||
"call delimitMate#RmBuffer(1)
|
||||
return "\<BS>" . delimitMate#Del()
|
||||
elseif delimitMate#IsCRExpansion()
|
||||
return "\<BS>\<Del>"
|
||||
else
|
||||
return "\<BS>"
|
||||
endif
|
||||
endfunction " }}} delimitMate#BS()
|
||||
|
||||
function! delimitMate#Del() " {{{
|
||||
if len(b:_l_delimitMate_buffer) > 0
|
||||
let line = getline('.')
|
||||
let col = col('.') - 2
|
||||
call delimitMate#RmBuffer(1)
|
||||
call setline('.', line[:col] . line[col+2:])
|
||||
return ''
|
||||
else
|
||||
return "\<Del>"
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
function! delimitMate#Finish() " {{{
|
||||
let len = len(b:_l_delimitMate_buffer)
|
||||
if len > 0
|
||||
let buffer = join(b:_l_delimitMate_buffer, '')
|
||||
let len2 = len(buffer)
|
||||
" Reset buffer:
|
||||
let b:_l_delimitMate_buffer = []
|
||||
let line = getline('.')
|
||||
let col = col('.') -2
|
||||
"echom 'col: ' . col . '-' . line[:col] . "|" . line[col+len+1:] . '%' . buffer
|
||||
if col < 0
|
||||
call setline('.', line[col+len2+1:])
|
||||
else
|
||||
call setline('.', line[:col] . line[col+len2+1:])
|
||||
endif
|
||||
let i = 1
|
||||
let lefts = "\<Left>"
|
||||
while i < len
|
||||
let lefts = lefts . "\<Left>"
|
||||
let i += 1
|
||||
endwhile
|
||||
return substitute(buffer, "s", "\<Space>", 'g') . lefts
|
||||
endif
|
||||
return ''
|
||||
endfunction " }}}
|
||||
|
||||
function! delimitMate#RmBuffer(num) " {{{
|
||||
if len(b:_l_delimitMate_buffer) > 0
|
||||
call remove(b:_l_delimitMate_buffer, 0, (a:num-1))
|
||||
endif
|
||||
return ""
|
||||
endfunction " }}}
|
||||
|
||||
" }}}
|
||||
|
||||
" Tools: {{{
|
||||
function! delimitMate#TestMappings() "{{{
|
||||
let options = sort(keys(delimitMate#OptionsList()))
|
||||
let optoutput = ['delimitMate Report', '==================', '', '* Options: (-) unset, (g) global, (b) buffer','']
|
||||
for option in options
|
||||
exec 'call add(optoutput, ''('.(exists('b:delimitMate_'.option) ? 'b' : exists('g:delimitMate_'.option) ? 'g' : '-').') delimitMate_''.option.'' = ''.string(b:_l_delimitMate_'.option.'))'
|
||||
endfor
|
||||
call append(line('$'), optoutput + ['--------------------',''])
|
||||
|
||||
" Check if mappings were set. {{{
|
||||
let imaps = b:_l_delimitMate_right_delims
|
||||
let imaps = imaps + ( b:_l_delimitMate_autoclose ? b:_l_delimitMate_left_delims : [] )
|
||||
let imaps = imaps +
|
||||
\ b:_l_delimitMate_quotes_list +
|
||||
\ b:_l_delimitMate_apostrophes_list +
|
||||
\ ['<BS>', '<S-BS>', '<Del>', '<S-Tab>', '<Esc>'] +
|
||||
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] +
|
||||
\ ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>', '<S-Up>']
|
||||
let imaps = imaps + ( b:_l_delimitMate_expand_cr ? ['<CR>'] : [] )
|
||||
let imaps = imaps + ( b:_l_delimitMate_expand_space ? ['<Space>'] : [] )
|
||||
|
||||
let vmaps =
|
||||
\ b:_l_delimitMate_right_delims +
|
||||
\ b:_l_delimitMate_left_delims +
|
||||
\ b:_l_delimitMate_quotes_list
|
||||
|
||||
let ibroken = []
|
||||
for map in imaps
|
||||
if maparg(map, "i") !~? 'delimitMate'
|
||||
let output = ''
|
||||
if map == '|'
|
||||
let map = '<Bar>'
|
||||
endif
|
||||
redir => output | execute "verbose imap ".map | redir END
|
||||
let ibroken = ibroken + [map.": is not set:"] + split(output, '\n')
|
||||
endif
|
||||
endfor
|
||||
|
||||
unlet! output
|
||||
if ibroken == []
|
||||
let output = ['* Mappings:', '', 'All mappings were set-up.', '--------------------', '', '']
|
||||
else
|
||||
let output = ['* Mappings:', ''] + ibroken + ['--------------------', '']
|
||||
endif
|
||||
call append('$', output+['* Showcase:', ''])
|
||||
" }}}
|
||||
if b:_l_delimitMate_autoclose
|
||||
" {{{
|
||||
for i in range(len(b:_l_delimitMate_left_delims))
|
||||
exec "normal GGoOpen: " . b:_l_delimitMate_left_delims[i]. "|"
|
||||
exec "normal oDelete: " . b:_l_delimitMate_left_delims[i] . "\<BS>|"
|
||||
exec "normal oExit: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
|
||||
exec "normal oSpace: " . b:_l_delimitMate_left_delims[i] . " |"
|
||||
exec "normal oDelete space: " . b:_l_delimitMate_left_delims[i] . " \<BS>|"
|
||||
exec "normal oCar return: " . b:_l_delimitMate_left_delims[i] . "\<CR>|"
|
||||
exec "normal GGoDelete car return: " . b:_l_delimitMate_left_delims[i] . "\<CR>\<BS>|\<Esc>GG\<Esc>o"
|
||||
endfor
|
||||
for i in range(len(b:_l_delimitMate_quotes_list))
|
||||
exec "normal GGAOpen: " . b:_l_delimitMate_quotes_list[i] . "|"
|
||||
exec "normal oDelete: " . b:_l_delimitMate_quotes_list[i] . "\<BS>|"
|
||||
exec "normal oExit: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
|
||||
exec "normal oSpace: " . b:_l_delimitMate_quotes_list[i] . " |"
|
||||
exec "normal oDelete space: " . b:_l_delimitMate_quotes_list[i] . " \<BS>|"
|
||||
exec "normal oCar return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>|"
|
||||
exec "normal GGoDelete car return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GG\<Esc>o"
|
||||
endfor
|
||||
"}}}
|
||||
else
|
||||
"{{{
|
||||
for i in range(len(b:_l_delimitMate_left_delims))
|
||||
exec "normal GGoOpen & close: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
|
||||
exec "normal oDelete: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<BS>|"
|
||||
exec "normal oExit: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
|
||||
exec "normal oSpace: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . " |"
|
||||
exec "normal oDelete space: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . " \<BS>|"
|
||||
exec "normal oCar return: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<CR>|"
|
||||
exec "normal GGoDelete car return: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<CR>\<BS>|\<Esc>GG\<Esc>o"
|
||||
endfor
|
||||
for i in range(len(b:_l_delimitMate_quotes_list))
|
||||
exec "normal GGoOpen & close: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
|
||||
exec "normal oDelete: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<BS>|"
|
||||
exec "normal oExit: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
|
||||
exec "normal oSpace: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . " |"
|
||||
exec "normal oDelete space: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . " \<BS>|"
|
||||
exec "normal oCar return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>|"
|
||||
exec "normal GGoDelete car return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GG\<Esc>o"
|
||||
endfor
|
||||
endif "}}}
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#OptionsList() "{{{
|
||||
return {'autoclose' : 1,'matchpairs': &matchpairs, 'quotes' : '" '' `', 'nesting_quotes' : [], 'expand_cr' : 0, 'expand_space' : 0, 'smart_quotes' : 1, 'smart_matchpairs' : 1, 'balance_matchpairs' : 0, 'excluded_regions' : 'Comment', 'excluded_ft' : '', 'apostrophes' : ''}
|
||||
endfunction " delimitMate#OptionsList }}}
|
||||
"}}}
|
||||
|
||||
" vim:foldmethod=marker:foldcolumn=4
|
||||
@@ -0,0 +1,260 @@
|
||||
function! delimitMateTests#Main()
|
||||
if !exists("g:delimitMate_testing")
|
||||
echoerr "delimitMateTests#Main(): If you really want to use me, you must set delimitMate_testing to any value."
|
||||
return
|
||||
elseif g:delimitMate_testing == "fork"
|
||||
!gvim -N -u NONE -U NONE -c "set backspace=eol,start" -c "set background=light" -c "syntax on" -c "let delimitMate_testing = 1" -c "so autoload/delimitMate.vim" -c "so autoload/delimitMateTests.vim" -c "so plugin/delimitMate.vim" -c "call delimitMateTests\#Main()"
|
||||
return ""
|
||||
endif
|
||||
nmap <F1> :qall!<CR>
|
||||
let nomore = &more
|
||||
set nomore
|
||||
let b:test_results = {}
|
||||
let b:errors = 0
|
||||
let b:corrects = 0
|
||||
let b:ignores = 0
|
||||
|
||||
function! SetOptions(list) " {{{
|
||||
let b:delimitMate_autoclose = 1
|
||||
let b:delimitMate_matchpairs = &matchpairs
|
||||
let b:delimitMate_quotes = "\" ' `"
|
||||
let b:delimitMate_excluded_regions = "Comment"
|
||||
let b:delimitMate_expand_space = 0
|
||||
let b:delimitMate_expand_cr = 0
|
||||
let b:delimitMate_smart_quotes = 1
|
||||
let b:delimitMate_apostrophes = ""
|
||||
let b:delimitMate_tab2exit = 1
|
||||
" Set current test options:
|
||||
for str in a:list
|
||||
"echom '1:'.str
|
||||
let op = strpart(str, 0, stridx(str,':'))
|
||||
"echom op
|
||||
let val = strpart(str, stridx(str, ':' ) + 1)
|
||||
"echom val
|
||||
exec "let b:delimitMate_" . op . " = " . val
|
||||
endfor
|
||||
DelimitMateReload
|
||||
endfunction " }}}
|
||||
|
||||
function! Type(name, input, output, options, ...) " {{{
|
||||
if a:0 > 0
|
||||
let ignore = a:1
|
||||
else
|
||||
let ignore = 0
|
||||
endif
|
||||
if a:input != "\<Esc>."
|
||||
" Set default options:
|
||||
call SetOptions(a:options)
|
||||
let CapR = ""
|
||||
normal ggVG"_d
|
||||
exec "normal i" . a:input . "|\<Esc>"
|
||||
else
|
||||
let CapR = "_R"
|
||||
normal gg.
|
||||
endif
|
||||
|
||||
exec "normal \<Esc>"
|
||||
call setpos('.', [0, 1, 1, 0])
|
||||
let result = len(a:output) != line('$')
|
||||
for line in a:output
|
||||
if getline('.') != line || result == 1
|
||||
let result = 1
|
||||
break
|
||||
endif
|
||||
call setpos('.', [0, line('.') + 1, 1, 0])
|
||||
endfor
|
||||
let text = getline('.')
|
||||
let i = 2
|
||||
while i <= line('$')
|
||||
let text = text . "<cr>" . getline(i)
|
||||
let i += 1
|
||||
endwhile
|
||||
if ignore == 1
|
||||
let label = "Ignored"
|
||||
let result = "?="
|
||||
let b:ignores += 1
|
||||
elseif result == 0
|
||||
let label = "Passed"
|
||||
let result = "=="
|
||||
let b:corrects += 1
|
||||
else
|
||||
let label = "Failed"
|
||||
let result = "!="
|
||||
let b:errors += 1
|
||||
endif
|
||||
exec "let b:test_results['" .
|
||||
\ substitute(a:name, "[^a-zA-Z0-9_]", "_", "g") . CapR . "'] = '" .
|
||||
\ label . ": ' . a:input . ' => ' . text . ' " .
|
||||
\ result . " ' . join(a:output, '<cr>')"
|
||||
endfunction " }}}
|
||||
|
||||
function! RepeatLast(name, output, ...) " {{{
|
||||
if a:0 > 0
|
||||
let arg1 = a:1
|
||||
else
|
||||
let arg1 = ''
|
||||
endif
|
||||
call Type(a:name, "\<Esc>.", a:output, [], arg1)
|
||||
endfunction " }}}
|
||||
|
||||
" Test's test {{{
|
||||
call Type("Test 1", "123", ["123|"], [])
|
||||
call RepeatLast("Test 1", ["123|123|"])
|
||||
|
||||
" Auto-closing parens
|
||||
call Type("Autoclose parens", "(", ["(|)"], [])
|
||||
call RepeatLast("Autoclose_parens", ["(|)(|)"])
|
||||
|
||||
" Auto-closing quotes
|
||||
call Type("Autoclose quotes", '"', ['"|"'], [])
|
||||
call RepeatLast("Autoclose_quotes", ['"|""|"'])
|
||||
|
||||
" Deleting parens
|
||||
call Type("Delete empty parens", "(\<BS>", ["|"], [])
|
||||
call RepeatLast("Delete empty parens", ["||"])
|
||||
|
||||
" Deleting quotes
|
||||
call Type("Delete emtpy quotes", "\"\<BS>", ['|'], [])
|
||||
call RepeatLast("Delete empty quotes", ["||"])
|
||||
|
||||
" Manual closing parens
|
||||
call Type("Manual closing parens", "()", ["(|)"], ["autoclose:0"])
|
||||
call RepeatLast("Manual closing parens", ["(|)(|)"])
|
||||
|
||||
" Manual closing quotes
|
||||
call Type("Manual closing quotes", "\"\"", ['"|"'], ["autoclose:0"])
|
||||
call RepeatLast("Manual closing quotes", ['"|""|"'])
|
||||
|
||||
" Jump over paren
|
||||
call Type("Jump over paren", "()", ['()|'], [])
|
||||
call RepeatLast("Jump over paren", ['()|()|'])
|
||||
|
||||
" Jump over quote
|
||||
call Type("Jump over quote", "\"\"", ['""|'], [])
|
||||
call RepeatLast("Jump over quote", ['""|""|'])
|
||||
|
||||
" Apostrophe
|
||||
call Type("Apostrophe", "test'", ["test'|"], [])
|
||||
call RepeatLast("Apostrophe", ["test'|test'|"])
|
||||
|
||||
" Close quote
|
||||
call Type("Close quote", "'\<Del>\<Esc>a'", ["'|'"], [])
|
||||
|
||||
" Closing paren
|
||||
call Type("Closing paren", "abcd)", ["abcd)|"], [])
|
||||
|
||||
" <S-Tab>
|
||||
call Type("S Tab", "(\<S-Tab>", ["()|"], [])
|
||||
call RepeatLast("S Tab", ["()|()|"])
|
||||
|
||||
" Space expansion
|
||||
call Type("Space expansion", "(\<Space>\<BS>", ['(|)'], ['expand_space:1'])
|
||||
call RepeatLast("BS with space expansion", ['(|)(|)'])
|
||||
|
||||
" BS with space expansion
|
||||
call Type("BS with space expansion", "(\<Space>", ['( | )'], ['expand_space:1'])
|
||||
call RepeatLast("Space expansion", ['( | )( | )'])
|
||||
|
||||
" Car return expansion
|
||||
call Type("CR expansion", "(\<CR>", ['(', '|', ')'], ['expand_cr:1'])
|
||||
call RepeatLast("CR expansion", ['(', '|', ')(', '|', ')'], 1)
|
||||
|
||||
" BS with car return expansion
|
||||
call Type("BS with CR expansion", "(\<CR>\<BS>", ['(|)'], ['expand_cr:1'])
|
||||
call RepeatLast("BS with CR expansion", ['(|)(|)'], 1)
|
||||
|
||||
" Smart quotes
|
||||
call Type("Smart quote alphanumeric", "a\"4", ['a"4|'], [])
|
||||
call RepeatLast("Smart quote alphanumeric", ['a"4|a"4|'])
|
||||
|
||||
" Smart quotes
|
||||
call Type("Smart quote escaped", "esc\\\"", ['esc\"|'], [])
|
||||
call RepeatLast("Smart quote escaped", ['esc\"|esc\"|'])
|
||||
|
||||
" Smart quotes
|
||||
call Type("Smart quote apostrophe", "I'm", ["I'm|"], ['smart_quotes:0'])
|
||||
call RepeatLast("Smart quote escaped", ["I'm|I'm|"])
|
||||
|
||||
" Backspace inside space expansion
|
||||
call Type("Backspace inside space expansion", "(\<Space>\<BS>", ['(|)'], ['expand_space:1'])
|
||||
call RepeatLast("Backspace inside space expansion", ['(|)(|)'])
|
||||
|
||||
" <Right-arrow> inserts text
|
||||
call Type("<Right-arrow> inserts text", "(he\<Right>\<Space>th\<Right>\<Right>", ['(he) th|'], [])
|
||||
|
||||
" Backspace inside CR expansion
|
||||
call Type("Backspace inside CR expansion", "(\<CR>\<BS>", ['(|)'], ['expand_cr:1'])
|
||||
call RepeatLast("Backspace inside CR expansion", ['(|)(|)'], 1)
|
||||
|
||||
" FileType event
|
||||
let g:delimitMate_excluded_ft = "vim"
|
||||
set ft=vim
|
||||
call Type("FileType Autoclose parens", "(", ["(|"], [])
|
||||
unlet g:delimitMate_excluded_ft
|
||||
set ft=
|
||||
|
||||
" Duplicated delimiter after CR
|
||||
call Type("Duplicated delimiter after CR", "(\<CR>", ['(', '|)'], [])
|
||||
|
||||
" Deactivate on comments: The first call to a closing delimiter
|
||||
" will not work here as expected, but it does in real life tests.
|
||||
set ft=vim
|
||||
call Type("Deactivate on comments", "\"()``[]''\"\"", ["\"()``[]''\"\"|"], ["autoclose:0"], 1)
|
||||
set ft=
|
||||
|
||||
" Deactivate parens on comments: The first call to a closing delimiter
|
||||
" will not work here as expected, but it does in real life tests.
|
||||
set ft=vim
|
||||
call Type("Deactivate parens on comments", "\"()[]", ["\"()[]|"], ["autoclose:0"], 1)
|
||||
set ft=
|
||||
|
||||
" Deactivate quotes on comments: See previous note.
|
||||
set ft=vim
|
||||
call Type("Deactivate parens on comments", "\"(`", ["\"(``|"], [], 1)
|
||||
set ft=
|
||||
|
||||
" Manual close at start of line
|
||||
call Type("Manual close at start of line", "m)\<Left>\<Left>)", [')|m)'], ["autoclose:0"])
|
||||
|
||||
" Use | in quotes
|
||||
call Type("Use <Bar> in quotes", "\<Bar>bars", ['|bars|'], ["quotes:'|'"])
|
||||
|
||||
" Use | in matchpairs
|
||||
call Type("Use <Bar> in matchpairs", "\<Bar>bars", ['|bars|$$'], ["matchpairs:'|:$'"])
|
||||
|
||||
"}}}
|
||||
|
||||
" Show results: {{{
|
||||
normal ggVG"_d
|
||||
call append(0, split(string(b:test_results)[1:-2], ', '))
|
||||
call append(0, "*TESTS REPORT: " . b:errors . " failed, " . b:corrects . " passed and " . b:ignores . " ignored.")
|
||||
normal "_ddgg
|
||||
let @/ = ".\\+Failed:.*!="
|
||||
2,$sort /^.\+':/
|
||||
normal gg
|
||||
exec search('Ignored:','nW').",$sort! /^.\\+':/"
|
||||
set nohlsearch
|
||||
syn match lineIgnored ".*Ignored.*"
|
||||
syn match labelPassed "'\@<=.\+\(': 'Passed\)\@="
|
||||
syn match labelFailed "'\@<=.\+\(': 'Failed\)\@="
|
||||
syn match resultPassed "\('Passed: \)\@<=.\+\('$\)\@="
|
||||
syn match resultFailed "\('Failed: \)\@<=.\+\('$\)\@=" contains=resultInequal
|
||||
syn match resultIgnored "\('Ignored: \)\@<=.\+\('$\)\@="
|
||||
syn match resultInequal "!="
|
||||
syn match resultSummary "^\*.\+" contains=resultSummaryNumber
|
||||
syn match resultSummaryNumber "[1-9][0-9]* failed*" contained
|
||||
|
||||
hi def link lineIgnored Ignore
|
||||
hi def link labelPassed Comment
|
||||
hi def link labelFailed Special
|
||||
hi def link resultPassed Ignore
|
||||
hi def link resultFailed Boolean
|
||||
hi def link resultInequal Error
|
||||
hi def link resultSummary SpecialComment
|
||||
hi def link resultSummaryNumber Error
|
||||
" }}}
|
||||
|
||||
let &more = nomore
|
||||
endfunction
|
||||
" vim:foldmethod=marker:foldcolumn=4
|
||||
|
||||
@@ -0,0 +1,761 @@
|
||||
*delimitMate.txt* Trying to keep those beasts at bay! v2.5.1 *delimitMate*
|
||||
|
||||
|
||||
|
||||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
||||
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMMMM MMMMMMMMMMMMMMMMMMMMM ~
|
||||
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMM MMMMMMMMMMMMMMMMMMMMM
|
||||
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMM MMM M M MMMMMMMMMM MMMMMMMMM ~
|
||||
MMMM MMM MMM MM MM M M MMM MM MM MM MM MMM MMM MMM MM
|
||||
MM MM M MM MMMMMM MMMMMMM MMM MMMMM MM M MMM MMM M M ~
|
||||
M M MM MM MM MM M M MM MMM MMM MMMMM MMMMM MMM MMM M
|
||||
M M MM MMMMM MM MM M M MM MMM MMM MMMMM MMM MMM MMM MMMM ~
|
||||
M M MM M MM MM MM M M MM MMM MMM MMMMM MM M MMM MMM M M
|
||||
MM MMM MMM MM MM M M MM MMM MM MMMMM MMM MMM MMM MM ~
|
||||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
||||
|
||||
|
||||
|
||||
==============================================================================
|
||||
0.- CONTENTS *delimitMate-contents*
|
||||
|
||||
1. Introduction____________________________|delimitMateIntro|
|
||||
2. Customization___________________________|delimitMateOptions|
|
||||
2.1 Options summary____________________|delimitMateOptionSummary|
|
||||
2.2 Options details____________________|delimitMateOptionDetails|
|
||||
3. Functionality___________________________|delimitMateFunctionality|
|
||||
3.1 Automatic closing & exiting________|delimitMateAutoClose|
|
||||
3.2 Expansion of space and CR__________|delimitMateExpansion|
|
||||
3.3 Backspace__________________________|delimitMateBackspace|
|
||||
3.4 Smart Quotes_______________________|delimitMateSmartQuotes|
|
||||
3.5 Balancing matching pairs___________|delimitMateBalance|
|
||||
3.6 FileType based configuration_______|delimitMateFileType|
|
||||
3.7 Syntax awareness___________________|delimitMateSyntax|
|
||||
4. Commands________________________________|delimitMateCommands|
|
||||
5. Mappings________________________________|delimitMateMappings|
|
||||
6. Functions_______________________________|delimitMateFunctions|
|
||||
7. TODO list_______________________________|delimitMateTodo|
|
||||
8. Maintainer______________________________|delimitMateMaintainer|
|
||||
9. Credits_________________________________|delimitMateCredits|
|
||||
10. History_________________________________|delimitMateHistory|
|
||||
|
||||
==============================================================================
|
||||
1.- INTRODUCTION *delimitMateIntro*
|
||||
|
||||
This plug-in provides automatic closing of quotes, parenthesis, brackets,
|
||||
etc.; besides some other related features that should make your time in insert
|
||||
mode a little bit easier.
|
||||
|
||||
Most of the features can be modified or disabled permanently, using global
|
||||
variables, or on a FileType basis, using autocommands. With a couple of
|
||||
exceptions and limitations, this features don't brake undo, redo or history.
|
||||
|
||||
NOTE 1: If you have any trouble with this plugin, please run |:DelimitMateTest|
|
||||
in a new buffer to see what is not working.
|
||||
|
||||
NOTE 2: |'timeout'| needs to be set when working in the terminal, otherwise you
|
||||
might find weird behaviour with mappings including <Esc> or arrow keys.
|
||||
|
||||
NOTE 3: Abbreiations set with |:iabbrev| will not be expanded by delimiters
|
||||
used on delimitMate, you should use <C-]> (read |i_CTRL-]|) to expand them on
|
||||
the go.
|
||||
|
||||
==============================================================================
|
||||
2. CUSTOMIZATION *delimitMateOptions*
|
||||
|
||||
You can create your own mappings for some features using the global functions.
|
||||
Read |DelimitMateFunctions| for more info.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.1 OPTIONS SUMMARY *delimitMateOptionSummary*
|
||||
|
||||
The behaviour of this script can be customized setting the following options
|
||||
in your vimrc file. You can use local options to set the configuration for
|
||||
specific file types, see |delimitMateOptionDetails| for examples.
|
||||
|
||||
|'loaded_delimitMate'| Turns off the script.
|
||||
|
||||
|'delimitMate_autoclose'| Tells delimitMate whether to automagically
|
||||
insert the closing delimiter.
|
||||
|
||||
|'delimitMate_matchpairs'| Tells delimitMate which characters are
|
||||
matching pairs.
|
||||
|
||||
|'delimitMate_quotes'| Tells delimitMate which quotes should be
|
||||
used.
|
||||
|
||||
|'delimitMate_nesting_quotes'| Tells delimitMate which quotes should be
|
||||
allowed to be nested.
|
||||
|
||||
|'delimitMate_expand_cr'| Turns on/off the expansion of <CR>.
|
||||
|
||||
|'delimitMate_expand_space'| Turns on/off the expansion of <Space>.
|
||||
|
||||
|'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature.
|
||||
|
||||
|'delimitMate_balance_matchpairs'|Turns on/off the "balance matching pairs"
|
||||
feature.
|
||||
|
||||
|'delimitMate_excluded_regions'| Turns off the script for the given regions or
|
||||
syntax group names.
|
||||
|
||||
|'delimitMate_excluded_ft'| Turns off the script for the given file types.
|
||||
|
||||
|'delimitMate_apostrophes'| Tells delimitMate how it should "fix"
|
||||
balancing of single quotes when used as
|
||||
apostrophes. NOTE: Not needed any more, kept
|
||||
for compatibility with older versions.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2 OPTIONS DETAILS *delimitMateOptionDetails*
|
||||
|
||||
Add the shown lines to your vimrc file in order to set the below options.
|
||||
Buffer variables take precedence over global ones and can be used along with
|
||||
autocmd to modify delimitMate's behavior for specific file types, read more in
|
||||
|delimitMateFileType|.
|
||||
|
||||
Note: Use buffer variables only to set options for specific file types using
|
||||
:autocmd, use global variables to set options for every buffer. Read more in
|
||||
|g:var| and |b:var|.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'loaded_delimitMate'*
|
||||
*'b:loaded_delimitMate'*
|
||||
This option prevents delimitMate from loading.
|
||||
e.g.: >
|
||||
let loaded_delimitMate = 1
|
||||
au FileType mail let b:loaded_delimitMate = 1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_autoclose'*
|
||||
*'b:delimitMate_autoclose'*
|
||||
Values: 0 or 1. ~
|
||||
Default: 1 ~
|
||||
|
||||
If this option is set to 0, delimitMate will not add a closing delimiter
|
||||
automagically. See |delimitMateAutoClose| for details.
|
||||
e.g.: >
|
||||
let delimitMate_autoclose = 0
|
||||
au FileType mail let b:delimitMate_autoclose = 0
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_matchpairs'*
|
||||
*'b:delimitMate_matchpairs'*
|
||||
Values: A string with |'matchpairs'| syntax, plus support for multi-byte~
|
||||
characters.~
|
||||
Default: &matchpairs ~
|
||||
|
||||
Use this option to tell delimitMate which characters should be considered
|
||||
matching pairs. Read |delimitMateAutoClose| for details.
|
||||
e.g: >
|
||||
let delimitMate_matchpairs = "(:),[:],{:},<:>"
|
||||
au FileType vim,html let b:delimitMate_matchpairs = "(:),[:],{:},<:>"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_quotes'*
|
||||
*'b:delimitMate_quotes'*
|
||||
Values: A string of characters separated by spaces. ~
|
||||
Default: "\" ' `" ~
|
||||
|
||||
Use this option to tell delimitMate which characters should be considered as
|
||||
quotes. Read |delimitMateAutoClose| for details.
|
||||
e.g.: >
|
||||
let delimitMate_quotes = "\" ' ` *"
|
||||
au FileType html let b:delimitMate_quotes = "\" '"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_nesting_quotes'*
|
||||
*'b:delimitMate_nesting_quotes'*
|
||||
Values: A list of quotes. ~
|
||||
Default: [] ~
|
||||
|
||||
Quotes listed here will not be able to jump out of the empty pair, thus
|
||||
allowing the autoclosed quotes to be nested.
|
||||
e.g.: >
|
||||
let delimitMate_nesting_quotes = ['"','`']
|
||||
au FileType python let b:delimitMate_nesting_quotes = ['"']
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_expand_cr'*
|
||||
*'b:delimitMate_expand_cr'*
|
||||
Values: 1 or 0 ~
|
||||
Default: 0 ~
|
||||
|
||||
This option turns on/off the expansion of <CR>. Read |delimitMateExpansion|
|
||||
for details. NOTE This feature requires that 'backspace' is either set to 2 or
|
||||
has "eol" and "start" as part of its value.
|
||||
e.g.: >
|
||||
let delimitMate_expand_cr = 1
|
||||
au FileType mail let b:delimitMate_expand_cr = 1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_expand_space'*
|
||||
*'b:delimitMate_expand_space'*
|
||||
Values: 1 or 0 ~
|
||||
Default: 0 ~
|
||||
This option turns on/off the expansion of <Space>. Read |delimitMateExpansion|
|
||||
for details.
|
||||
e.g.: >
|
||||
let delimitMate_expand_space = 1
|
||||
au FileType tcl let b:delimitMate_expand_space = 1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_smart_quotes'*
|
||||
*'b:delimitMate_smart_quotes'*
|
||||
Values: 1 or 0 ~
|
||||
Default: 1 ~
|
||||
|
||||
This option turns on/off the smart quotes feature. Read
|
||||
|delimitMateSmartQuotes| for details.
|
||||
e.g.: >
|
||||
let delimitMate_smart_quotes = 0
|
||||
au FileType tcl let b:delimitMate_smart_quotes = 0
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_balance_matchpairs'*
|
||||
*'b:delimitMate_balance_matchpairs'*
|
||||
Values: 1 or 0 ~
|
||||
Default: 0 ~
|
||||
|
||||
This option turns on/off the balancing of matching pairs. Read
|
||||
|delimitMateBalance| for details.
|
||||
e.g.: >
|
||||
let delimitMate_balance_matchpairs = 1
|
||||
au FileType tcl let b:delimitMate_balance_matchpairs = 1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_excluded_regions'*
|
||||
Values: A string of syntax group names names separated by single commas. ~
|
||||
Default: Comment ~
|
||||
|
||||
This options turns delimitMate off for the listed regions, read |group-name|
|
||||
for more info about what is a region.
|
||||
e.g.: >
|
||||
let delimitMate_excluded_regions = "Comments,String"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_excluded_ft'*
|
||||
Values: A string of file type names separated by single commas. ~
|
||||
Default: Empty. ~
|
||||
|
||||
This options turns delimitMate off for the listed file types, use this option
|
||||
only if you don't want any of the features it provides on those file types.
|
||||
e.g.: >
|
||||
let delimitMate_excluded_ft = "mail,txt"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_apostrophes'*
|
||||
Values: Strings separated by ":". ~
|
||||
Default: No longer used. ~
|
||||
|
||||
NOTE: This feature is turned off by default, it's been kept for compatibility
|
||||
with older version, read |delimitMateSmartQuotes| for details.
|
||||
If auto-close is enabled, this option tells delimitMate how to try to fix the
|
||||
balancing of single quotes when used as apostrophes. The values of this option
|
||||
are strings of text where a single quote would be used as an apostrophe (e.g.:
|
||||
the "n't" of wouldn't or can't) separated by ":". Set it to an empty string to
|
||||
disable this feature.
|
||||
e.g.: >
|
||||
let delimitMate_apostrophes = ""
|
||||
au FileType tcl let delimitMate_apostrophes = ""
|
||||
<
|
||||
==============================================================================
|
||||
3. FUNCTIONALITY *delimitMateFunctionality*
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.1 AUTOMATIC CLOSING AND EXITING *delimitMateAutoClose*
|
||||
|
||||
With automatic closing enabled, if an opening delimiter is inserted the plugin
|
||||
inserts the closing delimiter and places the cursor between the pair. With
|
||||
automatic closing disabled, no closing delimiters is inserted by delimitMate,
|
||||
but when a pair of delimiters is typed, the cursor is placed in the middle.
|
||||
|
||||
When the cursor is inside an empty pair or located next to the left of a
|
||||
closing delimiter, the cursor is placed outside the pair to the right of the
|
||||
closing delimiter.
|
||||
|
||||
Unless |'delimitMate_matchpairs'| or |'delimitMate_quotes'|are set, this
|
||||
script uses the values in '&matchpairs' to identify the pairs, and ", ' and `
|
||||
for quotes respectively.
|
||||
|
||||
The following table shows the behaviour, this applies to quotes too (the final
|
||||
position of the cursor is represented by a "|"):
|
||||
|
||||
With auto-close: >
|
||||
Type | You get
|
||||
====================
|
||||
( | (|)
|
||||
–––––––––|––––––––––
|
||||
() | ()|
|
||||
–––––––––|––––––––––
|
||||
(<S-Tab> | ()|
|
||||
<
|
||||
Without auto-close: >
|
||||
|
||||
Type | You get
|
||||
=====================
|
||||
() | (|)
|
||||
–––––––––-|––––––––––
|
||||
()) | ()|
|
||||
–––––––––-|––––––––––
|
||||
()<S-Tab> | ()|
|
||||
<
|
||||
NOTE: Abbreviations will not be expanded by delimiters used on delimitMate,
|
||||
you should use <C-]> (read |i_CTRL-]|) to expand them on the go.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
|
||||
|
||||
When the cursor is inside an empty pair of delimiters, <Space> and <CR> can be
|
||||
expanded, see |'delimitMate_expand_space'| and
|
||||
|'delimitMate_expand_cr'|:
|
||||
|
||||
Expand <Space> to: >
|
||||
|
||||
<Space><Space><Left> | You get
|
||||
====================================
|
||||
(|) | ( | )
|
||||
<
|
||||
Expand <CR> to: >
|
||||
|
||||
<CR><CR><Up> | You get
|
||||
============================
|
||||
(|) | (
|
||||
| |
|
||||
| )
|
||||
<
|
||||
|
||||
NOTE that the expansion of <CR> will brake the redo command.
|
||||
|
||||
Since <Space> and <CR> are used everywhere, I have made the functions involved
|
||||
in expansions global, so they can be used to make custom mappings. Read
|
||||
|delimitMateFunctions| for more details.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.3 BACKSPACE *delimitMateBackspace*
|
||||
|
||||
If you press backspace inside an empty pair, both delimiters are deleted. When
|
||||
expansions are enabled, <BS> will also delete the expansions. NOTE that
|
||||
deleting <CR> expansions will brake the redo command.
|
||||
|
||||
If you type <S-BS> (shift + backspace) instead, only the closing delimiter
|
||||
will be deleted. NOTE that this will not usually work when using Vim from the
|
||||
terminal, see 'delimitMate#JumpAny()' below to see how to fix it.
|
||||
|
||||
e.g. typing at the "|": >
|
||||
|
||||
What | Before | After
|
||||
==============================================
|
||||
<BS> | call expand(|) | call expand|
|
||||
---------|-------------------|-----------------
|
||||
<BS> | call expand( | ) | call expand(|)
|
||||
---------|-------------------|-----------------
|
||||
<BS> | call expand( | call expand(|)
|
||||
| | |
|
||||
| ) |
|
||||
---------|-------------------|-----------------
|
||||
<S-BS> | call expand(|) | call expand(|
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.4 SMART QUOTES *delimitMateSmartQuotes*
|
||||
|
||||
Only one quote will be inserted following a quote, a "\" or, following or
|
||||
preceding an alphanumeric character. This should cover closing quotes after a
|
||||
string, opening quotes before a string, escaped quotes and apostrophes. Except
|
||||
for apostrophes, this feature can be disabled setting the option
|
||||
|'delimitMate_smart_quotes'| to 0.
|
||||
|
||||
e.g. typing at the "|": >
|
||||
|
||||
What | Before | After
|
||||
=======================================
|
||||
" | Text | | Text "|"
|
||||
" | "String| | "String"|
|
||||
" | let i = "| | let i = "|"
|
||||
'm | I| | I'm|
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
3.5 BALANCING MATCHING PAIRS *delimitMateBalance*
|
||||
|
||||
When inserting an opening paren and |'delimitMate_balance_matchpairs'| is
|
||||
enabled, delimitMate will try to balance the closing pairs in the current
|
||||
line.
|
||||
|
||||
e.g. typing at the "|": >
|
||||
|
||||
What | Before | After
|
||||
=======================================
|
||||
( | |) | (|)
|
||||
( | | | (|)
|
||||
( | (|) | ((|))
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
3.6 FILE TYPE BASED CONFIGURATION *delimitMateFileType*
|
||||
|
||||
delimitMate options can be set globally for all buffers using global
|
||||
("regular") variables in your |vimrc| file. But |:autocmd| can be used to set
|
||||
options for specific file types (see |'filetype'|) using buffer variables in
|
||||
the following way: >
|
||||
|
||||
au FileType mail,text let b:delimitMate_autoclose = 0
|
||||
^ ^ ^ ^ ^
|
||||
| | | | |
|
||||
| | | | - Option value.
|
||||
| | | - Option name.
|
||||
| | - Buffer variable.
|
||||
| - File types for which the option will be set.
|
||||
- Don't forget to put this event.
|
||||
<
|
||||
NOTE that you should use buffer variables (|b:var|) only to set options with
|
||||
|:autocmd|, for global options use regular variables (|g:var|) in your vimrc.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.7 SYNTAX AWARENESS *delimitMateSyntax*
|
||||
|
||||
The features of this plug-in might not be always helpful, comments and strings
|
||||
usualy don't need auto-completion. delimitMate monitors which region is being
|
||||
edited and if it detects that the cursor is in a comment it'll turn itself off
|
||||
until the cursor leaves the comment. The excluded regions can be set using the
|
||||
option |'delimitMate_excluded_regions'|. Read |group-name| for a list of
|
||||
regions or syntax group names.
|
||||
|
||||
NOTE that this feature relies on a proper syntax file for the current file
|
||||
type, if the appropiate syntax file doesn't define a region, delimitMate won't
|
||||
know about it.
|
||||
|
||||
==============================================================================
|
||||
4. COMMANDS *delimitMateCommands*
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
:DelimitMateReload *:DelimitMateReload*
|
||||
|
||||
Re-sets all the mappings used for this script, use it if any option has been
|
||||
changed or if the filetype option hasn't been set yet.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
:DelimitMateSwitch *:DelimitMateSwitch*
|
||||
|
||||
Switches the plug-in on and off.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
:DelimitMateTest *:DelimitMateTest*
|
||||
|
||||
This command tests every mapping set-up for this script, useful for testing
|
||||
custom configurations.
|
||||
|
||||
The following output corresponds to the default values, it will be different
|
||||
depending on your configuration. "Open & close:" represents the final result
|
||||
when the closing delimiter has been inserted, either manually or
|
||||
automatically, see |delimitMateExpansion|. "Delete:" typing backspace in an
|
||||
empty pair, see |delimitMateBackspace|. "Exit:" typing a closing delimiter
|
||||
inside a pair of delimiters, see |delimitMateAutoclose|. "Space:" the
|
||||
expansion, if any, of space, see |delimitMateExpansion|. "Visual-L",
|
||||
"Visual-R" and "Visual" shows visual wrapping, see
|
||||
|delimitMateVisualWrapping|. "Car return:" the expansion of car return, see
|
||||
|delimitMateExpansion|. The cursor's position at the end of every test is
|
||||
represented by an "|": >
|
||||
|
||||
* AUTOCLOSE:
|
||||
Open & close: (|)
|
||||
Delete: |
|
||||
Exit: ()|
|
||||
Space: ( |)
|
||||
Visual-L: (v)
|
||||
Visual-R: (v)
|
||||
Car return: (
|
||||
|)
|
||||
|
||||
Open & close: {|}
|
||||
Delete: |
|
||||
Exit: {}|
|
||||
Space: { |}
|
||||
Visual-L: {v}
|
||||
Visual-R: {v}
|
||||
Car return: {
|
||||
|}
|
||||
|
||||
Open & close: [|]
|
||||
Delete: |
|
||||
Exit: []|
|
||||
Space: [ |]
|
||||
Visual-L: [v]
|
||||
Visual-R: [v]
|
||||
Car return: [
|
||||
|]
|
||||
|
||||
Open & close: "|"
|
||||
Delete: |
|
||||
Exit: ""|
|
||||
Space: " |"
|
||||
Visual: "v"
|
||||
Car return: "
|
||||
|"
|
||||
|
||||
Open & close: '|'
|
||||
Delete: |
|
||||
Exit: ''|
|
||||
Space: ' |'
|
||||
Visual: 'v'
|
||||
Car return: '
|
||||
|'
|
||||
|
||||
Open & close: `|`
|
||||
Delete: |
|
||||
Exit: ``|
|
||||
Space: ` |`
|
||||
Visual: `v`
|
||||
Car return: `
|
||||
|`
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
5. MAPPINGS *delimitMateMappings*
|
||||
|
||||
delimitMate doesn't override any existing map, so you may encounter that it
|
||||
doesn't work as expected because a mapping is missing. In that case, the
|
||||
conflicting mappings should be resolved by either disabling the conflicting
|
||||
mapping or creating a custom mappings.
|
||||
|
||||
In order to make custom mappings easier and prevent overwritting existing
|
||||
ones, delimitMate uses the |<Plug>| + |hasmapto()| (|usr_41.txt|) construct
|
||||
for its mappings.
|
||||
|
||||
The following are the mappings alway set by delimitMate:
|
||||
|
||||
<BS> is mapped to <Plug>delimitMateBS
|
||||
<S-BS> is mapped to <Plug>delimitMateS-BS
|
||||
<S-Tab> is mapped to <Plug>delimitMateS-Tab
|
||||
<Del> is mapped to <Plug>delimitMateDel
|
||||
<Esc> is mapped to <Plug>delimitMateEsc
|
||||
<Left> is mapped to <Plug>delimitMateLeft
|
||||
<Right> is mapped to <Plug>delimitMateRight
|
||||
<Home> is mapped to <Plug>delimitMateHome
|
||||
<End> is mapped to <Plug>delimitMateEnd
|
||||
<Up> is mapped to <Plug>delimitMateUp
|
||||
<Down> is mapped to <Plug>delimitMateDown
|
||||
<PageUp> is mapped to <Plug>delimitMatePageUp
|
||||
<PageDown> is mapped to <Plug>delimitMatePageDown
|
||||
<S-Down> is mapped to <Plug>delimitMateS-Down
|
||||
<S-Up> is mapped to <Plug>delimitMateS-Up
|
||||
<LeftMouse> is mapped to <Plug>delimitMateMLeftMouse
|
||||
<RightMouse> is mapped to <Plug>delimitMateMRightMouse
|
||||
|
||||
The rest of the mappings correspond to parens, quotes, CR, Space, etc. and they
|
||||
depend on the values of the delimitMate options, they have the following form:
|
||||
|
||||
<Plug>delimitMate + char
|
||||
|
||||
e.g.: for "(":
|
||||
|
||||
( is mapped to <Plug>delimitMate(
|
||||
|
||||
e.g.: If you have <CR> expansion enabled, you might want to skip it on pop-up
|
||||
menus:
|
||||
|
||||
imap <expr> <CR> pumvisible() ?
|
||||
\"\<c-y>" :
|
||||
\ "<Plug>delimitMateCR"
|
||||
|
||||
|
||||
==============================================================================
|
||||
6. FUNCTIONS *delimitMateFunctions*
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair()*
|
||||
|
||||
Returns 1 if the cursor is inside an empty pair, 0 otherwise.
|
||||
e.g.: >
|
||||
|
||||
inoremap <expr> <CR> delimitMate#WithinEmptyPair() ?
|
||||
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>" :
|
||||
\ "external_mapping"
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
delimitMate#ShouldJump() *delimitMate#ShouldJump()*
|
||||
|
||||
Returns 1 if there is a closing delimiter or a quote to the right of the
|
||||
cursor, 0 otherwise.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
delimitMate#JumpAny(key) *delimitMate#JumpAny()*
|
||||
|
||||
This function returns a mapping that will make the cursor jump to the right
|
||||
when delimitMate#ShouldJump() returns 1, returns the argument "key" otherwise.
|
||||
e.g.: You can use this to create your own mapping to jump over any delimiter.
|
||||
>
|
||||
inoremap <C-Tab> <C-R>=delimitMate#JumpAny("\<C-Tab>")<CR>
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
7. TODO LIST *delimitMateTodo*
|
||||
|
||||
- Automatic set-up by file type.
|
||||
- Make block-wise visual wrapping work on un-even regions.
|
||||
|
||||
==============================================================================
|
||||
8. MAINTAINER *delimitMateMaintainer*
|
||||
|
||||
Hi there! My name is Israel Chauca F. and I can be reached at:
|
||||
mailto:israelchauca@gmail.com
|
||||
|
||||
Feel free to send me any suggestions and/or comments about this plugin, I'll
|
||||
be very pleased to read them.
|
||||
|
||||
==============================================================================
|
||||
9. CREDITS *delimitMateCredits*
|
||||
|
||||
Some of the code that make this script is modified or just shamelessly copied
|
||||
from the following sources:
|
||||
|
||||
- Ian McCracken
|
||||
Post titled: Vim, Part II: Matching Pairs:
|
||||
http://concisionandconcinnity.blogspot.com/
|
||||
|
||||
- Aristotle Pagaltzis
|
||||
From the comments on the previous blog post and from:
|
||||
http://gist.github.com/144619
|
||||
|
||||
- Karl Guertin
|
||||
AutoClose:
|
||||
http://www.vim.org/scripts/script.php?script_id=1849
|
||||
|
||||
- Thiago Alves
|
||||
AutoClose:
|
||||
http://www.vim.org/scripts/script.php?script_id=2009
|
||||
|
||||
- Edoardo Vacchi
|
||||
ClosePairs:
|
||||
http://www.vim.org/scripts/script.php?script_id=2373
|
||||
|
||||
This script was inspired by the auto-completion of delimiters on TextMate.
|
||||
|
||||
==============================================================================
|
||||
10. HISTORY *delimitMateHistory*
|
||||
|
||||
Version Date Release notes ~
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.5.1 2010-09-30 * Current release:
|
||||
- Remove visual wrapping. Surround.vim offers a much
|
||||
better implementation.
|
||||
- Minor mods to DelimitMateTest.
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.5 2010-09-22 * - Better handling of mappings.
|
||||
- Add report for mappings in |:DelimitMateTest|.
|
||||
- Allow the use of "|" and multi-byte characters in
|
||||
|'delimitMate_quotes'| and |'delimitMate_matchpairs'|.
|
||||
- Allow commands to be concatenated using |.
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.4.1 2010-07-31 * - Fix problem with <Home> and <End>.
|
||||
- Add missing doc on |'delimitMate_smart_quotes'|,
|
||||
|delimitMateBalance| and
|
||||
|'delimitMate_balance_matchpairs'|.
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.4 2010-07-29 * - Unbalanced parens: see :help delimitMateBalance.
|
||||
- Visual wrapping now works on block-wise visual
|
||||
with some limitations.
|
||||
- Arrow keys didn't work on terminal.
|
||||
- Added option to allow nested quotes.
|
||||
- Expand Smart Quotes to look for a string on the
|
||||
right of the cursor.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.3.1 2010-06-06 * - Fix: an extra <Space> is inserted after <Space>
|
||||
expansion.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.3 2010-06-06 * - Syntax aware: Will turn off when editing comments
|
||||
or other regions, customizable.
|
||||
- Changed format of most mappings.
|
||||
- Fix: <CR> expansion doesn't brake automatic
|
||||
indentation adjustments anymore.
|
||||
- Fix: Arrow keys would insert A, B, C or D instead
|
||||
of moving the cursor when using Vim on a terminal.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.2 2010-05-16 * - Added command to switch the plug-in on and off.
|
||||
- Fix: some problems with <Left>, <Right> and <CR>.
|
||||
- Fix: A small problem when inserting a delimiter at
|
||||
the beginning of the line.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.1 2010-05-10 * - Most of the functions have been moved to an
|
||||
autoload script to avoid loading unnecessary ones.
|
||||
- Fixed a problem with the redo command.
|
||||
- Many small fixes.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.0 2010-04-01 * New features:
|
||||
- All features are redo/undo-wise safe.
|
||||
- A single quote typed after an alphanumeric
|
||||
character is considered an apostrophe and one
|
||||
single quote is inserted.
|
||||
- A quote typed after another quote inserts a single
|
||||
quote and the cursor jumps to the middle.
|
||||
- <S-Tab> jumps out of any empty pair.
|
||||
- <CR> and <Space> expansions are fixed, but the
|
||||
functions used for it are global and can be used in
|
||||
custom mappings. The previous system is still
|
||||
active if you have any of the expansion options
|
||||
set.
|
||||
- <S-Backspace> deletes the closing delimiter.
|
||||
* Fixed bug:
|
||||
- s:vars were being used to store buffer options.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
1.6 2009-10-10 * Now delimitMate tries to fix the balancing of single
|
||||
quotes when used as apostrophes. You can read
|
||||
|delimitMate_apostrophes| for details.
|
||||
Fixed an error when |b:delimitMate_expand_space|
|
||||
wasn't set but |delimitMate_expand_space| wasn't.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
1.5 2009-10-05 * Fix: delimitMate should work correctly for files
|
||||
passed as arguments to Vim. Thanks to Ben Beuchler
|
||||
for helping to nail this bug.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
1.4 2009-09-27 * Fix: delimitMate is now enabled on new buffers even
|
||||
if they don't have set the file type option or were
|
||||
opened directly from the terminal.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
1.3 2009-09-24 * Now local options can be used along with autocmd
|
||||
for specific file type configurations.
|
||||
Fixes:
|
||||
- Unnamed register content is not lost on visual
|
||||
mode.
|
||||
- Use noremap where appropiate.
|
||||
- Wrapping a single empty line works as expected.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
1.2 2009-09-07 * Fixes:
|
||||
- When inside nested empty pairs, deleting the
|
||||
innermost left delimiter would delete all right
|
||||
contiguous delimiters.
|
||||
- When inside an empty pair, inserting a left
|
||||
delimiter wouldn't insert the right one, instead
|
||||
the cursor would jump to the right.
|
||||
- New buffer inside the current window wouldn't
|
||||
have the mappings set.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
1.1 2009-08-25 * Fixed an error that ocurred when mapleader wasn't
|
||||
set and added support for GetLatestScripts
|
||||
auto-detection.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
1.0 2009-08-23 * Initial upload.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
|
||||
|
||||
`\|||/´ MMM \|/ www __^__ ~
|
||||
(o o) (o o) @ @ (O-O) /(o o)\\ ~
|
||||
ooO_(_)_Ooo__ ooO_(_)_Ooo___oOO_(_)_OOo___oOO__(_)__OOo___oOO__(_)__OOo_____ ~
|
||||
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
||||
__|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_ ~
|
||||
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
||||
|
||||
vim:tw=78:et:ts=2:sw=2:ft=help:norl:formatoptions+=tcroqn:autoindent:
|
||||
@@ -0,0 +1,427 @@
|
||||
" ============================================================================
|
||||
" File: plugin/delimitMate.vim
|
||||
" Version: 2.5.1
|
||||
" Modified: 2010-09-30
|
||||
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
||||
" Manual: Read ":help delimitMate".
|
||||
|
||||
" Initialization: {{{
|
||||
|
||||
if exists("g:loaded_delimitMate") || &cp
|
||||
" User doesn't want this plugin or compatible is set, let's get out!
|
||||
finish
|
||||
endif
|
||||
let g:loaded_delimitMate = 1
|
||||
|
||||
if exists("s:loaded_delimitMate") && !exists("g:delimitMate_testing")
|
||||
" Don't define the functions if they already exist: just do the work
|
||||
" (unless we are testing):
|
||||
call s:DelimitMateDo()
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version < 700
|
||||
echoerr "delimitMate: this plugin requires vim >= 7!"
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:loaded_delimitMate = 1
|
||||
let delimitMate_version = "2.5.1"
|
||||
|
||||
function! s:option_init(name, default) "{{{
|
||||
let b = exists("b:delimitMate_" . a:name)
|
||||
let g = exists("g:delimitMate_" . a:name)
|
||||
let prefix = "_l_delimitMate_"
|
||||
|
||||
if !b && !g
|
||||
let sufix = a:default
|
||||
elseif !b && g
|
||||
exec "let sufix = g:delimitMate_" . a:name
|
||||
else
|
||||
exec "let sufix = b:delimitMate_" . a:name
|
||||
endif
|
||||
if exists("b:" . prefix . a:name)
|
||||
exec "unlockvar! b:" . prefix . a:name
|
||||
endif
|
||||
exec "let b:" . prefix . a:name . " = " . string(sufix)
|
||||
exec "lockvar! b:" . prefix . a:name
|
||||
endfunction "}}}
|
||||
|
||||
function! s:init() "{{{
|
||||
" Initialize variables:
|
||||
|
||||
" autoclose
|
||||
call s:option_init("autoclose", 1)
|
||||
|
||||
" matchpairs
|
||||
call s:option_init("matchpairs", string(&matchpairs)[1:-2])
|
||||
call s:option_init("matchpairs_list", split(b:_l_delimitMate_matchpairs, ','))
|
||||
call s:option_init("left_delims", split(b:_l_delimitMate_matchpairs, ':.,\='))
|
||||
call s:option_init("right_delims", split(b:_l_delimitMate_matchpairs, ',\=.:'))
|
||||
|
||||
" quotes
|
||||
call s:option_init("quotes", "\" ' `")
|
||||
call s:option_init("quotes_list", split(b:_l_delimitMate_quotes))
|
||||
|
||||
" nesting_quotes
|
||||
call s:option_init("nesting_quotes", [])
|
||||
|
||||
" excluded_regions
|
||||
call s:option_init("excluded_regions", "Comment")
|
||||
call s:option_init("excluded_regions_list", split(b:_l_delimitMate_excluded_regions, ',\s*'))
|
||||
let enabled = len(b:_l_delimitMate_excluded_regions_list) > 0
|
||||
call s:option_init("excluded_regions_enabled", enabled)
|
||||
|
||||
" excluded filetypes
|
||||
call s:option_init("excluded_ft", "")
|
||||
|
||||
" expand_space
|
||||
if exists("b:delimitMate_expand_space") && type(b:delimitMate_expand_space) == type("")
|
||||
echom "b:delimitMate_expand_space is '".b:delimitMate_expand_space."' but it must be either 1 or 0!"
|
||||
echom "Read :help 'delimitMate_expand_space' for more details."
|
||||
unlet b:delimitMate_expand_space
|
||||
let b:delimitMate_expand_space = 1
|
||||
endif
|
||||
if exists("g:delimitMate_expand_space") && type(g:delimitMate_expand_space) == type("")
|
||||
echom "delimitMate_expand_space is '".g:delimitMate_expand_space."' but it must be either 1 or 0!"
|
||||
echom "Read :help 'delimitMate_expand_space' for more details."
|
||||
unlet g:delimitMate_expand_space
|
||||
let g:delimitMate_expand_space = 1
|
||||
endif
|
||||
call s:option_init("expand_space", 0)
|
||||
|
||||
" expand_cr
|
||||
if exists("b:delimitMate_expand_cr") && type(b:delimitMate_expand_cr) == type("")
|
||||
echom "b:delimitMate_expand_cr is '".b:delimitMate_expand_cr."' but it must be either 1 or 0!"
|
||||
echom "Read :help 'delimitMate_expand_cr' for more details."
|
||||
unlet b:delimitMate_expand_cr
|
||||
let b:delimitMate_expand_cr = 1
|
||||
endif
|
||||
if exists("g:delimitMate_expand_cr") && type(g:delimitMate_expand_cr) == type("")
|
||||
echom "delimitMate_expand_cr is '".g:delimitMate_expand_cr."' but it must be either 1 or 0!"
|
||||
echom "Read :help 'delimitMate_expand_cr' for more details."
|
||||
unlet g:delimitMate_expand_cr
|
||||
let g:delimitMate_expand_cr = 1
|
||||
endif
|
||||
if ((&backspace !~ 'eol' || &backspace !~ 'start') && &backspace != 2) &&
|
||||
\ ((exists('b:delimitMate_expand_cr') && b:delimitMate_expand_cr == 1) ||
|
||||
\ (exists('g:delimitMate_expand_cr') && g:delimitMate_expand_cr == 1))
|
||||
echom "delimitMate: There seems to be some incompatibility with your settings that may interfer with the expansion of <CR>. See :help 'delimitMate_expand_cr' for details."
|
||||
endif
|
||||
call s:option_init("expand_cr", 0)
|
||||
|
||||
" smart_matchpairs
|
||||
call s:option_init("smart_matchpairs", 1)
|
||||
|
||||
" smart_quotes
|
||||
call s:option_init("smart_quotes", 1)
|
||||
|
||||
" apostrophes
|
||||
call s:option_init("apostrophes", "")
|
||||
call s:option_init("apostrophes_list", split(b:_l_delimitMate_apostrophes, ":\s*"))
|
||||
|
||||
" tab2exit
|
||||
call s:option_init("tab2exit", 1)
|
||||
|
||||
" balance_matchpairs
|
||||
call s:option_init("balance_matchpairs", 0)
|
||||
|
||||
let b:_l_delimitMate_buffer = []
|
||||
|
||||
let b:loaded_delimitMate = 1
|
||||
|
||||
endfunction "}}} Init()
|
||||
|
||||
"}}}
|
||||
|
||||
" Functions: {{{
|
||||
|
||||
function! s:Map() "{{{
|
||||
" Set mappings:
|
||||
try
|
||||
let save_cpo = &cpo
|
||||
let save_keymap = &keymap
|
||||
let save_iminsert = &iminsert
|
||||
let save_imsearch = &imsearch
|
||||
set keymap=
|
||||
set cpo&vim
|
||||
if b:_l_delimitMate_autoclose
|
||||
call s:AutoClose()
|
||||
else
|
||||
call s:NoAutoClose()
|
||||
endif
|
||||
call s:ExtraMappings()
|
||||
finally
|
||||
let &cpo = save_cpo
|
||||
let &keymap = save_keymap
|
||||
let &iminsert = save_iminsert
|
||||
let &imsearch = save_imsearch
|
||||
endtry
|
||||
|
||||
let b:delimitMate_enabled = 1
|
||||
|
||||
endfunction "}}} Map()
|
||||
|
||||
function! s:Unmap() " {{{
|
||||
let imaps =
|
||||
\ b:_l_delimitMate_right_delims +
|
||||
\ b:_l_delimitMate_left_delims +
|
||||
\ b:_l_delimitMate_quotes_list +
|
||||
\ b:_l_delimitMate_apostrophes_list +
|
||||
\ ['<BS>', '<S-BS>', '<Del>', '<CR>', '<Space>', '<S-Tab>', '<Esc>'] +
|
||||
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] +
|
||||
\ ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>', '<S-Up>']
|
||||
|
||||
for map in imaps
|
||||
if maparg(map, "i") =~? 'delimitMate'
|
||||
if map == '|'
|
||||
let map = '<Bar>'
|
||||
endif
|
||||
exec 'silent! iunmap <buffer> ' . map
|
||||
endif
|
||||
endfor
|
||||
|
||||
if !has('gui_running')
|
||||
silent! iunmap <C-[>OC
|
||||
endif
|
||||
|
||||
let b:delimitMate_enabled = 0
|
||||
endfunction " }}} s:Unmap()
|
||||
|
||||
function! s:TestMappingsDo() "{{{
|
||||
%d
|
||||
if !exists("g:delimitMate_testing")
|
||||
silent call delimitMate#TestMappings()
|
||||
else
|
||||
let temp_varsDM = [b:_l_delimitMate_expand_space, b:_l_delimitMate_expand_cr, b:_l_delimitMate_autoclose]
|
||||
for i in [0,1]
|
||||
let b:delimitMate_expand_space = i
|
||||
let b:delimitMate_expand_cr = i
|
||||
for a in [0,1]
|
||||
let b:delimitMate_autoclose = a
|
||||
call s:init()
|
||||
call s:Unmap()
|
||||
call s:Map()
|
||||
call delimitMate#TestMappings()
|
||||
normal o
|
||||
endfor
|
||||
endfor
|
||||
let b:delimitMate_expand_space = temp_varsDM[0]
|
||||
let b:delimitMate_expand_cr = temp_varsDM[1]
|
||||
let b:delimitMate_autoclose = temp_varsDM[2]
|
||||
unlet temp_varsDM
|
||||
endif
|
||||
normal gg
|
||||
g/\%^$/d
|
||||
endfunction "}}}
|
||||
|
||||
function! s:DelimitMateDo(...) "{{{
|
||||
" Initialize settings:
|
||||
call s:init()
|
||||
|
||||
" Check if this file type is excluded:
|
||||
if exists("g:delimitMate_excluded_ft") &&
|
||||
\ index(split(g:delimitMate_excluded_ft, ','), &filetype, 0, 1) >= 0
|
||||
|
||||
" Remove any magic:
|
||||
call s:Unmap()
|
||||
|
||||
" Finish here:
|
||||
return 1
|
||||
endif
|
||||
|
||||
" First, remove all magic, if needed:
|
||||
if exists("b:delimitMate_enabled") && b:delimitMate_enabled == 1
|
||||
call s:Unmap()
|
||||
endif
|
||||
|
||||
" Now, add magic:
|
||||
call s:Map()
|
||||
|
||||
if a:0 > 0
|
||||
echo "delimitMate has been reset."
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:DelimitMateSwitch() "{{{
|
||||
call s:init()
|
||||
if exists("b:delimitMate_enabled") && b:delimitMate_enabled
|
||||
call s:Unmap()
|
||||
echo "delimitMate has been disabled."
|
||||
else
|
||||
call s:Unmap()
|
||||
call s:Map()
|
||||
echo "delimitMate has been enabled."
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:Finish()
|
||||
if exists('g:delimitMate_loaded')
|
||||
return delimitMate#Finish()
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! s:FlushBuffer()
|
||||
if exists('g:delimitMate_loaded')
|
||||
return delimitMate#FlushBuffer()
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
"}}}
|
||||
|
||||
" Mappers: {{{
|
||||
function! s:NoAutoClose() "{{{
|
||||
" inoremap <buffer> ) <C-R>=delimitMate#SkipDelim('\)')<CR>
|
||||
for delim in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
|
||||
if delim == '|'
|
||||
let delim = '<Bar>'
|
||||
endif
|
||||
exec 'inoremap <silent> <Plug>delimitMate' . delim . ' <C-R>=delimitMate#SkipDelim("' . escape(delim,'"') . '")<CR>'
|
||||
exec 'silent! imap <unique> <buffer> '.delim.' <Plug>delimitMate'.delim
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
function! s:AutoClose() "{{{
|
||||
" Add matching pair and jump to the midle:
|
||||
" inoremap <silent> <buffer> ( ()<Left>
|
||||
let i = 0
|
||||
while i < len(b:_l_delimitMate_matchpairs_list)
|
||||
let ld = b:_l_delimitMate_left_delims[i] == '|' ? '<bar>' : b:_l_delimitMate_left_delims[i]
|
||||
let rd = b:_l_delimitMate_right_delims[i] == '|' ? '<bar>' : b:_l_delimitMate_right_delims[i]
|
||||
exec 'inoremap <silent> <Plug>delimitMate' . ld . ' ' . ld . '<C-R>=delimitMate#ParenDelim("' . escape(rd, '|') . '")<CR>'
|
||||
exec 'silent! imap <unique> <buffer> '.ld.' <Plug>delimitMate'.ld
|
||||
let i += 1
|
||||
endwhile
|
||||
|
||||
" Exit from inside the matching pair:
|
||||
for delim in b:_l_delimitMate_right_delims
|
||||
exec 'inoremap <silent> <Plug>delimitMate' . delim . ' <C-R>=delimitMate#JumpOut("\' . delim . '")<CR>'
|
||||
exec 'silent! imap <unique> <buffer> ' . delim . ' <Plug>delimitMate'. delim
|
||||
endfor
|
||||
|
||||
" Add matching quote and jump to the midle, or exit if inside a pair of matching quotes:
|
||||
" inoremap <silent> <buffer> " <C-R>=delimitMate#QuoteDelim("\"")<CR>
|
||||
for delim in b:_l_delimitMate_quotes_list
|
||||
if delim == '|'
|
||||
let delim = '<Bar>'
|
||||
endif
|
||||
exec 'inoremap <silent> <Plug>delimitMate' . delim . ' <C-R>=delimitMate#QuoteDelim("\' . delim . '")<CR>'
|
||||
exec 'silent! imap <unique> <buffer> ' . delim . ' <Plug>delimitMate' . delim
|
||||
endfor
|
||||
|
||||
" Try to fix the use of apostrophes (kept for backward compatibility):
|
||||
" inoremap <silent> <buffer> n't n't
|
||||
for map in b:_l_delimitMate_apostrophes_list
|
||||
exec "inoremap <silent> " . map . " " . map
|
||||
exec 'silent! imap <unique> <buffer> ' . map . ' <Plug>delimitMate' . map
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
function! s:ExtraMappings() "{{{
|
||||
" If pair is empty, delete both delimiters:
|
||||
inoremap <silent> <Plug>delimitMateBS <C-R>=delimitMate#BS()<CR>
|
||||
" If pair is empty, delete closing delimiter:
|
||||
inoremap <silent> <expr> <Plug>delimitMateS-BS delimitMate#WithinEmptyPair() ? "\<C-R>=delimitMate#Del()\<CR>" : "\<S-BS>"
|
||||
" Expand return if inside an empty pair:
|
||||
inoremap <silent> <Plug>delimitMateCR <C-R>=delimitMate#ExpandReturn()<CR>
|
||||
" Expand space if inside an empty pair:
|
||||
inoremap <silent> <Plug>delimitMateSpace <C-R>=delimitMate#ExpandSpace()<CR>
|
||||
" Jump out ot any empty pair:
|
||||
inoremap <silent> <Plug>delimitMateS-Tab <C-R>=delimitMate#JumpAny("\<S-Tab>")<CR>
|
||||
" Change char buffer on Del:
|
||||
inoremap <silent> <Plug>delimitMateDel <C-R>=delimitMate#Del()<CR>
|
||||
" Flush the char buffer on movement keystrokes or when leaving insert mode:
|
||||
for map in ['Esc', 'Left', 'Right', 'Home', 'End']
|
||||
exec 'inoremap <silent> <Plug>delimitMate'.map.' <C-R>=<SID>Finish()<CR><'.map.'>'
|
||||
if !hasmapto('<Plug>delimitMate'.map, 'i')
|
||||
exec 'silent! imap <unique> <buffer> <'.map.'> <Plug>delimitMate'.map
|
||||
endif
|
||||
endfor
|
||||
" Except when pop-up menu is active:
|
||||
for map in ['Up', 'Down', 'PageUp', 'PageDown', 'S-Down', 'S-Up']
|
||||
exec 'inoremap <silent> <expr> <Plug>delimitMate'.map.' pumvisible() ? "\<'.map.'>" : "\<C-R>=\<SID>Finish()\<CR>\<'.map.'>"'
|
||||
if !hasmapto('<Plug>delimitMate'.map, 'i')
|
||||
exec 'silent! imap <unique> <buffer> <'.map.'> <Plug>delimitMate'.map
|
||||
endif
|
||||
endfor
|
||||
" Avoid ambiguous mappings:
|
||||
for map in ['LeftMouse', 'RightMouse']
|
||||
exec 'inoremap <silent> <Plug>delimitMateM'.map.' <C-R>=delimitMate#Finish()<CR><'.map.'>'
|
||||
if !hasmapto('<Plug>delimitMate'.map, 'i')
|
||||
exec 'silent! imap <unique> <buffer> <'.map.'> <Plug>delimitMateM'.map
|
||||
endif
|
||||
endfor
|
||||
|
||||
" Map away!
|
||||
if !hasmapto('<Plug>delimitMateDel', 'i')
|
||||
silent! imap <unique> <buffer> <Del> <Plug>delimitMateDel
|
||||
endif
|
||||
if !hasmapto('<Plug>delimitMateBS','i')
|
||||
silent! imap <unique> <buffer> <BS> <Plug>delimitMateBS
|
||||
endif
|
||||
if !hasmapto('<Plug>delimitMateS-BS','i')
|
||||
silent! imap <unique> <buffer> <S-BS> <Plug>delimitMateS-BS
|
||||
endif
|
||||
if b:_l_delimitMate_expand_cr != 0 && !hasmapto('<Plug>delimitMateCR', 'i')
|
||||
silent! imap <unique> <buffer> <CR> <Plug>delimitMateCR
|
||||
endif
|
||||
if b:_l_delimitMate_expand_space != 0 && !hasmapto('<Plug>delimitMateSpace', 'i')
|
||||
silent! imap <unique> <buffer> <Space> <Plug>delimitMateSpace
|
||||
endif
|
||||
if b:_l_delimitMate_tab2exit && !hasmapto('<Plug>delimitMateS-Tab', 'i')
|
||||
silent! imap <unique> <buffer> <S-Tab> <Plug>delimitMateS-Tab
|
||||
endif
|
||||
" The following simply creates an ambiguous mapping so vim fully processes
|
||||
" the escape sequence for terminal keys, see 'ttimeout' for a rough
|
||||
" explanation, this just forces it to work
|
||||
if !has('gui_running')
|
||||
imap <silent> <C-[>OC <RIGHT>
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
"}}}
|
||||
|
||||
" Commands: {{{
|
||||
|
||||
call s:DelimitMateDo()
|
||||
|
||||
" Let me refresh without re-loading the buffer:
|
||||
command! -bar DelimitMateReload call s:DelimitMateDo(1)
|
||||
|
||||
" Quick test:
|
||||
command! -bar DelimitMateTest silent call s:TestMappingsDo()
|
||||
|
||||
" Switch On/Off:
|
||||
command! -bar DelimitMateSwitch call s:DelimitMateSwitch()
|
||||
"}}}
|
||||
|
||||
" Autocommands: {{{
|
||||
|
||||
augroup delimitMate
|
||||
au!
|
||||
" Run on file type change.
|
||||
"autocmd VimEnter * autocmd FileType * call <SID>DelimitMateDo()
|
||||
autocmd FileType * call <SID>DelimitMateDo()
|
||||
|
||||
" Run on new buffers.
|
||||
autocmd BufNewFile,BufRead,BufEnter *
|
||||
\ if !exists("b:loaded_delimitMate") |
|
||||
\ call <SID>DelimitMateDo() |
|
||||
\ endif
|
||||
|
||||
" Flush the char buffer:
|
||||
autocmd InsertEnter * call <SID>FlushBuffer()
|
||||
autocmd BufEnter *
|
||||
\ if mode() == 'i' |
|
||||
\ call <SID>FlushBuffer() |
|
||||
\ endif
|
||||
|
||||
augroup END
|
||||
|
||||
"}}}
|
||||
|
||||
" GetLatestVimScripts: 2754 1 :AutoInstall: delimitMate.vim
|
||||
" vim:foldmethod=marker:foldcolumn=4
|
||||
@@ -0,0 +1,6 @@
|
||||
autocmd BufNewFile,BufRead *.markdown,*.md,*.mdown,*.mkd,*.mkdn
|
||||
\ if &ft =~# '^\%(conf\|modula2\)$' |
|
||||
\ set ft=markdown |
|
||||
\ else |
|
||||
\ setf markdown |
|
||||
\ endif
|
||||
@@ -0,0 +1,18 @@
|
||||
" Vim filetype plugin
|
||||
" Language: Markdown
|
||||
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
|
||||
unlet! b:did_ftplugin
|
||||
|
||||
setlocal comments=fb:*,fb:-,fb:+,n:> commentstring=>\ %s
|
||||
setlocal formatoptions+=tcqln
|
||||
setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+
|
||||
|
||||
let b:undo_ftplugin .= "|setl cms< com< fo<"
|
||||
|
||||
" vim:set sw=2:
|
||||
@@ -0,0 +1,101 @@
|
||||
" Vim syntax file
|
||||
" Language: Markdown
|
||||
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
|
||||
" Filenames: *.markdown
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime! syntax/html.vim
|
||||
unlet! b:current_syntax
|
||||
|
||||
syn sync minlines=10
|
||||
syn case ignore
|
||||
|
||||
syn match markdownValid '[<>]\S\@!'
|
||||
syn match markdownValid '&\%(#\=\w*;\)\@!'
|
||||
|
||||
syn match markdownLineStart "^[<@]\@!" nextgroup=@markdownBlock
|
||||
|
||||
syn cluster markdownBlock contains=markdownH1,markdownH2,markdownH3,markdownH4,markdownH5,markdownH6,markdownBlockquote,markdownListMarker,markdownOrderedListMarker,markdownCodeBlock,markdownRule
|
||||
syn cluster markdownInline contains=markdownLineBreak,markdownLinkText,markdownItalic,markdownBold,markdownCode,markdownEscape,@htmlTop
|
||||
|
||||
syn match markdownH1 ".\+\n=\+$" contained contains=@markdownInline,markdownHeadingRule
|
||||
syn match markdownH2 ".\+\n-\+$" contained contains=@markdownInline,markdownHeadingRule
|
||||
|
||||
syn match markdownHeadingRule "^[=-]\+$" contained
|
||||
|
||||
syn region markdownH1 matchgroup=markdownHeadingDelimiter start="##\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
|
||||
syn region markdownH2 matchgroup=markdownHeadingDelimiter start="###\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
|
||||
syn region markdownH3 matchgroup=markdownHeadingDelimiter start="####\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
|
||||
syn region markdownH4 matchgroup=markdownHeadingDelimiter start="#####\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
|
||||
syn region markdownH5 matchgroup=markdownHeadingDelimiter start="######\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
|
||||
syn region markdownH6 matchgroup=markdownHeadingDelimiter start="#######\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
|
||||
|
||||
syn match markdownBlockquote ">\s" contained nextgroup=@markdownBlock
|
||||
|
||||
syn region markdownCodeBlock start=" \|\t" end="$" contained
|
||||
|
||||
" TODO: real nesting
|
||||
syn match markdownListMarker " \{0,4\}[-*+]\%(\s\+\S\)\@=" contained
|
||||
syn match markdownOrderedListMarker " \{0,4}\<\d\+\.\%(\s*\S\)\@=" contained
|
||||
|
||||
syn match markdownRule "\* *\* *\*[ *]*$" contained
|
||||
syn match markdownRule "- *- *-[ -]*$" contained
|
||||
|
||||
syn match markdownLineBreak "\s\{2,\}$"
|
||||
|
||||
syn region markdownIdDeclaration matchgroup=markdownLinkDelimiter start="^ \{0,3\}!\=\[" end="\]:" oneline keepend nextgroup=markdownUrl skipwhite
|
||||
syn match markdownUrl "\S\+" nextgroup=markdownUrlTitle skipwhite contained
|
||||
syn region markdownUrl matchgroup=markdownUrlDelimiter start="<" end=">" oneline keepend nextgroup=markdownUrlTitle skipwhite contained
|
||||
syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+"+ end=+"+ keepend contained
|
||||
syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+'+ end=+'+ keepend contained
|
||||
syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+(+ end=+)+ keepend contained
|
||||
|
||||
syn region markdownLinkText matchgroup=markdownLinkTextDelimiter start="!\=\[\%(\_[^]]*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@=" keepend nextgroup=markdownLink,markdownId skipwhite contains=@markdownInline,markdownLineStart
|
||||
syn region markdownLink matchgroup=markdownLinkDelimiter start="(" end=")" contains=markdownUrl keepend contained
|
||||
syn region markdownId matchgroup=markdownIdDelimiter start="\[" end="\]" keepend contained
|
||||
syn region markdownAutomaticLink matchgroup=markdownUrlDelimiter start="<\%(\w\+:\|[[:alnum:]_+-]\+@\)\@=" end=">" keepend oneline
|
||||
|
||||
syn region markdownItalic start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" keepend contains=markdownLineStart
|
||||
syn region markdownItalic start="\S\@<=_\|_\S\@=" end="\S\@<=_\|_\S\@=" keepend contains=markdownLineStart
|
||||
syn region markdownBold start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend contains=markdownLineStart
|
||||
syn region markdownBold start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend contains=markdownLineStart
|
||||
syn region markdownCode matchgroup=markdownCodeDelimiter start="`" end="`" transparent keepend contains=markdownLineStart
|
||||
syn region markdownCode matchgroup=markdownCodeDelimiter start="`` \=" end=" \=``" keepend contains=markdownLineStart
|
||||
|
||||
syn match markdownEscape "\\[][\\`*_{}()#+.!-]"
|
||||
|
||||
hi def link markdownH1 htmlH1
|
||||
hi def link markdownH2 htmlH2
|
||||
hi def link markdownH3 htmlH3
|
||||
hi def link markdownH4 htmlH4
|
||||
hi def link markdownH5 htmlH5
|
||||
hi def link markdownH6 htmlH6
|
||||
hi def link markdownHeadingRule markdownRule
|
||||
hi def link markdownHeadingDelimiter Delimiter
|
||||
hi def link markdownOrderedListMarker markdownListMarker
|
||||
hi def link markdownListMarker htmlTagName
|
||||
hi def link markdownBlockquote Comment
|
||||
hi def link markdownRule PreProc
|
||||
|
||||
hi def link markdownLinkText htmlLink
|
||||
hi def link markdownIdDeclaration Typedef
|
||||
hi def link markdownId Type
|
||||
hi def link markdownAutomaticLink markdownUrl
|
||||
hi def link markdownUrl Float
|
||||
hi def link markdownUrlTitle String
|
||||
hi def link markdownIdDelimiter markdownLinkDelimiter
|
||||
hi def link markdownUrlDelimiter htmlTag
|
||||
hi def link markdownUrlTitleDelimiter Delimiter
|
||||
|
||||
hi def link markdownItalic htmlItalic
|
||||
hi def link markdownBold htmlBold
|
||||
hi def link markdownCodeDelimiter Delimiter
|
||||
|
||||
hi def link markdownEscape Special
|
||||
|
||||
let b:current_syntax = "markdown"
|
||||
|
||||
" vim:set sw=2:
|
||||
@@ -0,0 +1,2 @@
|
||||
*~
|
||||
*.swp
|
||||
@@ -0,0 +1,18 @@
|
||||
desc "Copy the vim/doc files into ~/.vim"
|
||||
task :deploy_local do
|
||||
run "cp plugin/NERD_commenter.vim ~/.vim/plugin"
|
||||
run "cp doc/NERD_commenter.txt ~/.vim/doc"
|
||||
end
|
||||
|
||||
|
||||
desc "Create a zip archive for release to vim.org"
|
||||
task :zip do
|
||||
abort "NERD_commenter.zip already exists, aborting" if File.exist?("NERD_commenter.zip")
|
||||
run "zip NERD_commenter.zip plugin/NERD_commenter.vim doc/NERD_commenter.txt"
|
||||
end
|
||||
|
||||
def run(cmd)
|
||||
puts "Executing: #{cmd}"
|
||||
system cmd
|
||||
end
|
||||
|
||||
@@ -0,0 +1,991 @@
|
||||
*NERD_commenter.txt* Plugin for commenting code
|
||||
|
||||
|
||||
NERD COMMENTER REFERENCE MANUAL~
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
==============================================================================
|
||||
CONTENTS *NERDCommenterContents*
|
||||
|
||||
1.Intro...................................|NERDCommenter|
|
||||
2.Functionality provided..................|NERDComFunctionality|
|
||||
2.1 Functionality Summary.............|NERDComFunctionalitySummary|
|
||||
2.2 Functionality Details.............|NERDComFunctionalityDetails|
|
||||
2.2.1 Comment map.................|NERDComComment|
|
||||
2.2.2 Nested comment map..........|NERDComNestedComment|
|
||||
2.2.3 Toggle comment map..........|NERDComToggleComment|
|
||||
2.2.4 Minimal comment map.........|NERDComMinimalComment|
|
||||
2.2.5 Invert comment map..........|NERDComInvertComment|
|
||||
2.2.6 Sexy comment map............|NERDComSexyComment|
|
||||
2.2.7 Yank comment map............|NERDComYankComment|
|
||||
2.2.8 Comment to EOL map..........|NERDComEOLComment|
|
||||
2.2.9 Append com to line map......|NERDComAppendComment|
|
||||
2.2.10 Insert comment map.........|NERDComInsertComment|
|
||||
2.2.11 Use alternate delims map...|NERDComAltDelim|
|
||||
2.2.12 Comment aligned maps.......|NERDComAlignedComment|
|
||||
2.2.13 Uncomment line map.........|NERDComUncommentLine|
|
||||
2.3 Supported filetypes...............|NERDComFiletypes|
|
||||
2.4 Sexy Comments.....................|NERDComSexyComments|
|
||||
2.5 The NERDComment function..........|NERDComNERDComment|
|
||||
3.Options.................................|NERDComOptions|
|
||||
3.1 Options summary...................|NERDComOptionsSummary|
|
||||
3.2 Options details...................|NERDComOptionsDetails|
|
||||
3.3 Default delimiter Options.........|NERDComDefaultDelims|
|
||||
4. Customising key mappings...............|NERDComMappings|
|
||||
5. Issues with the script.................|NERDComIssues|
|
||||
5.1 Delimiter detection heuristics....|NERDComHeuristics|
|
||||
5.2 Nesting issues....................|NERDComNesting|
|
||||
6.About.. ............................|NERDComAbout|
|
||||
7.Changelog...............................|NERDComChangelog|
|
||||
8.Credits.................................|NERDComCredits|
|
||||
9.License.................................|NERDComLicense|
|
||||
|
||||
==============================================================================
|
||||
1. Intro *NERDCommenter*
|
||||
|
||||
The NERD commenter provides many different commenting operations and styles
|
||||
which are invoked via key mappings and a menu. These operations are available
|
||||
for most filetypes.
|
||||
|
||||
There are also options that allow to tweak the commenting engine to your
|
||||
taste.
|
||||
|
||||
==============================================================================
|
||||
2. Functionality provided *NERDComFunctionality*
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.1 Functionality summary *NERDComFunctionalitySummary*
|
||||
|
||||
The following key mappings are provided by default (there is also a menu
|
||||
with items corresponding to all the mappings below):
|
||||
|
||||
[count],cc |NERDComComment|
|
||||
Comment out the current line or text selected in visual mode.
|
||||
|
||||
|
||||
[count],cn |NERDComNestedComment|
|
||||
Same as ,cc but forces nesting.
|
||||
|
||||
|
||||
[count],c<space> |NERDComToggleComment|
|
||||
Toggles the comment state of the selected line(s). If the topmost selected
|
||||
line is commented, all selected lines are uncommented and vice versa.
|
||||
|
||||
|
||||
[count],cm |NERDComMinimalComment|
|
||||
Comments the given lines using only one set of multipart delimiters.
|
||||
|
||||
|
||||
[count],ci |NERDComInvertComment|
|
||||
Toggles the comment state of the selected line(s) individually.
|
||||
|
||||
|
||||
[count],cs |NERDComSexyComment|
|
||||
Comments out the selected lines ``sexily''
|
||||
|
||||
|
||||
[count],cy |NERDComYankComment|
|
||||
Same as ,cc except that the commented line(s) are yanked first.
|
||||
|
||||
|
||||
,c$ |NERDComEOLComment|
|
||||
Comments the current line from the cursor to the end of line.
|
||||
|
||||
|
||||
,cA |NERDComAppendComment|
|
||||
Adds comment delimiters to the end of line and goes into insert mode between
|
||||
them.
|
||||
|
||||
|
||||
|NERDComInsertComment|
|
||||
Adds comment delimiters at the current cursor position and inserts between.
|
||||
Disabled by default.
|
||||
|
||||
|
||||
,ca |NERDComAltDelim|
|
||||
Switches to the alternative set of delimiters.
|
||||
|
||||
|
||||
[count],cl
|
||||
[count],cb |NERDComAlignedComment|
|
||||
Same as |NERDComComment| except that the delimiters are aligned down the
|
||||
left side (,cl) or both sides (,cb).
|
||||
|
||||
|
||||
[count],cu |NERDComUncommentLine|
|
||||
Uncomments the selected line(s).
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2 Functionality details *NERDComFunctionalityDetails*
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.1 Comment map *NERDComComment*
|
||||
|
||||
Default mapping: [count],cc
|
||||
Mapped to: <plug>NERDCommenterComment
|
||||
Applicable modes: normal visual visual-line visual-block.
|
||||
|
||||
|
||||
Comments out the current line. If multiple lines are selected in visual-line
|
||||
mode, they are all commented out. If some text is selected in visual or
|
||||
visual-block mode then the script will try to comment out the exact text that
|
||||
is selected using multi-part delimiters if they are available.
|
||||
|
||||
If a [count] is given in normal mode, the mapping works as though that many
|
||||
lines were selected in visual-line mode.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.2 Nested comment map *NERDComNestedComment*
|
||||
|
||||
Default mapping: [count],cn
|
||||
Mapped to: <plug>NERDCommenterNest
|
||||
Applicable modes: normal visual visual-line visual-block.
|
||||
|
||||
Performs nested commenting. Works the same as ,cc except that if a line is
|
||||
already commented then it will be commented again.
|
||||
|
||||
If |'NERDUsePlaceHolders'| is set then the previous comment delimiters will
|
||||
be replaced by place-holder delimiters if needed. Otherwise the nested
|
||||
comment will only be added if the current commenting delimiters have no right
|
||||
delimiter (to avoid syntax errors)
|
||||
|
||||
If a [count] is given in normal mode, the mapping works as though that many
|
||||
lines were selected in visual-line mode.
|
||||
|
||||
Related options:
|
||||
|'NERDDefaultNesting'|
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.3 Toggle comment map *NERDComToggleComment*
|
||||
|
||||
Default mapping: [count],c<space>
|
||||
Mapped to: <plug>NERDCommenterToggle
|
||||
Applicable modes: normal visual-line.
|
||||
|
||||
Toggles commenting of the lines selected. The behaviour of this mapping
|
||||
depends on whether the first line selected is commented or not. If so, all
|
||||
selected lines are uncommented and vice versa.
|
||||
|
||||
With this mapping, a line is only considered to be commented if it starts with
|
||||
a left delimiter.
|
||||
|
||||
If a [count] is given in normal mode, the mapping works as though that many
|
||||
lines were selected in visual-line mode.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.4 Minimal comment map *NERDComMinimalComment*
|
||||
|
||||
Default mapping: [count],cm
|
||||
Mapped to: <plug>NERDCommenterMinimal
|
||||
Applicable modes: normal visual-line.
|
||||
|
||||
Comments the selected lines using one set of multipart delimiters if possible.
|
||||
|
||||
For example: if you are programming in c and you select 5 lines and press ,cm
|
||||
then a '/*' will be placed at the start of the top line and a '*/' will be
|
||||
placed at the end of the last line.
|
||||
|
||||
Sets of multipart comment delimiters that are between the top and bottom
|
||||
selected lines are replaced with place holders (see |'NERDLPlace'|) if
|
||||
|'NERDUsePlaceHolders'| is set for the current filetype. If it is not, then
|
||||
the comment will be aborted if place holders are required to prevent illegal
|
||||
syntax.
|
||||
|
||||
If a [count] is given in normal mode, the mapping works as though that many
|
||||
lines were selected in visual-line mode.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.5 Invert comment map *NERDComInvertComment*
|
||||
|
||||
Default mapping: ,ci
|
||||
Mapped to: <plug>NERDCommenterInvert
|
||||
Applicable modes: normal visual-line.
|
||||
|
||||
Inverts the commented state of each selected line. If the a selected line is
|
||||
commented then it is uncommented and vice versa. Each line is examined and
|
||||
commented/uncommented individually.
|
||||
|
||||
With this mapping, a line is only considered to be commented if it starts with
|
||||
a left delimiter.
|
||||
|
||||
If a [count] is given in normal mode, the mapping works as though that many
|
||||
lines were selected in visual-line mode.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.6 Sexy comment map *NERDComSexyComment*
|
||||
|
||||
Default mapping: [count],cs
|
||||
Mapped to: <plug>NERDCommenterSexy
|
||||
Applicable modes: normal, visual-line.
|
||||
|
||||
Comments the selected line(s) ``sexily''... see |NERDComSexyComments| for
|
||||
a description of what sexy comments are. Can only be done on filetypes for
|
||||
which there is at least one set of multipart comment delimiters specified.
|
||||
|
||||
Sexy comments cannot be nested and lines inside a sexy comment cannot be
|
||||
commented again.
|
||||
|
||||
If a [count] is given in normal mode, the mapping works as though that many
|
||||
lines were selected in visual-line mode.
|
||||
|
||||
Related options:
|
||||
|'NERDCompactSexyComs'|
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.7 Yank comment map *NERDComYankComment*
|
||||
|
||||
Default mapping: [count],cy
|
||||
Mapped to: <plug>NERDCommenterYank
|
||||
Applicable modes: normal visual visual-line visual-block.
|
||||
|
||||
Same as ,cc except that it yanks the line(s) that are commented first.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.8 Comment to EOL map *NERDComEOLComment*
|
||||
|
||||
Default mapping: ,c$
|
||||
Mapped to: <plug>NERDCommenterToEOL
|
||||
Applicable modes: normal.
|
||||
|
||||
Comments the current line from the current cursor position up to the end of
|
||||
the line.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.9 Append com to line map *NERDComAppendComment*
|
||||
|
||||
Default mapping: ,cA
|
||||
Mapped to: <plug>NERDCommenterAppend
|
||||
Applicable modes: normal.
|
||||
|
||||
Appends comment delimiters to the end of the current line and goes
|
||||
to insert mode between the new delimiters.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.10 Insert comment map *NERDComInsertComment*
|
||||
|
||||
Default mapping: disabled by default.
|
||||
Map it to: <plug>NERDCommenterInInsert
|
||||
Applicable modes: insert.
|
||||
|
||||
Adds comment delimiters at the current cursor position and inserts
|
||||
between them.
|
||||
|
||||
NOTE: prior to version 2.1.17 this was mapped to ctrl-c. To restore this
|
||||
mapping add >
|
||||
let NERDComInsertMap='<c-c>'
|
||||
<
|
||||
to your vimrc.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.11 Use alternate delims map *NERDComAltDelim*
|
||||
|
||||
Default mapping: ,ca
|
||||
Mapped to: <plug>NERDCommenterAltDelims
|
||||
Applicable modes: normal.
|
||||
|
||||
Changes to the alternative commenting style if one is available. For example,
|
||||
if the user is editing a c++ file using // comments and they hit ,ca
|
||||
then they will be switched over to /**/ comments.
|
||||
|
||||
See also |NERDComDefaultDelims|
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.12 Comment aligned maps *NERDComAlignedComment*
|
||||
|
||||
Default mappings: [count],cl [count],cb
|
||||
Mapped to: <plug>NERDCommenterAlignLeft
|
||||
<plug>NERDCommenterAlignBoth
|
||||
Applicable modes: normal visual-line.
|
||||
|
||||
Same as ,cc except that the comment delimiters are aligned on the left side or
|
||||
both sides respectively. These comments are always nested if the line(s) are
|
||||
already commented.
|
||||
|
||||
If a [count] is given in normal mode, the mapping works as though that many
|
||||
lines were selected in visual-line mode.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.13 Uncomment line map *NERDComUncommentLine*
|
||||
|
||||
Default mapping: [count],cu
|
||||
Mapped to: <plug>NERDCommenterUncomment
|
||||
Applicable modes: normal visual visual-line visual-block.
|
||||
|
||||
Uncomments the current line. If multiple lines are selected in
|
||||
visual mode then they are all uncommented.
|
||||
|
||||
When uncommenting, if the line contains multiple sets of delimiters then the
|
||||
``outtermost'' pair of delimiters will be removed.
|
||||
|
||||
The script uses a set of heurisics to distinguish ``real'' delimiters from
|
||||
``fake'' ones when uncommenting. See |NERDComIssues| for details.
|
||||
|
||||
If a [count] is given in normal mode, the mapping works as though that many
|
||||
lines were selected in visual-line mode.
|
||||
|
||||
Related options:
|
||||
|'NERDRemoveAltComs'|
|
||||
|'NERDRemoveExtraSpaces'|
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.3 Supported filetypes *NERDComFiletypes*
|
||||
|
||||
Filetypes that can be commented by this plugin:
|
||||
abaqus abc acedb ada ahdl amiga aml ampl ant apache apachestyle asm68k asm asn
|
||||
aspvbs atlas autohotkey autoit automake ave awk basic b bc bdf bib bindzone
|
||||
bst btm caos catalog c cfg cg ch changelog cl clean clipper cmake conf config
|
||||
context cpp crontab cs csc csp css cterm cupl csv cvs dcl debchangelog
|
||||
debcontrol debsources def diff django docbk dns dosbatch dosini dot dracula
|
||||
dsl dtd dtml dylan ecd eiffel elf elmfilt erlang eruby eterm expect exports
|
||||
fetchmail fgl focexec form fortran foxpro fstab fvwm fx gdb gdmo geek
|
||||
gentoo-package-keywords' gentoo-package-mask' gentoo-package-use' gnuplot
|
||||
gtkrc haskell hb h help hercules hog html htmldjango htmlos ia64 icon idlang
|
||||
idl indent inform inittab ishd iss ist jam java javascript jess jgraph
|
||||
jproperties jproperties jsp kconfig kix kscript lace lex lftp lifelines lilo
|
||||
lisp lite lotos lout lprolog lscript lss lua lynx m4 mail make maple masm
|
||||
master matlab mel mf mib mma model moduala. modula2 modula3 monk mush muttrc
|
||||
named nasm nastran natural ncf netdict netrw nqc nroff nsis objc ocaml occam
|
||||
omlet omnimark openroad opl ora otl ox pascal passwd pcap pccts perl pfmain
|
||||
php phtml pic pike pilrc pine plaintex plm plsql po postscr pov povini ppd
|
||||
ppwiz procmail progress prolog psf ptcap python python qf radiance ratpoison r
|
||||
rc readline rebol registry remind rexx robots rpl rtf ruby sa samba sas sass
|
||||
sather scheme scilab screen scsh sdl sed selectbuf sgml sgmldecl sgmllnx sh
|
||||
sicad simula sinda skill slang sl slrnrc sm smarty smil smith sml snnsnet
|
||||
snnspat snnsres snobol4 spec specman spice sql sqlforms sqlj sqr squid st stp
|
||||
strace svn systemverilog tads taglist tags tak tasm tcl terminfo tex text
|
||||
plaintex texinfo texmf tf tidy tli trasys tsalt tsscl tssgm uc uil vb verilog
|
||||
verilog_systemverilog vgrindefs vhdl vim viminfo virata vo_base vrml vsejcl
|
||||
webmacro wget winbatch wml wvdial xdefaults xf86conf xhtml xkb xmath xml
|
||||
xmodmap xpm2 xpm xslt yacc yaml z8a
|
||||
|
||||
If a language is not in the list of hardcoded supported filetypes then the
|
||||
&commentstring vim option is used.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.4 Sexy Comments *NERDComSexyComments*
|
||||
These are comments that use one set of multipart comment delimiters as well as
|
||||
one other marker symbol. For example: >
|
||||
/*
|
||||
* This is a c style sexy comment
|
||||
* So there!
|
||||
*/
|
||||
|
||||
/* This is a c style sexy comment
|
||||
* So there!
|
||||
* But this one is ``compact'' style */
|
||||
<
|
||||
Here the multipart delimiters are /* and */ and the marker is *.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.5 The NERDComment function *NERDComNERDComment*
|
||||
|
||||
All of the NERD commenter mappings and menu items invoke a single function
|
||||
which delegates the commenting work to other functions. This function is
|
||||
public and has the prototype: >
|
||||
function! NERDComment(isVisual, type)
|
||||
<
|
||||
The arguments to this function are simple:
|
||||
- isVisual: if you wish to do any kind of visual comment then set this to
|
||||
1 and the function will use the '< and '> marks to find the comment
|
||||
boundries. If set to 0 then the function will operate on the current
|
||||
line.
|
||||
- type: is used to specify what type of commenting operation is to be
|
||||
performed, and it can be one of the following: "sexy", "invert",
|
||||
"minimal", "toggle", "alignLeft", "alignBoth", "norm", "nested",
|
||||
"toEOL", "append", "insert", "uncomment", "yank"
|
||||
|
||||
For example, if you typed >
|
||||
:call NERDComment(1, 'sexy')
|
||||
<
|
||||
then the script would do a sexy comment on the last visual selection.
|
||||
|
||||
|
||||
==============================================================================
|
||||
3. Options *NERDComOptions*
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.1 Options summary *NERDComOptionsSummary*
|
||||
|
||||
|'loaded_nerd_comments'| Turns off the script.
|
||||
|'NERDAllowAnyVisualDelims'| Allows multipart alternative delims to
|
||||
be used when commenting in
|
||||
visual/visual-block mode.
|
||||
|'NERDBlockComIgnoreEmpty'| Forces right delims to be placed when
|
||||
doing visual-block comments.
|
||||
|'NERDCommentWholeLinesInVMode'| Changes behaviour of visual comments.
|
||||
|'NERDCreateDefaultMappings'| Turn the default mappings on/off.
|
||||
|'NERDDefaultNesting'| Tells the script to use nested comments
|
||||
by default.
|
||||
|'NERDMenuMode'| Specifies how the NERD commenter menu
|
||||
will appear (if at all).
|
||||
|'NERDLPlace'| Specifies what to use as the left
|
||||
delimiter placeholder when nesting
|
||||
comments.
|
||||
|'NERDUsePlaceHolders'| Specifies which filetypes may use
|
||||
placeholders when nesting comments.
|
||||
|'NERDRemoveAltComs'| Tells the script whether to remove
|
||||
alternative comment delimiters when
|
||||
uncommenting.
|
||||
|'NERDRemoveExtraSpaces'| Tells the script to always remove the
|
||||
extra spaces when uncommenting
|
||||
(regardless of whether NERDSpaceDelims
|
||||
is set)
|
||||
|'NERDRPlace'| Specifies what to use as the right
|
||||
delimiter placeholder when nesting
|
||||
comments.
|
||||
|'NERDSpaceDelims'| Specifies whether to add extra spaces
|
||||
around delimiters when commenting, and
|
||||
whether to remove them when
|
||||
uncommenting.
|
||||
|'NERDCompactSexyComs'| Specifies whether to use the compact
|
||||
style sexy comments.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.3 Options details *NERDComOptionsDetails*
|
||||
|
||||
To enable any of the below options you should put the given line in your
|
||||
~/.vimrc
|
||||
|
||||
*'loaded_nerd_comments'*
|
||||
If this script is driving you insane you can turn it off by setting this
|
||||
option >
|
||||
let loaded_nerd_comments=1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDAllowAnyVisualDelims'*
|
||||
Values: 0 or 1.
|
||||
Default: 1.
|
||||
|
||||
If set to 1 then, when doing a visual or visual-block comment (but not a
|
||||
visual-line comment), the script will choose the right delimiters to use for
|
||||
the comment. This means either using the current delimiters if they are
|
||||
multipart or using the alternative delimiters if THEY are multipart. For
|
||||
example if we are editing the following java code: >
|
||||
float foo = 1221;
|
||||
float bar = 324;
|
||||
System.out.println(foo * bar);
|
||||
<
|
||||
If we are using // comments and select the "foo" and "bar" in visual-block
|
||||
mode, as shown left below (where '|'s are used to represent the visual-block
|
||||
boundary), and comment it then the script will use the alternative delims as
|
||||
shown on the right: >
|
||||
|
||||
float |foo| = 1221; float /*foo*/ = 1221;
|
||||
float |bar| = 324; float /*bar*/ = 324;
|
||||
System.out.println(foo * bar); System.out.println(foo * bar);
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDBlockComIgnoreEmpty'*
|
||||
Values: 0 or 1.
|
||||
Default: 1.
|
||||
|
||||
This option affects visual-block mode commenting. If this option is turned
|
||||
on, lines that begin outside the right boundary of the selection block will be
|
||||
ignored.
|
||||
|
||||
For example, if you are commenting this chunk of c code in visual-block mode
|
||||
(where the '|'s are used to represent the visual-block boundary) >
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|int| main(){
|
||||
| | printf("SUCK THIS\n");
|
||||
| | while(1){
|
||||
| | fork();
|
||||
| | }
|
||||
|} |
|
||||
<
|
||||
If NERDBlockComIgnoreEmpty=0 then this code will become: >
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
/*int*/ main(){
|
||||
/* */ printf("SUCK THIS\n");
|
||||
/* */ while(1){
|
||||
/* */ fork();
|
||||
/* */ }
|
||||
/*} */
|
||||
<
|
||||
Otherwise, the code block would become: >
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
/*int*/ main(){
|
||||
printf("SUCK THIS\n");
|
||||
while(1){
|
||||
fork();
|
||||
}
|
||||
/*} */
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDCommentWholeLinesInVMode'*
|
||||
Values: 0, 1 or 2.
|
||||
Default: 0.
|
||||
|
||||
By default the script tries to comment out exactly what is selected in visual
|
||||
mode (v). For example if you select and comment the following c code (using |
|
||||
to represent the visual boundary): >
|
||||
in|t foo = 3;
|
||||
int bar =| 9;
|
||||
int baz = foo + bar;
|
||||
<
|
||||
This will result in: >
|
||||
in/*t foo = 3;*/
|
||||
/*int bar =*/ 9;
|
||||
int baz = foo + bar;
|
||||
<
|
||||
But some people prefer it if the whole lines are commented like: >
|
||||
/*int foo = 3;*/
|
||||
/*int bar = 9;*/
|
||||
int baz = foo + bar;
|
||||
<
|
||||
If you prefer the second option then stick this line in your vimrc: >
|
||||
let NERDCommentWholeLinesInVMode=1
|
||||
<
|
||||
|
||||
If the filetype you are editing only has no multipart delimiters (for example
|
||||
a shell script) and you hadnt set this option then the above would become >
|
||||
in#t foo = 3;
|
||||
#int bar = 9;
|
||||
<
|
||||
(where # is the comment delimiter) as this is the closest the script can
|
||||
come to commenting out exactly what was selected. If you prefer for whole
|
||||
lines to be commented out when there is no multipart delimiters but the EXACT
|
||||
text that was selected to be commented out if there IS multipart delimiters
|
||||
then stick the following line in your vimrc: >
|
||||
let NERDCommentWholeLinesInVMode=2
|
||||
<
|
||||
|
||||
Note that this option does not affect the behaviour of commenting in
|
||||
|visual-block| mode.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDCreateDefaultMappings'*
|
||||
Values: 0 or 1.
|
||||
Default: 1.
|
||||
|
||||
If set to 0, none of the default mappings will be created.
|
||||
|
||||
See also |NERDComMappings|.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDRemoveAltComs'*
|
||||
Values: 0 or 1.
|
||||
Default: 1.
|
||||
|
||||
When uncommenting a line (for a filetype with an alternative commenting style)
|
||||
this option tells the script whether to look for, and remove, comment
|
||||
delimiters of the alternative style.
|
||||
|
||||
For example, if you are editing a c++ file using // style comments and you go
|
||||
,cu on this line: >
|
||||
/* This is a c++ comment baby! */
|
||||
<
|
||||
It will not be uncommented if the NERDRemoveAltComs is set to 0.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDRemoveExtraSpaces'*
|
||||
Values: 0 or 1.
|
||||
Default: 1.
|
||||
|
||||
By default, the NERD commenter will remove spaces around comment delimiters if
|
||||
either:
|
||||
1. |'NERDSpaceDelims'| is set to 1.
|
||||
2. NERDRemoveExtraSpaces is set to 1.
|
||||
|
||||
This means that if we have the following lines in a c code file: >
|
||||
/* int foo = 5; */
|
||||
/* int bar = 10; */
|
||||
int baz = foo + bar
|
||||
<
|
||||
If either of the above conditions hold then if these lines are uncommented
|
||||
they will become: >
|
||||
int foo = 5;
|
||||
int bar = 10;
|
||||
int baz = foo + bar
|
||||
<
|
||||
Otherwise they would become: >
|
||||
int foo = 5;
|
||||
int bar = 10;
|
||||
int baz = foo + bar
|
||||
<
|
||||
If you want the spaces to be removed only if |'NERDSpaceDelims'| is set then
|
||||
set NERDRemoveExtraSpaces to 0.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDLPlace'*
|
||||
*'NERDRPlace'*
|
||||
Values: arbitrary string.
|
||||
Default:
|
||||
NERDLPlace: "[>"
|
||||
NERDRPlace: "<]"
|
||||
|
||||
These options are used to control the strings used as place-holder delimiters.
|
||||
Place holder delimiters are used when performing nested commenting when the
|
||||
filetype supports commenting styles with both left and right delimiters.
|
||||
To set these options use lines like: >
|
||||
let NERDLPlace="FOO"
|
||||
let NERDRPlace="BAR"
|
||||
<
|
||||
Following the above example, if we have line of c code: >
|
||||
/* int horse */
|
||||
<
|
||||
and we comment it with ,cn it will be changed to: >
|
||||
/*FOO int horse BAR*/
|
||||
<
|
||||
When we uncomment this line it will go back to what it was.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDMenuMode'*
|
||||
Values: 0, 1, 2, 3.
|
||||
Default: 3
|
||||
|
||||
This option can take 4 values:
|
||||
"0": Turns the menu off.
|
||||
"1": Turns the 'comment' menu on with no menu shortcut.
|
||||
"2": Turns the 'comment 'menu on with <alt>-c as the shortcut.
|
||||
"3": Turns the 'Plugin -> comment' menu on with <alt>-c as the shortcut.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDUsePlaceHolders'*
|
||||
Values: 0 or 1.
|
||||
Default 1.
|
||||
|
||||
This option is used to specify whether place-holder delimiters should be used
|
||||
when creating a nested comment.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDSpaceDelims'*
|
||||
Values: 0 or 1.
|
||||
Default 0.
|
||||
|
||||
Some people prefer a space after the left delimiter and before the right
|
||||
delimiter like this: >
|
||||
/* int foo=2; */
|
||||
<
|
||||
as opposed to this: >
|
||||
/*int foo=2;*/
|
||||
<
|
||||
If you want spaces to be added then set NERDSpaceDelims to 1 in your vimrc.
|
||||
|
||||
See also |'NERDRemoveExtraSpaces'|.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDCompactSexyComs'*
|
||||
Values: 0 or 1.
|
||||
Default 0.
|
||||
|
||||
Some people may want their sexy comments to be like this: >
|
||||
/* Hi There!
|
||||
* This is a sexy comment
|
||||
* in c */
|
||||
<
|
||||
As opposed to like this: >
|
||||
/*
|
||||
* Hi There!
|
||||
* This is a sexy comment
|
||||
* in c
|
||||
*/
|
||||
<
|
||||
If this option is set to 1 then the top style will be used.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDDefaultNesting'*
|
||||
Values: 0 or 1.
|
||||
Default 1.
|
||||
|
||||
When this option is set to 1, comments are nested automatically. That is, if
|
||||
you hit ,cc on a line that is already commented it will be commented again
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.3 Default delimiter customisation *NERDComDefaultDelims*
|
||||
|
||||
If you want the NERD commenter to use the alternative delimiters for a
|
||||
specific filetype by default then put a line of this form into your vimrc: >
|
||||
let NERD_<filetype>_alt_style=1
|
||||
<
|
||||
Example: java uses // style comments by default, but you want it to default to
|
||||
/* */ style comments instead. You would put this line in your vimrc: >
|
||||
let NERD_java_alt_style=1
|
||||
<
|
||||
|
||||
See |NERDComAltDelim| for switching commenting styles at runtime.
|
||||
|
||||
==============================================================================
|
||||
4. Key mapping customisation *NERDComMappings*
|
||||
|
||||
To change a mapping just map another key combo to the internal <plug> mapping.
|
||||
For example, to remap the |NERDComComment| mapping to ",omg" you would put
|
||||
this line in your vimrc: >
|
||||
map ,omg <plug>NERDCommenterComment
|
||||
<
|
||||
This will stop the corresponding default mappings from being created.
|
||||
|
||||
See the help for the mapping in question to see which <plug> mapping to
|
||||
map to.
|
||||
|
||||
See also |'NERDCreateDefaultMappings'|.
|
||||
|
||||
==============================================================================
|
||||
5. Issues with the script *NERDComIssues*
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
5.1 Delimiter detection heuristics *NERDComHeuristics*
|
||||
|
||||
Heuristics are used to distinguish the real comment delimiters
|
||||
|
||||
Because we have comment mappings that place delimiters in the middle of lines,
|
||||
removing comment delimiters is a bit tricky. This is because if comment
|
||||
delimiters appear in a line doesnt mean they really ARE delimiters. For
|
||||
example, Java uses // comments but the line >
|
||||
System.out.println("//");
|
||||
<
|
||||
clearly contains no real comment delimiters.
|
||||
|
||||
To distinguish between ``real'' comment delimiters and ``fake'' ones we use a
|
||||
set of heuristics. For example, one such heuristic states that any comment
|
||||
delimiter that has an odd number of non-escaped " characters both preceding
|
||||
and following it on the line is not a comment because it is probably part of a
|
||||
string. These heuristics, while usually pretty accurate, will not work for all
|
||||
cases.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
5.2 Nesting issues *NERDComNesting*
|
||||
|
||||
If we have some line of code like this: >
|
||||
/*int foo */ = /*5 + 9;*/
|
||||
<
|
||||
This will not be uncommented legally. The NERD commenter will remove the
|
||||
"outter most" delimiters so the line will become: >
|
||||
int foo */ = /*5 + 9;
|
||||
<
|
||||
which almost certainly will not be what you want. Nested sets of comments will
|
||||
uncomment fine though. Eg: >
|
||||
/*int/* foo =*/ 5 + 9;*/
|
||||
<
|
||||
will become: >
|
||||
int/* foo =*/ 5 + 9;
|
||||
<
|
||||
(Note that in the above examples I have deliberately not used place holders
|
||||
for simplicity)
|
||||
|
||||
==============================================================================
|
||||
6. About *NERDComAbout*
|
||||
|
||||
The author of the NERD commenter is Martyzillatron --- the half robot, half
|
||||
dinosaur bastard son of Megatron and Godzilla. He enjoys destroying
|
||||
metropolises and eating tourist busses.
|
||||
|
||||
Drop him a line at martin_grenfell at msn.com. He would love to hear from you.
|
||||
its a lonely life being the worlds premier terror machine. How would you feel
|
||||
if your face looked like a toaster and a t-rex put together? :(
|
||||
|
||||
The latest stable versions can be found at
|
||||
http://www.vim.org/scripts/script.php?script_id=1218
|
||||
|
||||
The latest dev versions are on github
|
||||
http://github.com/scrooloose/nerdcommenter
|
||||
|
||||
==============================================================================
|
||||
8. Changelog *NERDComChangelog*
|
||||
|
||||
2.2.2
|
||||
- remove the NERDShutup option and the message is suppresses, this makes
|
||||
the plugin silently rely on &commentstring for unknown filetypes.
|
||||
- add support for dhcpd, limits, ntp, resolv, rgb, sysctl, udevconf and
|
||||
udevrules. Thanks to Thilo Six.
|
||||
- match filetypes case insensitively
|
||||
- add support for mp (metapost), thanks to Andrey Skvortsov.
|
||||
- add support for htmlcheetah, thanks to Simon Hengel.
|
||||
- add support for javacc, thanks to Matt Tolton.
|
||||
- make <%# %> the default delims for eruby, thanks to tpope.
|
||||
- add support for javascript.jquery, thanks to Ivan Devat.
|
||||
- add support for cucumber and pdf. Fix sass and railslog delims,
|
||||
thanks to tpope
|
||||
|
||||
2.2.1
|
||||
- add support for newlisp and clojure, thanks to Matthew Lee Hinman.
|
||||
- fix automake comments, thanks to Elias Pipping
|
||||
- make haml comments default to -# with / as the alternative delimiter,
|
||||
thanks to tpope
|
||||
- add support for actionscript and processing thanks to Edwin Benavides
|
||||
- add support for ps1 (powershell), thanks to Jason Mills
|
||||
- add support for hostsaccess, thanks to Thomas Rowe
|
||||
- add support for CVScommit
|
||||
- add support for asciidoc, git and gitrebase. Thanks to Simon Ruderich.
|
||||
- use # for gitcommit comments, thanks to Simon Ruderich.
|
||||
- add support for mako and genshi, thanks to Keitheis.
|
||||
- add support for conkyrc, thanks to David
|
||||
- add support for SVNannotate, thanks to Miguel Jaque Barbero.
|
||||
- add support for sieve, thanks to Stefan Walk
|
||||
- add support for objj, thanks to Adam Thorsen.
|
||||
|
||||
2.2.0
|
||||
- rewrote the mappings system to be more "standard".
|
||||
- removed all the mapping options. Now, mappings to <plug> mappings are
|
||||
used
|
||||
- see :help NERDComMappings, and :help NERDCreateDefaultMappings for
|
||||
more info
|
||||
- remove "prepend comments" and "right aligned comments".
|
||||
- add support for applescript, calbire, man, SVNcommit, potwiki, txt2tags and SVNinfo.
|
||||
Thanks to nicothakis, timberke, sgronblo, mntnoe, Bernhard Grotz, John
|
||||
O'Shea, François and Giacomo Mariani respectively.
|
||||
- bugfix for haskell delimiters. Thanks to mntnoe.
|
||||
2.1.18
|
||||
- add support for llvm. Thanks to nicothakis.
|
||||
- add support for xquery. Thanks to Phillip Kovalev.
|
||||
2.1.17
|
||||
- fixed haskell delimiters (hackily). Thanks to Elias Pipping.
|
||||
- add support for mailcap. Thanks to Pascal Brueckner.
|
||||
- add support for stata. Thanks to Jerónimo Carballo.
|
||||
- applied a patch from ewfalor to fix an error in the help file with the
|
||||
NERDMapleader doc
|
||||
- disable the insert mode ctrl-c mapping by default, see :help
|
||||
NERDComInsertComment if you wish to restore it
|
||||
|
||||
==============================================================================
|
||||
8. Credits *NERDComCredits*
|
||||
|
||||
Thanks to the follow people for suggestions and patches:
|
||||
|
||||
Nick Brettell
|
||||
Matthew Hawkins
|
||||
Mathieu Clabaut
|
||||
Greg Searle
|
||||
Nguyen
|
||||
Litchi
|
||||
Jorge Scandaliaris
|
||||
Shufeng Zheng
|
||||
Martin Stubenschrott
|
||||
Markus Erlmann
|
||||
Brent Rice
|
||||
Richard Willis
|
||||
Igor Prischepoff
|
||||
Harry
|
||||
David Bourgeois
|
||||
Eike Von Seggern
|
||||
Torsten Blix
|
||||
Alexander Bosecke
|
||||
Stefano Zacchiroli
|
||||
Norick Chen
|
||||
Joseph Barker
|
||||
Gary Church
|
||||
Tim Carey-Smith
|
||||
Markus Klinik
|
||||
Anders
|
||||
Seth Mason
|
||||
James Hales
|
||||
Heptite
|
||||
Cheng Fang
|
||||
Yongwei Wu
|
||||
David Miani
|
||||
Jeremy Hinegardner
|
||||
Marco
|
||||
Ingo Karkat
|
||||
Zhang Shuhan
|
||||
tpope
|
||||
Ben Schmidt
|
||||
David Fishburn
|
||||
Erik Falor
|
||||
JaGoTerr
|
||||
Elias Pipping
|
||||
mntnoe
|
||||
Mark S.
|
||||
|
||||
|
||||
Thanks to the following people for sending me new filetypes to support:
|
||||
|
||||
The hackers The filetypes~
|
||||
Sam R verilog
|
||||
Jonathan Derque context, plaintext and mail
|
||||
Vigil fetchmail
|
||||
Michael Brunner kconfig
|
||||
Antono Vasiljev netdict
|
||||
Melissa Reid omlet
|
||||
Ilia N Ternovich quickfix
|
||||
John O'Shea RTF, SVNcommitlog and vcscommit, SVNCommit
|
||||
Anders occam
|
||||
Mark Woodward csv
|
||||
fREW gentoo-package-mask,
|
||||
gentoo-package-keywords,
|
||||
gentoo-package-use, and vo_base
|
||||
Alexey verilog_systemverilog, systemverilog
|
||||
Lizendir fstab
|
||||
Michael Böhler autoit, autohotkey and docbk
|
||||
Aaron Small cmake
|
||||
Ramiro htmldjango and django
|
||||
Stefano Zacchiroli debcontrol, debchangelog, mkd
|
||||
Alex Tarkovsky ebuild and eclass
|
||||
Jorge Rodrigues gams
|
||||
Rainer Müller Objective C
|
||||
Jason Mills Groovy, ps1
|
||||
Normandie Azucena vera
|
||||
Florian Apolloner ldif
|
||||
David Fishburn lookupfile
|
||||
Niels Aan de Brugh rst
|
||||
Don Hatlestad ahk
|
||||
Christophe Benz Desktop and xsd
|
||||
Eyolf Østrem lilypond, bbx and lytex
|
||||
Ingo Karkat dosbatch
|
||||
Nicolas Weber markdown, objcpp
|
||||
tinoucas gentoo-conf-d
|
||||
Greg Weber D, haml
|
||||
Bruce Sherrod velocity
|
||||
timberke cobol, calibre
|
||||
Aaron Schaefer factor
|
||||
Mr X asterisk, mplayerconf
|
||||
Kuchma Michael plsql
|
||||
Brett Warneke spectre
|
||||
Pipp lhaskell
|
||||
Renald Buter scala
|
||||
Vladimir Lomov asymptote
|
||||
Marco mrxvtrc, aap
|
||||
nicothakis SVNAnnotate, CVSAnnotate, SVKAnnotate,
|
||||
SVNdiff, gitAnnotate, gitdiff, dtrace
|
||||
llvm, applescript
|
||||
Chen Xing Wikipedia
|
||||
Jacobo Diaz dakota, patran
|
||||
Li Jin gentoo-env-d, gentoo-init-d,
|
||||
gentoo-make-conf, grub, modconf, sudoers
|
||||
SpookeyPeanut rib
|
||||
Greg Jandl pyrex/cython
|
||||
Christophe Benz services, gitcommit
|
||||
A Pontus vimperator
|
||||
Stromnov slice, bzr
|
||||
Martin Kustermann pamconf
|
||||
Indriði Einarsson mason
|
||||
Chris map
|
||||
Krzysztof A. Adamski group
|
||||
Pascal Brueckner mailcap
|
||||
Jerónimo Carballo stata
|
||||
Phillip Kovalev xquery
|
||||
Bernhard Grotz potwiki
|
||||
sgronblo man
|
||||
François txt2tags
|
||||
Giacomo Mariani SVNinfo
|
||||
Matthew Lee Hinman newlisp, clojure
|
||||
Elias Pipping automake
|
||||
Edwin Benavides actionscript, processing
|
||||
Thomas Rowe hostsaccess
|
||||
Simon Ruderich asciidoc, git, gitcommit, gitrebase
|
||||
Keitheis mako, genshi
|
||||
David conkyrc
|
||||
Miguel Jaque Barbero SVNannotate
|
||||
Stefan Walk sieve
|
||||
Adam Thorsen objj
|
||||
Thilo Six dhcpd, limits, ntp, resolv, rgb, sysctl,
|
||||
udevconf, udevrules
|
||||
Andrey Skvortsov mp
|
||||
Simon Hengel htmlcheetah
|
||||
Matt Tolton javacc
|
||||
Ivan Devat javascript.jquery
|
||||
tpope cucumber,pdf
|
||||
==============================================================================
|
||||
9. License *NERDComLicense*
|
||||
|
||||
The NERD commenter is released under the wtfpl.
|
||||
See http://sam.zoy.org/wtfpl/COPYING.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
*~
|
||||
*.swp
|
||||
tags
|
||||
@@ -0,0 +1,75 @@
|
||||
# written by travis jeffery <travisjeffery@gmail.com>
|
||||
# contributions by scrooloose <github:scrooloose>
|
||||
|
||||
require 'rake'
|
||||
require 'find'
|
||||
require 'pathname'
|
||||
|
||||
IGNORE = [/\.gitignore$/, /Rakefile$/]
|
||||
|
||||
files = `git ls-files`.split("\n")
|
||||
files.reject! { |f| IGNORE.any? { |re| f.match(re) } }
|
||||
|
||||
desc 'Zip up the project files'
|
||||
task :zip do
|
||||
zip_name = File.basename(File.dirname(__FILE__))
|
||||
zip_name.gsub!(/ /, '_')
|
||||
zip_name = "#{zip_name}.zip"
|
||||
|
||||
if File.exist?(zip_name)
|
||||
abort("Zip file #{zip_name} already exists. Remove it first.")
|
||||
end
|
||||
|
||||
puts "Creating zip file: #{zip_name}"
|
||||
system("zip #{zip_name} #{files.join(" ")}")
|
||||
end
|
||||
|
||||
desc 'Install plugin and documentation'
|
||||
task :install do
|
||||
vimfiles = if ENV['VIMFILES']
|
||||
ENV['VIMFILES']
|
||||
elsif RUBY_PLATFORM =~ /(win|w)32$/
|
||||
File.expand_path("~/vimfiles")
|
||||
else
|
||||
File.expand_path("~/.vim")
|
||||
end
|
||||
files.each do |file|
|
||||
target_file = File.join(vimfiles, file)
|
||||
FileUtils.mkdir_p File.dirname(target_file)
|
||||
FileUtils.cp file, target_file
|
||||
|
||||
puts "Installed #{file} to #{target_file}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
desc 'Pulls from origin'
|
||||
task :pull do
|
||||
puts "Updating local repo..."
|
||||
system("cd " << Dir.new(File.dirname(__FILE__)).path << " && git pull")
|
||||
end
|
||||
|
||||
desc 'Calls pull task and then install task'
|
||||
task :update => ['pull', 'install'] do
|
||||
puts "Update of vim script complete."
|
||||
end
|
||||
|
||||
desc 'Uninstall plugin and documentation'
|
||||
task :uninstall do
|
||||
vimfiles = if ENV['VIMFILES']
|
||||
ENV['VIMFILES']
|
||||
elsif RUBY_PLATFORM =~ /(win|w)32$/
|
||||
File.expand_path("~/vimfiles")
|
||||
else
|
||||
File.expand_path("~/.vim")
|
||||
end
|
||||
files.each do |file|
|
||||
target_file = File.join(vimfiles, file)
|
||||
FileUtils.rm target_file
|
||||
|
||||
puts "Uninstalled #{target_file}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
task :default => ['update']
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,41 @@
|
||||
" ============================================================================
|
||||
" File: exec_menuitem.vim
|
||||
" Description: plugin for NERD Tree that provides an execute file menu item
|
||||
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
" Last Change: 22 July, 2009
|
||||
" License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
" ============================================================================
|
||||
if exists("g:loaded_nerdtree_exec_menuitem")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_nerdtree_exec_menuitem = 1
|
||||
|
||||
call NERDTreeAddMenuItem({
|
||||
\ 'text': '(!)Execute file',
|
||||
\ 'shortcut': '!',
|
||||
\ 'callback': 'NERDTreeExecFile',
|
||||
\ 'isActiveCallback': 'NERDTreeExecFileActive' })
|
||||
|
||||
function! NERDTreeExecFileActive()
|
||||
let node = g:NERDTreeFileNode.GetSelected()
|
||||
return !node.path.isDirectory && node.path.isExecutable
|
||||
endfunction
|
||||
|
||||
function! NERDTreeExecFile()
|
||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
||||
echo "==========================================================\n"
|
||||
echo "Complete the command to execute (add arguments etc):\n"
|
||||
let cmd = treenode.path.str({'escape': 1})
|
||||
let cmd = input(':!', cmd . ' ')
|
||||
|
||||
if cmd != ''
|
||||
exec ':!' . cmd
|
||||
else
|
||||
echo "Aborted"
|
||||
endif
|
||||
endfunction
|
||||
@@ -0,0 +1,194 @@
|
||||
" ============================================================================
|
||||
" File: fs_menu.vim
|
||||
" Description: plugin for the NERD Tree that provides a file system menu
|
||||
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
" Last Change: 17 July, 2009
|
||||
" License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
" ============================================================================
|
||||
if exists("g:loaded_nerdtree_fs_menu")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_nerdtree_fs_menu = 1
|
||||
|
||||
call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'})
|
||||
call NERDTreeAddMenuItem({'text': '(m)ove the curent node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
|
||||
call NERDTreeAddMenuItem({'text': '(d)elete the curent node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
|
||||
if g:NERDTreePath.CopyingSupported()
|
||||
call NERDTreeAddMenuItem({'text': '(c)copy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
|
||||
endif
|
||||
|
||||
"FUNCTION: s:echo(msg){{{1
|
||||
function! s:echo(msg)
|
||||
redraw
|
||||
echomsg "NERDTree: " . a:msg
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:echoWarning(msg){{{1
|
||||
function! s:echoWarning(msg)
|
||||
echohl warningmsg
|
||||
call s:echo(a:msg)
|
||||
echohl normal
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1
|
||||
"prints out the given msg and, if the user responds by pushing 'y' then the
|
||||
"buffer with the given bufnum is deleted
|
||||
"
|
||||
"Args:
|
||||
"bufnum: the buffer that may be deleted
|
||||
"msg: a message that will be echoed to the user asking them if they wish to
|
||||
" del the buffer
|
||||
function! s:promptToDelBuffer(bufnum, msg)
|
||||
echo a:msg
|
||||
if nr2char(getchar()) ==# 'y'
|
||||
exec "silent bdelete! " . a:bufnum
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: NERDTreeAddNode(){{{1
|
||||
function! NERDTreeAddNode()
|
||||
let curDirNode = g:NERDTreeDirNode.GetSelected()
|
||||
|
||||
let newNodeName = input("Add a childnode\n".
|
||||
\ "==========================================================\n".
|
||||
\ "Enter the dir/file name to be created. Dirs end with a '/'\n" .
|
||||
\ "", curDirNode.path.str({'format': 'Glob'}) . g:NERDTreePath.Slash())
|
||||
|
||||
if newNodeName ==# ''
|
||||
call s:echo("Node Creation Aborted.")
|
||||
return
|
||||
endif
|
||||
|
||||
try
|
||||
let newPath = g:NERDTreePath.Create(newNodeName)
|
||||
let parentNode = b:NERDTreeRoot.findNode(newPath.getParent())
|
||||
|
||||
let newTreeNode = g:NERDTreeFileNode.New(newPath)
|
||||
if parentNode.isOpen || !empty(parentNode.children)
|
||||
call parentNode.addChild(newTreeNode, 1)
|
||||
call NERDTreeRender()
|
||||
call newTreeNode.putCursorHere(1, 0)
|
||||
endif
|
||||
catch /^NERDTree/
|
||||
call s:echoWarning("Node Not Created.")
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
"FUNCTION: NERDTreeMoveNode(){{{1
|
||||
function! NERDTreeMoveNode()
|
||||
let curNode = g:NERDTreeFileNode.GetSelected()
|
||||
let newNodePath = input("Rename the current node\n" .
|
||||
\ "==========================================================\n" .
|
||||
\ "Enter the new path for the node: \n" .
|
||||
\ "", curNode.path.str())
|
||||
|
||||
if newNodePath ==# ''
|
||||
call s:echo("Node Renaming Aborted.")
|
||||
return
|
||||
endif
|
||||
|
||||
try
|
||||
let bufnum = bufnr(curNode.path.str())
|
||||
|
||||
call curNode.rename(newNodePath)
|
||||
call NERDTreeRender()
|
||||
|
||||
"if the node is open in a buffer, ask the user if they want to
|
||||
"close that buffer
|
||||
if bufnum != -1
|
||||
let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
|
||||
call s:promptToDelBuffer(bufnum, prompt)
|
||||
endif
|
||||
|
||||
call curNode.putCursorHere(1, 0)
|
||||
|
||||
redraw
|
||||
catch /^NERDTree/
|
||||
call s:echoWarning("Node Not Renamed.")
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" FUNCTION: NERDTreeDeleteNode() {{{1
|
||||
function! NERDTreeDeleteNode()
|
||||
let currentNode = g:NERDTreeFileNode.GetSelected()
|
||||
let confirmed = 0
|
||||
|
||||
if currentNode.path.isDirectory
|
||||
let choice =input("Delete the current node\n" .
|
||||
\ "==========================================================\n" .
|
||||
\ "STOP! To delete this entire directory, type 'yes'\n" .
|
||||
\ "" . currentNode.path.str() . ": ")
|
||||
let confirmed = choice ==# 'yes'
|
||||
else
|
||||
echo "Delete the current node\n" .
|
||||
\ "==========================================================\n".
|
||||
\ "Are you sure you wish to delete the node:\n" .
|
||||
\ "" . currentNode.path.str() . " (yN):"
|
||||
let choice = nr2char(getchar())
|
||||
let confirmed = choice ==# 'y'
|
||||
endif
|
||||
|
||||
|
||||
if confirmed
|
||||
try
|
||||
call currentNode.delete()
|
||||
call NERDTreeRender()
|
||||
|
||||
"if the node is open in a buffer, ask the user if they want to
|
||||
"close that buffer
|
||||
let bufnum = bufnr(currentNode.path.str())
|
||||
if buflisted(bufnum)
|
||||
let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
|
||||
call s:promptToDelBuffer(bufnum, prompt)
|
||||
endif
|
||||
|
||||
redraw
|
||||
catch /^NERDTree/
|
||||
call s:echoWarning("Could not remove node")
|
||||
endtry
|
||||
else
|
||||
call s:echo("delete aborted")
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
" FUNCTION: NERDTreeCopyNode() {{{1
|
||||
function! NERDTreeCopyNode()
|
||||
let currentNode = g:NERDTreeFileNode.GetSelected()
|
||||
let newNodePath = input("Copy the current node\n" .
|
||||
\ "==========================================================\n" .
|
||||
\ "Enter the new path to copy the node to: \n" .
|
||||
\ "", currentNode.path.str())
|
||||
|
||||
if newNodePath != ""
|
||||
"strip trailing slash
|
||||
let newNodePath = substitute(newNodePath, '\/$', '', '')
|
||||
|
||||
let confirmed = 1
|
||||
if currentNode.path.copyingWillOverwrite(newNodePath)
|
||||
call s:echo("Warning: copying may overwrite files! Continue? (yN)")
|
||||
let choice = nr2char(getchar())
|
||||
let confirmed = choice ==# 'y'
|
||||
endif
|
||||
|
||||
if confirmed
|
||||
try
|
||||
let newNode = currentNode.copy(newNodePath)
|
||||
call NERDTreeRender()
|
||||
call newNode.putCursorHere(0, 0)
|
||||
catch /^NERDTree/
|
||||
call s:echoWarning("Could not copy node")
|
||||
endtry
|
||||
endif
|
||||
else
|
||||
call s:echo("Copy aborted.")
|
||||
endif
|
||||
redraw
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
||||
Quickly install with:
|
||||
|
||||
git clone git://github.com/msanders/snipmate.vim.git
|
||||
cd snipmate.vim
|
||||
cp -R * ~/.vim
|
||||
@@ -0,0 +1,40 @@
|
||||
" 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
|
||||
@@ -0,0 +1,435 @@
|
||||
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
|
||||
@@ -0,0 +1,322 @@
|
||||
*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:
|
||||
@@ -0,0 +1,10 @@
|
||||
" 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
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"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."
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
" 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
|
||||
@@ -0,0 +1,9 @@
|
||||
# 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")`
|
||||
@@ -0,0 +1,66 @@
|
||||
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)
|
||||
@@ -0,0 +1,113 @@
|
||||
# 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}
|
||||
@@ -0,0 +1,34 @@
|
||||
# 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 */}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
# 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}
|
||||
@@ -0,0 +1,190 @@
|
||||
# Some useful Unicode entities
|
||||
# Non-Breaking Space
|
||||
snippet nbs
|
||||
|
||||
# ←
|
||||
snippet left
|
||||
←
|
||||
# →
|
||||
snippet right
|
||||
→
|
||||
# ↑
|
||||
snippet up
|
||||
↑
|
||||
# ↓
|
||||
snippet down
|
||||
↓
|
||||
# ↩
|
||||
snippet return
|
||||
↩
|
||||
# ⇤
|
||||
snippet backtab
|
||||
⇤
|
||||
# ⇥
|
||||
snippet tab
|
||||
⇥
|
||||
# ⇧
|
||||
snippet shift
|
||||
⇧
|
||||
# ⌃
|
||||
snippet control
|
||||
⌃
|
||||
# ⌅
|
||||
snippet enter
|
||||
⌅
|
||||
# ⌘
|
||||
snippet command
|
||||
⌘
|
||||
# ⌥
|
||||
snippet option
|
||||
⌥
|
||||
# ⌦
|
||||
snippet delete
|
||||
⌦
|
||||
# ⌫
|
||||
snippet backspace
|
||||
⌫
|
||||
# ⎋
|
||||
snippet escape
|
||||
⎋
|
||||
# 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 →"`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}
|
||||
@@ -0,0 +1,95 @@
|
||||
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}
|
||||
@@ -0,0 +1,74 @@
|
||||
# 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}
|
||||
@@ -0,0 +1,54 @@
|
||||
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:}" />
|
||||
@@ -0,0 +1,247 @@
|
||||
# #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}
|
||||
@@ -0,0 +1,97 @@
|
||||
# #!/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}
|
||||
@@ -0,0 +1,216 @@
|
||||
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}
|
||||
@@ -0,0 +1,89 @@
|
||||
snippet env
|
||||
#!/usr/bin/env python
|
||||
|
||||
snippet enc
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
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 class
|
||||
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}
|
||||
@@ -0,0 +1,504 @@
|
||||
# #!/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
|
||||
@@ -0,0 +1,28 @@
|
||||
# #!/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
|
||||
@@ -0,0 +1,7 @@
|
||||
# snippets for making snippets :)
|
||||
snippet snip
|
||||
snippet ${1:trigger}
|
||||
${2}
|
||||
snippet msnip
|
||||
snippet ${1:trigger} ${2:description}
|
||||
${3}
|
||||
@@ -0,0 +1,92 @@
|
||||
# #!/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
|
||||
@@ -0,0 +1,115 @@
|
||||
# \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}
|
||||
@@ -0,0 +1,32 @@
|
||||
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
|
||||
@@ -0,0 +1,58 @@
|
||||
# #!/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}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
" 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
|
||||
Executable
+950
@@ -0,0 +1,950 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import re
|
||||
from optparse import OptionParser
|
||||
|
||||
VERSION = "v0.1.99-20100514"
|
||||
|
||||
# =============================================================================
|
||||
|
||||
class Dialect:
|
||||
shortcuts = {}
|
||||
synonyms = {}
|
||||
required = {}
|
||||
short_tags = ()
|
||||
|
||||
class HtmlDialect(Dialect):
|
||||
shortcuts = {
|
||||
'cc:ie': {
|
||||
'opening_tag': '<!--[if IE]>',
|
||||
'closing_tag': '<![endif]-->'},
|
||||
'cc:ie6': {
|
||||
'opening_tag': '<!--[if lte IE 6]>',
|
||||
'closing_tag': '<![endif]-->'},
|
||||
'cc:ie7': {
|
||||
'opening_tag': '<!--[if lte IE 7]>',
|
||||
'closing_tag': '<![endif]-->'},
|
||||
'cc:noie': {
|
||||
'opening_tag': '<!--[if !IE]><!-->',
|
||||
'closing_tag': '<!--<![endif]-->'},
|
||||
'html:4t': {
|
||||
'expand': True,
|
||||
'opening_tag':
|
||||
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n' +
|
||||
'<html lang="en">\n' +
|
||||
'<head>\n' +
|
||||
' ' + '<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />\n' +
|
||||
' ' + '<title></title>\n' +
|
||||
'</head>\n' +
|
||||
'<body>',
|
||||
'closing_tag':
|
||||
'</body>\n' +
|
||||
'</html>'},
|
||||
'html:4s': {
|
||||
'expand': True,
|
||||
'opening_tag':
|
||||
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\n' +
|
||||
'<html lang="en">\n' +
|
||||
'<head>\n' +
|
||||
' ' + '<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />\n' +
|
||||
' ' + '<title></title>\n' +
|
||||
'</head>\n' +
|
||||
'<body>',
|
||||
'closing_tag':
|
||||
'</body>\n' +
|
||||
'</html>'},
|
||||
'html:xt': {
|
||||
'expand': True,
|
||||
'opening_tag':
|
||||
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n' +
|
||||
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\n' +
|
||||
'<head>\n' +
|
||||
' ' + '<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />\n' +
|
||||
' ' + '<title></title>\n' +
|
||||
'</head>\n' +
|
||||
'<body>',
|
||||
'closing_tag':
|
||||
'</body>\n' +
|
||||
'</html>'},
|
||||
'html:xs': {
|
||||
'expand': True,
|
||||
'opening_tag':
|
||||
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n' +
|
||||
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\n' +
|
||||
'<head>\n' +
|
||||
' ' + '<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />\n' +
|
||||
' ' + '<title></title>\n' +
|
||||
'</head>\n' +
|
||||
'<body>',
|
||||
'closing_tag':
|
||||
'</body>\n' +
|
||||
'</html>'},
|
||||
'html:xxs': {
|
||||
'expand': True,
|
||||
'opening_tag':
|
||||
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n' +
|
||||
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\n' +
|
||||
'<head>\n' +
|
||||
' ' + '<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />\n' +
|
||||
' ' + '<title></title>\n' +
|
||||
'</head>\n' +
|
||||
'<body>',
|
||||
'closing_tag':
|
||||
'</body>\n' +
|
||||
'</html>'},
|
||||
'html:5': {
|
||||
'expand': True,
|
||||
'opening_tag':
|
||||
'<!DOCTYPE html>\n' +
|
||||
'<html lang="en">\n' +
|
||||
'<head>\n' +
|
||||
' ' + '<meta charset="UTF-8" />\n' +
|
||||
' ' + '<title></title>\n' +
|
||||
'</head>\n' +
|
||||
'<body>',
|
||||
'closing_tag':
|
||||
'</body>\n' +
|
||||
'</html>'},
|
||||
'input:button': {
|
||||
'name': 'input',
|
||||
'attributes': { 'class': 'button', 'type': 'button', 'name': '', 'value': '' }
|
||||
},
|
||||
'input:password': {
|
||||
'name': 'input',
|
||||
'attributes': { 'class': 'text password', 'type': 'password', 'name': '', 'value': '' }
|
||||
},
|
||||
'input:radio': {
|
||||
'name': 'input',
|
||||
'attributes': { 'class': 'radio', 'type': 'radio', 'name': '', 'value': '' }
|
||||
},
|
||||
'input:checkbox': {
|
||||
'name': 'input',
|
||||
'attributes': { 'class': 'checkbox', 'type': 'checkbox', 'name': '', 'value': '' }
|
||||
},
|
||||
'input:file': {
|
||||
'name': 'input',
|
||||
'attributes': { 'class': 'file', 'type': 'file', 'name': '', 'value': '' }
|
||||
},
|
||||
'input:text': {
|
||||
'name': 'input',
|
||||
'attributes': { 'class': 'text', 'type': 'text', 'name': '', 'value': '' }
|
||||
},
|
||||
'input:submit': {
|
||||
'name': 'input',
|
||||
'attributes': { 'class': 'submit', 'type': 'submit', 'value': '' }
|
||||
},
|
||||
'input:hidden': {
|
||||
'name': 'input',
|
||||
'attributes': { 'type': 'hidden', 'name': '', 'value': '' }
|
||||
},
|
||||
'script:src': {
|
||||
'name': 'script',
|
||||
'attributes': { 'src': '' }
|
||||
},
|
||||
'script:jquery': {
|
||||
'name': 'script',
|
||||
'attributes': { 'src': 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js' }
|
||||
},
|
||||
'script:jsapi': {
|
||||
'name': 'script',
|
||||
'attributes': { 'src': 'http://www.google.com/jsapi' }
|
||||
},
|
||||
'script:jsapix': {
|
||||
'name': 'script',
|
||||
'text': '\n google.load("jquery", "1.3.2");\n google.setOnLoadCallback(function() {\n \n });\n'
|
||||
},
|
||||
'link:css': {
|
||||
'name': 'link',
|
||||
'attributes': { 'rel': 'stylesheet', 'type': 'text/css', 'href': '', 'media': 'all' },
|
||||
},
|
||||
'link:print': {
|
||||
'name': 'link',
|
||||
'attributes': { 'rel': 'stylesheet', 'type': 'text/css', 'href': '', 'media': 'print' },
|
||||
},
|
||||
'link:favicon': {
|
||||
'name': 'link',
|
||||
'attributes': { 'rel': 'shortcut icon', 'type': 'image/x-icon', 'href': '' },
|
||||
},
|
||||
'link:touch': {
|
||||
'name': 'link',
|
||||
'attributes': { 'rel': 'apple-touch-icon', 'href': '' },
|
||||
},
|
||||
'link:rss': {
|
||||
'name': 'link',
|
||||
'attributes': { 'rel': 'alternate', 'type': 'application/rss+xml', 'title': 'RSS', 'href': '' },
|
||||
},
|
||||
'link:atom': {
|
||||
'name': 'link',
|
||||
'attributes': { 'rel': 'alternate', 'type': 'application/atom+xml', 'title': 'Atom', 'href': '' },
|
||||
},
|
||||
'meta:ie7': {
|
||||
'name': 'meta',
|
||||
'attributes': { 'http-equiv': 'X-UA-Compatible', 'content': 'IE=7' },
|
||||
},
|
||||
'meta:ie8': {
|
||||
'name': 'meta',
|
||||
'attributes': { 'http-equiv': 'X-UA-Compatible', 'content': 'IE=8' },
|
||||
},
|
||||
'form:get': {
|
||||
'name': 'form',
|
||||
'attributes': { 'method': 'get' },
|
||||
},
|
||||
'form:g': {
|
||||
'name': 'form',
|
||||
'attributes': { 'method': 'get' },
|
||||
},
|
||||
'form:post': {
|
||||
'name': 'form',
|
||||
'attributes': { 'method': 'post' },
|
||||
},
|
||||
'form:p': {
|
||||
'name': 'form',
|
||||
'attributes': { 'method': 'post' },
|
||||
},
|
||||
}
|
||||
synonyms = {
|
||||
'checkbox': 'input:checkbox',
|
||||
'check': 'input:checkbox',
|
||||
'input:c': 'input:checkbox',
|
||||
'button': 'input:button',
|
||||
'input:b': 'input:button',
|
||||
'input:h': 'input:hidden',
|
||||
'hidden': 'input:hidden',
|
||||
'submit': 'input:submit',
|
||||
'input:s': 'input:submit',
|
||||
'radio': 'input:radio',
|
||||
'input:r': 'input:radio',
|
||||
'text': 'input:text',
|
||||
'passwd': 'input:password',
|
||||
'password': 'input:password',
|
||||
'pw': 'input:password',
|
||||
'input:t': 'input:text',
|
||||
'linkcss': 'link:css',
|
||||
'scriptsrc': 'script:src',
|
||||
'jquery': 'script:jquery',
|
||||
'jsapi': 'script:jsapi',
|
||||
'html5': 'html:5',
|
||||
'html4': 'html:4s',
|
||||
'html4s': 'html:4s',
|
||||
'html4t': 'html:4t',
|
||||
'xhtml': 'html:xxs',
|
||||
'xhtmlt': 'html:xt',
|
||||
'xhtmls': 'html:xs',
|
||||
'xhtml11': 'html:xxs',
|
||||
'opt': 'option',
|
||||
'st': 'strong',
|
||||
'css': 'style',
|
||||
'csss': 'link:css',
|
||||
'css:src': 'link:css',
|
||||
'csssrc': 'link:css',
|
||||
'js': 'script',
|
||||
'jss': 'script:src',
|
||||
'js:src': 'script:src',
|
||||
'jssrc': 'script:src',
|
||||
}
|
||||
short_tags = (
|
||||
'area', 'base', 'basefont', 'br', 'embed', 'hr',
|
||||
'input', 'img', 'link', 'param', 'meta')
|
||||
required = {
|
||||
'a': {'href':''},
|
||||
'base': {'href':''},
|
||||
'abbr': {'title': ''},
|
||||
'acronym':{'title': ''},
|
||||
'bdo': {'dir': ''},
|
||||
'link': {'rel': 'stylesheet', 'href': ''},
|
||||
'style': {'type': 'text/css'},
|
||||
'script': {'type': 'text/javascript'},
|
||||
'img': {'src':'', 'alt':''},
|
||||
'iframe': {'src': '', 'frameborder': '0'},
|
||||
'embed': {'src': '', 'type': ''},
|
||||
'object': {'data': '', 'type': ''},
|
||||
'param': {'name': '', 'value': ''},
|
||||
'form': {'action': '', 'method': 'post'},
|
||||
'table': {'cellspacing': '0'},
|
||||
'input': {'type': '', 'name': '', 'value': ''},
|
||||
'base': {'href': ''},
|
||||
'area': {'shape': '', 'coords': '', 'href': '', 'alt': ''},
|
||||
'select': {'name': ''},
|
||||
'option': {'value': ''},
|
||||
'textarea':{'name': ''},
|
||||
'meta': {'content': ''},
|
||||
}
|
||||
|
||||
class Parser:
|
||||
"""The parser.
|
||||
"""
|
||||
|
||||
# Constructor
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
def __init__(self, options, string, dialect=HtmlDialect()):
|
||||
"""Constructor.
|
||||
"""
|
||||
|
||||
self.tokens = []
|
||||
self.string = string
|
||||
self.options = options
|
||||
self.dialect = dialect
|
||||
self.root = Element(parser=self)
|
||||
self.caret = []
|
||||
self.caret.append(self.root)
|
||||
self._last = []
|
||||
|
||||
self._tokenize()
|
||||
self._parse()
|
||||
|
||||
|
||||
# Methods
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
def render(self):
|
||||
"""Renders.
|
||||
Called by [[Router]].
|
||||
"""
|
||||
|
||||
# Get the initial render of the root node
|
||||
output = self.root.render()
|
||||
|
||||
# Indent by whatever the input is indented with
|
||||
indent = re.findall(r"^[\r\n]*(\s*)", self.string)[0]
|
||||
output = indent + output.replace("\n", "\n" + indent)
|
||||
|
||||
# Strip newline if not needed
|
||||
if not self.options.last_newline \
|
||||
or self.prefix or self.suffix:
|
||||
output = re.sub(r'\n\s*$', '', output)
|
||||
|
||||
# TextMate mode
|
||||
if self.options.textmate:
|
||||
output = self._textmatify(output)
|
||||
|
||||
return output
|
||||
|
||||
# Protected methods
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
def _textmatify(self, output):
|
||||
"""Returns a version of the output with TextMate placeholders in it.
|
||||
"""
|
||||
|
||||
matches = re.findall(r'(></)|("")|(\n\s+)\n|(.|\s)', output)
|
||||
output = ''
|
||||
n = 1
|
||||
for i in matches:
|
||||
if i[0]:
|
||||
output += '>$%i</' % n
|
||||
n += 1
|
||||
elif i[1]:
|
||||
output += '"$%i"' % n
|
||||
n += 1
|
||||
elif i[2]:
|
||||
output += i[2] + '$%i\n' % n
|
||||
n += 1
|
||||
elif i[3]:
|
||||
output += i[3]
|
||||
output += "$0"
|
||||
return output
|
||||
|
||||
def _tokenize(self):
|
||||
"""Tokenizes.
|
||||
Initializes [[self.tokens]].
|
||||
"""
|
||||
|
||||
string = self.string.strip()
|
||||
|
||||
# Find prefix/suffix
|
||||
while True:
|
||||
match = re.match(r"^(\s*<[^>]+>\s*)", string)
|
||||
if match is None: break
|
||||
if self.prefix is None: self.prefix = ''
|
||||
self.prefix += match.group(0)
|
||||
string = string[len(match.group(0)):]
|
||||
|
||||
while True:
|
||||
match = re.findall(r"(\s*<[^>]+>[\s\n\r]*)$", string)
|
||||
if not match: break
|
||||
if self.suffix is None: self.suffix = ''
|
||||
self.suffix = match[0] + self.suffix
|
||||
string = string[:-len(match[0])]
|
||||
|
||||
# Split by the element separators
|
||||
for token in re.split('(<|>|\+(?!\\s*\+|$))', string):
|
||||
if token.strip() != '':
|
||||
self.tokens.append(Token(token, parser=self))
|
||||
|
||||
def _parse(self):
|
||||
"""Takes the tokens and does its thing.
|
||||
Populates [[self.root]].
|
||||
"""
|
||||
|
||||
# Carry it over to the root node.
|
||||
if self.prefix or self.suffix:
|
||||
self.root.prefix = self.prefix
|
||||
self.root.suffix = self.suffix
|
||||
self.root.depth += 1
|
||||
|
||||
for token in self.tokens:
|
||||
if token.type == Token.ELEMENT:
|
||||
# Reset the "last elements added" list. We will
|
||||
# repopulate this with the new elements added now.
|
||||
self._last[:] = []
|
||||
|
||||
# Create [[Element]]s from a [[Token]].
|
||||
# They will be created as many as the multiplier specifies,
|
||||
# multiplied by how many carets we have
|
||||
count = 0
|
||||
for caret in self.caret:
|
||||
for local_count in range(1, token.multiplier + 1):
|
||||
count += 1
|
||||
new = Element(token, caret,
|
||||
count = count,
|
||||
local_count = local_count,
|
||||
parser = self)
|
||||
self._last.append(new)
|
||||
caret.append(new)
|
||||
|
||||
# For >
|
||||
elif token.type == Token.CHILD:
|
||||
# The last children added.
|
||||
self.caret[:] = self._last
|
||||
|
||||
# For <
|
||||
elif token.type == Token.PARENT:
|
||||
# If we're the root node, don't do anything
|
||||
parent = self.caret[0].parent
|
||||
if parent is not None:
|
||||
self.caret[:] = [parent]
|
||||
|
||||
# Properties
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
# Property: dialect
|
||||
# The dialect of XML
|
||||
dialect = None
|
||||
|
||||
# Property: string
|
||||
# The string
|
||||
string = ''
|
||||
|
||||
# Property: tokens
|
||||
# The list of tokens
|
||||
tokens = []
|
||||
|
||||
# Property: options
|
||||
# Reference to the [[Options]] instance
|
||||
options = None
|
||||
|
||||
# Property: root
|
||||
# The root [[Element]] node.
|
||||
root = None
|
||||
|
||||
# Property: caret
|
||||
# The current insertion point.
|
||||
caret = None
|
||||
|
||||
# Property: _last
|
||||
# List of the last appended stuff
|
||||
_last = None
|
||||
|
||||
# Property: indent
|
||||
# Yeah
|
||||
indent = ''
|
||||
|
||||
# Property: prefix
|
||||
# (String) The trailing tag in the beginning.
|
||||
#
|
||||
# Description:
|
||||
# For instance, in `<div>ul>li</div>`, the `prefix` is `<div>`.
|
||||
prefix = ''
|
||||
|
||||
# Property: suffix
|
||||
# (string) The trailing tag at the end.
|
||||
suffix = ''
|
||||
|
||||
# =============================================================================
|
||||
|
||||
class Element:
|
||||
"""An element.
|
||||
"""
|
||||
|
||||
def __init__(self, token=None, parent=None, count=None, local_count=None,
|
||||
parser=None, opening_tag=None, closing_tag=None,
|
||||
attributes=None, name=None, text=None):
|
||||
"""Constructor.
|
||||
|
||||
This is called by ???.
|
||||
|
||||
Description:
|
||||
All parameters are optional.
|
||||
|
||||
token - (Token) The token (required)
|
||||
parent - (Element) Parent element; `None` if root
|
||||
count - (Int) The number to substitute for `&` (e.g., in `li.item-&`)
|
||||
local_count - (Int) The number to substitute for `$` (e.g., in `li.item-$`)
|
||||
parser - (Parser) The parser
|
||||
|
||||
attributes - ...
|
||||
name - ...
|
||||
text - ...
|
||||
"""
|
||||
|
||||
self.children = []
|
||||
self.attributes = {}
|
||||
self.parser = parser
|
||||
|
||||
if token is not None:
|
||||
# Assumption is that token is of type [[Token]] and is
|
||||
# a [[Token.ELEMENT]].
|
||||
self.name = token.name
|
||||
self.attributes = token.attributes.copy()
|
||||
self.text = token.text
|
||||
self.populate = token.populate
|
||||
self.expand = token.expand
|
||||
self.opening_tag = token.opening_tag
|
||||
self.closing_tag = token.closing_tag
|
||||
|
||||
# `count` can be given. This will substitude & in classname and ID
|
||||
if count is not None:
|
||||
for key in self.attributes:
|
||||
attrib = self.attributes[key]
|
||||
attrib = attrib.replace('&', ("%i" % count))
|
||||
if local_count is not None:
|
||||
attrib = attrib.replace('$', ("%i" % local_count))
|
||||
self.attributes[key] = attrib
|
||||
|
||||
# Copy over from parameters
|
||||
if attributes: self.attributes = attributes
|
||||
if name: self.name = name
|
||||
if text: self.text = text
|
||||
|
||||
self._fill_attributes()
|
||||
|
||||
self.parent = parent
|
||||
if parent is not None:
|
||||
self.depth = parent.depth + 1
|
||||
|
||||
if self.populate: self._populate()
|
||||
|
||||
def render(self):
|
||||
"""Renders the element, along with it's subelements, into HTML code.
|
||||
|
||||
[Grouped under "Rendering methods"]
|
||||
"""
|
||||
|
||||
options = self.parser.options
|
||||
output = ""
|
||||
spaces_count = options.indent_spaces
|
||||
spaces = ' ' * spaces_count
|
||||
indent = self.depth * spaces
|
||||
|
||||
prefix, suffix = ('', '')
|
||||
if self.prefix: prefix = self.prefix + "\n"
|
||||
if self.suffix: suffix = self.suffix
|
||||
|
||||
# Make the guide from the ID (/#header), or the class if there's no
|
||||
# ID (/.item)
|
||||
# This is for the start-guide, end-guide and post_tag_guides
|
||||
guide_string = ''
|
||||
if 'id' in self.attributes:
|
||||
guide_string += "#%s" % self.attributes['id']
|
||||
elif 'class' in self.attributes:
|
||||
guide_string += ".%s" % self.attributes['class'].replace(' ', '.')
|
||||
|
||||
# Build the post-tag guide (e.g., </div><!-- /#header -->),
|
||||
# the start guide, and the end guide.
|
||||
guide = ''
|
||||
start_guide = ''
|
||||
end_guide = ''
|
||||
|
||||
if ((self.name == 'div') and \
|
||||
(('id' in self.attributes) or ('class' in self.attributes))):
|
||||
|
||||
if (options.post_tag_guides):
|
||||
guide = "<!-- /%s -->" % guide_string
|
||||
|
||||
if (options.start_guide_format):
|
||||
format = options.start_guide_format
|
||||
try: start_guide = format % guide_string
|
||||
except: start_guide = (format + " " + guide_string).strip()
|
||||
start_guide = "%s<!-- %s -->\n" % (indent, start_guide)
|
||||
|
||||
if (options.end_guide_format):
|
||||
format = options.end_guide_format
|
||||
try: end_guide = format % guide_string
|
||||
except: end_guide = (format + " " + guide_string).strip()
|
||||
|
||||
if options.end_guide_newline:
|
||||
end_guide = "\n%s<!-- %s -->" % (indent, end_guide)
|
||||
else:
|
||||
end_guide = "<!-- %s -->" % (end_guide)
|
||||
|
||||
# Short, self-closing tags (<br />)
|
||||
short_tags = self.parser.dialect.short_tags
|
||||
|
||||
# When it should be expanded..
|
||||
# (That is, <div>\n...\n</div> or similar -- wherein something must go
|
||||
# inside the opening/closing tags)
|
||||
if len(self.children) > 0 \
|
||||
or self.expand \
|
||||
or prefix or suffix \
|
||||
or (self.parser.options.expand_divs and self.name == 'div'):
|
||||
|
||||
for child in self.children:
|
||||
output += child.render()
|
||||
|
||||
# For expand divs: if there are no children (that is, `output`
|
||||
# is still blank despite above), fill it with a blank line.
|
||||
if (output == ''): output = indent + spaces + "\n"
|
||||
|
||||
# If we're a root node and we have a prefix or suffix...
|
||||
# (Only the root node can have a prefix or suffix.)
|
||||
if prefix or suffix:
|
||||
output = "%s%s%s%s%s\n" % \
|
||||
(indent, prefix, output, suffix, guide)
|
||||
|
||||
# Uh..
|
||||
elif self.name != '' or \
|
||||
self.opening_tag is not None or \
|
||||
self.closing_tag is not None:
|
||||
output = start_guide + \
|
||||
indent + self.get_opening_tag() + "\n" + \
|
||||
output + \
|
||||
indent + self.get_closing_tag() + \
|
||||
guide + end_guide + "\n"
|
||||
|
||||
|
||||
# Short, self-closing tags (<br />)
|
||||
elif self.name in short_tags:
|
||||
output = "%s<%s />\n" % (indent, self.get_default_tag())
|
||||
|
||||
# Tags with text, possibly
|
||||
elif self.name != '' or \
|
||||
self.opening_tag is not None or \
|
||||
self.closing_tag is not None:
|
||||
output = "%s%s%s%s%s%s%s%s" % \
|
||||
(start_guide, indent, self.get_opening_tag(), \
|
||||
self.text, \
|
||||
self.get_closing_tag(), \
|
||||
guide, end_guide, "\n")
|
||||
|
||||
return output
|
||||
|
||||
def get_default_tag(self):
|
||||
"""Returns the opening tag (without brackets).
|
||||
|
||||
Usage:
|
||||
element.get_default_tag()
|
||||
|
||||
[Grouped under "Rendering methods"]
|
||||
"""
|
||||
|
||||
output = '%s' % (self.name)
|
||||
for key, value in self.attributes.iteritems():
|
||||
output += ' %s="%s"' % (key, value)
|
||||
return output
|
||||
|
||||
def get_opening_tag(self):
|
||||
if self.opening_tag is None:
|
||||
return "<%s>" % self.get_default_tag()
|
||||
else:
|
||||
return self.opening_tag
|
||||
|
||||
def get_closing_tag(self):
|
||||
if self.closing_tag is None:
|
||||
return "</%s>" % self.name
|
||||
else:
|
||||
return self.closing_tag
|
||||
|
||||
def append(self, object):
|
||||
"""Registers an element as a child of this element.
|
||||
|
||||
Usage:
|
||||
element.append(child)
|
||||
|
||||
Description:
|
||||
Adds a given element `child` to the children list of this element. It
|
||||
will be rendered when [[render()]] is called on the element.
|
||||
|
||||
See also:
|
||||
- [[get_last_child()]]
|
||||
|
||||
[Grouped under "Traversion methods"]
|
||||
"""
|
||||
|
||||
self.children.append(object)
|
||||
|
||||
def get_last_child(self):
|
||||
"""Returns the last child element which was [[append()]]ed
|
||||
to this element.
|
||||
|
||||
Usage:
|
||||
element.get_last_child()
|
||||
|
||||
Description:
|
||||
This is the same as using `element.children[-1]`.
|
||||
|
||||
[Grouped under "Traversion methods"]
|
||||
"""
|
||||
|
||||
return self.children[-1]
|
||||
|
||||
def _populate(self):
|
||||
"""Expands with default items.
|
||||
|
||||
This is called when the [[populate]] flag is turned on.
|
||||
"""
|
||||
|
||||
if self.name == 'ul':
|
||||
elements = [Element(name='li', parent=self, parser=self.parser)]
|
||||
|
||||
elif self.name == 'dl':
|
||||
elements = [
|
||||
Element(name='dt', parent=self, parser=self.parser),
|
||||
Element(name='dd', parent=self, parser=self.parser)]
|
||||
|
||||
elif self.name == 'table':
|
||||
tr = Element(name='tr', parent=self, parser=self.parser)
|
||||
td = Element(name='td', parent=tr, parser=self.parser)
|
||||
tr.children.append(td)
|
||||
elements = [tr]
|
||||
|
||||
else:
|
||||
elements = []
|
||||
|
||||
for el in elements:
|
||||
self.children.append(el)
|
||||
|
||||
def _fill_attributes(self):
|
||||
"""Fills default attributes for certain elements.
|
||||
|
||||
Description:
|
||||
This is called by the constructor.
|
||||
|
||||
[Protected, grouped under "Protected methods"]
|
||||
"""
|
||||
|
||||
# Make sure <a>'s have a href, <img>'s have an src, etc.
|
||||
required = self.parser.dialect.required
|
||||
|
||||
for element, attribs in required.iteritems():
|
||||
if self.name == element:
|
||||
for attrib in attribs:
|
||||
if attrib not in self.attributes:
|
||||
self.attributes[attrib] = attribs[attrib]
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
# Property: last_child
|
||||
# [Read-only]
|
||||
last_child = property(get_last_child)
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
# Property: parent
|
||||
# (Element) The parent element.
|
||||
parent = None
|
||||
|
||||
# Property: name
|
||||
# (String) The name of the element (e.g., `div`)
|
||||
name = ''
|
||||
|
||||
# Property: attributes
|
||||
# (Dict) The dictionary of attributes (e.g., `{'src': 'image.jpg'}`)
|
||||
attributes = None
|
||||
|
||||
# Property: children
|
||||
# (List of Elements) The children
|
||||
children = None
|
||||
|
||||
# Property: opening_tag
|
||||
# (String or None) The opening tag. Optional; will use `name` and
|
||||
# `attributes` if this is not given.
|
||||
opening_tag = None
|
||||
|
||||
# Property: closing_tag
|
||||
# (String or None) The closing tag
|
||||
closing_tag = None
|
||||
|
||||
text = ''
|
||||
depth = -1
|
||||
expand = False
|
||||
populate = False
|
||||
parser = None
|
||||
|
||||
# Property: prefix
|
||||
# Only the root note can have this.
|
||||
prefix = None
|
||||
suffix = None
|
||||
|
||||
# =============================================================================
|
||||
|
||||
class Token:
|
||||
def __init__(self, string, parser=None):
|
||||
"""Token.
|
||||
|
||||
Description:
|
||||
string - The string to parse
|
||||
|
||||
In the string `div > ul`, there are 3 tokens. (`div`, `>`, and `ul`)
|
||||
|
||||
For `>`, it will be a `Token` with `type` set to `Token.CHILD`
|
||||
"""
|
||||
|
||||
self.string = string.strip()
|
||||
self.attributes = {}
|
||||
self.parser = parser
|
||||
|
||||
# Set the type.
|
||||
if self.string == '<':
|
||||
self.type = Token.PARENT
|
||||
elif self.string == '>':
|
||||
self.type = Token.CHILD
|
||||
elif self.string == '+':
|
||||
self.type = Token.SIBLING
|
||||
else:
|
||||
self.type = Token.ELEMENT
|
||||
self._init_element()
|
||||
|
||||
def _init_element(self):
|
||||
"""Initializes. Only called if the token is an element token.
|
||||
[Private]
|
||||
"""
|
||||
|
||||
# Get the tag name. Default to DIV if none given.
|
||||
name = re.findall(r'^([\w\-:]*)', self.string)[0]
|
||||
name = name.lower().replace('-', ':')
|
||||
|
||||
# Find synonyms through this thesaurus
|
||||
synonyms = self.parser.dialect.synonyms
|
||||
if name in synonyms.keys():
|
||||
name = synonyms[name]
|
||||
|
||||
if ':' in name:
|
||||
shortcuts = self.parser.dialect.shortcuts
|
||||
if name in shortcuts.keys():
|
||||
for key, value in shortcuts[name].iteritems():
|
||||
setattr(self, key, value)
|
||||
if 'html' in name:
|
||||
return
|
||||
else:
|
||||
self.name = name
|
||||
|
||||
elif (name == ''): self.name = 'div'
|
||||
else: self.name = name
|
||||
|
||||
# Look for attributes
|
||||
attribs = []
|
||||
for attrib in re.findall(r'\[([^\]]*)\]', self.string):
|
||||
attribs.append(attrib)
|
||||
self.string = self.string.replace("[" + attrib + "]", "")
|
||||
if len(attribs) > 0:
|
||||
for attrib in attribs:
|
||||
try: key, value = attrib.split('=', 1)
|
||||
except: key, value = attrib, ''
|
||||
self.attributes[key] = value
|
||||
|
||||
# Try looking for text
|
||||
text = None
|
||||
for text in re.findall(r'\{([^\}]*)\}', self.string):
|
||||
self.string = self.string.replace("{" + text + "}", "")
|
||||
if text is not None:
|
||||
self.text = text
|
||||
|
||||
# Get the class names
|
||||
classes = []
|
||||
for classname in re.findall(r'\.([\$a-zA-Z0-9_\-\&]+)', self.string):
|
||||
classes.append(classname)
|
||||
if len(classes) > 0:
|
||||
try: self.attributes['class']
|
||||
except: self.attributes['class'] = ''
|
||||
self.attributes['class'] += ' ' + ' '.join(classes)
|
||||
self.attributes['class'] = self.attributes['class'].strip()
|
||||
|
||||
# Get the ID
|
||||
id_match = re.search(r'#([\$a-zA-Z0-9_\-\&]+)', self.string)
|
||||
if id_match is not None:
|
||||
self.attributes['id'] = id_match.group(1)
|
||||
|
||||
# See if there's a multiplier (e.g., "li*3")
|
||||
multiplier_match = re.search(r'\*\s*([0-9]+)', self.string)
|
||||
if multiplier_match is not None:
|
||||
self.multiplier = int(multiplier_match.group(1))
|
||||
|
||||
# Populate flag (e.g., ul+)
|
||||
flags_match = re.search(r'[\+\!]+$', self.string)
|
||||
if flags_match is not None:
|
||||
if '+' in flags_match.group(0):
|
||||
self.populate = True
|
||||
if '!' in flags_match.group(0):
|
||||
self.expand = True
|
||||
|
||||
def __str__(self):
|
||||
return self.string
|
||||
|
||||
string = ''
|
||||
parser = None
|
||||
|
||||
# For elements
|
||||
# See the properties of `Element` for description on these.
|
||||
name = ''
|
||||
attributes = None
|
||||
multiplier = 1
|
||||
expand = False
|
||||
populate = False
|
||||
text = ''
|
||||
opening_tag = None
|
||||
closing_tag = None
|
||||
|
||||
# Type
|
||||
type = 0
|
||||
ELEMENT = 2
|
||||
CHILD = 4
|
||||
PARENT = 8
|
||||
SIBLING = 16
|
||||
|
||||
# =============================================================================
|
||||
|
||||
def parse_args():
|
||||
optparser = OptionParser(version=VERSION,
|
||||
description="Expands input into HTML.",
|
||||
epilog="Please refer to the manual for more information.")
|
||||
|
||||
|
||||
optparser.add_option('--no-guides', action="store_true", help='Deprecated')
|
||||
optparser.add_option('--post-tag-guides', action="store_true",
|
||||
help='Adds comments at the end of DIV tags')
|
||||
optparser.add_option('--textmate', action="store_true",
|
||||
help='Adds snippet info (textmate mode)')
|
||||
optparser.add_option('--indent-spaces', help='Indent spaces')
|
||||
optparser.add_option('--expand-divs', action="store_true",
|
||||
help='Automatically expand divs')
|
||||
optparser.add_option('--no-last-newline', action="store_false",
|
||||
help='Skip the trailing newline')
|
||||
optparser.add_option('--start-guide-format', help='To be documented')
|
||||
optparser.add_option('--end-guide-format', help='To be documented')
|
||||
optparser.add_option('--end-guide-newline', help='To be documented')
|
||||
|
||||
optparser.set_defaults(post_tag_guides=False, textmate=False,
|
||||
indent_spaces=4, expand_divs=False, last_newline=True,
|
||||
start_guide_format="", end_guide_format="", end_guide_newline=True)
|
||||
|
||||
# Make sure they're the correct types
|
||||
opt_args = optparser.parse_args()
|
||||
opt_args[0].indent_spaces = int(opt_args[0].indent_spaces)
|
||||
opt_args[0].end_guide_newline = bool(int(opt_args[0].end_guide_newline))
|
||||
return opt_args
|
||||
|
||||
def main():
|
||||
(options, _) = parse_args()
|
||||
|
||||
lines = sys.stdin.read()
|
||||
|
||||
parser = Parser(options, lines)
|
||||
|
||||
output = parser.render()
|
||||
sys.stdout.write(output)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,74 @@
|
||||
" Sparkup
|
||||
" Installation:
|
||||
" Copy the contents of vim/ftplugin/ to your ~/.vim/ftplugin directory.
|
||||
"
|
||||
" $ cp -R vim/ftplugin ~/.vim/ftplugin/
|
||||
"
|
||||
" Configuration:
|
||||
" g:sparkup (Default: 'sparkup') -
|
||||
" Location of the sparkup executable. You shouldn't need to change this
|
||||
" setting if you used the install option above.
|
||||
"
|
||||
" g:sparkupArgs (Default: '--no-last-newline') -
|
||||
" Additional args passed to sparkup.
|
||||
"
|
||||
" g:sparkupExecuteMapping (Default: '<c-e>') -
|
||||
" Mapping used to execute sparkup.
|
||||
"
|
||||
" g:sparkupNextMapping (Default: '<c-n>') -
|
||||
" Mapping used to jump to the next empty tag/attribute.
|
||||
|
||||
if !exists('g:sparkupExecuteMapping')
|
||||
let g:sparkupExecuteMapping = '<c-e>'
|
||||
endif
|
||||
|
||||
if !exists('g:sparkupNextMapping')
|
||||
let g:sparkupNextMapping = '<c-n>'
|
||||
endif
|
||||
|
||||
exec 'nnoremap <buffer> ' . g:sparkupExecuteMapping . ' :call <SID>Sparkup()<cr>'
|
||||
exec 'inoremap <buffer> ' . g:sparkupExecuteMapping . ' <c-g>u<Esc>:call <SID>Sparkup()<cr>'
|
||||
exec 'nnoremap <buffer> ' . g:sparkupNextMapping . ' :call <SID>SparkupNext()<cr>'
|
||||
exec 'inoremap <buffer> ' . g:sparkupNextMapping . ' <c-g>u<Esc>:call <SID>SparkupNext()<cr>'
|
||||
|
||||
if exists('*s:Sparkup')
|
||||
finish
|
||||
endif
|
||||
|
||||
function! s:Sparkup()
|
||||
if !exists('s:sparkup')
|
||||
let s:sparkup = exists('g:sparkup') ? g:sparkup : 'sparkup'
|
||||
let s:sparkupArgs = exists('g:sparkupArgs') ? g:sparkupArgs : '--no-last-newline'
|
||||
" check the user's path first. if not found then search relative to
|
||||
" sparkup.vim in the runtimepath.
|
||||
if !executable(s:sparkup)
|
||||
let paths = substitute(escape(&runtimepath, ' '), '\(,\|$\)', '/**\1', 'g')
|
||||
let s:sparkup = findfile('sparkup.py', paths)
|
||||
|
||||
if !filereadable(s:sparkup)
|
||||
echohl WarningMsg
|
||||
echom 'Warning: could not find sparkup on your path or in your vim runtime path.'
|
||||
echohl None
|
||||
finish
|
||||
endif
|
||||
endif
|
||||
let s:sparkup = '"' . s:sparkup . '"'
|
||||
let s:sparkup .= printf(' %s --indent-spaces=%s', s:sparkupArgs, &shiftwidth)
|
||||
if has('win32') || has('win64')
|
||||
let s:sparkup = 'python ' . s:sparkup
|
||||
endif
|
||||
endif
|
||||
exec '.!' . s:sparkup
|
||||
call s:SparkupNext()
|
||||
endfunction
|
||||
|
||||
function! s:SparkupNext()
|
||||
" 1: empty tag, 2: empty attribute, 3: empty line
|
||||
let n = search('><\/\|\(""\)\|^\s*$', 'Wp')
|
||||
if n == 3
|
||||
startinsert!
|
||||
else
|
||||
execute 'normal l'
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
+1
@@ -0,0 +1 @@
|
||||
/Users/sjl/lib/dotfiles/vim/bundle/sparkup/ftplugin/html
|
||||
@@ -0,0 +1 @@
|
||||
*.swp
|
||||
@@ -0,0 +1,118 @@
|
||||
" vimrc file for following the coding standards specified in PEP 7 & 8.
|
||||
"
|
||||
" To use this file, source it in your own personal .vimrc file (``source
|
||||
" <filename>``) or, if you don't have a .vimrc file, you can just symlink to it
|
||||
" (``ln -s <this file> ~/.vimrc``). All options are protected by autocmds
|
||||
" (read below for an explanation of the command) so blind sourcing of this file
|
||||
" is safe and will not affect your settings for non-Python or non-C files.
|
||||
"
|
||||
"
|
||||
" All setting are protected by 'au' ('autocmd') statements. Only files ending
|
||||
" in .py or .pyw will trigger the Python settings while files ending in *.c or
|
||||
" *.h will trigger the C settings. This makes the file "safe" in terms of only
|
||||
" adjusting settings for Python and C files.
|
||||
"
|
||||
" Only basic settings needed to enforce the style guidelines are set.
|
||||
" Some suggested options are listed but commented out at the end of this file.
|
||||
|
||||
" Number of spaces that a pre-existing tab is equal to.
|
||||
" For the amount of space used for a new tab use shiftwidth.
|
||||
au BufRead,BufNewFile *py,*pyw,*.c,*.h set tabstop=8
|
||||
|
||||
" What to use for an indent.
|
||||
" This will affect Ctrl-T and 'autoindent'.
|
||||
" Python: 4 spaces
|
||||
" C: tabs (pre-existing files) or 4 spaces (new files)
|
||||
au BufRead,BufNewFile *.py,*pyw,*.html,*.js set shiftwidth=4
|
||||
au BufRead,BufNewFile *.py,*.pyw set expandtab
|
||||
fu Select_c_style()
|
||||
if search('^\t', 'n', 150)
|
||||
set shiftwidth=8
|
||||
set noexpandtab
|
||||
el
|
||||
set shiftwidth=4
|
||||
set expandtab
|
||||
en
|
||||
endf
|
||||
au BufRead,BufNewFile *.c,*.h call Select_c_style()
|
||||
au BufRead,BufNewFile Makefile* set noexpandtab
|
||||
|
||||
" Use the below highlight group when displaying bad whitespace is desired.
|
||||
highlight BadWhitespace ctermbg=red guibg=red
|
||||
|
||||
" Display tabs at the beginning of a line in Python mode as bad.
|
||||
au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
|
||||
" Make trailing whitespace be flagged as bad.
|
||||
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
|
||||
|
||||
" Wrap text after a certain number of characters
|
||||
" Python: 79
|
||||
" C: 79
|
||||
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h set textwidth=79
|
||||
|
||||
" Turn off settings in 'formatoptions' relating to comment formatting.
|
||||
" - c : do not automatically insert the comment leader when wrapping based on
|
||||
" 'textwidth'
|
||||
" - o : do not insert the comment leader when using 'o' or 'O' from command mode
|
||||
" - r : do not insert the comment leader when hitting <Enter> in insert mode
|
||||
" Python: not needed
|
||||
" C: prevents insertion of '*' at the beginning of every line in a comment
|
||||
au BufRead,BufNewFile *.c,*.h set formatoptions-=c formatoptions-=o formatoptions-=r
|
||||
|
||||
" Use UNIX (\n) line endings.
|
||||
" Only used for new files so as to not force existing files to change their
|
||||
" line endings.
|
||||
" Python: yes
|
||||
" C: yes
|
||||
au BufNewFile *.py,*.pyw,*.c,*.h set fileformat=unix
|
||||
|
||||
|
||||
" ----------------------------------------------------------------------------
|
||||
" The following section contains suggested settings. While in no way required
|
||||
" to meet coding standards, they are helpful.
|
||||
|
||||
" Set the default file encoding to UTF-8:
|
||||
set encoding=utf-8
|
||||
|
||||
" Puts a marker at the beginning of the file to differentiate between UTF and
|
||||
" UCS encoding (WARNING: can trick shells into thinking a text file is actually
|
||||
" a binary file when executing the text file): ``set bomb``
|
||||
|
||||
" For full syntax highlighting:
|
||||
let python_highlight_all=1
|
||||
syntax on
|
||||
|
||||
" Automatically indent based on file type:
|
||||
"filetype indent on
|
||||
" Keep indentation level from previous line:
|
||||
"set autoindent
|
||||
|
||||
" Folding based on indentation:
|
||||
set foldmethod=indent
|
||||
set nofoldenable
|
||||
|
||||
""""""""""""""""""""""""""""""""
|
||||
" END http://svn.python.org/projects/python/trunk/Misc/Vim/vimrc
|
||||
""""""""""""""""""""""""""""""""
|
||||
|
||||
filetype plugin on
|
||||
set iskeyword+=.
|
||||
|
||||
autocmd FileType python set omnifunc=pythoncomplete#Complete
|
||||
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
|
||||
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
|
||||
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
|
||||
|
||||
" inoremap <Nul> <C-x><C-o>
|
||||
|
||||
" setlocal tabstop=4
|
||||
setlocal softtabstop=4
|
||||
" setlocal shiftwidth=4
|
||||
" setlocal textwidth=80
|
||||
" setlocal smarttab
|
||||
" setlocal expandtab
|
||||
" setlocal smartindent
|
||||
" set noic "no ignore case
|
||||
" set t_Co=256
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
Python-Vim-IDE
|
||||
==============
|
||||
|
||||
There will be multiple branches. The first branch will be the basic branch.
|
||||
The basic branch will stay true to vim defaults, adding PEP008 and basic
|
||||
onmicomplete, folding and path-hacking for django settings with few/no remaps.
|
||||
I will branch from here with a more featureful config with nerdtree, supertab and more.
|
||||
|
||||
The idea will be that one can check it out and symlink to $VIMRUNTIME and change
|
||||
configs just by checking out a different branch.
|
||||
|
||||
|
||||
Current details of basic
|
||||
========================
|
||||
|
||||
* Syntax highlighting
|
||||
|
||||
* (http://www.vim.org/scripts/script.php?script_id=790)
|
||||
* now in .vim/syntax/python.vim
|
||||
|
||||
* Indention
|
||||
|
||||
* simple use of the following works::
|
||||
|
||||
if has("autocmd")
|
||||
filetype plugin indent on
|
||||
endif
|
||||
|
||||
I uncommented this from my global /etc/vim/vimrc
|
||||
|
||||
* Folding
|
||||
|
||||
* Just going to use indentation folds from the default .vimrc::
|
||||
|
||||
:help fold
|
||||
|
||||
zM to fold everything
|
||||
zR to unfold everything
|
||||
za to toggle the current fold
|
||||
zA to recursively toggle the current fold
|
||||
|
||||
Everything is unfolded to start.
|
||||
|
||||
* Code completion
|
||||
|
||||
* Going with regular http://www.vim.org/scripts/script.php?script_id=1542::
|
||||
|
||||
still <c-x><c-o> for omnicomplete (may remap to <s-tab>)
|
||||
still <c-p> for keyword completion (may remap to <tab>)
|
||||
|
||||
* :help preview
|
||||
|
||||
To see how to do things like close the preview viewport (:pc)
|
||||
|
||||
* Django settings:
|
||||
|
||||
There are two ways that you can get the settings module imported and be able to omnicomplete
|
||||
modules that rely on ``DJANGO_SETTINGS_MODULE``::
|
||||
|
||||
1) You can be in an environment with django and settings.py in the CWD, parent or grandparent
|
||||
|
||||
2) You can be inside a virtualenv that contains pinax
|
||||
|
||||
|
||||
supertab branch
|
||||
===============
|
||||
|
||||
The same as above except that code completion is context sensitive and you
|
||||
can get it with <tab>. So, if you are in insert mode and you have::
|
||||
|
||||
import django
|
||||
|
||||
you can start typing django and complete it with keyword completion::
|
||||
|
||||
dja<tab>
|
||||
|
||||
then you can type ``.`` and ``<tab>`` again and get omnicompletion::
|
||||
|
||||
django.c<tab>
|
||||
|
||||
this will give you a dropdown between ``conf``, ``core`` and ``contrib``
|
||||
|
||||
|
||||
@@ -0,0 +1,662 @@
|
||||
"pythoncomplete.vim - Omni Completion for python
|
||||
" Maintainer: Aaron Griffin <aaronmgriffin@gmail.com>
|
||||
" Version: 0.9
|
||||
" Last Updated: 18 Jun 2009
|
||||
"
|
||||
" Changes
|
||||
" TODO:
|
||||
" 'info' item output can use some formatting work
|
||||
" Add an "unsafe eval" mode, to allow for return type evaluation
|
||||
" Complete basic syntax along with import statements
|
||||
" i.e. "import url<c-x,c-o>"
|
||||
" Continue parsing on invalid line??
|
||||
"
|
||||
" v 0.9
|
||||
" * Fixed docstring parsing for classes and functions
|
||||
" * Fixed parsing of *args and **kwargs type arguments
|
||||
" * Better function param parsing to handle things like tuples and
|
||||
" lambda defaults args
|
||||
"
|
||||
" v 0.8
|
||||
" * Fixed an issue where the FIRST assignment was always used instead of
|
||||
" using a subsequent assignment for a variable
|
||||
" * Fixed a scoping issue when working inside a parameterless function
|
||||
"
|
||||
"
|
||||
" v 0.7
|
||||
" * Fixed function list sorting (_ and __ at the bottom)
|
||||
" * Removed newline removal from docs. It appears vim handles these better in
|
||||
" recent patches
|
||||
"
|
||||
" v 0.6:
|
||||
" * Fixed argument completion
|
||||
" * Removed the 'kind' completions, as they are better indicated
|
||||
" with real syntax
|
||||
" * Added tuple assignment parsing (whoops, that was forgotten)
|
||||
" * Fixed import handling when flattening scope
|
||||
"
|
||||
" v 0.5:
|
||||
" Yeah, I skipped a version number - 0.4 was never public.
|
||||
" It was a bugfix version on top of 0.3. This is a complete
|
||||
" rewrite.
|
||||
"
|
||||
|
||||
if !has('python')
|
||||
echo "Error: Required vim compiled with +python"
|
||||
finish
|
||||
endif
|
||||
|
||||
function! pythoncomplete#Complete(findstart, base)
|
||||
"findstart = 1 when we need to get the text length
|
||||
if a:findstart == 1
|
||||
let line = getline('.')
|
||||
let idx = col('.')
|
||||
while idx > 0
|
||||
let idx -= 1
|
||||
let c = line[idx]
|
||||
if c =~ '\w'
|
||||
continue
|
||||
elseif ! c =~ '\.'
|
||||
let idx = -1
|
||||
break
|
||||
else
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
|
||||
return idx
|
||||
"findstart = 0 when we need to return the list of completions
|
||||
else
|
||||
"vim no longer moves the cursor upon completion... fix that
|
||||
let line = getline('.')
|
||||
let idx = col('.')
|
||||
let cword = ''
|
||||
while idx > 0
|
||||
let idx -= 1
|
||||
let c = line[idx]
|
||||
if c =~ '\w' || c =~ '\.'
|
||||
let cword = c . cword
|
||||
continue
|
||||
elseif strlen(cword) > 0 || idx == 0
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
execute "python vimcomplete('" . cword . "', '" . a:base . "')"
|
||||
return g:pythoncomplete_completions
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:DefPython()
|
||||
python << PYTHONEOF
|
||||
import sys, tokenize, cStringIO, types, os
|
||||
from token import NAME, DEDENT, NEWLINE, STRING
|
||||
|
||||
''' Path-hacking for django by SKYL '''
|
||||
|
||||
parent = os.path.split( os.getcwd() )[0]
|
||||
gparent = os.path.split( parent )[0]
|
||||
|
||||
sys.path.append( os.getcwd() )
|
||||
sys.path.append( parent )
|
||||
sys.path.append( gparent )
|
||||
|
||||
try:
|
||||
# if you have django installed, and a settings.py in your CWD,
|
||||
# the parent or the grandparent,
|
||||
# you can use those project settings
|
||||
import settings
|
||||
import django.core.management
|
||||
django.core.management.setup_environ(settings)
|
||||
|
||||
#print 'got Django settings', settings.__file__
|
||||
|
||||
except ImportError:
|
||||
# if you have pinax in your env, you can use the social_project
|
||||
# settings
|
||||
try:
|
||||
from pinax.projects.social_project import settings
|
||||
import django.core.management
|
||||
django.core.management.setup_environ(settings)
|
||||
|
||||
#print 'got Django settings', settings.__file__
|
||||
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
''' END PATH HACKING '''
|
||||
|
||||
|
||||
debugstmts=[]
|
||||
def dbg(s): debugstmts.append(s)
|
||||
def showdbg():
|
||||
for d in debugstmts: print "DBG: %s " % d
|
||||
|
||||
def vimcomplete(context,match):
|
||||
global debugstmts
|
||||
debugstmts = []
|
||||
try:
|
||||
import vim
|
||||
def complsort(x,y):
|
||||
try:
|
||||
xa = x['abbr']
|
||||
ya = y['abbr']
|
||||
if xa[0] == '_':
|
||||
if xa[1] == '_' and ya[0:2] == '__':
|
||||
return xa > ya
|
||||
elif ya[0:2] == '__':
|
||||
return -1
|
||||
elif y[0] == '_':
|
||||
return xa > ya
|
||||
else:
|
||||
return 1
|
||||
elif ya[0] == '_':
|
||||
return -1
|
||||
else:
|
||||
return xa > ya
|
||||
except:
|
||||
return 0
|
||||
cmpl = Completer()
|
||||
cmpl.evalsource('\n'.join(vim.current.buffer),vim.eval("line('.')"))
|
||||
all = cmpl.get_completions(context,match)
|
||||
all.sort(complsort)
|
||||
dictstr = '['
|
||||
# have to do this for double quoting
|
||||
for cmpl in all:
|
||||
dictstr += '{'
|
||||
for x in cmpl: dictstr += '"%s":"%s",' % (x,cmpl[x])
|
||||
dictstr += '"icase":0},'
|
||||
if dictstr[-1] == ',': dictstr = dictstr[:-1]
|
||||
dictstr += ']'
|
||||
#dbg("dict: %s" % dictstr)
|
||||
vim.command("silent let g:pythoncomplete_completions = %s" % dictstr)
|
||||
#dbg("Completion dict:\n%s" % all)
|
||||
except vim.error:
|
||||
dbg("VIM Error: %s" % vim.error)
|
||||
|
||||
class Completer(object):
|
||||
def __init__(self):
|
||||
self.compldict = {}
|
||||
self.parser = PyParser()
|
||||
|
||||
def evalsource(self,text,line=0):
|
||||
sc = self.parser.parse(text,line)
|
||||
src = sc.get_code()
|
||||
dbg("source: %s" % src)
|
||||
try: exec(src) in self.compldict
|
||||
except: dbg("parser: %s, %s" % (sys.exc_info()[0],sys.exc_info()[1]))
|
||||
for l in sc.locals:
|
||||
try: exec(l) in self.compldict
|
||||
except: dbg("locals: %s, %s [%s]" % (sys.exc_info()[0],sys.exc_info()[1],l))
|
||||
|
||||
def _cleanstr(self,doc):
|
||||
return doc.replace('"',' ').replace("'",' ')
|
||||
|
||||
def get_arguments(self,func_obj):
|
||||
def _ctor(obj):
|
||||
try: return class_ob.__init__.im_func
|
||||
except AttributeError:
|
||||
for base in class_ob.__bases__:
|
||||
rc = _find_constructor(base)
|
||||
if rc is not None: return rc
|
||||
return None
|
||||
|
||||
arg_offset = 1
|
||||
if type(func_obj) == types.ClassType: func_obj = _ctor(func_obj)
|
||||
elif type(func_obj) == types.MethodType: func_obj = func_obj.im_func
|
||||
else: arg_offset = 0
|
||||
|
||||
arg_text=''
|
||||
if type(func_obj) in [types.FunctionType, types.LambdaType]:
|
||||
try:
|
||||
cd = func_obj.func_code
|
||||
real_args = cd.co_varnames[arg_offset:cd.co_argcount]
|
||||
defaults = func_obj.func_defaults or ''
|
||||
defaults = map(lambda name: "=%s" % name, defaults)
|
||||
defaults = [""] * (len(real_args)-len(defaults)) + defaults
|
||||
items = map(lambda a,d: a+d, real_args, defaults)
|
||||
if func_obj.func_code.co_flags & 0x4:
|
||||
items.append("...")
|
||||
if func_obj.func_code.co_flags & 0x8:
|
||||
items.append("***")
|
||||
arg_text = (','.join(items)) + ')'
|
||||
|
||||
except:
|
||||
dbg("arg completion: %s: %s" % (sys.exc_info()[0],sys.exc_info()[1]))
|
||||
pass
|
||||
if len(arg_text) == 0:
|
||||
# The doc string sometimes contains the function signature
|
||||
# this works for alot of C modules that are part of the
|
||||
# standard library
|
||||
doc = func_obj.__doc__
|
||||
if doc:
|
||||
doc = doc.lstrip()
|
||||
pos = doc.find('\n')
|
||||
if pos > 0:
|
||||
sigline = doc[:pos]
|
||||
lidx = sigline.find('(')
|
||||
ridx = sigline.find(')')
|
||||
if lidx > 0 and ridx > 0:
|
||||
arg_text = sigline[lidx+1:ridx] + ')'
|
||||
if len(arg_text) == 0: arg_text = ')'
|
||||
return arg_text
|
||||
|
||||
def get_completions(self,context,match):
|
||||
dbg("get_completions('%s','%s')" % (context,match))
|
||||
stmt = ''
|
||||
if context: stmt += str(context)
|
||||
if match: stmt += str(match)
|
||||
try:
|
||||
result = None
|
||||
all = {}
|
||||
ridx = stmt.rfind('.')
|
||||
if len(stmt) > 0 and stmt[-1] == '(':
|
||||
result = eval(_sanitize(stmt[:-1]), self.compldict)
|
||||
doc = result.__doc__
|
||||
if doc is None: doc = ''
|
||||
args = self.get_arguments(result)
|
||||
return [{'word':self._cleanstr(args),'info':self._cleanstr(doc)}]
|
||||
elif ridx == -1:
|
||||
match = stmt
|
||||
all = self.compldict
|
||||
else:
|
||||
match = stmt[ridx+1:]
|
||||
stmt = _sanitize(stmt[:ridx])
|
||||
result = eval(stmt, self.compldict)
|
||||
all = dir(result)
|
||||
|
||||
dbg("completing: stmt:%s" % stmt)
|
||||
completions = []
|
||||
|
||||
try: maindoc = result.__doc__
|
||||
except: maindoc = ' '
|
||||
if maindoc is None: maindoc = ' '
|
||||
for m in all:
|
||||
if m == "_PyCmplNoType": continue #this is internal
|
||||
try:
|
||||
dbg('possible completion: %s' % m)
|
||||
if m.find(match) == 0:
|
||||
if result is None: inst = all[m]
|
||||
else: inst = getattr(result,m)
|
||||
try: doc = inst.__doc__
|
||||
except: doc = maindoc
|
||||
typestr = str(inst)
|
||||
if doc is None or doc == '': doc = maindoc
|
||||
|
||||
wrd = m[len(match):]
|
||||
c = {'word':wrd, 'abbr':m, 'info':self._cleanstr(doc)}
|
||||
if "function" in typestr:
|
||||
c['word'] += '('
|
||||
c['abbr'] += '(' + self._cleanstr(self.get_arguments(inst))
|
||||
elif "method" in typestr:
|
||||
c['word'] += '('
|
||||
c['abbr'] += '(' + self._cleanstr(self.get_arguments(inst))
|
||||
elif "module" in typestr:
|
||||
c['word'] += '.'
|
||||
elif "class" in typestr:
|
||||
c['word'] += '('
|
||||
c['abbr'] += '('
|
||||
completions.append(c)
|
||||
except:
|
||||
i = sys.exc_info()
|
||||
dbg("inner completion: %s,%s [stmt='%s']" % (i[0],i[1],stmt))
|
||||
return completions
|
||||
except:
|
||||
i = sys.exc_info()
|
||||
dbg("completion: %s,%s [stmt='%s']" % (i[0],i[1],stmt))
|
||||
return []
|
||||
|
||||
class Scope(object):
|
||||
def __init__(self,name,indent,docstr=''):
|
||||
self.subscopes = []
|
||||
self.docstr = docstr
|
||||
self.locals = []
|
||||
self.parent = None
|
||||
self.name = name
|
||||
self.indent = indent
|
||||
|
||||
def add(self,sub):
|
||||
#print 'push scope: [%s@%s]' % (sub.name,sub.indent)
|
||||
sub.parent = self
|
||||
self.subscopes.append(sub)
|
||||
return sub
|
||||
|
||||
def doc(self,str):
|
||||
""" Clean up a docstring """
|
||||
d = str.replace('\n',' ')
|
||||
d = d.replace('\t',' ')
|
||||
while d.find(' ') > -1: d = d.replace(' ',' ')
|
||||
while d[0] in '"\'\t ': d = d[1:]
|
||||
while d[-1] in '"\'\t ': d = d[:-1]
|
||||
dbg("Scope(%s)::docstr = %s" % (self,d))
|
||||
self.docstr = d
|
||||
|
||||
def local(self,loc):
|
||||
self._checkexisting(loc)
|
||||
self.locals.append(loc)
|
||||
|
||||
def copy_decl(self,indent=0):
|
||||
""" Copy a scope's declaration only, at the specified indent level - not local variables """
|
||||
return Scope(self.name,indent,self.docstr)
|
||||
|
||||
def _checkexisting(self,test):
|
||||
"Convienance function... keep out duplicates"
|
||||
if test.find('=') > -1:
|
||||
var = test.split('=')[0].strip()
|
||||
for l in self.locals:
|
||||
if l.find('=') > -1 and var == l.split('=')[0].strip():
|
||||
self.locals.remove(l)
|
||||
|
||||
def get_code(self):
|
||||
str = ""
|
||||
if len(self.docstr) > 0: str += '"""'+self.docstr+'"""\n'
|
||||
for l in self.locals:
|
||||
if l.startswith('import'): str += l+'\n'
|
||||
str += 'class _PyCmplNoType:\n def __getattr__(self,name):\n return None\n'
|
||||
for sub in self.subscopes:
|
||||
str += sub.get_code()
|
||||
for l in self.locals:
|
||||
if not l.startswith('import'): str += l+'\n'
|
||||
|
||||
return str
|
||||
|
||||
def pop(self,indent):
|
||||
#print 'pop scope: [%s] to [%s]' % (self.indent,indent)
|
||||
outer = self
|
||||
while outer.parent != None and outer.indent >= indent:
|
||||
outer = outer.parent
|
||||
return outer
|
||||
|
||||
def currentindent(self):
|
||||
#print 'parse current indent: %s' % self.indent
|
||||
return ' '*self.indent
|
||||
|
||||
def childindent(self):
|
||||
#print 'parse child indent: [%s]' % (self.indent+1)
|
||||
return ' '*(self.indent+1)
|
||||
|
||||
class Class(Scope):
|
||||
def __init__(self, name, supers, indent, docstr=''):
|
||||
Scope.__init__(self,name,indent, docstr)
|
||||
self.supers = supers
|
||||
def copy_decl(self,indent=0):
|
||||
c = Class(self.name,self.supers,indent, self.docstr)
|
||||
for s in self.subscopes:
|
||||
c.add(s.copy_decl(indent+1))
|
||||
return c
|
||||
def get_code(self):
|
||||
str = '%sclass %s' % (self.currentindent(),self.name)
|
||||
if len(self.supers) > 0: str += '(%s)' % ','.join(self.supers)
|
||||
str += ':\n'
|
||||
if len(self.docstr) > 0: str += self.childindent()+'"""'+self.docstr+'"""\n'
|
||||
if len(self.subscopes) > 0:
|
||||
for s in self.subscopes: str += s.get_code()
|
||||
else:
|
||||
str += '%spass\n' % self.childindent()
|
||||
return str
|
||||
|
||||
|
||||
class Function(Scope):
|
||||
def __init__(self, name, params, indent, docstr=''):
|
||||
Scope.__init__(self,name,indent, docstr)
|
||||
self.params = params
|
||||
def copy_decl(self,indent=0):
|
||||
return Function(self.name,self.params,indent, self.docstr)
|
||||
def get_code(self):
|
||||
str = "%sdef %s(%s):\n" % \
|
||||
(self.currentindent(),self.name,','.join(self.params))
|
||||
if len(self.docstr) > 0: str += self.childindent()+'"""'+self.docstr+'"""\n'
|
||||
str += "%spass\n" % self.childindent()
|
||||
return str
|
||||
|
||||
class PyParser:
|
||||
def __init__(self):
|
||||
self.top = Scope('global',0)
|
||||
self.scope = self.top
|
||||
|
||||
def _parsedotname(self,pre=None):
|
||||
#returns (dottedname, nexttoken)
|
||||
name = []
|
||||
if pre is None:
|
||||
tokentype, token, indent = self.next()
|
||||
if tokentype != NAME and token != '*':
|
||||
return ('', token)
|
||||
else: token = pre
|
||||
name.append(token)
|
||||
while True:
|
||||
tokentype, token, indent = self.next()
|
||||
if token != '.': break
|
||||
tokentype, token, indent = self.next()
|
||||
if tokentype != NAME: break
|
||||
name.append(token)
|
||||
return (".".join(name), token)
|
||||
|
||||
def _parseimportlist(self):
|
||||
imports = []
|
||||
while True:
|
||||
name, token = self._parsedotname()
|
||||
if not name: break
|
||||
name2 = ''
|
||||
if token == 'as': name2, token = self._parsedotname()
|
||||
imports.append((name, name2))
|
||||
while token != "," and "\n" not in token:
|
||||
tokentype, token, indent = self.next()
|
||||
if token != ",": break
|
||||
return imports
|
||||
|
||||
def _parenparse(self):
|
||||
name = ''
|
||||
names = []
|
||||
level = 1
|
||||
while True:
|
||||
tokentype, token, indent = self.next()
|
||||
if token in (')', ',') and level == 1:
|
||||
if '=' not in name: name = name.replace(' ', '')
|
||||
names.append(name.strip())
|
||||
name = ''
|
||||
if token == '(':
|
||||
level += 1
|
||||
name += "("
|
||||
elif token == ')':
|
||||
level -= 1
|
||||
if level == 0: break
|
||||
else: name += ")"
|
||||
elif token == ',' and level == 1:
|
||||
pass
|
||||
else:
|
||||
name += "%s " % str(token)
|
||||
return names
|
||||
|
||||
def _parsefunction(self,indent):
|
||||
self.scope=self.scope.pop(indent)
|
||||
tokentype, fname, ind = self.next()
|
||||
if tokentype != NAME: return None
|
||||
|
||||
tokentype, open, ind = self.next()
|
||||
if open != '(': return None
|
||||
params=self._parenparse()
|
||||
|
||||
tokentype, colon, ind = self.next()
|
||||
if colon != ':': return None
|
||||
|
||||
return Function(fname,params,indent)
|
||||
|
||||
def _parseclass(self,indent):
|
||||
self.scope=self.scope.pop(indent)
|
||||
tokentype, cname, ind = self.next()
|
||||
if tokentype != NAME: return None
|
||||
|
||||
super = []
|
||||
tokentype, next, ind = self.next()
|
||||
if next == '(':
|
||||
super=self._parenparse()
|
||||
elif next != ':': return None
|
||||
|
||||
return Class(cname,super,indent)
|
||||
|
||||
def _parseassignment(self):
|
||||
assign=''
|
||||
tokentype, token, indent = self.next()
|
||||
if tokentype == tokenize.STRING or token == 'str':
|
||||
return '""'
|
||||
elif token == '(' or token == 'tuple':
|
||||
return '()'
|
||||
elif token == '[' or token == 'list':
|
||||
return '[]'
|
||||
elif token == '{' or token == 'dict':
|
||||
return '{}'
|
||||
elif tokentype == tokenize.NUMBER:
|
||||
return '0'
|
||||
elif token == 'open' or token == 'file':
|
||||
return 'file'
|
||||
elif token == 'None':
|
||||
return '_PyCmplNoType()'
|
||||
elif token == 'type':
|
||||
return 'type(_PyCmplNoType)' #only for method resolution
|
||||
else:
|
||||
assign += token
|
||||
level = 0
|
||||
while True:
|
||||
tokentype, token, indent = self.next()
|
||||
if token in ('(','{','['):
|
||||
level += 1
|
||||
elif token in (']','}',')'):
|
||||
level -= 1
|
||||
if level == 0: break
|
||||
elif level == 0:
|
||||
if token in (';','\n'): break
|
||||
assign += token
|
||||
return "%s" % assign
|
||||
|
||||
def next(self):
|
||||
type, token, (lineno, indent), end, self.parserline = self.gen.next()
|
||||
if lineno == self.curline:
|
||||
#print 'line found [%s] scope=%s' % (line.replace('\n',''),self.scope.name)
|
||||
self.currentscope = self.scope
|
||||
return (type, token, indent)
|
||||
|
||||
def _adjustvisibility(self):
|
||||
newscope = Scope('result',0)
|
||||
scp = self.currentscope
|
||||
while scp != None:
|
||||
if type(scp) == Function:
|
||||
slice = 0
|
||||
#Handle 'self' params
|
||||
if scp.parent != None and type(scp.parent) == Class:
|
||||
slice = 1
|
||||
newscope.local('%s = %s' % (scp.params[0],scp.parent.name))
|
||||
for p in scp.params[slice:]:
|
||||
i = p.find('=')
|
||||
if len(p) == 0: continue
|
||||
pvar = ''
|
||||
ptype = ''
|
||||
if i == -1:
|
||||
pvar = p
|
||||
ptype = '_PyCmplNoType()'
|
||||
else:
|
||||
pvar = p[:i]
|
||||
ptype = _sanitize(p[i+1:])
|
||||
if pvar.startswith('**'):
|
||||
pvar = pvar[2:]
|
||||
ptype = '{}'
|
||||
elif pvar.startswith('*'):
|
||||
pvar = pvar[1:]
|
||||
ptype = '[]'
|
||||
|
||||
newscope.local('%s = %s' % (pvar,ptype))
|
||||
|
||||
for s in scp.subscopes:
|
||||
ns = s.copy_decl(0)
|
||||
newscope.add(ns)
|
||||
for l in scp.locals: newscope.local(l)
|
||||
scp = scp.parent
|
||||
|
||||
self.currentscope = newscope
|
||||
return self.currentscope
|
||||
|
||||
#p.parse(vim.current.buffer[:],vim.eval("line('.')"))
|
||||
def parse(self,text,curline=0):
|
||||
self.curline = int(curline)
|
||||
buf = cStringIO.StringIO(''.join(text) + '\n')
|
||||
self.gen = tokenize.generate_tokens(buf.readline)
|
||||
self.currentscope = self.scope
|
||||
|
||||
try:
|
||||
freshscope=True
|
||||
while True:
|
||||
tokentype, token, indent = self.next()
|
||||
#dbg( 'main: token=[%s] indent=[%s]' % (token,indent))
|
||||
|
||||
if tokentype == DEDENT or token == "pass":
|
||||
self.scope = self.scope.pop(indent)
|
||||
elif token == 'def':
|
||||
func = self._parsefunction(indent)
|
||||
if func is None:
|
||||
print "function: syntax error..."
|
||||
continue
|
||||
dbg("new scope: function")
|
||||
freshscope = True
|
||||
self.scope = self.scope.add(func)
|
||||
elif token == 'class':
|
||||
cls = self._parseclass(indent)
|
||||
if cls is None:
|
||||
print "class: syntax error..."
|
||||
continue
|
||||
freshscope = True
|
||||
dbg("new scope: class")
|
||||
self.scope = self.scope.add(cls)
|
||||
|
||||
elif token == 'import':
|
||||
imports = self._parseimportlist()
|
||||
for mod, alias in imports:
|
||||
loc = "import %s" % mod
|
||||
if len(alias) > 0: loc += " as %s" % alias
|
||||
self.scope.local(loc)
|
||||
freshscope = False
|
||||
elif token == 'from':
|
||||
mod, token = self._parsedotname()
|
||||
if not mod or token != "import":
|
||||
print "from: syntax error..."
|
||||
continue
|
||||
names = self._parseimportlist()
|
||||
for name, alias in names:
|
||||
loc = "from %s import %s" % (mod,name)
|
||||
if len(alias) > 0: loc += " as %s" % alias
|
||||
self.scope.local(loc)
|
||||
freshscope = False
|
||||
elif tokentype == STRING:
|
||||
if freshscope: self.scope.doc(token)
|
||||
elif tokentype == NAME:
|
||||
name,token = self._parsedotname(token)
|
||||
if token == '=':
|
||||
stmt = self._parseassignment()
|
||||
dbg("parseassignment: %s = %s" % (name, stmt))
|
||||
if stmt != None:
|
||||
self.scope.local("%s = %s" % (name,stmt))
|
||||
freshscope = False
|
||||
except StopIteration: #thrown on EOF
|
||||
pass
|
||||
except:
|
||||
dbg("parse error: %s, %s @ %s" %
|
||||
(sys.exc_info()[0], sys.exc_info()[1], self.parserline))
|
||||
return self._adjustvisibility()
|
||||
|
||||
def _sanitize(str):
|
||||
val = ''
|
||||
level = 0
|
||||
for c in str:
|
||||
if c in ('(','{','['):
|
||||
level += 1
|
||||
elif c in (']','}',')'):
|
||||
level -= 1
|
||||
elif level == 0:
|
||||
val += c
|
||||
return val
|
||||
|
||||
|
||||
sys.path.extend(['.','..'])
|
||||
|
||||
PYTHONEOF
|
||||
endfunction
|
||||
|
||||
call s:DefPython()
|
||||
" vim: set et ts=4:
|
||||
@@ -0,0 +1,308 @@
|
||||
*supertab.txt*
|
||||
|
||||
Authors:
|
||||
Original: Gergely Kontra <kgergely@mcl.hu>
|
||||
Current: Eric Van Dewoestine <ervandew@gmail.com> (as of version 0.4)
|
||||
|
||||
Contributors:
|
||||
Christophe-Marie Duquesne <chm.duquesne@gmail.com> (documentation)
|
||||
|
||||
Please direct all correspondence to Eric.
|
||||
|
||||
This plugin is licensed under the terms of the BSD License. Please see
|
||||
supertab.vim for the license in its entirety.
|
||||
|
||||
==============================================================================
|
||||
Supertab *supertab*
|
||||
|
||||
1. Introduction |supertab-intro|
|
||||
2. Supertab Usage |supertab-usage|
|
||||
3. Supertab Options |supertab-options|
|
||||
Default completion type |supertab-defaultcompletion|
|
||||
Secondary default completion type |supertab-contextdefault|
|
||||
Completion contexts |supertab-completioncontexts|
|
||||
Context text |supertab-contexttext|
|
||||
Context Discover |supertab-contextdiscover|
|
||||
Example |supertab-contextexample|
|
||||
Completion Duration |supertab-duration|
|
||||
Midword completion |supertab-midword|
|
||||
Changing default mapping |supertab-forwardbackward|
|
||||
Inserting true tabs |supertab-mappingtabliteral|
|
||||
Preselecting the first entry |supertab-longesthighlight|
|
||||
|
||||
==============================================================================
|
||||
1. Introduction *supertab-intro*
|
||||
|
||||
Supertab is a plugin which allows you to perform all your insert completion
|
||||
(|ins-completion|) using the tab key.
|
||||
|
||||
Supertab requires Vim version 7.0 or above.
|
||||
|
||||
==============================================================================
|
||||
2. Supertab usage *supertab-usage*
|
||||
|
||||
Using Supertab is as easy as hitting <Tab> or <S-Tab> (shift+tab) while in
|
||||
insert mode, with at least one non whitespace character before the cursor, to
|
||||
start the completion and then <Tab> or <S-Tab> again to cycle forwards or
|
||||
backwards through the available completions.
|
||||
|
||||
Example ('|' denotes the cursor location):
|
||||
|
||||
bar
|
||||
baz
|
||||
b|<Tab> Hitting <Tab> here will start the completion, allowing you to
|
||||
then cycle through the suggested words ('bar' and 'baz').
|
||||
|
||||
==============================================================================
|
||||
3. Supertab Options *supertab-options*
|
||||
|
||||
Supertab is configured via several global variables that you can set in your
|
||||
|vimrc| file according to your needs. Below is a comprehensive list of
|
||||
the variables available.
|
||||
|
||||
g:SuperTabDefaultCompletionType |supertab-defaultcompletion|
|
||||
The default completion type to use. If you program in languages that support
|
||||
omni or user completions, it is highly recommended setting this to
|
||||
'context'.
|
||||
|
||||
For help about built in completion types in vim, see |i_CTRL-X_index|.
|
||||
|
||||
g:SuperTabContextDefaultCompletionType |supertab-contextdefault|
|
||||
The default completion type to use when 'context' is the global default, but
|
||||
context completion has determined that neither omni, user, or file
|
||||
completion should be used in the current context.
|
||||
|
||||
g:SuperTabCompletionContexts |supertab-completioncontexts|
|
||||
Used to configure a list of function names which are used when the global
|
||||
default type is 'context'. These functions will be consulted in order to
|
||||
determine which completion type to use. Advanced users can plug in their own
|
||||
functions here to customize their 'context' completion.
|
||||
|
||||
g:SuperTabRetainCompletionDuration |supertab-duration|
|
||||
This setting determines how long a non-default completion type should be
|
||||
retained as the temporary default. By default supertab will retain the
|
||||
alternate completion type until you leave insert mode.
|
||||
|
||||
g:SuperTabMidWordCompletion |supertab-midword|
|
||||
This can be used to turn off completion if you are in the middle of a word
|
||||
(word characters immediately preceding and following the cursor).
|
||||
|
||||
g:SuperTabMappingForward |supertab-forwardbackward|
|
||||
g:SuperTabMappingBackward |supertab-forwardbackward|
|
||||
If using the tab key for completion isn't for you, then you can use these to
|
||||
set an alternate key to be used for your insert completion needs.
|
||||
|
||||
g:SuperTabMappingTabLiteral |supertab-mappingtabliteral|
|
||||
For those rare cases where supertab would normal want to start insert
|
||||
completion, but you just want to insert a tab, this setting is used to
|
||||
define the key combination to use to do just that. By default Ctrl-Tab is
|
||||
used.
|
||||
|
||||
g:SuperTabLongestHighlight |supertab-longesthighlight|
|
||||
When enabled and you have the completion popup enable and 'longest' in your
|
||||
completeopt, supertab will auto highlight the first selection in the popup.
|
||||
|
||||
|
||||
Default Completion Type *supertab-defaultcompletion*
|
||||
*g:SuperTabDefaultCompletionType*
|
||||
|
||||
g:SuperTabDefaultCompletionType (default value: "<c-p>")
|
||||
|
||||
Used to set the default completion type. There is no need to escape this
|
||||
value as that will be done for you when the type is set.
|
||||
|
||||
Example: setting the default completion to 'user' completion:
|
||||
|
||||
let g:SuperTabDefaultCompletionType = "<c-x><c-u>"
|
||||
|
||||
Note: a special value of 'context' is supported which will result in
|
||||
super tab attempting to use the text preceding the cursor to decide which
|
||||
type of completion to attempt. Currently super tab can recognize method
|
||||
calls or attribute references via '.', '::' or '->', and file path
|
||||
references containing '/'.
|
||||
|
||||
let g:SuperTabDefaultCompletionType = "context"
|
||||
|
||||
/usr/l<tab> # will use filename completion
|
||||
myvar.t<tab> # will use user completion if completefunc set,
|
||||
# or omni completion if omnifunc set.
|
||||
myvar-><tab> # same as above
|
||||
|
||||
When using context completion, super tab will fall back to a secondary default
|
||||
completion type set by |g:SuperTabContextDefaultCompletionType|.
|
||||
|
||||
Note: once the buffer has been initialized, changing the value of this setting
|
||||
will not change the default complete type used. If you want to change the
|
||||
default completion type for the current buffer after it has been set, perhaps
|
||||
in an ftplugin, you'll need to call SuperTabSetDefaultCompletionType like so,
|
||||
supplying the completion type you wish to switch to:
|
||||
|
||||
call SuperTabSetDefaultCompletionType("<c-x><c-u>")
|
||||
|
||||
|
||||
Secondary default completion type *supertab-contextdefault*
|
||||
*g:SuperTabContextDefaultCompletionType*
|
||||
|
||||
g:SuperTabContextDefaultCompletionType (default value: "<c-p>")
|
||||
|
||||
Sets the default completion type used when g:SuperTabDefaultCompletionType is
|
||||
set to 'context' and no completion type is returned by any of the configured
|
||||
contexts.
|
||||
|
||||
|
||||
Completion contexts *supertab-completioncontexts*
|
||||
*g:SuperTabCompletionContexts*
|
||||
|
||||
g:SuperTabCompletionContexts (default value: ['s:ContextText'])
|
||||
|
||||
Sets the list of contexts used for context completion. This value should
|
||||
be a list of function names which provide the context implementation.
|
||||
|
||||
When supertab starts the default completion, each of these contexts will be
|
||||
consulted, in the order they were supplied, to determine the completion type
|
||||
to use. If a context returns a completion type, that type will be used,
|
||||
otherwise the next context in the list will be consulted. If after executing
|
||||
all the context functions, no completion type has been determined, then the
|
||||
value of g:SuperTabContextDefaultCompletionType will be used.
|
||||
|
||||
Built in completion contexts:
|
||||
|
||||
s:ContextText *supertab-contexttext*
|
||||
|
||||
The text context will examine the text near the cursor to decide which type
|
||||
of completion to attempt. Currently the text context can recognize method
|
||||
calls or attribute references via '.', '::' or '->', and file path
|
||||
references containing '/'.
|
||||
|
||||
/usr/l<tab> # will use filename completion
|
||||
myvar.t<tab> # will use user completion if completefunc set, or
|
||||
# omni completion if omnifunc set.
|
||||
myvar-><tab> # same as above
|
||||
|
||||
Supported configuration attributes:
|
||||
|
||||
g:SuperTabContextTextFileTypeExclusions
|
||||
List of file types for which the text context will be skipped.
|
||||
|
||||
g:SuperTabContextTextOmniPrecedence
|
||||
List of omni completion option names in the order of precedence that they
|
||||
should be used if available. By default, user completion will be given
|
||||
precedence over omni completion, but you can use this variable to give
|
||||
omni completion higher precedence by placing it first in the list.
|
||||
|
||||
s:ContextDiscover *supertab-contextdiscover*
|
||||
|
||||
This context will use the 'g:SuperTabContextDiscoverDiscovery' variable to
|
||||
determine the completion type to use. It will evaluate each value, in the
|
||||
order they were defined, until a variable evaluates to a non-zero or
|
||||
non-empty value, then the associated completion type is used.
|
||||
|
||||
Supported configuration properties:
|
||||
|
||||
g:SuperTabContextDiscoverDiscovery
|
||||
List of variable:completionType mappings.
|
||||
|
||||
Example context configuration: *supertab-contextexample*
|
||||
|
||||
let g:SuperTabCompletionContexts = ['s:ContextText', 's:ContextDiscover']
|
||||
let g:SuperTabContextTextOmniPrecedence = ['&omnifunc', '&completefunc']
|
||||
let g:SuperTabContextDiscoverDiscovery =
|
||||
\ ["&completefunc:<c-x><c-u>", "&omnifunc:<c-x><c-o>"]
|
||||
|
||||
In addition to the default completion contexts, you can plug in your own
|
||||
implementation by creating a globally accessible function that returns
|
||||
the completion type to use (eg. "\<c-x>\<c-u>").
|
||||
|
||||
function MyTagContext()
|
||||
if filereadable(expand('%:p:h') . '/tags')
|
||||
return "\<c-x>\<c-]>"
|
||||
endif
|
||||
" no return will result in the evaluation of the next
|
||||
" configured context
|
||||
endfunction
|
||||
let g:SuperTabCompletionContexts =
|
||||
\ ['MyTagContext', 's:ContextText', 's:ContextDiscover']
|
||||
|
||||
Note: supertab also supports the b:SuperTabCompletionContexts variable
|
||||
allowing you to set the list of contexts separately for the current buffer,
|
||||
like from an ftplugin for example.
|
||||
|
||||
|
||||
Completion Duration *supertab-duration*
|
||||
*g:SuperTabRetainCompletionDuration*
|
||||
|
||||
g:SuperTabRetainCompletionDuration (default value: 'insert')
|
||||
|
||||
Determines if, and for how long, the current completion type is retained.
|
||||
The possible values include:
|
||||
'completion' - The current completion type is only retained for the
|
||||
current completion. Once you have chosen a completion
|
||||
result or exited the completion mode, the default
|
||||
completion type is restored.
|
||||
'insert' - The current completion type is saved until you exit insert
|
||||
mode (via ESC). Once you exit insert mode the default
|
||||
completion type is restored. (supertab default)
|
||||
'session' - The current completion type is saved for the duration of
|
||||
your vim session or until you enter a different completion
|
||||
mode.
|
||||
|
||||
|
||||
Midword completion *supertab-midword*
|
||||
*g:SuperTabMidWordCompletion*
|
||||
|
||||
g:SuperTabMidWordCompletion (default value: 1)
|
||||
|
||||
Sets whether or not mid word completion is enabled. When enabled, <tab> will
|
||||
kick off completion when ever a non whitespace character is to the left of the
|
||||
cursor. When disabled, completion will only occur if the char to the left is
|
||||
non whitespace char and the char to the right is not a keyword character (you
|
||||
are at the end of the word).
|
||||
|
||||
|
||||
Changing the default mapping *supertab-forwardbackward*
|
||||
*g:SuperTabMappingForward*
|
||||
*g:SuperTabMappingBackward*
|
||||
|
||||
g:SuperTabMappingForward (default value: '<tab>')
|
||||
g:SuperTabMappingBackward (default value: '<s-tab>')
|
||||
|
||||
These two variables allow you to set the keys used to kick off the current
|
||||
completion. By default this is <tab> and <s-tab>. To change to something
|
||||
like <c-space> and <s-c-space>, you can add the following to your |vimrc|.
|
||||
|
||||
let g:SuperTabMappingForward = '<c-space>'
|
||||
let g:SuperTabMappingBackward = '<s-c-space>'
|
||||
|
||||
Note: if the above does not have the desired effect (which may happen in
|
||||
console version of vim), you can try the following mappings. Although the
|
||||
backwards mapping still doesn't seem to work in the console for me, your
|
||||
milage may vary.
|
||||
|
||||
let g:SuperTabMappingForward = '<nul>'
|
||||
let g:SuperTabMappingBackward = '<s-nul>'
|
||||
|
||||
|
||||
Inserting true tabs *supertab-mappingtabliteral*
|
||||
*g:SuperTabMappingTabLiteral*
|
||||
|
||||
g:SuperTabMappingTabLiteral (default value: '<c-tab>')
|
||||
|
||||
Sets the key mapping used to insert a literal tab where supertab would
|
||||
otherwise attempt to kick off insert completion. The default is '<c-tab>'
|
||||
(ctrl-tab) which unfortunately might not work at the console. So if you are
|
||||
using a console vim and want this functionality, you may have to change it to
|
||||
something that is supported. Alternatively, you can escape the <tab> with
|
||||
<c-v> (see |i_CTRL-V| for more infos).
|
||||
|
||||
|
||||
Preselecting the first entry *supertab-longesthighlight*
|
||||
*g:SuperTabLongestHighlight*
|
||||
|
||||
g:SuperTabLongestHighlight (default value: 0)
|
||||
|
||||
Sets whether or not to pre-highlight the first match when completeopt has the
|
||||
popup menu enabled and the 'longest' option as well. When enabled, <tab> will
|
||||
kick off completion and pre-select the first entry in the popup menu, allowing
|
||||
you to simply hit <enter> to use it.
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
@@ -0,0 +1,511 @@
|
||||
" Author:
|
||||
" Original: Gergely Kontra <kgergely@mcl.hu>
|
||||
" Current: Eric Van Dewoestine <ervandew@gmail.com> (as of version 0.4)
|
||||
" Please direct all correspondence to Eric.
|
||||
" Version: 1.0
|
||||
" GetLatestVimScripts: 1643 1 :AutoInstall: supertab.vim
|
||||
"
|
||||
" Description: {{{
|
||||
" Use your tab key to do all your completion in insert mode!
|
||||
" You can cycle forward and backward with the <Tab> and <S-Tab> keys
|
||||
" Note: you must press <Tab> once to be able to cycle back
|
||||
"
|
||||
" http://www.vim.org/scripts/script.php?script_id=1643
|
||||
" }}}
|
||||
"
|
||||
" License: {{{
|
||||
" Software License Agreement (BSD License)
|
||||
"
|
||||
" Copyright (c) 2002 - 2009
|
||||
" All rights reserved.
|
||||
"
|
||||
" Redistribution and use of this software in source and binary forms, with
|
||||
" or without modification, are permitted provided that the following
|
||||
" conditions are met:
|
||||
"
|
||||
" * Redistributions of source code must retain the above
|
||||
" copyright notice, this list of conditions and the
|
||||
" following disclaimer.
|
||||
"
|
||||
" * Redistributions in binary form must reproduce the above
|
||||
" copyright notice, this list of conditions and the
|
||||
" following disclaimer in the documentation and/or other
|
||||
" materials provided with the distribution.
|
||||
"
|
||||
" * Neither the name of Gergely Kontra or Eric Van Dewoestine nor the names
|
||||
" of its contributors may be used to endorse or promote products derived
|
||||
" from this software without specific prior written permission of Gergely
|
||||
" Kontra or Eric Van Dewoestine.
|
||||
"
|
||||
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
" }}}
|
||||
"
|
||||
" Testing Info: {{{
|
||||
" Running vim + supertab with the absolute bar minimum settings:
|
||||
" $ vim -u NONE -U NONE -c "set nocp | runtime plugin/supertab.vim"
|
||||
" }}}
|
||||
|
||||
if v:version < 700
|
||||
finish
|
||||
endif
|
||||
|
||||
if exists('complType') " Integration with other completion functions.
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo=&cpo
|
||||
set cpo&vim
|
||||
|
||||
" Global Variables {{{
|
||||
|
||||
if !exists("g:SuperTabDefaultCompletionType")
|
||||
let g:SuperTabDefaultCompletionType = "context"
|
||||
endif
|
||||
|
||||
if !exists("g:SuperTabContextDefaultCompletionType")
|
||||
let g:SuperTabContextDefaultCompletionType = "<c-p>"
|
||||
endif
|
||||
|
||||
if !exists("g:SuperTabCompletionContexts")
|
||||
let g:SuperTabCompletionContexts = ['s:ContextText']
|
||||
endif
|
||||
|
||||
if !exists("g:SuperTabRetainCompletionDuration")
|
||||
let g:SuperTabRetainCompletionDuration = 'completion'
|
||||
endif
|
||||
|
||||
if !exists("g:SuperTabMidWordCompletion")
|
||||
let g:SuperTabMidWordCompletion = 1
|
||||
endif
|
||||
|
||||
if !exists("g:SuperTabMappingForward")
|
||||
let g:SuperTabMappingForward = '<D-Space>'
|
||||
|
||||
endif
|
||||
if !exists("g:SuperTabMappingBackward")
|
||||
let g:SuperTabMappingBackward = '<s-tab>'
|
||||
endif
|
||||
|
||||
if !exists("g:SuperTabMappingTabLiteral")
|
||||
let g:SuperTabMappingTabLiteral = '<c-tab>'
|
||||
endif
|
||||
|
||||
if !exists("g:SuperTabLongestHighlight")
|
||||
let g:SuperTabLongestHighlight = 0
|
||||
endif
|
||||
|
||||
" }}}
|
||||
|
||||
" Script Variables {{{
|
||||
|
||||
" construct the help text.
|
||||
let s:tabHelp =
|
||||
\ "Hit <CR> or CTRL-] on the completion type you wish to switch to.\n" .
|
||||
\ "Use :help ins-completion for more information.\n" .
|
||||
\ "\n" .
|
||||
\ "|<c-n>| - Keywords in 'complete' searching down.\n" .
|
||||
\ "|<c-p>| - Keywords in 'complete' searching up (SuperTab default).\n" .
|
||||
\ "|<c-x><c-l>| - Whole lines.\n" .
|
||||
\ "|<c-x><c-n>| - Keywords in current file.\n" .
|
||||
\ "|<c-x><c-k>| - Keywords in 'dictionary'.\n" .
|
||||
\ "|<c-x><c-t>| - Keywords in 'thesaurus', thesaurus-style.\n" .
|
||||
\ "|<c-x><c-i>| - Keywords in the current and included files.\n" .
|
||||
\ "|<c-x><c-]>| - Tags.\n" .
|
||||
\ "|<c-x><c-f>| - File names.\n" .
|
||||
\ "|<c-x><c-d>| - Definitions or macros.\n" .
|
||||
\ "|<c-x><c-v>| - Vim command-line.\n" .
|
||||
\ "|<c-x><c-u>| - User defined completion.\n" .
|
||||
\ "|<c-x><c-o>| - Omni completion.\n" .
|
||||
\ "|<c-x>s| - Spelling suggestions."
|
||||
|
||||
" set the available completion types and modes.
|
||||
let s:types =
|
||||
\ "\<c-e>\<c-y>\<c-l>\<c-n>\<c-k>\<c-t>\<c-i>\<c-]>" .
|
||||
\ "\<c-f>\<c-d>\<c-v>\<c-n>\<c-p>\<c-u>\<c-o>\<c-n>\<c-p>s"
|
||||
let s:modes = '/^E/^Y/^L/^N/^K/^T/^I/^]/^F/^D/^V/^P/^U/^O/s'
|
||||
let s:types = s:types . "np"
|
||||
let s:modes = s:modes . '/n/p'
|
||||
|
||||
" }}}
|
||||
|
||||
" SuperTabSetDefaultCompletionType(type) {{{
|
||||
" Globally available function that users can use to set the default
|
||||
" completion type for the current buffer, like in an ftplugin.
|
||||
function! SuperTabSetDefaultCompletionType(type)
|
||||
" init hack for <c-x><c-v> workaround.
|
||||
let b:complCommandLine = 0
|
||||
|
||||
let b:SuperTabDefaultCompletionType = a:type
|
||||
|
||||
" set the current completion type to the default
|
||||
call SuperTabSetCompletionType(b:SuperTabDefaultCompletionType)
|
||||
endfunction " }}}
|
||||
|
||||
" SuperTabSetCompletionType(type) {{{
|
||||
" Globally available function that users can use to create mappings to quickly
|
||||
" switch completion modes. Useful when a user wants to restore the default or
|
||||
" switch to another mode without having to kick off a completion of that type
|
||||
" or use SuperTabHelp. Note, this function only changes the current
|
||||
" completion type, not the default, meaning that the default will still be
|
||||
" restored once the configured retension duration has been met (see
|
||||
" g:SuperTabRetainCompletionDuration). To change the default for the current
|
||||
" buffer, use SuperTabDefaultCompletionType(type) instead. Example mapping to
|
||||
" restore SuperTab default:
|
||||
" nmap <F6> :call SetSuperTabCompletionType("<c-p>")<cr>
|
||||
function! SuperTabSetCompletionType(type)
|
||||
exec "let b:complType = \"" . escape(a:type, '<') . "\""
|
||||
endfunction " }}}
|
||||
|
||||
" SuperTabAlternateCompletion(type) {{{
|
||||
" Function which can be mapped to a key to kick off an alternate completion
|
||||
" other than the default. For instance, if you have 'context' as the default
|
||||
" and want to map ctrl+space to issue keyword completion.
|
||||
" Note: due to the way vim expands ctrl characters in mappings, you cannot
|
||||
" create the alternate mapping like so:
|
||||
" imap <c-space> <c-r>=SuperTabAlternateCompletion("<c-p>")<cr>
|
||||
" instead, you have to use \<lt> to prevent vim from expanding the key
|
||||
" when creating the mapping.
|
||||
" gvim:
|
||||
" imap <c-space> <c-r>=SuperTabAlternateCompletion("\<lt>c-p>")<cr>
|
||||
" console:
|
||||
" imap <nul> <c-r>=SuperTabAlternateCompletion("\<lt>c-p>")<cr>
|
||||
function! SuperTabAlternateCompletion(type)
|
||||
call SuperTabSetCompletionType(a:type)
|
||||
" end any current completion before attempting to start the new one.
|
||||
" use feedkeys to prevent possible remapping of <c-e> from causing issues.
|
||||
"call feedkeys("\<c-e>", 'n')
|
||||
" ^ since we can't detect completion mode vs regular insert mode, we force
|
||||
" vim into keyword completion mode and end that mode to prevent the regular
|
||||
" insert behavior of <c-e> from occurring.
|
||||
call feedkeys("\<c-x>\<c-p>\<c-e>", 'n')
|
||||
call feedkeys(b:complType)
|
||||
return ''
|
||||
endfunction " }}}
|
||||
|
||||
" s:Init {{{
|
||||
" Global initilization when supertab is loaded.
|
||||
function! s:Init()
|
||||
augroup supertab_init
|
||||
autocmd!
|
||||
autocmd BufEnter * call <SID>InitBuffer()
|
||||
augroup END
|
||||
|
||||
" ensure InitBuffer gets called for the first buffer, after the ftplugins
|
||||
" have been called.
|
||||
augroup supertab_init_first
|
||||
autocmd!
|
||||
autocmd FileType <buffer> call <SID>InitBuffer()
|
||||
augroup END
|
||||
|
||||
" Setup mechanism to restore orignial completion type upon leaving insert
|
||||
" mode if configured to do so
|
||||
if g:SuperTabRetainCompletionDuration == 'insert'
|
||||
augroup supertab_retain
|
||||
autocmd!
|
||||
autocmd InsertLeave * call s:SetDefaultCompletionType()
|
||||
augroup END
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" s:InitBuffer {{{
|
||||
" Per buffer initilization.
|
||||
function! s:InitBuffer()
|
||||
if exists("b:complType")
|
||||
return
|
||||
endif
|
||||
|
||||
" init hack for <c-x><c-v> workaround.
|
||||
let b:complCommandLine = 0
|
||||
|
||||
let b:SuperTabDefaultCompletionType = g:SuperTabDefaultCompletionType
|
||||
|
||||
" set the current completion type to the default
|
||||
call SuperTabSetCompletionType(b:SuperTabDefaultCompletionType)
|
||||
endfunction " }}}
|
||||
|
||||
" s:ManualCompletionEnter() {{{
|
||||
" Handles manual entrance into completion mode.
|
||||
function! s:ManualCompletionEnter()
|
||||
if &smd
|
||||
echo '' | echohl ModeMsg | echo '-- ^X++ mode (' . s:modes . ')' | echohl None
|
||||
endif
|
||||
let complType = nr2char(getchar())
|
||||
if stridx(s:types, complType) != -1
|
||||
if stridx("\<c-e>\<c-y>", complType) != -1 " no memory, just scroll...
|
||||
return "\<c-x>" . complType
|
||||
elseif stridx('np', complType) != -1
|
||||
let complType = nr2char(char2nr(complType) - 96)
|
||||
else
|
||||
let complType = "\<c-x>" . complType
|
||||
endif
|
||||
|
||||
if index(['insert', 'session'], g:SuperTabRetainCompletionDuration) != -1
|
||||
let b:complType = complType
|
||||
endif
|
||||
|
||||
" Hack to workaround bug when invoking command line completion via <c-r>=
|
||||
if complType == "\<c-x>\<c-v>"
|
||||
return s:CommandLineCompletion()
|
||||
endif
|
||||
|
||||
return complType
|
||||
endif
|
||||
|
||||
echohl "Unknown mode"
|
||||
return complType
|
||||
endfunction " }}}
|
||||
|
||||
" s:SetCompletionType() {{{
|
||||
" Sets the completion type based on what the user has chosen from the help
|
||||
" buffer.
|
||||
function! s:SetCompletionType()
|
||||
let chosen = substitute(getline('.'), '.*|\(.*\)|.*', '\1', '')
|
||||
if chosen != getline('.')
|
||||
let winnr = b:winnr
|
||||
close
|
||||
exec winnr . 'winc w'
|
||||
call SuperTabSetCompletionType(chosen)
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" s:SetDefaultCompletionType() {{{
|
||||
function! s:SetDefaultCompletionType()
|
||||
if exists('b:SuperTabDefaultCompletionType') &&
|
||||
\ (!exists('b:complCommandLine') || !b:complCommandLine)
|
||||
call SuperTabSetCompletionType(b:SuperTabDefaultCompletionType)
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" s:SuperTab(command) {{{
|
||||
" Used to perform proper cycle navigation as the user requests the next or
|
||||
" previous entry in a completion list, and determines whether or not to simply
|
||||
" retain the normal usage of <tab> based on the cursor position.
|
||||
function! s:SuperTab(command)
|
||||
if s:WillComplete()
|
||||
" rare case where no autocmds have fired for this buffer to initialize the
|
||||
" supertab vars.
|
||||
call s:InitBuffer()
|
||||
|
||||
let key = ''
|
||||
" highlight first result if longest enabled
|
||||
if g:SuperTabLongestHighlight && !pumvisible() && &completeopt =~ 'longest'
|
||||
let key = (b:complType == "\<c-p>") ? "\<c-p>" : "\<c-n>"
|
||||
endif
|
||||
|
||||
" exception: if in <c-p> mode, then <c-n> should move up the list, and
|
||||
" <c-p> down the list.
|
||||
if a:command == 'p' &&
|
||||
\ (b:complType == "\<c-p>" ||
|
||||
\ (b:complType == 'context' &&
|
||||
\ tolower(g:SuperTabContextDefaultCompletionType) == '<c-p>'))
|
||||
return "\<c-n>"
|
||||
elseif a:command == 'p' &&
|
||||
\ (b:complType == "\<c-n>" ||
|
||||
\ (b:complType == 'context' &&
|
||||
\ tolower(g:SuperTabContextDefaultCompletionType) == '<c-n>'))
|
||||
return "\<c-p>"
|
||||
endif
|
||||
|
||||
" handle 'context' completion.
|
||||
if b:complType == 'context'
|
||||
let complType = s:ContextCompletion()
|
||||
if complType == ''
|
||||
exec "let complType = \"" .
|
||||
\ escape(g:SuperTabContextDefaultCompletionType, '<') . "\""
|
||||
endif
|
||||
return complType . key
|
||||
endif
|
||||
|
||||
" Hack to workaround bug when invoking command line completion via <c-r>=
|
||||
if b:complType == "\<c-x>\<c-v>"
|
||||
return s:CommandLineCompletion()
|
||||
endif
|
||||
return b:complType . key
|
||||
endif
|
||||
|
||||
return "\<tab>"
|
||||
endfunction " }}}
|
||||
|
||||
" s:SuperTabHelp() {{{
|
||||
" Opens a help window where the user can choose a completion type to enter.
|
||||
function! s:SuperTabHelp()
|
||||
let winnr = winnr()
|
||||
if bufwinnr("SuperTabHelp") == -1
|
||||
botright split SuperTabHelp
|
||||
|
||||
setlocal noswapfile
|
||||
setlocal buftype=nowrite
|
||||
setlocal bufhidden=delete
|
||||
|
||||
let saved = @"
|
||||
let @" = s:tabHelp
|
||||
silent put
|
||||
call cursor(1, 1)
|
||||
silent 1,delete
|
||||
call cursor(4, 1)
|
||||
let @" = saved
|
||||
exec "resize " . line('$')
|
||||
|
||||
syntax match Special "|.\{-}|"
|
||||
|
||||
setlocal readonly
|
||||
setlocal nomodifiable
|
||||
|
||||
nmap <silent> <buffer> <cr> :call <SID>SetCompletionType()<cr>
|
||||
nmap <silent> <buffer> <c-]> :call <SID>SetCompletionType()<cr>
|
||||
else
|
||||
exec bufwinnr("SuperTabHelp") . "winc w"
|
||||
endif
|
||||
let b:winnr = winnr
|
||||
endfunction " }}}
|
||||
|
||||
" s:WillComplete() {{{
|
||||
" Determines if completion should be kicked off at the current location.
|
||||
function! s:WillComplete()
|
||||
let line = getline('.')
|
||||
let cnum = col('.')
|
||||
|
||||
" Start of line.
|
||||
let prev_char = strpart(line, cnum - 2, 1)
|
||||
if prev_char =~ '^\s*$'
|
||||
return 0
|
||||
endif
|
||||
|
||||
" Within a word, but user does not have mid word completion enabled.
|
||||
let next_char = strpart(line, cnum - 1, 1)
|
||||
if !g:SuperTabMidWordCompletion && next_char =~ '\k'
|
||||
return 0
|
||||
endif
|
||||
|
||||
" In keyword completion mode and no preceding word characters.
|
||||
"if (b:complType == "\<c-n>" || b:complType == "\<c-p>") && prev_char !~ '\k'
|
||||
" return 0
|
||||
"endif
|
||||
|
||||
return 1
|
||||
endfunction " }}}
|
||||
|
||||
" s:CommandLineCompletion() {{{
|
||||
" Hack needed to account for apparent bug in vim command line mode completion
|
||||
" when invoked via <c-r>=
|
||||
function! s:CommandLineCompletion()
|
||||
" This hack will trigger InsertLeave which will then invoke
|
||||
" s:SetDefaultCompletionType. To prevent default completion from being
|
||||
" restored prematurely, set an internal flag for s:SetDefaultCompletionType
|
||||
" to check for.
|
||||
let b:complCommandLine = 1
|
||||
return "\<c-\>\<c-o>:call feedkeys('\<c-x>\<c-v>\<c-v>', 'n') | " .
|
||||
\ "let b:complCommandLine = 0\<cr>"
|
||||
endfunction " }}}
|
||||
|
||||
" s:ContextCompletion() {{{
|
||||
function! s:ContextCompletion()
|
||||
let contexts = exists('b:SuperTabCompletionContexts') ?
|
||||
\ b:SuperTabCompletionContexts : g:SuperTabCompletionContexts
|
||||
|
||||
for context in contexts
|
||||
try
|
||||
let Context = function(context)
|
||||
let complType = Context()
|
||||
unlet Context
|
||||
if type(complType) == 1 && complType != ''
|
||||
return complType
|
||||
endif
|
||||
catch /E700/
|
||||
echohl Error
|
||||
echom 'supertab: no context function "' . context . '" found.'
|
||||
echohl None
|
||||
endtry
|
||||
endfor
|
||||
return ''
|
||||
endfunction " }}}
|
||||
|
||||
" s:ContextDiscover() {{{
|
||||
function! s:ContextDiscover()
|
||||
let discovery = exists('g:SuperTabContextDiscoverDiscovery') ?
|
||||
\ g:SuperTabContextDiscoverDiscovery : []
|
||||
|
||||
" loop through discovery list to find the default
|
||||
if !empty(discovery)
|
||||
for pair in discovery
|
||||
let var = substitute(pair, '\(.*\):.*', '\1', '')
|
||||
let type = substitute(pair, '.*:\(.*\)', '\1', '')
|
||||
exec 'let value = ' . var
|
||||
if value !~ '^\s*$' && value != '0'
|
||||
exec "let complType = \"" . escape(type, '<') . "\""
|
||||
return complType
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" s:ContextText() {{{
|
||||
function! s:ContextText()
|
||||
let exclusions = exists('g:SuperTabContextTextFileTypeExclusions') ?
|
||||
\ g:SuperTabContextTextFileTypeExclusions : []
|
||||
|
||||
if index(exclusions, &ft) == -1
|
||||
let curline = getline('.')
|
||||
let cnum = col('.')
|
||||
let synname = synIDattr(synID(line('.'), cnum - 1, 1), 'name')
|
||||
if curline =~ '.*/\w*\%' . cnum . 'c' ||
|
||||
\ ((has('win32') || has('win64')) && curline =~ '.*\\\w*\%' . cnum . 'c')
|
||||
return "\<c-x>\<c-f>"
|
||||
|
||||
elseif curline =~ '.*\(\w\|[\])]\)\(\.\|::\|->\)\w*\%' . cnum . 'c' &&
|
||||
\ synname !~ '\(String\|Comment\)'
|
||||
let omniPrecedence = exists('g:SuperTabContextTextOmniPrecedence') ?
|
||||
\ g:SuperTabContextTextOmniPrecedence : ['&completefunc', '&omnifunc']
|
||||
|
||||
for omniFunc in omniPrecedence
|
||||
if omniFunc !~ '^&'
|
||||
let omniFunc = '&' . omniFunc
|
||||
endif
|
||||
if getbufvar(bufnr('%'), omniFunc) != ''
|
||||
return omniFunc == '&omnifunc' ? "\<c-x>\<c-o>" : "\<c-x>\<c-u>"
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" Key Mappings {{{
|
||||
" map a regular tab to ctrl-tab (note: doesn't work in console vim)
|
||||
exec 'inoremap ' . g:SuperTabMappingTabLiteral . ' <tab>'
|
||||
|
||||
imap <c-x> <c-r>=<SID>ManualCompletionEnter()<cr>
|
||||
|
||||
" From the doc |insert.txt| improved
|
||||
exec 'imap ' . g:SuperTabMappingForward . ' <c-n>'
|
||||
exec 'imap ' . g:SuperTabMappingBackward . ' <c-p>'
|
||||
|
||||
" After hitting <Tab>, hitting it once more will go to next match
|
||||
" (because in XIM mode <c-n> and <c-p> mappings are ignored)
|
||||
" and wont start a brand new completion
|
||||
" The side effect, that in the beginning of line <c-n> and <c-p> inserts a
|
||||
" <Tab>, but I hope it may not be a problem...
|
||||
inoremap <c-n> <c-r>=<SID>SuperTab('n')<cr>
|
||||
inoremap <c-p> <c-r>=<SID>SuperTab('p')<cr>
|
||||
" }}}
|
||||
|
||||
" Command Mappings {{{
|
||||
if !exists(":SuperTabHelp")
|
||||
command SuperTabHelp :call <SID>SuperTabHelp()
|
||||
endif
|
||||
" }}}
|
||||
|
||||
call s:Init()
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
|
||||
" vim:ft=vim:fdm=marker
|
||||
@@ -0,0 +1,358 @@
|
||||
" Vim syntax file
|
||||
" Language: Python
|
||||
" Maintainer: Dmitry Vasiliev <dima@hlabs.spb.ru>
|
||||
" URL: http://www.hlabs.spb.ru/vim/python.vim
|
||||
" Last Change: 2009-07-24
|
||||
" Filenames: *.py
|
||||
" Version: 2.6.5
|
||||
"
|
||||
" Based on python.vim (from Vim 6.1 distribution)
|
||||
" by Neil Schemenauer <nas@python.ca>
|
||||
"
|
||||
" Thanks:
|
||||
"
|
||||
" Jeroen Ruigrok van der Werven
|
||||
" for the idea to highlight erroneous operators
|
||||
" Pedro Algarvio
|
||||
" for the patch to enable spell checking only for the right spots
|
||||
" (strings and comments)
|
||||
" John Eikenberry
|
||||
" for the patch fixing small typo
|
||||
" Caleb Adamantine
|
||||
" for the patch fixing highlighting for decorators
|
||||
|
||||
"
|
||||
" Options:
|
||||
"
|
||||
" For set option do: let OPTION_NAME = 1
|
||||
" For clear option do: let OPTION_NAME = 0
|
||||
"
|
||||
" Option names:
|
||||
"
|
||||
" For highlight builtin functions:
|
||||
" python_highlight_builtins
|
||||
"
|
||||
" For highlight standard exceptions:
|
||||
" python_highlight_exceptions
|
||||
"
|
||||
" For highlight string formatting:
|
||||
" python_highlight_string_formatting
|
||||
"
|
||||
" For highlight str.format syntax:
|
||||
" python_highlight_string_format
|
||||
"
|
||||
" For highlight string.Template syntax:
|
||||
" python_highlight_string_templates
|
||||
"
|
||||
" For highlight indentation errors:
|
||||
" python_highlight_indent_errors
|
||||
"
|
||||
" For highlight trailing spaces:
|
||||
" python_highlight_space_errors
|
||||
"
|
||||
" For highlight doc-tests:
|
||||
" python_highlight_doctests
|
||||
"
|
||||
" If you want all Python highlightings above:
|
||||
" python_highlight_all
|
||||
" (This option not override previously set options)
|
||||
"
|
||||
" For fast machines:
|
||||
" python_slow_sync
|
||||
"
|
||||
" For "print" builtin as function:
|
||||
" python_print_as_function
|
||||
|
||||
" For version 5.x: Clear all syntax items
|
||||
" For version 6.x: Quit when a syntax file was already loaded
|
||||
if version < 600
|
||||
syntax clear
|
||||
elseif exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
if exists("python_highlight_all") && python_highlight_all != 0
|
||||
" Not override previously set options
|
||||
if !exists("python_highlight_builtins")
|
||||
let python_highlight_builtins = 1
|
||||
endif
|
||||
if !exists("python_highlight_exceptions")
|
||||
let python_highlight_exceptions = 1
|
||||
endif
|
||||
if !exists("python_highlight_string_formatting")
|
||||
let python_highlight_string_formatting = 1
|
||||
endif
|
||||
if !exists("python_highlight_string_format")
|
||||
let python_highlight_string_format = 1
|
||||
endif
|
||||
if !exists("python_highlight_string_templates")
|
||||
let python_highlight_string_templates = 1
|
||||
endif
|
||||
if !exists("python_highlight_indent_errors")
|
||||
let python_highlight_indent_errors = 1
|
||||
endif
|
||||
if !exists("python_highlight_space_errors")
|
||||
let python_highlight_space_errors = 1
|
||||
endif
|
||||
if !exists("python_highlight_doctests")
|
||||
let python_highlight_doctests = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
" Keywords
|
||||
syn keyword pythonStatement break continue del
|
||||
syn keyword pythonStatement exec return
|
||||
syn keyword pythonStatement pass raise
|
||||
syn keyword pythonStatement global assert
|
||||
syn keyword pythonStatement lambda yield
|
||||
syn keyword pythonStatement with
|
||||
syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite
|
||||
syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" display contained
|
||||
syn keyword pythonRepeat for while
|
||||
syn keyword pythonConditional if elif else
|
||||
syn keyword pythonPreCondit import from as
|
||||
syn keyword pythonException try except finally
|
||||
syn keyword pythonOperator and in is not or
|
||||
|
||||
if !exists("python_print_as_function") || python_print_as_function == 0
|
||||
syn keyword pythonStatement print
|
||||
endif
|
||||
|
||||
" Decorators (new in Python 2.4)
|
||||
syn match pythonDecorator "@" display nextgroup=pythonDottedName skipwhite
|
||||
syn match pythonDottedName "[a-zA-Z_][a-zA-Z0-9_]*\(\.[a-zA-Z_][a-zA-Z0-9_]*\)*" display contained
|
||||
syn match pythonDot "\." display containedin=pythonDottedName
|
||||
|
||||
" Comments
|
||||
syn match pythonComment "#.*$" display contains=pythonTodo,@Spell
|
||||
syn match pythonRun "\%^#!.*$"
|
||||
syn match pythonCoding "\%^.*\(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$"
|
||||
syn keyword pythonTodo TODO FIXME XXX contained
|
||||
|
||||
" Errors
|
||||
syn match pythonError "\<\d\+\D\+\>" display
|
||||
syn match pythonError "[$?]" display
|
||||
syn match pythonError "[&|]\{2,}" display
|
||||
syn match pythonError "[=]\{3,}" display
|
||||
|
||||
" TODO: Mixing spaces and tabs also may be used for pretty formatting multiline
|
||||
" statements. For now I don't know how to work around this.
|
||||
if exists("python_highlight_indent_errors") && python_highlight_indent_errors != 0
|
||||
syn match pythonIndentError "^\s*\( \t\|\t \)\s*\S"me=e-1 display
|
||||
endif
|
||||
|
||||
" Trailing space errors
|
||||
if exists("python_highlight_space_errors") && python_highlight_space_errors != 0
|
||||
syn match pythonSpaceError "\s\+$" display
|
||||
endif
|
||||
|
||||
" Strings
|
||||
syn region pythonString start=+[bB]\='+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonEscape,pythonEscapeError,@Spell
|
||||
syn region pythonString start=+[bB]\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonEscape,pythonEscapeError,@Spell
|
||||
syn region pythonString start=+[bB]\="""+ end=+"""+ keepend contains=pythonEscape,pythonEscapeError,pythonDocTest2,pythonSpaceError,@Spell
|
||||
syn region pythonString start=+[bB]\='''+ end=+'''+ keepend contains=pythonEscape,pythonEscapeError,pythonDocTest,pythonSpaceError,@Spell
|
||||
|
||||
syn match pythonEscape +\\[abfnrtv'"\\]+ display contained
|
||||
syn match pythonEscape "\\\o\o\=\o\=" display contained
|
||||
syn match pythonEscapeError "\\\o\{,2}[89]" display contained
|
||||
syn match pythonEscape "\\x\x\{2}" display contained
|
||||
syn match pythonEscapeError "\\x\x\=\X" display contained
|
||||
syn match pythonEscape "\\$"
|
||||
|
||||
" Unicode strings
|
||||
syn region pythonUniString start=+[uU]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,@Spell
|
||||
syn region pythonUniString start=+[uU]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,@Spell
|
||||
syn region pythonUniString start=+[uU]"""+ end=+"""+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
|
||||
syn region pythonUniString start=+[uU]'''+ end=+'''+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
|
||||
|
||||
syn match pythonUniEscape "\\u\x\{4}" display contained
|
||||
syn match pythonUniEscapeError "\\u\x\{,3}\X" display contained
|
||||
syn match pythonUniEscape "\\U\x\{8}" display contained
|
||||
syn match pythonUniEscapeError "\\U\x\{,7}\X" display contained
|
||||
syn match pythonUniEscape "\\N{[A-Z ]\+}" display contained
|
||||
syn match pythonUniEscapeError "\\N{[^A-Z ]\+}" display contained
|
||||
|
||||
" Raw strings
|
||||
syn region pythonRawString start=+[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell
|
||||
syn region pythonRawString start=+[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell
|
||||
syn region pythonRawString start=+[rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell
|
||||
syn region pythonRawString start=+[rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell
|
||||
|
||||
syn match pythonRawEscape +\\['"]+ display transparent contained
|
||||
|
||||
" Unicode raw strings
|
||||
syn region pythonUniRawString start=+[uU][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell
|
||||
syn region pythonUniRawString start=+[uU][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell
|
||||
syn region pythonUniRawString start=+[uU][rR]"""+ end=+"""+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest2,pythonSpaceError,@Spell
|
||||
syn region pythonUniRawString start=+[uU][rR]'''+ end=+'''+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest,pythonSpaceError,@Spell
|
||||
|
||||
syn match pythonUniRawEscape "\([^\\]\(\\\\\)*\)\@<=\\u\x\{4}" display contained
|
||||
syn match pythonUniRawEscapeError "\([^\\]\(\\\\\)*\)\@<=\\u\x\{,3}\X" display contained
|
||||
|
||||
if exists("python_highlight_string_formatting") && python_highlight_string_formatting != 0
|
||||
" String formatting
|
||||
syn match pythonStrFormatting "%\(([^)]\+)\)\=[-#0 +]*\d*\(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
|
||||
syn match pythonStrFormatting "%[-#0 +]*\(\*\|\d\+\)\=\(\.\(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
|
||||
endif
|
||||
|
||||
if exists("python_highlight_string_format") && python_highlight_string_format != 0
|
||||
" str.format syntax
|
||||
syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
|
||||
syn match pythonStrFormat "{\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)\(\.[a-zA-Z_][a-zA-Z0-9_]*\|\[\(\d\+\|[^!:\}]\+\)\]\)*\(![rs]\)\=\(:\({\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)}\|\([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*\(\.\d\+\)\=[bcdeEfFgGnoxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
|
||||
endif
|
||||
|
||||
if exists("python_highlight_string_templates") && python_highlight_string_templates != 0
|
||||
" String templates
|
||||
syn match pythonStrTemplate "\$\$" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
|
||||
syn match pythonStrTemplate "\${[a-zA-Z_][a-zA-Z0-9_]*}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
|
||||
syn match pythonStrTemplate "\$[a-zA-Z_][a-zA-Z0-9_]*" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
|
||||
endif
|
||||
|
||||
if exists("python_highlight_doctests") && python_highlight_doctests != 0
|
||||
" DocTests
|
||||
syn region pythonDocTest start="^\s*>>>" end=+'''+he=s-1 end="^\s*$" contained
|
||||
syn region pythonDocTest2 start="^\s*>>>" end=+"""+he=s-1 end="^\s*$" contained
|
||||
endif
|
||||
|
||||
" Numbers (ints, longs, floats, complex)
|
||||
syn match pythonHexError "\<0[xX]\x*[g-zG-Z]\x*[lL]\=\>" display
|
||||
|
||||
syn match pythonHexNumber "\<0[xX]\x\+[lL]\=\>" display
|
||||
syn match pythonOctNumber "\<0[oO]\o\+[lL]\=\>" display
|
||||
syn match pythonBinNumber "\<0[bB][01]\+[lL]\=\>" display
|
||||
|
||||
syn match pythonNumber "\<\d\+[lLjJ]\=\>" display
|
||||
|
||||
syn match pythonFloat "\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>" display
|
||||
syn match pythonFloat "\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display
|
||||
syn match pythonFloat "\<\d\+\.\d*\([eE][+-]\=\d\+\)\=[jJ]\=" display
|
||||
|
||||
syn match pythonOctError "\<0[oO]\=\o*[8-9]\d*[lL]\=\>" display
|
||||
syn match pythonBinError "\<0[bB][01]*[2-9]\d*[lL]\=\>" display
|
||||
|
||||
if exists("python_highlight_builtins") && python_highlight_builtins != 0
|
||||
" Builtin functions, types and objects
|
||||
syn keyword pythonBuiltinObj True False Ellipsis None NotImplemented
|
||||
syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__
|
||||
|
||||
syn keyword pythonBuiltinFunc __import__ abs all any apply
|
||||
syn keyword pythonBuiltinFunc basestring bin bool buffer bytearray bytes callable
|
||||
syn keyword pythonBuiltinFunc chr classmethod cmp coerce compile complex
|
||||
syn keyword pythonBuiltinFunc delattr dict dir divmod enumerate eval
|
||||
syn keyword pythonBuiltinFunc execfile file filter float format frozenset getattr
|
||||
syn keyword pythonBuiltinFunc globals hasattr hash help hex id
|
||||
syn keyword pythonBuiltinFunc input int intern isinstance
|
||||
syn keyword pythonBuiltinFunc issubclass iter len list locals long map max
|
||||
syn keyword pythonBuiltinFunc min next object oct open ord
|
||||
syn keyword pythonBuiltinFunc pow property range
|
||||
syn keyword pythonBuiltinFunc raw_input reduce reload repr
|
||||
syn keyword pythonBuiltinFunc reversed round set setattr
|
||||
syn keyword pythonBuiltinFunc slice sorted staticmethod str sum super tuple
|
||||
syn keyword pythonBuiltinFunc type unichr unicode vars xrange zip
|
||||
|
||||
if exists("python_print_as_function") && python_print_as_function != 0
|
||||
syn keyword pythonBuiltinFunc print
|
||||
endif
|
||||
endif
|
||||
|
||||
if exists("python_highlight_exceptions") && python_highlight_exceptions != 0
|
||||
" Builtin exceptions and warnings
|
||||
syn keyword pythonExClass BaseException
|
||||
syn keyword pythonExClass Exception StandardError ArithmeticError
|
||||
syn keyword pythonExClass LookupError EnvironmentError
|
||||
|
||||
syn keyword pythonExClass AssertionError AttributeError BufferError EOFError
|
||||
syn keyword pythonExClass FloatingPointError GeneratorExit IOError
|
||||
syn keyword pythonExClass ImportError IndexError KeyError
|
||||
syn keyword pythonExClass KeyboardInterrupt MemoryError NameError
|
||||
syn keyword pythonExClass NotImplementedError OSError OverflowError
|
||||
syn keyword pythonExClass ReferenceError RuntimeError StopIteration
|
||||
syn keyword pythonExClass SyntaxError IndentationError TabError
|
||||
syn keyword pythonExClass SystemError SystemExit TypeError
|
||||
syn keyword pythonExClass UnboundLocalError UnicodeError
|
||||
syn keyword pythonExClass UnicodeEncodeError UnicodeDecodeError
|
||||
syn keyword pythonExClass UnicodeTranslateError ValueError VMSError
|
||||
syn keyword pythonExClass WindowsError ZeroDivisionError
|
||||
|
||||
syn keyword pythonExClass Warning UserWarning BytesWarning DeprecationWarning
|
||||
syn keyword pythonExClass PendingDepricationWarning SyntaxWarning
|
||||
syn keyword pythonExClass RuntimeWarning FutureWarning
|
||||
syn keyword pythonExClass ImportWarning UnicodeWarning
|
||||
endif
|
||||
|
||||
if exists("python_slow_sync") && python_slow_sync != 0
|
||||
syn sync minlines=2000
|
||||
else
|
||||
" This is fast but code inside triple quoted strings screws it up. It
|
||||
" is impossible to fix because the only way to know if you are inside a
|
||||
" triple quoted string is to start from the beginning of the file.
|
||||
syn sync match pythonSync grouphere NONE "):$"
|
||||
syn sync maxlines=200
|
||||
endif
|
||||
|
||||
if version >= 508 || !exists("did_python_syn_inits")
|
||||
if version <= 508
|
||||
let did_python_syn_inits = 1
|
||||
command -nargs=+ HiLink hi link <args>
|
||||
else
|
||||
command -nargs=+ HiLink hi def link <args>
|
||||
endif
|
||||
|
||||
HiLink pythonStatement Statement
|
||||
HiLink pythonPreCondit Statement
|
||||
HiLink pythonFunction Function
|
||||
HiLink pythonConditional Conditional
|
||||
HiLink pythonRepeat Repeat
|
||||
HiLink pythonException Exception
|
||||
HiLink pythonOperator Operator
|
||||
|
||||
HiLink pythonDecorator Define
|
||||
HiLink pythonDottedName Function
|
||||
HiLink pythonDot Normal
|
||||
|
||||
HiLink pythonComment Comment
|
||||
HiLink pythonCoding Special
|
||||
HiLink pythonRun Special
|
||||
HiLink pythonTodo Todo
|
||||
|
||||
HiLink pythonError Error
|
||||
HiLink pythonIndentError Error
|
||||
HiLink pythonSpaceError Error
|
||||
|
||||
HiLink pythonString String
|
||||
HiLink pythonUniString String
|
||||
HiLink pythonRawString String
|
||||
HiLink pythonUniRawString String
|
||||
|
||||
HiLink pythonEscape Special
|
||||
HiLink pythonEscapeError Error
|
||||
HiLink pythonUniEscape Special
|
||||
HiLink pythonUniEscapeError Error
|
||||
HiLink pythonUniRawEscape Special
|
||||
HiLink pythonUniRawEscapeError Error
|
||||
|
||||
HiLink pythonStrFormatting Special
|
||||
HiLink pythonStrFormat Special
|
||||
HiLink pythonStrTemplate Special
|
||||
|
||||
HiLink pythonDocTest Special
|
||||
HiLink pythonDocTest2 Special
|
||||
|
||||
HiLink pythonNumber Number
|
||||
HiLink pythonHexNumber Number
|
||||
HiLink pythonOctNumber Number
|
||||
HiLink pythonBinNumber Number
|
||||
HiLink pythonFloat Float
|
||||
HiLink pythonOctError Error
|
||||
HiLink pythonHexError Error
|
||||
HiLink pythonBinError Error
|
||||
|
||||
HiLink pythonBuiltinObj Structure
|
||||
HiLink pythonBuiltinFunc Function
|
||||
|
||||
HiLink pythonExClass Structure
|
||||
|
||||
delcommand HiLink
|
||||
endif
|
||||
|
||||
let b:current_syntax = "python"
|
||||
@@ -0,0 +1 @@
|
||||
/doc/tags
|
||||
@@ -0,0 +1,45 @@
|
||||
fugitive.vim
|
||||
============
|
||||
|
||||
I'm not going to lie to you; fugitive.vim may very well be the best
|
||||
Git wrapper of all time. Check out these features:
|
||||
|
||||
View any blob, tree, commit, or tag in the repository with `:Gedit` (and
|
||||
`:Gsplit`, `:Gvsplit`, `:Gtabedit`, ...). Edit a file in the index and
|
||||
write to it to stage the changes. Use `:Gdiff` to bring up the staged
|
||||
version of the file side by side with the working tree version and use
|
||||
Vim's diff handling capabilities to stage a subset of the file's
|
||||
changes.
|
||||
|
||||
Bring up the output of `git status` with `:Gstatus`. Press `-` to
|
||||
`add`/`reset` a file's changes, or `p` to `add`/`reset` `--patch` that
|
||||
mofo. And guess what `:Gcommit` does!
|
||||
|
||||
`:Gblame` brings up an interactive vertical split with `git blame`
|
||||
output. Press enter on a line to reblame the file as it stood in that
|
||||
commit, or `o` to open that commit in a split.
|
||||
|
||||
`:Gmove` does a `git mv` on a file and simultaneously renames the
|
||||
buffer. `:Gremove` does a `git rm` on a file and simultaneously deletes
|
||||
the buffer.
|
||||
|
||||
Use `:Ggrep` to search the work tree (or any arbitrary commit) with
|
||||
`git grep`, skipping over that which is not tracked in the repository.
|
||||
`:Glog` loads all previous revisions of a file into the quickfix list so
|
||||
you can iterate over them and watch the file evolve!
|
||||
|
||||
`:Gread` is a variant of `git checkout -- filename` that operates on the
|
||||
buffer rather than the filename. This means you can use `u` to undo it
|
||||
and you never get any warnings about the file changing outside Vim.
|
||||
`:Gwrite` writes to both the work tree and index versions of a file,
|
||||
making it like `git add` when called from a work tree file and like
|
||||
`git checkout` when called from the index or a blob in history.
|
||||
|
||||
Add `%{fugitive#statusline()}` to `'statusline'` to get an indicator
|
||||
with the current branch in (surprise!) your statusline.
|
||||
|
||||
Oh, and of course there's `:Git` for running any arbitrary command.
|
||||
|
||||
Like fugitive.vim? Follow the repository on
|
||||
[GitHub](http://github.com/tpope/vim-fugitive) and vote for it on
|
||||
[vim.org](http://www.vim.org/scripts/script.php?script_id=2975).
|
||||
@@ -0,0 +1,226 @@
|
||||
*fugitive.txt* A Git wrapper so awesome, it should be illegal
|
||||
|
||||
Author: Tim Pope <vimNOSPAM@tpope.org> *fugitive-author*
|
||||
License: Same terms as Vim itself (see |license|)
|
||||
|
||||
This plugin is only available if 'compatible' is not set.
|
||||
|
||||
INTRODUCTION *fugitive*
|
||||
|
||||
Install in ~/.vim, or in ~\vimfiles if you're on Windows and feeling lucky.
|
||||
Vim 7.2 is recommended as it ships with syntax highlighting for many Git file
|
||||
types.
|
||||
|
||||
If you're in a hurry to get started, here are some things to try:
|
||||
|
||||
In any file in your repository, run |:Gedit| HEAD. Press <CR> to jump to the
|
||||
current branch. Press <CR> again to jump to the top most commit. Keep using
|
||||
<CR> to explore parent commits, trees, and blobs. Use C in a tree or blob to
|
||||
get back to the commit.
|
||||
|
||||
Edit a file in the work tree and make some changes. Use |:Gdiff| to open up
|
||||
the indexed version. Use |do| and |dp| on various hunks to bring the files in
|
||||
sync, or use |:Gread| to pull in all changes. Write the indexed version to
|
||||
stage the file.
|
||||
|
||||
Run |:Gstatus| to check your repository's status. Use "-" to stage and reset
|
||||
files and "p" to add/reset --patch them. Invoke |:Gcommit| to commit your
|
||||
changes.
|
||||
|
||||
Run |:Gblame| in a work tree file to see a blame in a vertical split. Press
|
||||
<CR> on any line to reopen and reblame that file as it stood in that commit.
|
||||
Press o or O on any line to inspect that commit in a split or a tab.
|
||||
|
||||
Run |:Ggrep| to search the work tree or history. Run |:Gmove| to rename a
|
||||
file. Run |:Gremove| to delete a file.
|
||||
|
||||
COMMANDS *fugitive-commands*
|
||||
|
||||
These commands are local to the buffers in which they work (generally, buffers
|
||||
that are part of Git repositories).
|
||||
|
||||
*fugitive-:Git*
|
||||
:Git [args] Run an arbitrary git command. Similar to :!git [args]
|
||||
but chdir to the repository tree first.
|
||||
|
||||
*fugitive-:Gcd*
|
||||
:Gcd [directory] |:cd| relative to the repository.
|
||||
|
||||
*fugitive-:Glcd*
|
||||
:Glcd [directory] |:lcd| relative to the repository.
|
||||
|
||||
*fugitive-:Gstatus*
|
||||
:Gstatus Bring up the output of git-status in the preview
|
||||
window. In addition to standard motions, you can
|
||||
use <C-N> and <C-P> to jump from filename to
|
||||
filename. Press D to |:Gdiff| the file on the cursor
|
||||
line, or dh to |:Gdiff!|. Press - to stage or unstage
|
||||
the file on the cursor line. Press p to do so on a
|
||||
per hunk basis (--patch). Press C to invoke
|
||||
|:Gcommit|.
|
||||
|
||||
*fugitive-:Gcommit*
|
||||
:Gcommit [args] A wrapper around git-commit. If there is nothing
|
||||
to commit, |:Gstatus| is called instead. Unless the
|
||||
arguments given would skip the invocation of an editor
|
||||
(e.g., -m), a split window will be used to obtain a
|
||||
commit message. Write and close that window (:wq or
|
||||
|:Gwrite|) to finish the commit. Unlike when running
|
||||
the actual git-commit command, it is possible (but
|
||||
unadvisable) to muck with the index with commands like
|
||||
git-add and git-reset while a commit message is
|
||||
pending.
|
||||
|
||||
*fugitive-:Ggrep*
|
||||
:Ggrep [args] |:grep| with git-grep as 'grepprg'.
|
||||
|
||||
*fugitive-:Glog*
|
||||
:Glog [args] Load all previous revisions of the current file into
|
||||
the quickfix list. Additional git-log arguments can
|
||||
be given (for example, --reverse). If "--" appears as
|
||||
an argument, no file specific filtering is done, and
|
||||
commits are loaded into the quickfix list.
|
||||
|
||||
*fugitive-:Gedit* *fugitive-:Ge*
|
||||
:Gedit [revision] |:edit| a |fugitive-revision|.
|
||||
|
||||
*fugitive-:Gsplit*
|
||||
:Gsplit [revision] |:split| a |fugitive-revision|.
|
||||
|
||||
*fugitive-:Gvsplit*
|
||||
:Gvsplit [revision] |:vsplit| a |fugitive-revision|.
|
||||
|
||||
*fugitive-:Gtabedit*
|
||||
:Gtabedit [revision] |:tabedit| a |fugitive-revision|
|
||||
|
||||
*fugitive-:Gpedit*
|
||||
:Gpedit [revision] |:pedit| a |fugitive-revision|
|
||||
|
||||
*fugitive-:Gread*
|
||||
:Gread [revision] Empty the buffer and |:read| a |fugitive-revision|.
|
||||
When the argument is omitted, this is similar to
|
||||
git-checkout on a work tree file or git-add on a stage
|
||||
file, but without writing anything to disk.
|
||||
|
||||
:{range}Gread [revision]
|
||||
|:read| in a |fugitive-revision| after {range}.
|
||||
|
||||
*fugitive-:Gread!*
|
||||
:Gread! [revision] Deprecated synonym for |:Gread|.
|
||||
|
||||
*fugitive-:Gwrite*
|
||||
:Gwrite Write to the current file's path and stage the results.
|
||||
When run in a work tree file, it is effectively git
|
||||
add. Elsewhere, it is effectively git-checkout. A
|
||||
great deal of effort is expended to behave sensibly
|
||||
when the work tree or index version of the file is
|
||||
open in another buffer.
|
||||
|
||||
:Gwrite {path} You can give |:Gwrite| an explicit path of where in
|
||||
the work tree to write. You can also give a path like
|
||||
:0:foo.txt or even :0 to write to just that stage in
|
||||
the index.
|
||||
|
||||
*fugitive-:Gdiff*
|
||||
:Gdiff [revision] Perform a |vimdiff| against the current file in the
|
||||
given revision. With no argument, the version in the
|
||||
index is used (which means a three-way diff during a
|
||||
merge conflict, making it a git-mergetool
|
||||
alternative). The newer of the two files is placed
|
||||
to the right. Use |do| and |dp| and write to the
|
||||
index file to simulate "git add --patch".
|
||||
|
||||
*fugitive-:Gdiff!*
|
||||
:Gdiff! [revision] Like |:Gdiff|, but split horizontally.
|
||||
|
||||
*fugitive-:Gmove*
|
||||
:Gmove {destination} Wrapper around git-mv that renames the buffer
|
||||
afterward. The destination is relative to the current
|
||||
directory except when started with a /, in which case
|
||||
it is relative to the work tree. Add a ! to pass -f.
|
||||
|
||||
*fugitive-:Gremove*
|
||||
:Gremove Wrapper around git-rm that deletes the buffer
|
||||
afterward. When invoked in an index file, --cached is
|
||||
passed. Add a ! to pass -f and forcefully discard the
|
||||
buffer.
|
||||
|
||||
*fugitive-:Gblame*
|
||||
:Gblame [flags] Run git-blame on the file and open the results in a
|
||||
scroll bound vertical split. Press enter on a line to
|
||||
reblame the file as it was in that commit. You can
|
||||
give any of ltwfsMC as flags and they will be passed
|
||||
along to git-blame.
|
||||
|
||||
:[range]Gblame [flags] Run git-blame on the given range.
|
||||
|
||||
MAPPINGS *fugitive-mappings*
|
||||
|
||||
These maps are available in Git objects.
|
||||
|
||||
*fugitive-<CR>*
|
||||
<CR> Jump to the revision under the cursor.
|
||||
|
||||
*fugitive-o*
|
||||
o Jump to the revision under the cursor in a new split.
|
||||
|
||||
*fugitive-O*
|
||||
O Jump to the revision under the cursor in a new tab.
|
||||
|
||||
*fugitive-~*
|
||||
~ Go to the current file in the [count]th first
|
||||
ancestor.
|
||||
|
||||
*fugitive-P*
|
||||
P Go to the current file in the [count]th parent.
|
||||
|
||||
*fugitive-C*
|
||||
C Go to the commit containing the current file.
|
||||
|
||||
*fugitive-a*
|
||||
a Show the current tag, commit, or tree in an alternate
|
||||
format.
|
||||
|
||||
SPECIFYING REVISIONS *fugitive-revision*
|
||||
|
||||
Fugitive revisions are similar to Git revisions as defined in the "SPECIFYING
|
||||
REVISIONS" section in the git-rev-parse man page. For commands that accept an
|
||||
optional revision, the default is the file in the index for work tree files
|
||||
and the work tree file for everything else. Example revisions follow.
|
||||
|
||||
Revision Meaning ~
|
||||
HEAD .git/HEAD
|
||||
master .git/refs/heads/master
|
||||
HEAD^{} The commit referenced by HEAD
|
||||
HEAD^ The parent of the commit referenced by HEAD
|
||||
HEAD: The tree referenced by HEAD
|
||||
/HEAD The file named HEAD in the work tree
|
||||
Makefile The file named Makefile in the work tree
|
||||
HEAD^:Makefile The file named Makefile in the parent of HEAD
|
||||
:Makefile The file named Makefile in the index (writable)
|
||||
- The current file in HEAD
|
||||
^ The current file in the previous commit
|
||||
~3 The current file 3 commits ago
|
||||
: .git/index (Same as |:Gstatus|)
|
||||
:0 The current file in the index
|
||||
:1 The current file's common ancestor during a conflict
|
||||
:2 The current file in the target branch during a conflict
|
||||
:3 The current file in the merged branch during a conflict
|
||||
:/foo The most recent commit with "foo" in the message
|
||||
|
||||
STATUSLINE *fugitive-statusline*
|
||||
|
||||
*fugitive#statusline()*
|
||||
Add %{fugitive#statusline()} to your statusline to get an indicator including
|
||||
the current branch and the currently edited file's commit. If you don't have
|
||||
a statusline, this one matches the default when 'ruler' is set:
|
||||
>
|
||||
set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P
|
||||
<
|
||||
ABOUT *fugitive-about*
|
||||
|
||||
Grab the latest version or report a bug on GitHub:
|
||||
|
||||
http://github.com/tpope/vim-fugitive
|
||||
|
||||
vim:tw=78:et:ft=help:norl:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,142 @@
|
||||
" pathogen.vim - path option manipulation
|
||||
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
|
||||
" Version: 1.2
|
||||
|
||||
" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
|
||||
"
|
||||
" API is documented below.
|
||||
|
||||
if exists("g:loaded_pathogen") || &cp
|
||||
finish
|
||||
endif
|
||||
let g:loaded_pathogen = 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 has_key(seen,a:list[i])
|
||||
call remove(a:list,i)
|
||||
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
|
||||
|
||||
" Checks if a bundle is 'disabled'. A bundle is considered 'disabled' if
|
||||
" its 'basename()' is included in g:pathogen_disabled[]'.
|
||||
function! pathogen#is_disabled(path) " {{{1
|
||||
if !exists("g:pathogen_disabled")
|
||||
return 0
|
||||
endif
|
||||
let sep = pathogen#separator()
|
||||
return index(g:pathogen_disabled, strpart(a:path, strridx(a:path, sep)+1)) != -1
|
||||
endfunction "}}}1
|
||||
|
||||
" Prepend all subdirectories of path to the rtp, and append all 'after'
|
||||
" directories in those subdirectories.
|
||||
function! pathogen#runtime_prepend_subdirectories(path) " {{{1
|
||||
let sep = pathogen#separator()
|
||||
let before = filter(pathogen#glob_directories(a:path.sep."*[^~]"), '!pathogen#is_disabled(v:val)')
|
||||
let after = filter(pathogen#glob_directories(a:path.sep."*[^~]".sep."after"), '!pathogen#is_disabled(v:val)')
|
||||
let rtp = pathogen#split(&rtp)
|
||||
let path = expand(a:path)
|
||||
call filter(rtp,'v:val[0:strlen(path)-1] !=# path')
|
||||
let &rtp = pathogen#join(pathogen#uniq(before + rtp + after))
|
||||
return &rtp
|
||||
endfunction " }}}1
|
||||
|
||||
" For each directory in rtp, check for a subdirectory named dir. If it
|
||||
" exists, add all subdirectories of that subdirectory to the rtp, immediately
|
||||
" after the original directory. If no argument is given, 'bundle' is used.
|
||||
" Repeated calls with the same arguments are ignored.
|
||||
function! pathogen#runtime_append_all_bundles(...) " {{{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$'
|
||||
let list += filter(pathogen#glob_directories(substitute(dir,'after$',name,'').sep.'*[^~]'.sep.'after'), '!pathogen#is_disabled(v:val)') + [dir]
|
||||
else
|
||||
let list += [dir] + filter(pathogen#glob_directories(dir.sep.name.sep.'*[^~]'), '!pathogen#is_disabled(v:val)')
|
||||
endif
|
||||
endfor
|
||||
let &rtp = pathogen#join(pathogen#uniq(list))
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
let s:done_bundles = ''
|
||||
" }}}1
|
||||
|
||||
" Invoke :helptags on all non-$VIM doc directories in runtimepath.
|
||||
function! pathogen#helptags() " {{{1
|
||||
for dir in pathogen#split(&rtp)
|
||||
if dir[0 : strlen($VIM)-1] !=# $VIM && isdirectory(dir.'/doc') && (!filereadable(dir.'/doc/tags') || filewritable(dir.'/doc/tags'))
|
||||
helptags `=dir.'/doc'`
|
||||
endif
|
||||
endfor
|
||||
endfunction " }}}1
|
||||
|
||||
" vim:set ft=vim ts=8 sw=2 sts=2:
|
||||
@@ -0,0 +1,33 @@
|
||||
vim-peepopen
|
||||
=============
|
||||
|
||||
A plugin for the Vim text editor. PeepOpen provides fuzzy search of filenames and paths in a programming project.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Get the PeepOpen.app and open it at least once to approve the Mac OS X security dialog.
|
||||
|
||||
Standard:
|
||||
|
||||
Copy `peepopen.vim` to your `~/.vim/plugin` directory.
|
||||
|
||||
With Tim Pope's [Pathogen](http://github.com/tpope/vim-pathogen):
|
||||
|
||||
Copy the entire `vim-peepopen` plugin directory to your `~/.vim/bundle` directory.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
`<Leader>p` opens the current project directory with the PeepOpen application.
|
||||
|
||||
Use the [vim-rooter](http://github.com/airblade/vim-rooter) plugin for automatic assignment of the current working directory for projects stored in Git.
|
||||
|
||||
(Leader is mapped to '\' by default)
|
||||
|
||||
Credits
|
||||
-------
|
||||
|
||||
- Initial Vim Plugin by [Andrew Stewart](http://www.airbladesoftware.com/).
|
||||
- Some plugin boilerplate from [Rein Henrichs](http://reinh.com/).
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
" plugin/peepopen.vim
|
||||
" Author: Geoffrey Grosenbach <boss@topfunky.com>
|
||||
" License: MIT License
|
||||
|
||||
" Install this file as plugin/peepopen.vim.
|
||||
|
||||
" If you prefer Command-T, use this snippet in your .gvimrc:
|
||||
|
||||
" if has("gui_macvim")
|
||||
" macmenu &File.New\ Tab key=<nop>
|
||||
" map <D-t> <Plug>PeepOpen
|
||||
" end
|
||||
|
||||
" ============================================================================
|
||||
|
||||
" Exit quickly when:
|
||||
" - this plugin was already loaded (or disabled)
|
||||
" - when 'compatible' is set
|
||||
if &cp || exists("g:peepopen_loaded") && g:peepopen_loaded
|
||||
finish
|
||||
endif
|
||||
let g:peepopen_loaded = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function s:LaunchPeepOpenViaVim()
|
||||
let cwd = getcwd()
|
||||
silent exe "!open -a PeepOpen " . shellescape(cwd)
|
||||
endfunction
|
||||
|
||||
command! PeepOpen :call <SID>LaunchPeepOpenViaVim()
|
||||
|
||||
noremap <unique> <script> <Plug>PeepOpen <SID>Launch
|
||||
noremap <SID>Launch :call <SID>LaunchPeepOpenViaVim()<CR>
|
||||
|
||||
if !hasmapto('<Plug>PeepOpen')
|
||||
map <unique> <silent> <Leader>p <Plug>PeepOpen
|
||||
endif
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim:set sw=2 sts=2:
|
||||
|
||||
au VimEnter *.py NERDTree
|
||||
@@ -0,0 +1,38 @@
|
||||
Installation
|
||||
------------
|
||||
1. Install [pyflakes](http://pypi.python.org/pypi/pyflakes/)
|
||||
2. Copy the file `ftplugin/python_pyflakes.vim` to your `~/.vim/ftplugin` directory
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
1. Open a Python file
|
||||
2. Press `<F7>` to run `pyflakes` on it
|
||||
|
||||
It shows the errors inside a quickfix window, which will allow your to quickly
|
||||
jump to the error locations by simply pressing [Enter].
|
||||
|
||||
|
||||
Customization
|
||||
-------------
|
||||
If you don't want to use the `<F7>` key for pyflakes-checking, simply remap it to
|
||||
another key. It autodetects whether it has been remapped and won't register
|
||||
the `<F7>` key if so. For example, to remap it to `<F3>` instead, use:
|
||||
|
||||
autocmd FileType python map <buffer> <F3> :call Pyflakes()<CR>
|
||||
|
||||
|
||||
Tips
|
||||
----
|
||||
A tip might be to run the Pyflakes check every time you write a Python file, to
|
||||
enable this, add the following line to your `.vimrc` file (thanks
|
||||
[Godefroid](http://github.com/gotcha)!):
|
||||
|
||||
autocmd BufWritePost *.py call Pyflakes()
|
||||
|
||||
|
||||
This plugin goes well together with the following plugins:
|
||||
|
||||
- [PEP8](http://github.com/nvie/vim-pep8) (Python coding style checker under `<F6>`)
|
||||
- [PyUnit](http://github.com/nvie/vim-pyunit) (unit test helper under `<F8>`
|
||||
and `<F9>`)
|
||||
@@ -0,0 +1,74 @@
|
||||
"
|
||||
" Python filetype plugin for running pyflakes
|
||||
" Language: Python (ft=python)
|
||||
" Maintainer: Vincent Driessen <vincent@datafox.nl>
|
||||
" Version: Vim 7 (may work with lower Vim versions, but not tested)
|
||||
" URL: http://github.com/nvie/vim-pyflakes
|
||||
"
|
||||
" Only do this when not done yet for this buffer
|
||||
if exists("b:loaded_pyflakes_ftplugin")
|
||||
finish
|
||||
endif
|
||||
let b:loaded_pyflakes_ftplugin=1
|
||||
|
||||
let s:pyflakes_cmd="/usr/local/Cellar/python/2.7/Frameworks/Python.framework/Versions/2.7/bin//pyflakes"
|
||||
|
||||
if !exists("*Pyflakes()")
|
||||
function Pyflakes()
|
||||
if !executable(s:pyflakes_cmd)
|
||||
echoerr "File " . s:pyflakes_cmd . " not found. Please install it first."
|
||||
return
|
||||
endif
|
||||
|
||||
set lazyredraw " delay redrawing
|
||||
cclose " close any existing cwindows
|
||||
|
||||
" store old grep settings (to restore later)
|
||||
let l:old_gfm=&grepformat
|
||||
let l:old_gp=&grepprg
|
||||
|
||||
" write any changes before continuing
|
||||
if &readonly == 0
|
||||
update
|
||||
endif
|
||||
|
||||
" perform the grep itself
|
||||
let &grepformat="%f:%l: %m"
|
||||
let &grepprg=s:pyflakes_cmd
|
||||
silent! grep! %
|
||||
|
||||
" restore grep settings
|
||||
let &grepformat=l:old_gfm
|
||||
let &grepprg=l:old_gp
|
||||
|
||||
" open cwindow
|
||||
let has_results=getqflist() != []
|
||||
if has_results
|
||||
execute 'belowright copen'
|
||||
setlocal wrap
|
||||
nnoremap <buffer> <silent> c :cclose<CR>
|
||||
nnoremap <buffer> <silent> q :cclose<CR>
|
||||
endif
|
||||
|
||||
set nolazyredraw
|
||||
redraw!
|
||||
|
||||
if has_results == 0
|
||||
" Show OK status
|
||||
hi Green ctermfg=green
|
||||
echohl Green
|
||||
echon "Static analysis OK"
|
||||
echohl
|
||||
endif
|
||||
endfunction
|
||||
endif
|
||||
|
||||
" Add mappings, unless the user didn't want this.
|
||||
" The default mapping is registered under to <F7> by default, unless the user
|
||||
" remapped it already (or a mapping exists already for <F7>)
|
||||
if !exists("no_plugin_maps") && !exists("no_pyflakes_maps")
|
||||
if !hasmapto('Pyflakes(')
|
||||
noremap <buffer> <F7> :call Pyflakes()<CR>
|
||||
noremap! <buffer> <F7> :call Pyflakes()<CR>
|
||||
endif
|
||||
endif
|
||||
@@ -0,0 +1,576 @@
|
||||
" tcomment.vim
|
||||
" @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: 2009-02-15.
|
||||
" @Revision: 0.0.66
|
||||
|
||||
if &cp || exists("loaded_tcomment_autoload")
|
||||
finish
|
||||
endif
|
||||
let loaded_tcomment_autoload = 1
|
||||
|
||||
|
||||
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, ?commentBegin, ?commentEnd)
|
||||
" commentMode:
|
||||
" G ... guess
|
||||
" B ... block
|
||||
" i ... maybe inline, guess
|
||||
" I ... inline
|
||||
" R ... right
|
||||
" v ... visual
|
||||
" o ... operator
|
||||
function! tcomment#Comment(beg, end, ...)
|
||||
" save the cursor position
|
||||
let co = col('.')
|
||||
let li = line('.')
|
||||
let s:pos_end = getpos("'>")
|
||||
let commentMode = a:0 >= 1 ? a:1 : 'G'
|
||||
let commentAnyway = a:0 >= 2 ? (a:2 == '!') : 0
|
||||
" TLogVAR a:beg, a:end, a:1, commentMode, commentAnyway
|
||||
if commentMode =~# 'i'
|
||||
let commentMode = substitute(commentMode, '\Ci', line("'<") == line("'>") ? 'I' : 'G', 'g')
|
||||
endif
|
||||
if commentMode =~# 'R' || commentMode =~# 'I'
|
||||
let cstart = col("'<")
|
||||
if cstart == 0
|
||||
let cstart = col('.')
|
||||
endif
|
||||
if commentMode =~# 'R'
|
||||
let commentMode = substitute(commentMode, '\CR', 'G', 'g')
|
||||
let cend = 0
|
||||
else
|
||||
let cend = col("'>")
|
||||
if commentMode =~# 'o'
|
||||
let cend += 1
|
||||
endif
|
||||
endif
|
||||
else
|
||||
let cstart = 0
|
||||
let cend = 0
|
||||
endif
|
||||
" TLogVAR commentMode, cstart, cend
|
||||
" get the correct commentstring
|
||||
if a:0 >= 3 && a:3 != ''
|
||||
let cms = s:EncodeCommentPart(a:3) .'%s'
|
||||
if a:0 >= 4 && a:4 != ''
|
||||
let cms = cms . s:EncodeCommentPart(a:4)
|
||||
endif
|
||||
else
|
||||
let [cms, commentMode] = s:GetCommentString(a:beg, a:end, commentMode)
|
||||
endif
|
||||
let cms0 = s:BlockGetCommentString(cms)
|
||||
let cms0 = escape(cms0, '\')
|
||||
" make whitespace optional; this conflicts with comments that require some
|
||||
" whitespace
|
||||
let cmtCheck = substitute(cms0, '\([ ]\)', '\1\\?', 'g')
|
||||
" turn commentstring into a search pattern
|
||||
let cmtCheck = s:SPrintF(cmtCheck, '\(\_.\{-}\)')
|
||||
" set commentMode and indentStr
|
||||
let [indentStr, uncomment] = s:CommentDef(a:beg, a:end, cmtCheck, commentMode, cstart, cend)
|
||||
" TLogVAR indentStr, uncomment
|
||||
if commentAnyway
|
||||
let uncomment = 0
|
||||
endif
|
||||
" go
|
||||
if commentMode =~# 'B'
|
||||
" We want a comment block
|
||||
call s:CommentBlock(a:beg, a:end, uncomment, cmtCheck, cms, indentStr)
|
||||
else
|
||||
" call s:CommentLines(a:beg, a:end, cstart, 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 = escape(cms0, '"/')
|
||||
silent exec a:beg .','. a:end .'s/\V'.
|
||||
\ s:StartRx(cstart) . indentStr .'\zs\(\.\{-}\)'. s:EndRx(cend) .'/'.
|
||||
\ '\=s:ProcessedLine('. uncomment .', submatch(0), "'. cmtCheck .'", "'. cmtReplace .'")/ge'
|
||||
endif
|
||||
" reposition cursor
|
||||
" TLogVAR commentMode
|
||||
if commentMode =~ '>'
|
||||
call setpos('.', s:pos_end)
|
||||
else
|
||||
" TLogVAR li, co
|
||||
call cursor(li, co)
|
||||
endif
|
||||
endf
|
||||
|
||||
function! tcomment#Operator(type, ...) "{{{3
|
||||
let commentMode = a:0 >= 1 ? a:1 : ''
|
||||
let bang = a:0 >= 2 ? a:2 : ''
|
||||
if !exists('w:tcommentPos')
|
||||
let w:tcommentPos = getpos(".")
|
||||
endif
|
||||
let sel_save = &selection
|
||||
let &selection = "inclusive"
|
||||
let reg_save = @@
|
||||
" let pos = getpos('.')
|
||||
" TLogVAR a:type
|
||||
try
|
||||
if a:type == 'line'
|
||||
silent exe "normal! '[V']"
|
||||
let commentMode1 = 'G'
|
||||
elseif a:type == 'block'
|
||||
silent exe "normal! `[\<C-V>`]"
|
||||
let commentMode1 = 'I'
|
||||
else
|
||||
silent exe "normal! `[v`]"
|
||||
let commentMode1 = 'i'
|
||||
endif
|
||||
if empty(commentMode)
|
||||
let commentMode = commentMode1
|
||||
endif
|
||||
let beg = line("'[")
|
||||
let end = line("']")
|
||||
norm!
|
||||
let commentMode .= g:tcommentOpModeExtra
|
||||
call tcomment#Comment(beg, end, commentMode.'o', bang)
|
||||
finally
|
||||
let &selection = sel_save
|
||||
let @@ = reg_save
|
||||
if g:tcommentOpModeExtra !~ '>'
|
||||
" TLogVAR pos
|
||||
" call setpos('.', pos)
|
||||
call setpos('.', w:tcommentPos)
|
||||
unlet! w:tcommentPos
|
||||
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
|
||||
|
||||
|
||||
" comment text as if it were of a specific filetype
|
||||
function! tcomment#CommentAs(beg, end, commentAnyway, filetype, ...)
|
||||
let ccount = a:0 >= 1 ? a:1 : 1
|
||||
" TLogVAR ccount
|
||||
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
|
||||
let [cms, commentMode] = s:GetCommentString(a:beg, a:end, commentMode, ft)
|
||||
let pre = substitute(cms, '%s.*$', '', '')
|
||||
let pre = substitute(pre, '%%', '%', 'g')
|
||||
let post = substitute(cms, '^.\{-}%s', '', '')
|
||||
let post = substitute(post, '%%', '%', 'g')
|
||||
if ccount > 1
|
||||
let pre_l = matchlist(pre, '^\(\S\+\)\(.*\)$')
|
||||
" TLogVAR pre_l
|
||||
if !empty(get(pre_l, 1))
|
||||
let pre = repeat(pre_l[1], ccount) . pre_l[2]
|
||||
endif
|
||||
let post_l = matchlist(post, '^\(\s*\)\(.\+\)$')
|
||||
" TLogVAR post_l
|
||||
if !empty(get(post_l, 2))
|
||||
let post = post_l[1] . repeat(post_l[2], ccount)
|
||||
endif
|
||||
endif
|
||||
keepjumps call tcomment#Comment(a:beg, a:end, commentMode, a:commentAnyway, pre, post)
|
||||
endf
|
||||
|
||||
|
||||
" ----------------------------------------------------------------
|
||||
" collect all variables matching ^tcomment_
|
||||
function! tcomment#CollectFileTypes()
|
||||
if g:tcommentFileTypesDirty
|
||||
redir => vars
|
||||
silent let
|
||||
redir END
|
||||
let g:tcommentFileTypes = split(vars, '\n')
|
||||
call filter(g:tcommentFileTypes, 'v:val =~ "tcomment_"')
|
||||
call map(g:tcommentFileTypes, 'matchstr(v:val, ''tcomment_\zs\S\+'')')
|
||||
call sort(g:tcommentFileTypes)
|
||||
let g:tcommentFileTypesRx = '\V\^\('. join(g:tcommentFileTypes, '\|') .'\)\(\u\.\*\)\?\$'
|
||||
let g:tcommentFileTypesDirty = 0
|
||||
endif
|
||||
endf
|
||||
|
||||
call tcomment#CollectFileTypes()
|
||||
|
||||
" return a list of filetypes for which a tcomment_{&ft} is defined
|
||||
function! tcomment#FileTypes(ArgLead, CmdLine, CursorPos)
|
||||
" TLogVAR a:ArgLead, a:CmdLine, a:CursorPos
|
||||
call tcomment#CollectFileTypes()
|
||||
let types = copy(g:tcommentFileTypes)
|
||||
if index(g:tcommentFileTypes, &filetype) != -1
|
||||
" TLogVAR &filetype
|
||||
call insert(types, &filetype)
|
||||
endif
|
||||
if empty(a:ArgLead)
|
||||
return types
|
||||
else
|
||||
return filter(types, 'v:val =~ ''\V''.a:ArgLead')
|
||||
endif
|
||||
endf
|
||||
|
||||
function! s:EncodeCommentPart(string)
|
||||
return substitute(a:string, '%', '%%', 'g')
|
||||
endf
|
||||
|
||||
" s:GetCommentString(beg, end, commentMode, ?filetype="")
|
||||
function! s:GetCommentString(beg, end, commentMode, ...)
|
||||
let ft = a:0 >= 1 ? a:1 : ''
|
||||
if ft != ''
|
||||
let [cms, commentMode] = s:GetCustomCommentString(ft, a:commentMode)
|
||||
else
|
||||
let cms = ''
|
||||
let commentMode = a:commentMode
|
||||
endif
|
||||
if empty(cms)
|
||||
if exists('b:commentstring')
|
||||
let cms = b:commentstring
|
||||
return s:GetCustomCommentString(&filetype, a:commentMode, cms)
|
||||
elseif exists('b:commentStart') && b:commentStart != ''
|
||||
let cms = s:EncodeCommentPart(b:commentStart) .' %s'
|
||||
if exists('b:commentEnd') && b:commentEnd != ''
|
||||
let cms = cms .' '. s:EncodeCommentPart(b:commentEnd)
|
||||
endif
|
||||
return s:GetCustomCommentString(&filetype, a:commentMode, cms)
|
||||
elseif g:tcommentGuessFileType || (exists('g:tcommentGuessFileType_'. &filetype)
|
||||
\ && g:tcommentGuessFileType_{&filetype} =~ '[^0]')
|
||||
if g:tcommentGuessFileType_{&filetype} == 1
|
||||
let altFiletype = ''
|
||||
else
|
||||
let altFiletype = g:tcommentGuessFileType_{&filetype}
|
||||
endif
|
||||
return s:GuessFileType(a:beg, a:end, a:commentMode, &filetype, altFiletype)
|
||||
else
|
||||
return s:GetCustomCommentString(&filetype, a:commentMode, s:GuessCurrentCommentString(a:commentMode))
|
||||
endif
|
||||
endif
|
||||
return [cms, commentMode]
|
||||
endf
|
||||
|
||||
" s:SPrintF(formatstring, ?values ...)
|
||||
" => string
|
||||
function! s:SPrintF(string, ...)
|
||||
let n = 1
|
||||
let r = ''
|
||||
let s = a:string
|
||||
while 1
|
||||
let i = match(s, '%\(.\)')
|
||||
if i >= 0
|
||||
let x = s[i + 1]
|
||||
let r = r . strpart(s, 0, i)
|
||||
let s = strpart(s, i + 2)
|
||||
if x == '%'
|
||||
let r = r.'%'
|
||||
else
|
||||
if a:0 >= n
|
||||
let v = a:{n}
|
||||
let n = n + 1
|
||||
else
|
||||
echoerr 'Malformed format string (too many arguments required): '. a:string
|
||||
endif
|
||||
if x ==# 's'
|
||||
let r = r.v
|
||||
elseif x ==# 'S'
|
||||
let r = r.'"'.v.'"'
|
||||
else
|
||||
echoerr 'Malformed format string: '. a:string
|
||||
endif
|
||||
endif
|
||||
else
|
||||
return r.s
|
||||
endif
|
||||
endwh
|
||||
endf
|
||||
|
||||
function! s:StartRx(pos)
|
||||
if a:pos == 0
|
||||
return '\^'
|
||||
else
|
||||
return '\%'. a:pos .'c'
|
||||
endif
|
||||
endf
|
||||
|
||||
function! s:EndRx(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)
|
||||
let mdrx = '\V'. s:StartRx(a:cstart) .'\s\*'. a:checkRx .'\s\*'. s:EndRx(0)
|
||||
let line = getline(a:beg)
|
||||
if a:cstart != 0 && a:cend != 0
|
||||
let line = strpart(line, 0, a:cend - 1)
|
||||
endif
|
||||
let uncomment = (line =~ mdrx)
|
||||
let it = s:GetIndentString(a:beg, a:cstart)
|
||||
let il = indent(a:beg)
|
||||
let n = a:beg + 1
|
||||
while n <= a:end
|
||||
if getline(n) =~ '\S'
|
||||
let jl = indent(n)
|
||||
if jl < il
|
||||
let it = s:GetIndentString(n, a:cstart)
|
||||
let il = jl
|
||||
endif
|
||||
if a:commentMode =~# 'G'
|
||||
if !(getline(n) =~ mdrx)
|
||||
let uncomment = 0
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
let n = n + 1
|
||||
endwh
|
||||
if a:commentMode =~# 'B'
|
||||
let t = @t
|
||||
try
|
||||
silent exec 'norm! '. a:beg.'G1|v'.a:end.'G$"ty'
|
||||
let uncomment = (@t =~ mdrx)
|
||||
finally
|
||||
let @t = t
|
||||
endtry
|
||||
endif
|
||||
return [it, uncomment]
|
||||
endf
|
||||
|
||||
function! s:ProcessedLine(uncomment, match, checkRx, replace)
|
||||
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', '')
|
||||
else
|
||||
let rv = s:SPrintF(a:replace, a:match)
|
||||
endif
|
||||
" let md = len(rv) - ml
|
||||
let s:pos_end = getpos('.')
|
||||
let s:pos_end[2] += len(rv)
|
||||
" TLogVAR pe, md, a:match
|
||||
let rv = escape(rv, '\
|
||||
')
|
||||
let rv = substitute(rv, '\n', '\\\n', 'g')
|
||||
return rv
|
||||
endf
|
||||
|
||||
function! s:CommentLines(beg, end, cstart, cend, uncomment, cmtCheck, cms0, indentStr) "{{{3
|
||||
" We want commented lines
|
||||
" final search pattern for uncommenting
|
||||
let cmtCheck = escape('\V\^\(\s\{-}\)'. a:cmtCheck .'\$', '"/\')
|
||||
" final pattern for commenting
|
||||
let cmtReplace = escape(a:cms0, '"/')
|
||||
silent exec a:beg .','. a:end .'s/\V'.
|
||||
\ s:StartRx(a:cstart) . a:indentStr .'\zs\(\.\{-}\)'. s:EndRx(a:cend) .'/'.
|
||||
\ '\=s:ProcessedLine('. a:uncomment .', submatch(0), "'. a:cmtCheck .'", "'. cmtReplace .'")/ge'
|
||||
endf
|
||||
|
||||
function! s:CommentBlock(beg, end, uncomment, checkRx, replace, indentStr)
|
||||
let t = @t
|
||||
try
|
||||
silent exec 'norm! '. a:beg.'G1|v'.a:end.'G$"td'
|
||||
let ms = s:BlockGetMiddleString(a:replace)
|
||||
let mx = escape(ms, '\')
|
||||
if a:uncomment
|
||||
let @t = substitute(@t, '\V\^\s\*'. a:checkRx .'\$', '\1', '')
|
||||
if ms != ''
|
||||
let @t = substitute(@t, '\V\n'. a:indentStr . mx, '\n'. a:indentStr, 'g')
|
||||
endif
|
||||
let @t = substitute(@t, '^\n', '', '')
|
||||
let @t = substitute(@t, '\n\s*$', '', '')
|
||||
else
|
||||
let cs = s:BlockGetCommentString(a:replace)
|
||||
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 = s:SPrintF(cs, "\n". @t ."\n")
|
||||
endif
|
||||
silent norm! "tP
|
||||
finally
|
||||
let @t = t
|
||||
endtry
|
||||
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, ...)
|
||||
if a:0 >= 1 && a:1 != ''
|
||||
let [cms, commentMode] = s:GetCustomCommentString(a:1, a:commentMode)
|
||||
if cms == ''
|
||||
let cms = s:GuessCurrentCommentString(a:commentMode)
|
||||
endif
|
||||
else
|
||||
let commentMode = s:CommentMode(a:commentMode, 'G')
|
||||
let cms = s:GuessCurrentCommentString(0)
|
||||
endif
|
||||
let n = a:beg
|
||||
" TLogVAR n, a:beg, a:end
|
||||
while n <= a:end
|
||||
let m = indent(n) + 1
|
||||
let le = len(getline(n))
|
||||
" TLogVAR m, le
|
||||
while m < le
|
||||
let syntaxName = synIDattr(synID(n, m, 1), 'name')
|
||||
" TLogVAR syntaxName, n, m
|
||||
let ftypeMap = get(g:tcommentSyntaxMap, syntaxName)
|
||||
if !empty(ftypeMap)
|
||||
" TLogVAR ftypeMap
|
||||
return s:GetCustomCommentString(ftypeMap, a:commentMode, cms)
|
||||
elseif syntaxName =~ g:tcommentFileTypesRx
|
||||
let ft = substitute(syntaxName, g:tcommentFileTypesRx, '\1', '')
|
||||
" TLogVAR ft
|
||||
if exists('g:tcommentIgnoreTypes_'. a:filetype) && g:tcommentIgnoreTypes_{a:filetype} =~ '\<'.ft.'\>'
|
||||
let m += 1
|
||||
else
|
||||
return s:GetCustomCommentString(ft, a:commentMode, cms)
|
||||
endif
|
||||
elseif syntaxName == '' || syntaxName == 'None' || syntaxName =~ '^\u\+$' || syntaxName =~ '^\u\U*$'
|
||||
let m += 1
|
||||
else
|
||||
break
|
||||
endif
|
||||
endwh
|
||||
let n += 1
|
||||
endwh
|
||||
return [cms, commentMode]
|
||||
endf
|
||||
|
||||
function! s:CommentMode(commentMode, newmode) "{{{3
|
||||
return substitute(a:commentMode, '\w\+', a:newmode, 'g')
|
||||
endf
|
||||
|
||||
function! s:GuessCurrentCommentString(commentMode)
|
||||
let valid_cms = (stridx(&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')
|
||||
" if a:commentMode
|
||||
" exec s:ExtractCommentsPart("m")
|
||||
" if m != ""
|
||||
" let m = "\n". m
|
||||
" endif
|
||||
" return s.'%s'.e.m
|
||||
" else
|
||||
return s.' %s '.e
|
||||
" endif
|
||||
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, ...)
|
||||
let commentMode = a:commentMode
|
||||
let customComment = exists('g:tcomment_'. a:ft)
|
||||
if commentMode =~# 'B' && exists('g:tcomment_'. a:ft .'_block')
|
||||
let cms = g:tcomment_{a:ft}_block
|
||||
elseif commentMode =~? 'I' && exists('g:tcomment_'. a:ft .'_inline')
|
||||
let cms = g:tcomment_{a:ft}_inline
|
||||
elseif customComment
|
||||
let cms = g:tcomment_{a:ft}
|
||||
let commentMode = s:CommentMode(commentMode, 'G')
|
||||
elseif a:0 >= 1
|
||||
let cms = a:1
|
||||
let commentMode = s:CommentMode(commentMode, 'G')
|
||||
else
|
||||
let cms = ''
|
||||
let commentMode = s:CommentMode(commentMode, 'G')
|
||||
endif
|
||||
return [cms, commentMode]
|
||||
endf
|
||||
|
||||
function! s:BlockGetCommentString(cms)
|
||||
" return substitute(a:cms, '\n.*$', '', '')
|
||||
return matchstr(a:cms, '^.\{-}\ze\(\n\|$\)')
|
||||
endf
|
||||
|
||||
function! s:BlockGetMiddleString(cms)
|
||||
" let rv = substitute(a:cms, '^.\{-}\n\([^\n]*\)', '\1', '')
|
||||
let rv = matchstr(a:cms, '\n\zs.*')
|
||||
return rv == a:cms ? '' : rv
|
||||
endf
|
||||
|
||||
|
||||
redraw
|
||||
@@ -0,0 +1,208 @@
|
||||
*tComment.txt* tComment -- 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-Installation*
|
||||
Installation~
|
||||
Edit the vba file and type:
|
||||
|
||||
:so %
|
||||
|
||||
See :help vimball for details. If you use vim 7.0, you may need to
|
||||
update your vimball installation first.
|
||||
|
||||
|
||||
*tComment-Usage*
|
||||
Usage~
|
||||
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 |TCommentDefineType()| 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-Key-Bindings*
|
||||
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 ;-).
|
||||
|
||||
*g:tcommentMapLeaderOp1*
|
||||
*g:tcommentMapLeaderOp2*
|
||||
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)
|
||||
gcc :: Toggle comment for the current line
|
||||
gC{motion} :: Comment region
|
||||
gCc :: Comment the current line
|
||||
|
||||
*g:tcommentOpModeExtra*
|
||||
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:
|
||||
|
||||
<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
|
||||
<c-_>r :: :TCommentRight
|
||||
<c-_>p :: Comment the current inner paragraph
|
||||
|
||||
A secondary set of key maps is defined for normal 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>
|
||||
|
||||
Keymaps are configurable via the following variables:
|
||||
|
||||
*g:tcommentMapLeader1*
|
||||
g:tcommentMapLeader1 string (default: <c-_>)
|
||||
Prefix for the keymaps. Set to '' to disable keymaps with this
|
||||
prefix.
|
||||
*g:tcommentMapLeader2*
|
||||
g:tcommentMapLeader2 string (default: <Leader>_)
|
||||
Secondary prefix. (The reason for why there are two prefixes is
|
||||
that <c-_> appears preferable with gvim but can be difficult to
|
||||
type on the terminal. The secondary prefix isn't used for insert
|
||||
mode maps. Set to '' to disable keymaps with this prefix.
|
||||
|
||||
*tComment-commands*
|
||||
Alternatively, you can type (? meaning "optional argument"):
|
||||
|
||||
*:TComment*
|
||||
:?<range> TComment ?commentBegin ?commentEnd
|
||||
:?<range> TComment! ?commentBegin ?commentEnd
|
||||
NOTE: If there is a visual selection that begins and ends in the same
|
||||
line, then TCommentInline is used instead.
|
||||
|
||||
NOTE: The range is optional and defaults to the current line.
|
||||
|
||||
*:TCommentInline*
|
||||
:?<range> TCommentInline ?commentBegin ?commentEnd
|
||||
:?<range> TCommentInline! ?commentBegin ?commentEnd
|
||||
Use the {&ft}_inline comment style.
|
||||
|
||||
*:TCommentBlock*
|
||||
:?<range> TCommentBlock ?commentBegin ?commentEnd
|
||||
:?<range> TCommentBlock! ?commentBegin ?commentEnd
|
||||
Comment as "block", e.g. use the {&ft}_block comment style.
|
||||
NOTE: This command is kind of crude. It doesn't indent or reformat
|
||||
the text.
|
||||
|
||||
*:TCommentAs*
|
||||
:?<range> TCommentAs filetype
|
||||
:?<range> TCommentAs! filetype
|
||||
NOTE: TCommentAs requires g:tcomment_{filetype} to be defined.
|
||||
NOTE: This command supports command line completion. See 'wildmode'
|
||||
and 'wildmenu' for how to get the most out of it.
|
||||
|
||||
*:TCommentRight*
|
||||
:?<range> TCommentRight
|
||||
:?<range> TCommentRight!
|
||||
NOTE: This command comments out 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.
|
||||
|
||||
The bang (!) variants always comment out the selected text and don't
|
||||
work as toggles.
|
||||
|
||||
*TCommentDefineType()*
|
||||
Using this command you can also use different comment styles with
|
||||
the TCommentDefineType(name, commentstring) function. This function
|
||||
takes two arguments:
|
||||
name :: The name is either &filetype or {&filetype}_{style}.
|
||||
I.e., For block comments the {&filetype}_block and for
|
||||
inline comments the {&filetype}_inline styles are used.
|
||||
comment string :: a string mostly as described in
|
||||
'commentstring'.
|
||||
|
||||
If you want to define, e.g., a fancy block comment style for html
|
||||
you put something like this into ~/.vim/after/plugin/tComment.vim:>
|
||||
|
||||
call TCommentDefineType("html_fancy_block", "<!--%s -->\n -- ")
|
||||
|
||||
< The part after the newline character is used for marking "middle"
|
||||
lines.
|
||||
|
||||
This comment style could then be accessed via (this command has
|
||||
command line completion): >
|
||||
|
||||
'<,'>TCommentAs html_fancy_block
|
||||
|
||||
< If you're editing a html file, this could best be done by the <c-_>s
|
||||
key map.
|
||||
|
||||
|
||||
Goals~
|
||||
- Maintain indentation of selected text; the comment markers are left
|
||||
aligned but the text on the right (i.e., the comment) is indented
|
||||
like the original text
|
||||
|
||||
- Handle embedded syntax like php+html or html+javaScript+css; you
|
||||
have to set g:tcommentGuessFileType_{&filetype} to 1 or to the
|
||||
fall-back file-type in order to activate this feature for other file
|
||||
types than php or html
|
||||
|
||||
tComment deduces the correct file type from the syntax name, similar
|
||||
to the way EnhancedCommentify.vim does it. In opposition to
|
||||
EnhancedCommentify.vim, it matches the syntax name against a list the
|
||||
known file types, so that it can deal with, e.g., embedded javaScript
|
||||
|
||||
- Easy to customize/adapt for an yet unknown syntax by setting buffer
|
||||
local variables (b:commentStart, b:commentEnd, or b:commentstring),
|
||||
global variables (g:tcomment_{&ft} and g:tcomment_{&ft}_block), or the
|
||||
buffer local &commentstring option (which can be set on a vim
|
||||
|modeline|)
|
||||
|
||||
- Use 'commentstring' or 'comments' as a fallback (i.e., if a file-type
|
||||
is properly defined, TComment will automatically support it)
|
||||
|
||||
- Same short-cut for commenting text and for removing comment markup
|
||||
|
||||
- The decision whether text should be commented or uncommented is made
|
||||
on the basis of the whole selection (not line by line); comments in
|
||||
code that should be commented aren't uncommented as it is the case
|
||||
with some other plug-ins
|
||||
|
||||
As of version 1.5, the following file types are explicitly defined
|
||||
(other file-types are most likely supported through the 'commentstring'
|
||||
or 'comments' variables):
|
||||
|
||||
ada, apache, autoit, catalog, cpp, css, c, cfg, conf, desktop,
|
||||
docbk, dosbatch, dosini, dsl, dylan, eiffel, gtkrc, haskell, html,
|
||||
io, javaScript, java, lisp, m4, nroff, objc, ocaml, pascal, perl,
|
||||
php, prolog, ruby, r, scheme, sgml, sh, sql, spec, sps, tcl, tex,
|
||||
tpl, viki, vim, websec, xml, xslt, yaml
|
||||
|
||||
|
||||
Credits~
|
||||
The way we check for embedded syntax was originally adapted
|
||||
from/inspired by Meikel Brandmeyer's EnhancedCommentify.vim
|
||||
(vimscript #23) but has evolved since.
|
||||
|
||||
|
||||
vim: tw=72
|
||||
@@ -0,0 +1,385 @@
|
||||
" 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: 2009-08-07.
|
||||
" @Revision: 1.9.671
|
||||
"
|
||||
" GetLatestVimScripts: 1173 1 tComment.vim
|
||||
|
||||
if &cp || exists('loaded_tcomment')
|
||||
finish
|
||||
endif
|
||||
let loaded_tcomment = 109
|
||||
|
||||
" If true, comment blank lines too
|
||||
if !exists("g:tcommentBlankLines")
|
||||
let g:tcommentBlankLines = 1
|
||||
endif
|
||||
|
||||
if !exists("g:tcommentMapLeader1")
|
||||
let g:tcommentMapLeader1 = '<c-_>'
|
||||
endif
|
||||
if !exists("g:tcommentMapLeader2")
|
||||
let g:tcommentMapLeader2 = '<Leader>_'
|
||||
endif
|
||||
if !exists("g:tcommentMapLeaderOp1")
|
||||
let g:tcommentMapLeaderOp1 = 'gc'
|
||||
endif
|
||||
if !exists("g:tcommentMapLeaderOp2")
|
||||
let g:tcommentMapLeaderOp2 = 'gC'
|
||||
endif
|
||||
if !exists("g:tcommentOpModeExtra")
|
||||
let g:tcommentOpModeExtra = ''
|
||||
endif
|
||||
|
||||
" Guess the file type based on syntax names always or for some fileformat only
|
||||
if !exists("g:tcommentGuessFileType")
|
||||
let g:tcommentGuessFileType = 0
|
||||
endif
|
||||
" 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
|
||||
if !exists("g:tcommentGuessFileType_dsl")
|
||||
let g:tcommentGuessFileType_dsl = 'xml'
|
||||
endif
|
||||
if !exists("g:tcommentGuessFileType_php")
|
||||
let g:tcommentGuessFileType_php = 'html'
|
||||
endif
|
||||
if !exists("g:tcommentGuessFileType_html")
|
||||
let g:tcommentGuessFileType_html = 1
|
||||
endif
|
||||
if !exists("g:tcommentGuessFileType_tskeleton")
|
||||
let g:tcommentGuessFileType_tskeleton = 1
|
||||
endif
|
||||
if !exists("g:tcommentGuessFileType_vim")
|
||||
let g:tcommentGuessFileType_vim = 1
|
||||
endif
|
||||
|
||||
if !exists("g:tcommentIgnoreTypes_php")
|
||||
let g:tcommentIgnoreTypes_php = 'sql'
|
||||
endif
|
||||
|
||||
if !exists('g:tcommentSyntaxMap') "{{{2
|
||||
let g:tcommentSyntaxMap = {
|
||||
\ 'vimMzSchemeRegion': 'scheme',
|
||||
\ 'vimPerlRegion': 'perl',
|
||||
\ 'vimPythonRegion': 'python',
|
||||
\ 'vimRubyRegion': 'ruby',
|
||||
\ 'vimTclRegion': 'tcl',
|
||||
\ }
|
||||
endif
|
||||
|
||||
" If you don't define these variables, 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.
|
||||
" The format for block comments is similar to normal 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.
|
||||
|
||||
" I personally find this style rather irritating but here is an alternative
|
||||
" definition that does this left-handed bar thing
|
||||
if !exists("g:tcommentBlockC")
|
||||
let g:tcommentBlockC = "/*%s */\n * "
|
||||
endif
|
||||
if !exists("g:tcommentBlockC2")
|
||||
let g:tcommentBlockC2 = "/**%s */\n * "
|
||||
endif
|
||||
if !exists("g:tcommentInlineC")
|
||||
let g:tcommentInlineC = "/* %s */"
|
||||
endif
|
||||
|
||||
if !exists("g:tcommentBlockXML")
|
||||
let g:tcommentBlockXML = "<!--%s-->\n "
|
||||
endif
|
||||
if !exists("g:tcommentInlineXML")
|
||||
let g:tcommentInlineXML = "<!-- %s -->"
|
||||
endif
|
||||
|
||||
let g:tcommentFileTypesDirty = 1
|
||||
|
||||
" Currently this function just sets a variable
|
||||
function! TCommentDefineType(name, commentstring)
|
||||
if !exists('g:tcomment_'. a:name)
|
||||
let g:tcomment_{a:name} = a:commentstring
|
||||
endif
|
||||
let g:tcommentFileTypesDirty = 1
|
||||
endf
|
||||
|
||||
function! TCommentTypeExists(name)
|
||||
return exists('g:tcomment_'. a:name)
|
||||
endf
|
||||
|
||||
call TCommentDefineType('aap', '# %s' )
|
||||
call TCommentDefineType('ada', '-- %s' )
|
||||
call TCommentDefineType('apache', '# %s' )
|
||||
call TCommentDefineType('autoit', '; %s' )
|
||||
call TCommentDefineType('asm', '; %s' )
|
||||
call TCommentDefineType('awk', '# %s' )
|
||||
call TCommentDefineType('catalog', '-- %s --' )
|
||||
call TCommentDefineType('catalog_block', "--%s--\n " )
|
||||
call TCommentDefineType('cpp', '// %s' )
|
||||
call TCommentDefineType('cpp_inline', g:tcommentInlineC )
|
||||
call TCommentDefineType('cpp_block', g:tcommentBlockC )
|
||||
call TCommentDefineType('css', '/* %s */' )
|
||||
call TCommentDefineType('css_inline', g:tcommentInlineC )
|
||||
call TCommentDefineType('css_block', g:tcommentBlockC )
|
||||
call TCommentDefineType('c', '/* %s */' )
|
||||
call TCommentDefineType('c_inline', g:tcommentInlineC )
|
||||
call TCommentDefineType('c_block', g:tcommentBlockC )
|
||||
call TCommentDefineType('cfg', '# %s' )
|
||||
call TCommentDefineType('conf', '# %s' )
|
||||
call TCommentDefineType('crontab', '# %s' )
|
||||
call TCommentDefineType('desktop', '# %s' )
|
||||
call TCommentDefineType('docbk', '<!-- %s -->' )
|
||||
call TCommentDefineType('docbk_inline', g:tcommentInlineXML)
|
||||
call TCommentDefineType('docbk_block', g:tcommentBlockXML )
|
||||
call TCommentDefineType('dosbatch', 'rem %s' )
|
||||
call TCommentDefineType('dosini', '; %s' )
|
||||
call TCommentDefineType('dsl', '; %s' )
|
||||
call TCommentDefineType('dylan', '// %s' )
|
||||
call TCommentDefineType('eiffel', '-- %s' )
|
||||
call TCommentDefineType('eruby', '<%%# %s%%>' )
|
||||
call TCommentDefineType('gtkrc', '# %s' )
|
||||
call TCommentDefineType('gitcommit', '# %s' )
|
||||
call TCommentDefineType('haskell', '-- %s' )
|
||||
call TCommentDefineType('haskell_block', "{-%s-}\n " )
|
||||
call TCommentDefineType('haskell_inline', '{- %s -}' )
|
||||
call TCommentDefineType('html', '<!-- %s -->' )
|
||||
call TCommentDefineType('html_inline', g:tcommentInlineXML)
|
||||
call TCommentDefineType('html_block', g:tcommentBlockXML )
|
||||
call TCommentDefineType('io', '// %s' )
|
||||
call TCommentDefineType('javaScript', '// %s' )
|
||||
call TCommentDefineType('javaScript_inline', g:tcommentInlineC )
|
||||
call TCommentDefineType('javaScript_block', g:tcommentBlockC )
|
||||
call TCommentDefineType('javascript', '// %s' )
|
||||
call TCommentDefineType('javascript_inline', g:tcommentInlineC )
|
||||
call TCommentDefineType('javascript_block', g:tcommentBlockC )
|
||||
call TCommentDefineType('java', '/* %s */' )
|
||||
call TCommentDefineType('java_inline', g:tcommentInlineC )
|
||||
call TCommentDefineType('java_block', g:tcommentBlockC )
|
||||
call TCommentDefineType('java_doc_block', g:tcommentBlockC2 )
|
||||
call TCommentDefineType('jproperties', '# %s' )
|
||||
call TCommentDefineType('lisp', '; %s' )
|
||||
call TCommentDefineType('lynx', '# %s' )
|
||||
call TCommentDefineType('m4', 'dnl %s' )
|
||||
call TCommentDefineType('mail', '> %s' )
|
||||
call TCommentDefineType('msidl', '// %s' )
|
||||
call TCommentDefineType('msidl_block', g:tcommentBlockC )
|
||||
call TCommentDefineType('nroff', '.\\" %s' )
|
||||
call TCommentDefineType('nsis', '# %s' )
|
||||
call TCommentDefineType('objc', '/* %s */' )
|
||||
call TCommentDefineType('objc_inline', g:tcommentInlineC )
|
||||
call TCommentDefineType('objc_block', g:tcommentBlockC )
|
||||
call TCommentDefineType('ocaml', '(* %s *)' )
|
||||
call TCommentDefineType('ocaml_inline', '(* %s *)' )
|
||||
call TCommentDefineType('ocaml_block', "(*%s*)\n " )
|
||||
call TCommentDefineType('pascal', '(* %s *)' )
|
||||
call TCommentDefineType('pascal_inline', '(* %s *)' )
|
||||
call TCommentDefineType('pascal_block', "(*%s*)\n " )
|
||||
call TCommentDefineType('perl', '# %s' )
|
||||
call TCommentDefineType('perl_block', "=cut%s=cut" )
|
||||
call TCommentDefineType('php', '// %s' )
|
||||
call TCommentDefineType('php_inline', g:tcommentInlineC )
|
||||
call TCommentDefineType('php_block', g:tcommentBlockC )
|
||||
call TCommentDefineType('php_2_block', g:tcommentBlockC2 )
|
||||
call TCommentDefineType('po', '# %s' )
|
||||
call TCommentDefineType('prolog', '%% %s' )
|
||||
call TCommentDefineType('rc', '// %s' )
|
||||
call TCommentDefineType('readline', '# %s' )
|
||||
call TCommentDefineType('ruby', '# %s' )
|
||||
call TCommentDefineType('ruby_3', '### %s' )
|
||||
call TCommentDefineType('ruby_block', "=begin rdoc%s=end")
|
||||
call TCommentDefineType('ruby_nodoc_block', "=begin%s=end" )
|
||||
call TCommentDefineType('r', '# %s' )
|
||||
call TCommentDefineType('sbs', "' %s" )
|
||||
call TCommentDefineType('scheme', '; %s' )
|
||||
call TCommentDefineType('sed', '# %s' )
|
||||
call TCommentDefineType('sgml', '<!-- %s -->' )
|
||||
call TCommentDefineType('sgml_inline', g:tcommentInlineXML)
|
||||
call TCommentDefineType('sgml_block', g:tcommentBlockXML )
|
||||
call TCommentDefineType('sh', '# %s' )
|
||||
call TCommentDefineType('sql', '-- %s' )
|
||||
call TCommentDefineType('spec', '# %s' )
|
||||
call TCommentDefineType('sps', '* %s.' )
|
||||
call TCommentDefineType('sps_block', "* %s." )
|
||||
call TCommentDefineType('spss', '* %s.' )
|
||||
call TCommentDefineType('spss_block', "* %s." )
|
||||
call TCommentDefineType('tcl', '# %s' )
|
||||
call TCommentDefineType('tex', '%% %s' )
|
||||
call TCommentDefineType('tpl', '<!-- %s -->' )
|
||||
call TCommentDefineType('viki', '%% %s' )
|
||||
call TCommentDefineType('viki_3', '%%%%%% %s' )
|
||||
call TCommentDefineType('viki_inline', '{cmt: %s}' )
|
||||
call TCommentDefineType('vim', '" %s' )
|
||||
call TCommentDefineType('vim_3', '""" %s' )
|
||||
call TCommentDefineType('websec', '# %s' )
|
||||
call TCommentDefineType('xml', '<!-- %s -->' )
|
||||
call TCommentDefineType('xml_inline', g:tcommentInlineXML)
|
||||
call TCommentDefineType('xml_block', g:tcommentBlockXML )
|
||||
call TCommentDefineType('xs', '// %s' )
|
||||
call TCommentDefineType('xs_block', g:tcommentBlockC )
|
||||
call TCommentDefineType('xslt', '<!-- %s -->' )
|
||||
call TCommentDefineType('xslt_inline', g:tcommentInlineXML)
|
||||
call TCommentDefineType('xslt_block', g:tcommentBlockXML )
|
||||
call TCommentDefineType('yaml', '# %s' )
|
||||
|
||||
|
||||
" :line1,line2 TCommentAs commenttype
|
||||
command! -bang -complete=customlist,tcomment#FileTypes -range -nargs=+ TCommentAs
|
||||
\ call tcomment#CommentAs(<line1>, <line2>, "<bang>", <f-args>)
|
||||
|
||||
" :line1,line2 TComment ?commentBegin ?commentEnd
|
||||
command! -bang -range -nargs=* TComment keepjumps call tcomment#Comment(<line1>, <line2>, 'G', "<bang>", <f-args>)
|
||||
|
||||
" :line1,line2 TCommentRight ?commentBegin ?commentEnd
|
||||
command! -bang -range -nargs=* TCommentRight keepjumps call tcomment#Comment(<line1>, <line2>, 'R', "<bang>", <f-args>)
|
||||
|
||||
" :line1,line2 TCommentBlock ?commentBegin ?commentEnd
|
||||
command! -bang -range -nargs=* TCommentBlock keepjumps call tcomment#Comment(<line1>, <line2>, 'B', "<bang>", <f-args>)
|
||||
|
||||
" :line1,line2 TCommentInline ?commentBegin ?commentEnd
|
||||
command! -bang -range -nargs=* TCommentInline keepjumps call tcomment#Comment(<line1>, <line2>, 'I', "<bang>", <f-args>)
|
||||
|
||||
" :line1,line2 TCommentMaybeInline ?commentBegin ?commentEnd
|
||||
command! -bang -range -nargs=* TCommentMaybeInline keepjumps call tcomment#Comment(<line1>, <line2>, 'i', "<bang>", <f-args>)
|
||||
|
||||
|
||||
|
||||
if (g:tcommentMapLeader1 != '')
|
||||
exec 'noremap <silent> '. g:tcommentMapLeader1 .'<c-_> :TComment<cr>'
|
||||
exec 'vnoremap <silent> '. g:tcommentMapLeader1 .'<c-_> :TCommentMaybeInline<cr>'
|
||||
exec 'inoremap <silent> '. g:tcommentMapLeader1 .'<c-_> <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 'vnoremap <silent> '. g:tcommentMapLeader1 .'r :TCommentRight<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>_'
|
||||
endif
|
||||
if (g:tcommentMapLeader2 != '')
|
||||
exec 'noremap <silent> '. g:tcommentMapLeader2 .'_ :TComment<cr>'
|
||||
exec 'vnoremap <silent> '. g:tcommentMapLeader2 .'_ :TCommentMaybeInline<cr>'
|
||||
exec 'noremap <silent> '. g:tcommentMapLeader2 .'p vip:TComment<cr>'
|
||||
exec 'noremap '. g:tcommentMapLeader2 .'<space> :TComment '
|
||||
exec 'vnoremap <silent> '. g:tcommentMapLeader2 .'i :TCommentInline<cr>'
|
||||
exec 'noremap <silent> '. g:tcommentMapLeader2 .'r :TCommentRight<cr>'
|
||||
exec 'vnoremap <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 .' :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#Operator<cr>g@'
|
||||
exec 'nnoremap <silent> '. g:tcommentMapLeaderOp1 .'c :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLine<cr>g@$'
|
||||
exec 'vnoremap <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 'vnoremap <silent> '. g:tcommentMapLeaderOp2 .' :TCommentMaybeInline<cr>'
|
||||
endif
|
||||
|
||||
finish
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
History
|
||||
|
||||
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()
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
" Maintainer: Henrique C. Alves (hcarvalhoalves@gmail.com)
|
||||
" Version: 1.0
|
||||
" Last Change: September 25 2008
|
||||
|
||||
set background=dark
|
||||
|
||||
hi clear
|
||||
|
||||
if exists("syntax_on")
|
||||
syntax reset
|
||||
endif
|
||||
|
||||
let colors_name = "mustang"
|
||||
|
||||
" Vim >= 7.0 specific colors
|
||||
if version >= 700
|
||||
hi CursorLine guibg=#2d2d2d ctermbg=236
|
||||
hi CursorColumn guibg=#2d2d2d ctermbg=236
|
||||
hi MatchParen guifg=#d0ffc0 guibg=#2f2f2f gui=bold ctermfg=157 ctermbg=237 cterm=bold
|
||||
hi Pmenu guifg=#ffffff guibg=#444444 ctermfg=255 ctermbg=238
|
||||
hi PmenuSel guifg=#000000 guibg=#b1d631 ctermfg=0 ctermbg=148
|
||||
endif
|
||||
|
||||
" General colors
|
||||
hi Cursor guifg=NONE guibg=#626262 gui=none ctermbg=241
|
||||
hi Normal guifg=#e2e2e5 guibg=#202020 gui=none ctermfg=253 ctermbg=234
|
||||
hi NonText guifg=#808080 guibg=#303030 gui=none ctermfg=244 ctermbg=235
|
||||
hi LineNr guifg=#808080 guibg=#000000 gui=none ctermfg=244 ctermbg=232
|
||||
hi StatusLine guifg=#d3d3d5 guibg=#444444 gui=italic ctermfg=253 ctermbg=238 cterm=italic
|
||||
hi StatusLineNC guifg=#939395 guibg=#444444 gui=none ctermfg=246 ctermbg=238
|
||||
hi VertSplit guifg=#444444 guibg=#444444 gui=none ctermfg=238 ctermbg=238
|
||||
hi Folded guibg=#384048 guifg=#a0a8b0 gui=none ctermbg=4 ctermfg=248
|
||||
hi Title guifg=#f6f3e8 guibg=NONE gui=bold ctermfg=254 cterm=bold
|
||||
hi Visual guifg=#faf4c6 guibg=#3c414c gui=none ctermfg=254 ctermbg=4
|
||||
hi SpecialKey guifg=#808080 guibg=#343434 gui=none ctermfg=244 ctermbg=236
|
||||
|
||||
" Syntax highlighting
|
||||
hi Comment guifg=#808080 gui=italic ctermfg=244
|
||||
hi Todo guifg=#8f8f8f gui=italic ctermfg=245
|
||||
hi Boolean guifg=#b1d631 gui=none ctermfg=148
|
||||
hi String guifg=#b1d631 gui=italic ctermfg=148
|
||||
hi Identifier guifg=#b1d631 gui=none ctermfg=148
|
||||
hi Function guifg=#ffffff gui=bold ctermfg=255
|
||||
hi Type guifg=#7e8aa2 gui=none ctermfg=103
|
||||
hi Statement guifg=#7e8aa2 gui=none ctermfg=103
|
||||
hi Keyword guifg=#ff9800 gui=none ctermfg=208
|
||||
hi Constant guifg=#ff9800 gui=none ctermfg=208
|
||||
hi Number guifg=#ff9800 gui=none ctermfg=208
|
||||
hi Special guifg=#ff9800 gui=none ctermfg=208
|
||||
hi PreProc guifg=#faf4c6 gui=none ctermfg=230
|
||||
hi Todo guifg=#000000 guibg=#e6ea50 gui=italic
|
||||
|
||||
" Code-specific colors
|
||||
hi pythonOperator guifg=#7e8aa2 gui=none ctermfg=103
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
" Generated by Inspiration at Sweyla
|
||||
" http://inspiration.sweyla.com/code/seed/991498/
|
||||
|
||||
set background=dark
|
||||
|
||||
hi clear
|
||||
|
||||
if exists("syntax_on")
|
||||
syntax reset
|
||||
endif
|
||||
|
||||
" Set environment to 256 colours
|
||||
set t_Co=256
|
||||
|
||||
let colors_name = "inspiration991498"
|
||||
|
||||
if version >= 700
|
||||
hi CursorLine guibg=#0E0000 ctermbg=16
|
||||
hi CursorColumn guibg=#0E0000 ctermbg=16
|
||||
hi MatchParen guifg=#FF2700 guibg=#0E0000 gui=bold ctermfg=196 ctermbg=16 cterm=bold
|
||||
hi Pmenu guifg=#FFFFFF guibg=#323232 ctermfg=255 ctermbg=236
|
||||
hi PmenuSel guifg=#FFFFFF guibg=#EDB545 ctermfg=255 ctermbg=215
|
||||
endif
|
||||
|
||||
" Background and menu colors
|
||||
hi Cursor guifg=NONE guibg=#FFFFFF ctermbg=255 gui=none
|
||||
hi Normal guifg=#FFFFFF guibg=#0E0000 gui=none ctermfg=255 ctermbg=16 cterm=none
|
||||
hi NonText guifg=#FFFFFF guibg=#1D0F0F gui=none ctermfg=255 ctermbg=233 cterm=none
|
||||
hi LineNr guifg=#FFFFFF guibg=#271919 gui=none ctermfg=255 ctermbg=234 cterm=none
|
||||
hi StatusLine guifg=#FFFFFF guibg=#3A240D gui=italic ctermfg=255 ctermbg=235 cterm=italic
|
||||
hi StatusLineNC guifg=#FFFFFF guibg=#362828 gui=none ctermfg=255 ctermbg=235 cterm=none
|
||||
hi VertSplit guifg=#FFFFFF guibg=#271919 gui=none ctermfg=255 ctermbg=234 cterm=none
|
||||
hi Folded guifg=#FFFFFF guibg=#0E0000 gui=none ctermfg=255 ctermbg=16 cterm=none
|
||||
hi Title guifg=#EDB545 guibg=NONE gui=bold ctermfg=215 ctermbg=NONE cterm=bold
|
||||
hi Visual guifg=#E6B4B3 guibg=#323232 gui=none ctermfg=181 ctermbg=236 cterm=none
|
||||
hi SpecialKey guifg=#D9FF02 guibg=#1D0F0F gui=none ctermfg=190 ctermbg=233 cterm=none
|
||||
"hi DiffChange guibg=#564C00 gui=none ctermbg=58 cterm=none
|
||||
"hi DiffAdd guibg=#2F254C gui=none ctermbg=236 cterm=none
|
||||
"hi DiffText guibg=#6E3266 gui=none ctermbg=241 cterm=none
|
||||
"hi DiffDelete guibg=#4A0000 gui=none ctermbg=52 cterm=none
|
||||
|
||||
hi DiffChange guibg=#4C4C09 gui=none ctermbg=234 cterm=none
|
||||
hi DiffAdd guibg=#252556 gui=none ctermbg=17 cterm=none
|
||||
hi DiffText guibg=#66326E gui=none ctermbg=22 cterm=none
|
||||
hi DiffDelete guibg=#3F000A gui=none ctermbg=0 ctermfg=196 cterm=none
|
||||
hi TabLineFill guibg=#5E5E5E gui=none ctermbg=235 ctermfg=228 cterm=none
|
||||
hi TabLineSel guifg=#FFFFD7 gui=bold ctermfg=230 cterm=bold
|
||||
|
||||
|
||||
" Syntax highlighting
|
||||
hi Comment guifg=#EDB545 gui=none ctermfg=215 cterm=none
|
||||
hi Constant guifg=#D9FF02 gui=none ctermfg=190 cterm=none
|
||||
hi Number guifg=#D9FF02 gui=none ctermfg=190 cterm=none
|
||||
hi Identifier guifg=#FF5E2C gui=none ctermfg=202 cterm=none
|
||||
hi Statement guifg=#FF2700 gui=none ctermfg=196 cterm=none
|
||||
hi Function guifg=#FF9732 gui=none ctermfg=209 cterm=none
|
||||
hi Special guifg=#EE1800 gui=none ctermfg=196 cterm=none
|
||||
hi PreProc guifg=#EE1800 gui=none ctermfg=196 cterm=none
|
||||
hi Keyword guifg=#FF2700 gui=none ctermfg=196 cterm=none
|
||||
hi String guifg=#E6B4B3 gui=none ctermfg=181 cterm=none
|
||||
hi Type guifg=#FF2A6C gui=none ctermfg=197 cterm=none
|
||||
hi pythonBuiltin guifg=#FF5E2C gui=none ctermfg=202 cterm=none
|
||||
hi TabLineFill guifg=#644847 gui=none ctermfg=239 cterm=none
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
" Vim color file
|
||||
" Converted from Textmate theme krTheme using Coloration v0.2.4 (http://github.com/sickill/coloration)
|
||||
|
||||
set background=dark
|
||||
highlight clear
|
||||
|
||||
if exists("syntax_on")
|
||||
syntax reset
|
||||
endif
|
||||
|
||||
let g:colors_name = "krTheme"
|
||||
|
||||
hi Cursor guifg=NONE guibg=#ff9900 gui=NONE
|
||||
hi Visual guifg=NONE guibg=#530678 gui=NONE
|
||||
hi CursorLine guifg=NONE guibg=#38403d gui=NONE
|
||||
hi CursorColumn guifg=NONE guibg=#38403d gui=NONE
|
||||
hi LineNr guifg=#848575 guibg=#0b0a09 gui=NONE
|
||||
hi VertSplit guifg=#393932 guibg=#393932 gui=NONE
|
||||
hi MatchParen guifg=#949c8b guibg=NONE gui=NONE
|
||||
hi StatusLine guifg=#fcffe0 guibg=#393932 gui=bold
|
||||
hi StatusLineNC guifg=#fcffe0 guibg=#393932 gui=NONE
|
||||
hi Pmenu guifg=#796903 guibg=NONE gui=NONE
|
||||
hi PmenuSel guifg=NONE guibg=#530678 gui=NONE
|
||||
hi IncSearch guifg=NONE guibg=#4c3e38 gui=NONE
|
||||
hi Search guifg=NONE guibg=#4c3e38 gui=NONE
|
||||
hi Directory guifg=#a25b14 guibg=NONE gui=NONE
|
||||
hi Folded guifg=#706d5b guibg=#0b0a09 gui=NONE
|
||||
|
||||
hi Normal guifg=#fcffe0 guibg=#0b0a09 gui=NONE
|
||||
hi Boolean guifg=#a25b14 guibg=NONE gui=NONE
|
||||
hi Character guifg=#a25b14 guibg=NONE gui=NONE
|
||||
hi Comment guifg=#706d5b guibg=NONE gui=italic
|
||||
hi Conditional guifg=#949c8b guibg=NONE gui=NONE
|
||||
hi Constant guifg=#a25b14 guibg=NONE gui=NONE
|
||||
hi Define guifg=#949c8b guibg=NONE gui=NONE
|
||||
hi ErrorMsg guifg=#f8f8f8 guibg=#a41300 gui=NONE
|
||||
hi WarningMsg guifg=#f8f8f8 guibg=#a41300 gui=NONE
|
||||
hi Float guifg=#a25b14 guibg=NONE gui=NONE
|
||||
hi Function guifg=#796903 guibg=NONE gui=NONE
|
||||
hi Identifier guifg=#ffee80 guibg=NONE gui=NONE
|
||||
hi Keyword guifg=#949c8b guibg=NONE gui=NONE
|
||||
hi Label guifg=#8f7673 guibg=NONE gui=NONE
|
||||
hi NonText guifg=#593f2a guibg=#38403d gui=NONE
|
||||
hi Number guifg=#a25b14 guibg=NONE gui=NONE
|
||||
hi Operator guifg=#949c8b guibg=NONE gui=NONE
|
||||
hi PreProc guifg=#949c8b guibg=NONE gui=NONE
|
||||
hi Special guifg=#fcffe0 guibg=NONE gui=NONE
|
||||
hi SpecialKey guifg=#593f2a guibg=#38403d gui=NONE
|
||||
hi Statement guifg=#949c8b guibg=NONE gui=NONE
|
||||
hi StorageClass guifg=#ffee80 guibg=NONE gui=NONE
|
||||
hi String guifg=#8f7673 guibg=NONE gui=NONE
|
||||
hi Tag guifg=#796903 guibg=NONE gui=NONE
|
||||
hi Title guifg=#fcffe0 guibg=NONE gui=bold
|
||||
hi Todo guifg=#706d5b guibg=NONE gui=inverse,bold,italic
|
||||
hi Type guifg=#796903 guibg=NONE gui=NONE
|
||||
hi Underlined guifg=NONE guibg=NONE gui=underline
|
||||
hi rubyClass guifg=#949c8b guibg=NONE gui=NONE
|
||||
hi rubyFunction guifg=#796903 guibg=NONE gui=NONE
|
||||
hi rubyInterpolationDelimiter guifg=NONE guibg=NONE gui=NONE
|
||||
hi rubySymbol guifg=#a25b14 guibg=NONE gui=NONE
|
||||
hi rubyConstant guifg=#9fc28a guibg=NONE gui=NONE
|
||||
hi rubyStringDelimiter guifg=#8f7673 guibg=NONE gui=NONE
|
||||
hi rubyBlockParameter guifg=#d1a796 guibg=NONE gui=NONE
|
||||
hi rubyInstanceVariable guifg=#ff80e1 guibg=NONE gui=NONE
|
||||
hi rubyInclude guifg=#949c8b guibg=NONE gui=NONE
|
||||
hi rubyGlobalVariable guifg=#d1a796 guibg=NONE gui=NONE
|
||||
hi rubyRegexp guifg=#55a980 guibg=NONE gui=NONE
|
||||
hi rubyRegexpDelimiter guifg=#55a980 guibg=NONE gui=NONE
|
||||
hi rubyEscape guifg=#a25b14 guibg=NONE gui=NONE
|
||||
hi rubyControl guifg=#949c8b guibg=NONE gui=NONE
|
||||
hi rubyClassVariable guifg=#d1a796 guibg=NONE gui=NONE
|
||||
hi rubyOperator guifg=#949c8b guibg=NONE gui=NONE
|
||||
hi rubyException guifg=#949c8b guibg=NONE gui=NONE
|
||||
hi rubyPseudoVariable guifg=#ff80e1 guibg=NONE gui=NONE
|
||||
hi rubyRailsUserClass guifg=#9fc28a guibg=NONE gui=NONE
|
||||
hi rubyRailsARAssociationMethod guifg=#85873a guibg=NONE gui=NONE
|
||||
hi rubyRailsARMethod guifg=#85873a guibg=NONE gui=NONE
|
||||
hi rubyRailsRenderMethod guifg=#85873a guibg=NONE gui=NONE
|
||||
hi rubyRailsMethod guifg=#85873a guibg=NONE gui=NONE
|
||||
hi erubyDelimiter guifg=NONE guibg=NONE gui=NONE
|
||||
hi erubyComment guifg=#706d5b guibg=NONE gui=italic
|
||||
hi erubyRailsMethod guifg=#85873a guibg=NONE gui=NONE
|
||||
hi htmlTag guifg=#babd9c guibg=NONE gui=NONE
|
||||
hi htmlEndTag guifg=#babd9c guibg=NONE gui=NONE
|
||||
hi htmlTagName guifg=#babd9c guibg=NONE gui=NONE
|
||||
hi htmlArg guifg=#babd9c guibg=NONE gui=NONE
|
||||
hi htmlSpecialChar guifg=#a25b14 guibg=NONE gui=NONE
|
||||
hi javaScriptFunction guifg=#ffee80 guibg=NONE gui=NONE
|
||||
hi javaScriptRailsFunction guifg=#85873a guibg=NONE gui=NONE
|
||||
hi javaScriptBraces guifg=NONE guibg=NONE gui=NONE
|
||||
hi yamlKey guifg=#796903 guibg=NONE gui=NONE
|
||||
hi yamlAnchor guifg=#d1a796 guibg=NONE gui=NONE
|
||||
hi yamlAlias guifg=#d1a796 guibg=NONE gui=NONE
|
||||
hi yamlDocumentHeader guifg=#8f7673 guibg=NONE gui=NONE
|
||||
hi cssURL guifg=#d1a796 guibg=NONE gui=NONE
|
||||
hi cssFunctionName guifg=#85873a guibg=NONE gui=NONE
|
||||
hi cssColor guifg=#a25b14 guibg=NONE gui=NONE
|
||||
hi cssPseudoClassId guifg=#ba6912 guibg=NONE gui=NONE
|
||||
hi cssClassName guifg=#ba6912 guibg=NONE gui=NONE
|
||||
hi cssValueLength guifg=#a25b14 guibg=NONE gui=NONE
|
||||
hi cssCommonAttr guifg=#c27e66 guibg=NONE gui=NONE
|
||||
hi cssBraces guifg=NONE guibg=NONE gui=NONE
|
||||
@@ -0,0 +1,222 @@
|
||||
" Vim color file
|
||||
"
|
||||
" Author: Tomas Restrepo <tomas@winterdom.com>
|
||||
"
|
||||
" Note: Based on the monokai theme for textmate
|
||||
" by Wimer Hazenberg and its darker variant
|
||||
" by Hamish Stuart Macpherson
|
||||
"
|
||||
|
||||
hi clear
|
||||
|
||||
set background=dark
|
||||
if version > 580
|
||||
" no guarantees for version 5.8 and below, but this makes it stop
|
||||
" complaining
|
||||
hi clear
|
||||
if exists("syntax_on")
|
||||
syntax reset
|
||||
endif
|
||||
endif
|
||||
let g:colors_name="molokai"
|
||||
|
||||
if exists("g:molokai_original")
|
||||
let s:molokai_original = g:molokai_original
|
||||
else
|
||||
let s:molokai_original = 0
|
||||
endif
|
||||
|
||||
|
||||
hi Boolean guifg=#AE81FF
|
||||
hi Character guifg=#E6DB74
|
||||
hi Number guifg=#AE81FF
|
||||
hi String guifg=#E6DB74
|
||||
hi Conditional guifg=#F92672 gui=bold
|
||||
hi Constant guifg=#AE81FF gui=bold
|
||||
hi Cursor guifg=#000000 guibg=#F35FBC
|
||||
hi Debug guifg=#BCA3A3 gui=bold
|
||||
hi Define guifg=#66D9EF
|
||||
hi Delimiter guifg=#8F8F8F
|
||||
hi DiffAdd guibg=#0F1D0B
|
||||
hi DiffChange guifg=#89807D guibg=#322F2D
|
||||
hi DiffDelete guifg=#960050 guibg=#1E0010
|
||||
hi DiffText guibg=#4A4340 gui=italic,bold
|
||||
|
||||
hi Directory guifg=#A6E22E gui=bold
|
||||
hi Error guifg=#960050 guibg=#1E0010
|
||||
hi ErrorMsg guifg=#F92672 guibg=#232526 gui=bold
|
||||
hi Exception guifg=#A6E22E gui=bold
|
||||
hi Float guifg=#AE81FF
|
||||
hi Folded guifg=#465457 guibg=#000000
|
||||
hi Function guifg=#A6E22E
|
||||
hi Identifier guifg=#FD971F
|
||||
hi Ignore guifg=#808080 guibg=bg
|
||||
hi IncSearch guifg=#C4BE89 guibg=#000000
|
||||
|
||||
hi Keyword guifg=#F92672 gui=bold
|
||||
hi Label guifg=#E6DB74 gui=none
|
||||
hi Macro guifg=#C4BE89 gui=italic
|
||||
hi SpecialKey guifg=#66D9EF gui=italic
|
||||
|
||||
hi MatchParen guifg=#CD5907 guibg=#232728 gui=bold
|
||||
hi ModeMsg guifg=#E6DB74
|
||||
hi MoreMsg guifg=#E6DB74
|
||||
hi Operator guifg=#F92672
|
||||
|
||||
" complete menu
|
||||
hi Pmenu guifg=#66D9EF guibg=#000000
|
||||
hi PmenuSel guibg=#808080
|
||||
hi PmenuSbar guibg=#080808
|
||||
hi PmenuThumb guifg=#66D9EF
|
||||
|
||||
hi PreCondit guifg=#A6E22E gui=bold
|
||||
hi PreProc guifg=#A6E22E
|
||||
hi Question guifg=#66D9EF
|
||||
hi Repeat guifg=#F92672 gui=bold
|
||||
hi Search guifg=#FFFFFF guibg=#455354
|
||||
" marks column
|
||||
hi SignColumn guifg=#A6E22E guibg=#232526
|
||||
hi SpecialChar guifg=#F92672 gui=bold
|
||||
hi SpecialComment guifg=#465457 gui=bold
|
||||
hi Special guifg=#66D9EF guibg=bg gui=italic
|
||||
hi SpecialKey guifg=#888A85 gui=italic
|
||||
if has("spell")
|
||||
hi SpellBad guisp=#FF0000 gui=undercurl
|
||||
hi SpellCap guisp=#7070F0 gui=undercurl
|
||||
hi SpellLocal guisp=#70F0F0 gui=undercurl
|
||||
hi SpellRare guisp=#FFFFFF gui=undercurl
|
||||
endif
|
||||
hi Statement guifg=#F92672 gui=bold
|
||||
hi StatusLine guifg=#CD5907 guibg=fg
|
||||
hi StatusLineNC guifg=#808080 guibg=#080808
|
||||
hi StorageClass guifg=#FD971F gui=italic
|
||||
hi Structure guifg=#66D9EF
|
||||
hi Tag guifg=#F92672 gui=italic
|
||||
hi Title guifg=#ef5939
|
||||
hi Todo guifg=#FFFFFF guibg=bg gui=bold
|
||||
|
||||
hi Typedef guifg=#66D9EF
|
||||
hi Type guifg=#66D9EF gui=none
|
||||
hi Underlined guifg=#808080 gui=underline
|
||||
|
||||
hi VertSplit guifg=#808080 guibg=#080808 gui=bold
|
||||
hi VisualNOS guibg=#403D3D
|
||||
hi Visual guibg=#403D3D
|
||||
hi WarningMsg guifg=#FFFFFF guibg=#333333 gui=bold
|
||||
hi WildMenu guifg=#66D9EF guibg=#000000
|
||||
|
||||
hi MyTagListFileName guifg=#F92672 guibg=#1B1D1E gui=bold
|
||||
|
||||
|
||||
|
||||
if s:molokai_original == 1
|
||||
hi Normal guifg=#F8F8F2 guibg=#272822
|
||||
hi Comment guifg=#75715E
|
||||
hi CursorLine guibg=#3E3D32
|
||||
hi CursorColumn guibg=#3E3D32
|
||||
hi ColorColumn guibg=#3E3D32
|
||||
hi LineNr guifg=#AAAAAA guibg=#3B3A32
|
||||
hi FoldColumn guifg=#AAAAAA guibg=#3B3A32
|
||||
hi NonText guifg=#BCBCBC guibg=#3B3A32
|
||||
else
|
||||
hi Normal guifg=#F8F8F2 guibg=#1B1D1E
|
||||
hi Folded guifg=#666666 guibg=#1B1D1E
|
||||
hi Comment guifg=#5c7176
|
||||
hi CursorLine guibg=#232728
|
||||
hi CursorColumn guibg=#232728
|
||||
hi ColorColumn guibg=#232728
|
||||
hi LineNr guifg=#AAAAAA guibg=#1B1D1E
|
||||
hi FoldColumn guifg=#AAAAAA guibg=#1B1D1E
|
||||
|
||||
" Invisible character colors
|
||||
highlight NonText guifg=#444444 guibg=#1a1c1d
|
||||
highlight SpecialKey guifg=#444444 guibg=#1a1c1d
|
||||
end
|
||||
|
||||
"
|
||||
" Support for 256-color terminal
|
||||
"
|
||||
if &t_Co > 255
|
||||
hi Boolean ctermfg=135
|
||||
hi Character ctermfg=144
|
||||
hi Number ctermfg=135
|
||||
hi String ctermfg=144
|
||||
hi Conditional ctermfg=161 cterm=bold
|
||||
hi Constant ctermfg=135 cterm=bold
|
||||
hi Cursor ctermfg=16 ctermbg=253
|
||||
hi Debug ctermfg=225 cterm=bold
|
||||
hi Define ctermfg=81
|
||||
hi Delimiter ctermfg=241
|
||||
|
||||
hi DiffAdd ctermbg=24
|
||||
hi DiffChange ctermfg=181 ctermbg=239
|
||||
hi DiffDelete ctermfg=162 ctermbg=53
|
||||
hi DiffText ctermbg=102 cterm=bold
|
||||
|
||||
hi Directory ctermfg=118 cterm=bold
|
||||
hi Error ctermfg=219 ctermbg=89
|
||||
hi ErrorMsg ctermfg=199 ctermbg=16 cterm=bold
|
||||
hi Exception ctermfg=118 cterm=bold
|
||||
hi Float ctermfg=135
|
||||
hi FoldColumn ctermfg=67 ctermbg=16
|
||||
hi Folded ctermfg=67 ctermbg=16
|
||||
hi Function ctermfg=118
|
||||
hi Identifier ctermfg=208
|
||||
hi Ignore ctermfg=244 ctermbg=232
|
||||
hi IncSearch ctermfg=193 ctermbg=16
|
||||
|
||||
hi Keyword ctermfg=161 cterm=bold
|
||||
hi Label ctermfg=229 cterm=none
|
||||
hi Macro ctermfg=193
|
||||
hi SpecialKey ctermfg=81
|
||||
|
||||
hi MatchParen ctermfg=16 ctermbg=208 cterm=bold
|
||||
hi ModeMsg ctermfg=229
|
||||
hi MoreMsg ctermfg=229
|
||||
hi Operator ctermfg=161
|
||||
|
||||
" complete menu
|
||||
hi Pmenu ctermfg=81 ctermbg=16
|
||||
hi PmenuSel ctermbg=244
|
||||
hi PmenuSbar ctermbg=232
|
||||
hi PmenuThumb ctermfg=81
|
||||
|
||||
hi PreCondit ctermfg=118 cterm=bold
|
||||
hi PreProc ctermfg=118
|
||||
hi Question ctermfg=81
|
||||
hi Repeat ctermfg=161 cterm=bold
|
||||
hi Search ctermfg=253 ctermbg=66
|
||||
|
||||
" marks column
|
||||
hi SignColumn ctermfg=118 ctermbg=235
|
||||
hi SpecialChar ctermfg=161 cterm=bold
|
||||
hi SpecialComment ctermfg=245 cterm=bold
|
||||
hi Special ctermfg=81 ctermbg=232
|
||||
hi SpecialKey ctermfg=245
|
||||
|
||||
hi Statement ctermfg=161 cterm=bold
|
||||
hi StatusLine ctermfg=238 ctermbg=253
|
||||
hi StatusLineNC ctermfg=244 ctermbg=232
|
||||
hi StorageClass ctermfg=208
|
||||
hi Structure ctermfg=81
|
||||
hi Tag ctermfg=161
|
||||
hi Title ctermfg=166
|
||||
hi Todo ctermfg=231 ctermbg=232 cterm=bold
|
||||
|
||||
hi Typedef ctermfg=81
|
||||
hi Type ctermfg=81 cterm=none
|
||||
hi Underlined ctermfg=244 cterm=underline
|
||||
|
||||
hi VertSplit ctermfg=244 ctermbg=232 cterm=bold
|
||||
hi VisualNOS ctermbg=238
|
||||
hi Visual ctermbg=235
|
||||
hi WarningMsg ctermfg=231 ctermbg=238 cterm=bold
|
||||
hi WildMenu ctermfg=81 ctermbg=16
|
||||
|
||||
hi Normal ctermfg=252 ctermbg=233
|
||||
hi Comment ctermfg=59
|
||||
hi CursorLine ctermbg=234 cterm=none
|
||||
hi CursorColumn ctermbg=234
|
||||
hi LineNr ctermfg=250 ctermbg=234
|
||||
hi NonText ctermfg=250 ctermbg=234
|
||||
end
|
||||
@@ -0,0 +1,124 @@
|
||||
" Vim color scheme
|
||||
"
|
||||
" Name: railscast.vim
|
||||
" Maintainer: Josh O'Rourke <jorourke23@gmail.com>
|
||||
" License: public domain
|
||||
"
|
||||
" A GUI Only port of the RailsCasts TextMate theme [1] to Vim.
|
||||
" Some parts of this theme were borrowed from the well-documented Lucius theme [2].
|
||||
"
|
||||
" [1] http://railscasts.com/about
|
||||
" [2] http://www.vim.org/scripts/script.php?script_id=2536
|
||||
|
||||
set background=dark
|
||||
hi clear
|
||||
if exists("syntax_on")
|
||||
syntax reset
|
||||
endif
|
||||
let g:colors_name = "railscasts"
|
||||
|
||||
" Colors
|
||||
" Brown #BC9458
|
||||
" Dark Blue #6D9CBE
|
||||
" Dark Green #519F50
|
||||
" Dark Orange #CC7833
|
||||
" Light Blue #D0D0FF
|
||||
" Light Green #A5C261
|
||||
" Tan #FFC66D
|
||||
|
||||
hi Normal guifg=#E6E1DC guibg=#2B2B2B
|
||||
hi Cursor guibg=#FFFFFF
|
||||
hi CursorLine guibg=#333435
|
||||
hi LineNr guifg=#888888 guibg=#DEDEDE
|
||||
hi Search guibg=#5A647E
|
||||
hi Visual guibg=#5A647E
|
||||
|
||||
" Folds
|
||||
" -----
|
||||
" line used for closed folds
|
||||
hi Folded guifg=#F6F3E8 guibg=#444444 gui=NONE
|
||||
|
||||
" Misc
|
||||
" ----
|
||||
" directory names and other special names in listings
|
||||
hi Directory guifg=#A5C261 gui=NONE
|
||||
|
||||
" Popup Menu
|
||||
" ----------
|
||||
" normal item in popup
|
||||
hi Pmenu guifg=#F6F3E8 guibg=#444444 gui=NONE
|
||||
" selected item in popup
|
||||
hi PmenuSel guifg=#000000 guibg=#A5C261 gui=NONE
|
||||
" scrollbar in popup
|
||||
hi PMenuSbar guibg=#5A647E gui=NONE
|
||||
" thumb of the scrollbar in the popup
|
||||
hi PMenuThumb guibg=#AAAAAA gui=NONE
|
||||
|
||||
|
||||
"rubyComment
|
||||
hi Comment guifg=#BC9458 gui=italic
|
||||
hi Todo guifg=#BC9458 guibg=NONE gui=italic
|
||||
|
||||
"rubyPseudoVariable
|
||||
"nil, self, symbols, etc
|
||||
hi Constant guifg=#6D9CBE
|
||||
|
||||
"rubyClass, rubyModule, rubyDefine
|
||||
"def, end, include, etc
|
||||
hi Define guifg=#CC7833
|
||||
|
||||
"rubyInterpolation
|
||||
hi Delimiter guifg=#519F50
|
||||
|
||||
"rubyError, rubyInvalidVariable
|
||||
hi Error guifg=#FFFFFF guibg=#990000
|
||||
|
||||
"rubyFunction
|
||||
hi Function guifg=#FFC66D gui=NONE
|
||||
|
||||
"rubyIdentifier
|
||||
"@var, @@var, $var, etc
|
||||
hi Identifier guifg=#D0D0FF gui=NONE
|
||||
|
||||
"rubyInclude
|
||||
"include, autoload, extend, load, require
|
||||
hi Include guifg=#CC7833 gui=NONE
|
||||
|
||||
"rubyKeyword, rubyKeywordAsMethod
|
||||
"alias, undef, super, yield, callcc, caller, lambda, proc
|
||||
hi Keyword guifg=#CC7833
|
||||
|
||||
" same as define
|
||||
hi Macro guifg=#CC7833 gui=NONE
|
||||
|
||||
"rubyInteger
|
||||
hi Number guifg=#A5C261
|
||||
|
||||
" #if, #else, #endif
|
||||
hi PreCondit guifg=#CC7833 gui=NONE
|
||||
|
||||
" generic preprocessor
|
||||
hi PreProc guifg=#CC7833 gui=NONE
|
||||
|
||||
"rubyControl, rubyAccess, rubyEval
|
||||
"case, begin, do, for, if unless, while, until else, etc.
|
||||
hi Statement guifg=#CC7833 gui=NONE
|
||||
|
||||
"rubyString
|
||||
hi String guifg=#A5C261
|
||||
|
||||
hi Title guifg=#FFFFFF
|
||||
|
||||
"rubyConstant
|
||||
hi Type guifg=#DA4939 gui=NONE
|
||||
|
||||
hi DiffAdd guifg=#E6E1DC guibg=#144212
|
||||
hi DiffDelete guifg=#E6E1DC guibg=#660000
|
||||
|
||||
hi link htmlTag xmlTag
|
||||
hi link htmlTagName xmlTagName
|
||||
hi link htmlEndTag xmlEndTag
|
||||
|
||||
hi xmlTag guifg=#E8BF6A
|
||||
hi xmlTagName guifg=#E8BF6A
|
||||
hi xmlEndTag guifg=#E8BF6A
|
||||
@@ -0,0 +1,70 @@
|
||||
" Vim color scheme
|
||||
"
|
||||
" Name: vibrantink.vim
|
||||
" Maintainer: Jo Vermeulen <jo.vermeulen@gmail.com>
|
||||
" Last Change: 30 Jul 2007
|
||||
" License: public domain
|
||||
" Version: 1.2
|
||||
"
|
||||
" This scheme should work in the GUI and in xterm's 256 color mode. It won't
|
||||
" work in 8/16 color terminals.
|
||||
"
|
||||
" I based it on John Lam's initial VibrantInk port to Vim [1]. Thanks to a
|
||||
" great tutorial [2], I was able to convert it to xterm 256 color mode. And
|
||||
" of course, credits go to Justin Palmer for creating the original VibrantInk
|
||||
" TextMate color scheme [3].
|
||||
"
|
||||
" [1] http://www.iunknown.com/articles/2006/09/04/vim-can-save-your-hands-too
|
||||
" [2] http://frexx.de/xterm-256-notes/
|
||||
" [3] http://encytemedia.com/blog/articles/2006/01/03/textmate-vibrant-ink-theme-and-prototype-bundle
|
||||
|
||||
set background=dark
|
||||
hi clear
|
||||
if exists("syntax_on")
|
||||
syntax reset
|
||||
endif
|
||||
|
||||
let g:colors_name = "vibrantink"
|
||||
|
||||
if has("gui_running")
|
||||
highlight Normal guifg=White guibg=Black
|
||||
highlight Cursor guifg=Black guibg=Yellow
|
||||
highlight Keyword guifg=#FF6600
|
||||
highlight Define guifg=#FF6600
|
||||
highlight Comment guifg=#9933CC
|
||||
highlight Type guifg=#FFEE98 gui=NONE
|
||||
highlight rubySymbol guifg=#339999 gui=NONE
|
||||
highlight Identifier guifg=#FFEE98 gui=NONE
|
||||
highlight rubyStringDelimiter guifg=#66FF00
|
||||
highlight rubyInterpolation guifg=White
|
||||
highlight rubyPseudoVariable guifg=#339999
|
||||
highlight Constant guifg=#FFEE98
|
||||
highlight Function guifg=#FFCC00 gui=NONE
|
||||
highlight Include guifg=#FFCC00 gui=NONE
|
||||
highlight Statement guifg=#FF6600 gui=NONE
|
||||
highlight String guifg=#66FF00
|
||||
highlight Search guibg=White
|
||||
highlight CursorLine guibg=#323300
|
||||
highlight Pmenu guifg=White ctermfg=White guibg=#666666 cterm=bold
|
||||
highlight PmenuSel guifg=White ctermfg=White guibg=#a41414 gui=bold cterm=bold
|
||||
else
|
||||
set t_Co=256
|
||||
highlight Normal ctermfg=White ctermbg=Black
|
||||
highlight Cursor ctermfg=Black ctermbg=Yellow
|
||||
highlight Keyword ctermfg=202
|
||||
highlight Define ctermfg=202
|
||||
highlight Comment ctermfg=98
|
||||
highlight Type ctermfg=White
|
||||
highlight rubySymbol ctermfg=66
|
||||
highlight Identifier ctermfg=White
|
||||
highlight rubyStringDelimiter ctermfg=82
|
||||
highlight rubyInterpolation ctermfg=White
|
||||
highlight rubyPseudoVariable ctermfg=66
|
||||
highlight Constant ctermfg=228
|
||||
highlight Function ctermfg=220
|
||||
highlight Include ctermfg=220
|
||||
highlight Statement ctermfg=202
|
||||
highlight String ctermfg=82
|
||||
highlight Search ctermbg=White
|
||||
highlight CursorLine cterm=NONE ctermbg=235
|
||||
endif
|
||||
@@ -0,0 +1,88 @@
|
||||
*rainbow_parenthsis.txt* Colorize Parenthsis
|
||||
|
||||
Author: Martin Krischik (krischik@users.sourceforge.net)
|
||||
John Gilmore
|
||||
Luc Hermitte (hermitte@free.fr)
|
||||
|
||||
For Vim version 7.0 and above
|
||||
Last change: 09 Oct, 2007
|
||||
|
||||
1. Overview |rainbow_parenthsis-about|
|
||||
2. Commands |rainbow_parenthsis-commands|
|
||||
2. Functions |rainbow_parenthsis-functions|
|
||||
3. Configuration |rainbow_parenthsis-configure|
|
||||
|
||||
==============================================================================
|
||||
*rainbow_parenthsis-about*
|
||||
1. Overview~
|
||||
|
||||
rainbow_parenthsis allows you to view the contents of a file in real time. When a
|
||||
change in the file is detected, the window displaying the file is updated and
|
||||
repositioned to the last line.
|
||||
|
||||
The update is not exactly real time, but usually updates within a few seconds
|
||||
of the file change. The update interval of the output is determined by the
|
||||
|updatetime| parameter, along with continued usage of Vim. This means that if
|
||||
you are not doing any editing or motion commands, the preview window will not
|
||||
be updated. See |CursorHold| for more information.
|
||||
|
||||
Because this window becomes the preview window, it will accept all related
|
||||
commands. For more information, see |preview-window|.
|
||||
|
||||
==============================================================================
|
||||
*rainbow_parenthsis-commands*
|
||||
2. Commands~
|
||||
|
||||
The rainbow_parenthsis plugin does not create any automatic mappings, but provides the
|
||||
following commands:
|
||||
|
||||
*:ToggleRaibowParenthesis*
|
||||
|:ToggleRaibowParenthesis|
|
||||
Manualy start rainbow parenthesis.. If no bracket type has been loaded
|
||||
yet then round brackets will be loaded by default.
|
||||
|
||||
==============================================================================
|
||||
*rainbow_parenthsis-functions*
|
||||
2. Functions~
|
||||
|
||||
|rainbow_parenthsis#Activate()| *rainbow_parenthsis#Activate()*
|
||||
Acticate the loaded parenthsis
|
||||
|
||||
|rainbow_parenthsis#Clear()| *rainbow_parenthsis#Clear()*
|
||||
Deactivate rainbow parenthesis
|
||||
|
||||
|rainbow_parenthsis#Toggle()| *rainbow_parenthsis#Toggle()*
|
||||
Toogles rainbow parenthesis status. If no bracket type has been loaded
|
||||
yet then round brackets will be loaded.
|
||||
|
||||
|rainbow_parenthsis#LoadRound()| *rainbow_parenthsis#LoadRound()*
|
||||
Load syntax for parenthesis or round brackets '(' ')' - This will be
|
||||
loaded by default if nothing else has been loaded.
|
||||
|
||||
|rainbow_parenthsis#LoadSquare()| *rainbow_parenthsis#LoadSquare()*
|
||||
Load syntax for box brackets or square brackets '[' ']'
|
||||
|
||||
|rainbow_parenthsis#LoadBraces()| *rainbow_parenthsis#LoadBraces()*
|
||||
Load syntax for curly brackets or braces '{' '}'
|
||||
|
||||
|rainbow_parenthsis#LoadChevrons()| *rainbow_parenthsis#LoadChevrons()*
|
||||
Load syntax for angle brackets or chevrons '<' '>'
|
||||
|
||||
==============================================================================
|
||||
*rainbow_parenthsis-configure*
|
||||
3. Configuration~
|
||||
|
||||
The best way to use rainbow_parenthsis is to add it to sytax plugin of any
|
||||
filetype used:
|
||||
>
|
||||
>if exists("g:btm_rainbow_color") && g:btm_rainbow_color
|
||||
> call rainbow_parenthsis#LoadSquare ()
|
||||
> call rainbow_parenthsis#LoadRound ()
|
||||
> call rainbow_parenthsis#Activate ()
|
||||
>endif
|
||||
>
|
||||
This way you don't need to load all options available but only those which
|
||||
are of importance to the actual filetype.
|
||||
|
||||
==============================================================================
|
||||
vim:textwidth=78:tabstop=8:noexpandtab:filetype=help
|
||||
@@ -0,0 +1,58 @@
|
||||
" This is a simple script. It extends the syntax highlighting to
|
||||
" highlight each matching set of parens in different colors, to make
|
||||
" it visually obvious what matches which.
|
||||
|
||||
" Obviously, most useful when working with lisp. But it's also nice othe
|
||||
" times.
|
||||
|
||||
" I don't intend to maintain this script. I hacked it together for my
|
||||
" own purposes, and it is sufficient to the day. If you want to improve it,
|
||||
" knock yourself out.
|
||||
|
||||
" This file is public domain.
|
||||
|
||||
|
||||
" define colors. Note that the one numbered '16' is the outermost pair,
|
||||
" keep that in mind if you want to change the colors.
|
||||
" Also, if this script doesn't work on your terminal, you may need to add
|
||||
" guifg=xx or ever termfg=, though what good this script will do on a
|
||||
" black and white terminal I don't know.
|
||||
hi level1c ctermfg=brown
|
||||
hi level2c ctermfg=Darkblue
|
||||
hi level3c ctermfg=darkgray
|
||||
hi level4c ctermfg=darkgreen
|
||||
hi level5c ctermfg=darkcyan
|
||||
hi level6c ctermfg=darkred
|
||||
hi level7c ctermfg=darkmagenta
|
||||
hi level8c ctermfg=brown
|
||||
hi level9c ctermfg=gray
|
||||
hi level10c ctermfg=black
|
||||
hi level11c ctermfg=darkmagenta
|
||||
hi level12c ctermfg=Darkblue
|
||||
hi level13c ctermfg=darkgreen
|
||||
hi level14c ctermfg=darkcyan
|
||||
hi level15c ctermfg=darkred
|
||||
hi level16c ctermfg=red
|
||||
|
||||
|
||||
|
||||
" These are the regions for each pair.
|
||||
" This could be improved, perhaps, by makeing them match [ and { also,
|
||||
" but I'm not going to take the time to figure out haw to make the
|
||||
" end pattern match only the proper type.
|
||||
syn region level1 matchgroup=level1c start=/(/ end=/)/ contains=TOP,level1,level2,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syn region level2 matchgroup=level2c start=/(/ end=/)/ contains=TOP,level2,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syn region level3 matchgroup=level3c start=/(/ end=/)/ contains=TOP,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syn region level4 matchgroup=level4c start=/(/ end=/)/ contains=TOP,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syn region level5 matchgroup=level5c start=/(/ end=/)/ contains=TOP,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syn region level6 matchgroup=level6c start=/(/ end=/)/ contains=TOP,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syn region level7 matchgroup=level7c start=/(/ end=/)/ contains=TOP,level7,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syn region level8 matchgroup=level8c start=/(/ end=/)/ contains=TOP,level8,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syn region level9 matchgroup=level9c start=/(/ end=/)/ contains=TOP,level9,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syn region level10 matchgroup=level10c start=/(/ end=/)/ contains=TOP,level10,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syn region level11 matchgroup=level11c start=/(/ end=/)/ contains=TOP,level11,level12,level13,level14,level15, level16,NoInParens
|
||||
syn region level12 matchgroup=level12c start=/(/ end=/)/ contains=TOP,level12,level13,level14,level15, level16,NoInParens
|
||||
syn region level13 matchgroup=level13c start=/(/ end=/)/ contains=TOP,level13,level14,level15, level16,NoInParens
|
||||
syn region level14 matchgroup=level14c start=/(/ end=/)/ contains=TOP,level14,level15, level16,NoInParens
|
||||
syn region level15 matchgroup=level15c start=/(/ end=/)/ contains=TOP,level15, level16,NoInParens
|
||||
syn region level16 matchgroup=level16c start=/(/ end=/)/ contains=TOP,level16,NoInParens
|
||||
@@ -0,0 +1,760 @@
|
||||
"=============================================================================
|
||||
" File: gist.vim
|
||||
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||
" Last Change: 04-Nov-2010.
|
||||
" Version: 4.4
|
||||
" WebPage: http://github.com/mattn/gist-vim
|
||||
" License: BSD
|
||||
" Usage:
|
||||
"
|
||||
" :Gist
|
||||
" post whole text to gist.
|
||||
"
|
||||
" :'<,'>Gist
|
||||
" post selected text to gist.
|
||||
"
|
||||
" :Gist -p
|
||||
" post whole text to gist with private.
|
||||
" if you got empty gist list, try :Gist --abandon
|
||||
"
|
||||
" :Gist -a
|
||||
" post whole text to gist with anonymous.
|
||||
"
|
||||
" :Gist -m
|
||||
" post multi buffer to gist.
|
||||
"
|
||||
" :Gist -e
|
||||
" edit the gist. (shoud be work on gist buffer)
|
||||
" you can update the gist with :w command on gist buffer.
|
||||
"
|
||||
" :Gist -d
|
||||
" delete the gist. (should be work on gist buffer)
|
||||
" password authentication is needed.
|
||||
"
|
||||
" :Gist -f
|
||||
" fork the gist. (should be work on gist buffer)
|
||||
" password authentication is needed.
|
||||
"
|
||||
" :Gist -e foo.js
|
||||
" edit the gist with name 'foo.js'. (shoud be work on gist buffer)
|
||||
"
|
||||
" :Gist XXXXX
|
||||
" edit gist XXXXX.
|
||||
"
|
||||
" :Gist -c XXXXX.
|
||||
" get gist XXXXX and put to clipboard.
|
||||
"
|
||||
" :Gist -l
|
||||
" list gists from mine.
|
||||
"
|
||||
" :Gist -l mattn
|
||||
" list gists from mattn.
|
||||
"
|
||||
" :Gist -la
|
||||
" list gists from all.
|
||||
"
|
||||
" Tips:
|
||||
" * if set g:gist_clip_command, gist.vim will copy the gist code
|
||||
" with option '-c'.
|
||||
"
|
||||
" # mac
|
||||
" let g:gist_clip_command = 'pbcopy'
|
||||
"
|
||||
" # linux
|
||||
" let g:gist_clip_command = 'xclip -selection clipboard'
|
||||
"
|
||||
" # others(cygwin?)
|
||||
" let g:gist_clip_command = 'putclip'
|
||||
"
|
||||
" * if you want to detect filetype from gist's filename...
|
||||
"
|
||||
" # detect filetype if vim failed auto-detection.
|
||||
" let g:gist_detect_filetype = 1
|
||||
"
|
||||
" # detect filetype always.
|
||||
" let g:gist_detect_filetype = 2
|
||||
"
|
||||
" * if you want to open browser after the post...
|
||||
"
|
||||
" let g:gist_open_browser_after_post = 1
|
||||
"
|
||||
" * if you want to change the browser...
|
||||
"
|
||||
" let g:gist_browser_command = 'w3m %URL%'
|
||||
"
|
||||
" or
|
||||
"
|
||||
" let g:gist_browser_command = 'opera %URL% &'
|
||||
"
|
||||
" on windows, should work with your setting.
|
||||
"
|
||||
" Thanks:
|
||||
" MATSUU Takuto:
|
||||
" removed carriage return
|
||||
" gist_browser_command enhancement
|
||||
" edit support
|
||||
"
|
||||
" GetLatestVimScripts: 2423 1 :AutoInstall: gist.vim
|
||||
" script type: plugin
|
||||
|
||||
if &cp || (exists('g:loaded_gist_vim') && g:loaded_gist_vim)
|
||||
finish
|
||||
endif
|
||||
let g:loaded_gist_vim = 1
|
||||
|
||||
if (!exists('g:github_user') || !exists('g:github_token')) && !executable('git')
|
||||
echoerr "Gist: require 'git' command"
|
||||
finish
|
||||
endif
|
||||
|
||||
if !executable('curl')
|
||||
echoerr "Gist: require 'curl' command"
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists('g:gist_open_browser_after_post')
|
||||
let g:gist_open_browser_after_post = 0
|
||||
endif
|
||||
|
||||
if !exists('g:gist_put_url_to_clipboard_after_post')
|
||||
let g:gist_put_url_to_clipboard_after_post = 1
|
||||
endif
|
||||
|
||||
if !exists('g:gist_browser_command')
|
||||
if has('win32')
|
||||
let g:gist_browser_command = "!start rundll32 url.dll,FileProtocolHandler %URL%"
|
||||
elseif has('mac')
|
||||
let g:gist_browser_command = "open %URL%"
|
||||
elseif executable('xdg-open')
|
||||
let g:gist_browser_command = "xdg-open %URL%"
|
||||
else
|
||||
let g:gist_browser_command = "firefox %URL% &"
|
||||
endif
|
||||
endif
|
||||
|
||||
if !exists('g:gist_detect_filetype')
|
||||
let g:gist_detect_filetype = 0
|
||||
endif
|
||||
|
||||
if !exists('g:gist_show_privates')
|
||||
let g:gist_show_privates = 0
|
||||
endif
|
||||
|
||||
function! s:nr2hex(nr)
|
||||
let n = a:nr
|
||||
let r = ""
|
||||
while n
|
||||
let r = '0123456789ABCDEF'[n % 16] . r
|
||||
let n = n / 16
|
||||
endwhile
|
||||
return r
|
||||
endfunction
|
||||
|
||||
function! s:encodeURIComponent(instr)
|
||||
let instr = iconv(a:instr, &enc, "utf-8")
|
||||
let len = strlen(instr)
|
||||
let i = 0
|
||||
let outstr = ''
|
||||
while i < len
|
||||
let ch = instr[i]
|
||||
if ch =~# '[0-9A-Za-z-._~!''()*]'
|
||||
let outstr = outstr . ch
|
||||
elseif ch == ' '
|
||||
let outstr = outstr . '+'
|
||||
else
|
||||
let outstr = outstr . '%' . substitute('0' . s:nr2hex(char2nr(ch)), '^.*\(..\)$', '\1', '')
|
||||
endif
|
||||
let i = i + 1
|
||||
endwhile
|
||||
return outstr
|
||||
endfunction
|
||||
|
||||
function! s:GistList(user, token, gistls, page)
|
||||
if a:gistls == '-all'
|
||||
let url = 'https://gist.github.com/gists'
|
||||
elseif g:gist_show_privates && a:gistls == a:user
|
||||
let url = 'https://gist.github.com/mine'
|
||||
else
|
||||
let url = 'https://gist.github.com/'.a:gistls
|
||||
endif
|
||||
let winnum = bufwinnr(bufnr('gist:'.a:gistls))
|
||||
if winnum != -1
|
||||
if winnum != bufwinnr('%')
|
||||
exe "normal \<c-w>".winnum."w"
|
||||
endif
|
||||
setlocal modifiable
|
||||
else
|
||||
exec 'silent split gist:'.a:gistls
|
||||
endif
|
||||
if a:page > 1
|
||||
let oldlines = getline(0, line('$'))
|
||||
let url = url . '?page=' . a:page
|
||||
endif
|
||||
|
||||
setlocal foldmethod=manual
|
||||
let oldlines = []
|
||||
if g:gist_show_privates
|
||||
echon 'Login to gist... '
|
||||
silent %d _
|
||||
let res = s:GistGetPage(url, a:user, '', '-L')
|
||||
silent put =res.content
|
||||
else
|
||||
silent %d _
|
||||
exec 'silent r! curl -s '.url
|
||||
endif
|
||||
|
||||
silent normal! ggdd
|
||||
silent! %s/>/>\r/g
|
||||
silent! %s/</\r</g
|
||||
silent! %g/<pre/,/<\/pre/join!
|
||||
silent! %g/<span class="date"/,/<\/span/join
|
||||
silent! %g/^<span class="date"/s/> */>/g
|
||||
silent! %v/^\(gist:\|<pre>\|<span class="date">\)/d _
|
||||
silent! %s/<div[^>]*>/\r /g
|
||||
silent! %s/<\/pre>/\r/g
|
||||
silent! %g/^gist:/,/<span class="date"/join
|
||||
silent! %s/<[^>]\+>//g
|
||||
silent! %s/\r//g
|
||||
silent! %s/ / /g
|
||||
silent! %s/"/"/g
|
||||
silent! %s/&/\&/g
|
||||
silent! %s/>/>/g
|
||||
silent! %s/</</g
|
||||
silent! %s/&#\(\d\d\);/\=nr2char(submatch(1))/g
|
||||
silent! %g/^gist: /s/ //g
|
||||
|
||||
call append(0, oldlines)
|
||||
normal! Gomore...
|
||||
|
||||
let b:user = a:user
|
||||
let b:token = a:token
|
||||
let b:gistls = a:gistls
|
||||
let b:page = a:page
|
||||
setlocal buftype=nofile bufhidden=hide noswapfile
|
||||
setlocal nomodified
|
||||
syntax match SpecialKey /^gist:/he=e-1
|
||||
exec 'nnoremap <silent> <buffer> <cr> :call <SID>GistListAction()<cr>'
|
||||
|
||||
cal cursor(1+len(oldlines),1)
|
||||
setlocal foldmethod=expr
|
||||
setlocal foldexpr=getline(v:lnum)=~'^\\(gist:\\\|more\\)'?'>1':'='
|
||||
setlocal foldtext=getline(v:foldstart)
|
||||
endfunction
|
||||
|
||||
function! s:GistGetFileName(gistid)
|
||||
let url = 'https://gist.github.com/'.a:gistid
|
||||
let res = system('curl -s '.url)
|
||||
let res = substitute(res, '^.*<a href="/raw/[^"]\+/\([^"]\+\)".*$', '\1', '')
|
||||
if res =~ '/'
|
||||
return ''
|
||||
else
|
||||
return res
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:GistDetectFiletype(gistid)
|
||||
let url = 'https://gist.github.com/'.a:gistid
|
||||
let mx = '^.*<div class="data syntax type-\([^"]\+\)">.*$'
|
||||
let res = system('curl -s '.url)
|
||||
let res = substitute(matchstr(res, mx), mx, '\1', '')
|
||||
let res = substitute(res, '.*\(\.[^\.]\+\)$', '\1', '')
|
||||
let res = substitute(res, '-', '', 'g')
|
||||
" TODO: more filetype detection that is specified in html.
|
||||
if res == 'bat' | let res = 'dosbatch' | endif
|
||||
if res == 'as' | let res = 'actionscript' | endif
|
||||
if res == 'bash' | let res = 'sh' | endif
|
||||
if res == 'cl' | let res = 'lisp' | endif
|
||||
if res == 'rb' | let res = 'ruby' | endif
|
||||
if res == 'viml' | let res = 'vim' | endif
|
||||
if res == 'plain' || res == 'text' | let res = '' | endif
|
||||
|
||||
if res =~ '^\.'
|
||||
silent! exec "doau BufRead *".res
|
||||
else
|
||||
silent! exec "setlocal ft=".tolower(res)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:GistWrite(fname)
|
||||
if substitute(a:fname, '\\', '/', 'g') == expand("%:p:gs@\\@/@")
|
||||
Gist -e
|
||||
else
|
||||
exe "w".(v:cmdbang ? "!" : "")." ".fnameescape(v:cmdarg)." ".fnameescape(a:fname)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:GistGet(user, token, gistid, clipboard)
|
||||
let url = 'https://gist.github.com/'.a:gistid.'.txt'
|
||||
let winnum = bufwinnr(bufnr('gist:'.a:gistid))
|
||||
if winnum != -1
|
||||
if winnum != bufwinnr('%')
|
||||
exe "normal \<c-w>".winnum."w"
|
||||
endif
|
||||
setlocal modifiable
|
||||
else
|
||||
exec 'silent split gist:'.a:gistid
|
||||
endif
|
||||
filetype detect
|
||||
silent %d _
|
||||
exec 'silent 0r! curl -s '.url
|
||||
normal! Gd_
|
||||
setlocal buftype=acwrite bufhidden=delete noswapfile
|
||||
setlocal nomodified
|
||||
doau StdinReadPost <buffer>
|
||||
if (&ft == '' && g:gist_detect_filetype == 1) || g:gist_detect_filetype == 2
|
||||
call s:GistDetectFiletype(a:gistid)
|
||||
endif
|
||||
if a:clipboard
|
||||
if exists('g:gist_clip_command')
|
||||
exec 'silent w !'.g:gist_clip_command
|
||||
else
|
||||
normal! gg"+yG
|
||||
endif
|
||||
endif
|
||||
normal! gg
|
||||
au! BufWriteCmd <buffer> call s:GistWrite(expand("<amatch>"))
|
||||
endfunction
|
||||
|
||||
function! s:GistListAction()
|
||||
let line = getline('.')
|
||||
let mx = '^gist:\(\w\+\).*'
|
||||
if line =~# mx
|
||||
let gistid = substitute(line, mx, '\1', '')
|
||||
call s:GistGet(g:github_user, g:github_token, gistid, 0)
|
||||
return
|
||||
endif
|
||||
if line =~# '^more\.\.\.$'
|
||||
normal! dd
|
||||
call s:GistList(b:user, b:token, b:gistls, b:page+1)
|
||||
return
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:GistUpdate(user, token, content, gistid, gistnm)
|
||||
if len(a:gistnm) == 0
|
||||
let name = s:GistGetFileName(a:gistid)
|
||||
else
|
||||
let name = a:gistnm
|
||||
endif
|
||||
let namemx = '^[^.]\+\(.\+\)$'
|
||||
let ext = ''
|
||||
if name =~ namemx
|
||||
let ext = substitute(name, namemx, '\1', '')
|
||||
endif
|
||||
let query = [
|
||||
\ '_method=put',
|
||||
\ 'file_ext[gistfile1%s]=%s',
|
||||
\ 'file_name[gistfile1%s]=%s',
|
||||
\ 'file_contents[gistfile1%s]=%s',
|
||||
\ 'login=%s',
|
||||
\ 'token=%s',
|
||||
\ ]
|
||||
let squery = printf(join(query, '&'),
|
||||
\ s:encodeURIComponent(ext), s:encodeURIComponent(ext),
|
||||
\ s:encodeURIComponent(ext), s:encodeURIComponent(name),
|
||||
\ s:encodeURIComponent(ext), s:encodeURIComponent(a:content),
|
||||
\ s:encodeURIComponent(a:user),
|
||||
\ s:encodeURIComponent(a:token))
|
||||
unlet query
|
||||
|
||||
let file = tempname()
|
||||
call writefile([squery], file)
|
||||
echon 'Updating it to gist... '
|
||||
let quote = &shellxquote == '"' ? "'" : '"'
|
||||
let url = 'https://gist.github.com/gists/'.a:gistid
|
||||
let res = system('curl -i -d @'.quote.file.quote.' '.url)
|
||||
call delete(file)
|
||||
let res = matchstr(split(res, '\(\r\?\n\|\r\n\?\)'), '^Location: ')
|
||||
let res = substitute(res, '^[^:]\+: ', '', '')
|
||||
if len(res) > 0 && res =~ '^\(http\|https\):\/\/gist\.github\.com\/'
|
||||
setlocal nomodified
|
||||
echo 'Done: '.res
|
||||
else
|
||||
echoerr 'Edit failed'
|
||||
endif
|
||||
return res
|
||||
endfunction
|
||||
|
||||
function! s:GistGetPage(url, user, param, opt)
|
||||
let cookiedir = substitute(expand('<sfile>:p:h'), '[/\\]plugin$', '', '').'/cookies'
|
||||
if !isdirectory(cookiedir)
|
||||
call mkdir(cookiedir, 'p')
|
||||
endif
|
||||
let cookiefile = cookiedir.'/github'
|
||||
|
||||
if len(a:url) == 0
|
||||
call delete(cookiefile)
|
||||
return
|
||||
endif
|
||||
|
||||
let quote = &shellxquote == '"' ? "'" : '"'
|
||||
if !filereadable(cookiefile)
|
||||
let password = inputsecret('Password:')
|
||||
if len(password) == 0
|
||||
echo 'Canceled'
|
||||
return
|
||||
endif
|
||||
let url = 'https://gist.github.com/login?return_to=gist'
|
||||
let res = system('curl -L -s -k -c '.quote.cookiefile.quote.' '.quote.url.quote)
|
||||
let token = substitute(res, '^.* name="authenticity_token" type="hidden" value="\([^"]\+\)".*$', '\1', '')
|
||||
|
||||
let query = [
|
||||
\ 'authenticity_token=%s',
|
||||
\ 'login=%s',
|
||||
\ 'password=%s',
|
||||
\ 'return_to=gist',
|
||||
\ 'commit=Log+in',
|
||||
\ ]
|
||||
let squery = printf(join(query, '&'),
|
||||
\ s:encodeURIComponent(token),
|
||||
\ s:encodeURIComponent(a:user),
|
||||
\ s:encodeURIComponent(password))
|
||||
unlet query
|
||||
|
||||
let file = tempname()
|
||||
let command = 'curl -s -k -i'
|
||||
let command .= ' -b '.quote.cookiefile.quote
|
||||
let command .= ' -c '.quote.cookiefile.quote
|
||||
let command .= ' '.quote.'https://gist.github.com/session'.quote
|
||||
let command .= ' -d @' . quote.file.quote
|
||||
call writefile([squery], file)
|
||||
let res = system(command)
|
||||
call delete(file)
|
||||
let res = matchstr(split(res, '\(\r\?\n\|\r\n\?\)'), '^Location: ')
|
||||
let res = substitute(res, '^[^:]\+: ', '', '')
|
||||
if len(res) == 0
|
||||
call delete(cookiefile)
|
||||
return ''
|
||||
endif
|
||||
endif
|
||||
let command = 'curl -s -k -i '.a:opt
|
||||
if len(a:param)
|
||||
let command .= ' -d '.quote.a:param.quote
|
||||
endif
|
||||
let command .= ' -b '.quote.cookiefile.quote
|
||||
let command .= ' '.quote.a:url.quote
|
||||
let res = iconv(system(command), "utf-8", &encoding)
|
||||
let pos = stridx(res, "\r\n\r\n")
|
||||
if pos != -1
|
||||
let content = res[pos+4:]
|
||||
else
|
||||
let pos = stridx(res, "\n\n")
|
||||
let content = res[pos+2:]
|
||||
endif
|
||||
return {
|
||||
\ "header" : split(res[0:pos], '\r\?\n'),
|
||||
\ "content" : content
|
||||
\}
|
||||
endfunction
|
||||
|
||||
function! s:GistDelete(user, token, gistid)
|
||||
echon 'Deleting gist... '
|
||||
let res = s:GistGetPage('https://gist.github.com/'.a:gistid, a:user, '', '')
|
||||
let mx = '^.* name="authenticity_token" type="hidden" value="\([^"]\+\)".*$'
|
||||
let token = substitute(matchstr(res.content, mx), mx, '\1', '')
|
||||
if len(token) > 0
|
||||
let res = s:GistGetPage('https://gist.github.com/delete/'.a:gistid, a:user, '_method=delete&authenticity_token='.token, '')
|
||||
if len(res.content) > 0
|
||||
echo 'Done: '
|
||||
else
|
||||
echoerr 'Delete failed'
|
||||
endif
|
||||
else
|
||||
echoerr 'Delete failed'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
" GistPost function:
|
||||
" Post new gist to github
|
||||
"
|
||||
" if there is an embedded gist url or gist id in your file,
|
||||
" it will just update it.
|
||||
" -- by c9s
|
||||
"
|
||||
" embedded gist url format:
|
||||
"
|
||||
" Gist: https://gist.github.com/123123
|
||||
"
|
||||
" embedded gist id format:
|
||||
"
|
||||
" GistID: 123123
|
||||
"
|
||||
function! s:GistPost(user, token, content, private)
|
||||
|
||||
" find GistID: in content , then we should just update
|
||||
for l in split( a:content , "\n" )
|
||||
if l =~ '\<GistID:'
|
||||
let gistid = matchstr( l , 'GistID:\s*\zs\d\+')
|
||||
|
||||
if strlen(gistid) == 0
|
||||
echohl WarningMsg | echo "GistID error" | echohl None
|
||||
return
|
||||
endif
|
||||
echo "Found GistID: " . gistid
|
||||
|
||||
cal s:GistUpdate( a:user , a:token , a:content , gistid , '' )
|
||||
return
|
||||
elseif l =~ '\<Gist:'
|
||||
let gistid = matchstr( l , 'Gist:\s*https://gist.github.com/\zs\d\+')
|
||||
|
||||
if strlen(gistid) == 0
|
||||
echohl WarningMsg | echo "GistID error" | echohl None
|
||||
return
|
||||
endif
|
||||
echo "Found GistID: " . gistid
|
||||
|
||||
cal s:GistUpdate( a:user , a:token , a:content , gistid , '' )
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
|
||||
let ext = expand('%:e')
|
||||
let ext = len(ext) ? '.'.ext : ''
|
||||
let name = expand('%:t')
|
||||
|
||||
let query = [
|
||||
\ 'file_ext[gistfile1]=%s',
|
||||
\ 'file_name[gistfile1]=%s',
|
||||
\ 'file_contents[gistfile1]=%s',
|
||||
\ ]
|
||||
|
||||
if len(a:user) > 0 && len(a:token) > 0
|
||||
call add(query, 'login=%s')
|
||||
call add(query, 'token=%s')
|
||||
else
|
||||
call add(query, '%.0s%.0s')
|
||||
endif
|
||||
|
||||
if a:private
|
||||
call add(query, 'action_button=private')
|
||||
endif
|
||||
let squery = printf(join(query, '&'),
|
||||
\ s:encodeURIComponent(ext),
|
||||
\ s:encodeURIComponent(name),
|
||||
\ s:encodeURIComponent(a:content),
|
||||
\ s:encodeURIComponent(a:user),
|
||||
\ s:encodeURIComponent(a:token))
|
||||
unlet query
|
||||
|
||||
let file = tempname()
|
||||
call writefile([squery], file)
|
||||
echon 'Posting it to gist... '
|
||||
let quote = &shellxquote == '"' ? "'" : '"'
|
||||
let url = 'https://gist.github.com/gists'
|
||||
let res = system('curl -i -d @'.quote.file.quote.' '.url)
|
||||
call delete(file)
|
||||
let res = matchstr(split(res, '\(\r\?\n\|\r\n\?\)'), '^Location: ')
|
||||
let res = substitute(res, '^[^:]\+: ', '', '')
|
||||
if len(res) > 0 && res =~ '^\(http\|https\):\/\/gist\.github\.com\/'
|
||||
echo 'Done: '.res
|
||||
else
|
||||
echoerr 'Post failed'
|
||||
endif
|
||||
return res
|
||||
endfunction
|
||||
|
||||
function! s:GistPostBuffers(user, token, private)
|
||||
let bufnrs = range(1, last_buffer_nr())
|
||||
let bn = bufnr('%')
|
||||
let query = []
|
||||
if len(a:user) > 0 && len(a:token) > 0
|
||||
call add(query, 'login=%s')
|
||||
call add(query, 'token=%s')
|
||||
else
|
||||
call add(query, '%.0s%.0s')
|
||||
endif
|
||||
if a:private
|
||||
call add(query, 'action_button=private')
|
||||
endif
|
||||
let squery = printf(join(query, "&"),
|
||||
\ s:encodeURIComponent(a:user),
|
||||
\ s:encodeURIComponent(a:token)) . '&'
|
||||
|
||||
let query = [
|
||||
\ 'file_ext[gistfile]=%s',
|
||||
\ 'file_name[gistfile]=%s',
|
||||
\ 'file_contents[gistfile]=%s',
|
||||
\ ]
|
||||
let format = join(query, "&") . '&'
|
||||
|
||||
let index = 1
|
||||
for bufnr in bufnrs
|
||||
if buflisted(bufnr) == 0 || bufwinnr(bufnr) == -1
|
||||
continue
|
||||
endif
|
||||
echo "Creating gist content".index."... "
|
||||
silent! exec "buffer! ".bufnr
|
||||
let content = join(getline(1, line('$')), "\n")
|
||||
let ext = expand('%:e')
|
||||
let ext = len(ext) ? '.'.ext : ''
|
||||
let name = expand('%:t')
|
||||
let squery .= printf(substitute(format, 'gistfile', 'gistfile'.index, 'g'),
|
||||
\ s:encodeURIComponent(ext),
|
||||
\ s:encodeURIComponent(name),
|
||||
\ s:encodeURIComponent(content))
|
||||
let index = index + 1
|
||||
endfor
|
||||
silent! exec "buffer! ".bn
|
||||
|
||||
let file = tempname()
|
||||
call writefile([squery], file)
|
||||
echo "Posting it to gist... "
|
||||
let quote = &shellxquote == '"' ? "'" : '"'
|
||||
let url = 'https://gist.github.com/gists'
|
||||
let res = system('curl -i -d @'.quote.file.quote.' '.url)
|
||||
call delete(file)
|
||||
let res = matchstr(split(res, '\(\r\?\n\|\r\n\?\)'), '^Location: ')
|
||||
let res = substitute(res, '^.*: ', '', '')
|
||||
if len(res) > 0 && res =~ '^\(http\|https\):\/\/gist\.github\.com\/'
|
||||
echo 'Done: '.res
|
||||
else
|
||||
echoerr 'Post failed'
|
||||
endif
|
||||
return res
|
||||
endfunction
|
||||
|
||||
function! Gist(line1, line2, ...)
|
||||
if !exists('g:github_user')
|
||||
let g:github_user = substitute(system('git config --global github.user'), "\n", '', '')
|
||||
if strlen(g:github_user) == 0
|
||||
let g:github_user = $GITHUB_USER
|
||||
end
|
||||
endif
|
||||
if !exists('g:github_token')
|
||||
let g:github_token = substitute(system('git config --global github.token'), "\n", '', '')
|
||||
if strlen(g:github_token) == 0
|
||||
let g:github_token = $GITHUB_TOKEN
|
||||
end
|
||||
endif
|
||||
if strlen(g:github_user) == 0 || strlen(g:github_token) == 0
|
||||
echoerr "You have no setting for github."
|
||||
echohl WarningMsg
|
||||
echo "git config --global github.user your-name"
|
||||
echo "git config --global github.token your-token"
|
||||
echo "or set g:github_user and g:github_token in your vimrc"
|
||||
echo "or set shell env vars GITHUB_USER and GITHUB_TOKEN"
|
||||
echohl None
|
||||
return 0
|
||||
end
|
||||
|
||||
let bufname = bufname("%")
|
||||
let user = g:github_user
|
||||
let token = g:github_token
|
||||
let gistid = ''
|
||||
let gistls = ''
|
||||
let gistnm = ''
|
||||
let private = 0
|
||||
let multibuffer = 0
|
||||
let clipboard = 0
|
||||
let deletepost = 0
|
||||
let editpost = 0
|
||||
let listmx = '^\(-l\|--list\)\s*\([^\s]\+\)\?$'
|
||||
let bufnamemx = '^gist:\([0-9a-f]\+\)$'
|
||||
|
||||
let args = (a:0 > 0) ? split(a:1, ' ') : []
|
||||
for arg in args
|
||||
if arg =~ '^\(-la\|--listall\)$'
|
||||
let gistls = '-all'
|
||||
elseif arg =~ '^\(-l\|--list\)$'
|
||||
if g:gist_show_privates
|
||||
let gistls = 'mine'
|
||||
else
|
||||
let gistls = g:github_user
|
||||
endif
|
||||
elseif arg == '--abandon'
|
||||
call s:GistGetPage('', '', '', '')
|
||||
return
|
||||
elseif arg =~ '^\(-m\|--multibuffer\)$'
|
||||
let multibuffer = 1
|
||||
elseif arg =~ '^\(-p\|--private\)$'
|
||||
let private = 1
|
||||
elseif arg =~ '^\(-a\|--anonymous\)$'
|
||||
let user = ''
|
||||
let token = ''
|
||||
elseif arg =~ '^\(-c\|--clipboard\)$'
|
||||
let clipboard = 1
|
||||
elseif arg =~ '^\(-d\|--delete\)$' && bufname =~ bufnamemx
|
||||
let deletepost = 1
|
||||
let gistid = substitute(bufname, bufnamemx, '\1', '')
|
||||
elseif arg =~ '^\(-e\|--edit\)$' && bufname =~ bufnamemx
|
||||
let editpost = 1
|
||||
let gistid = substitute(bufname, bufnamemx, '\1', '')
|
||||
elseif arg =~ '^\(-f\|--fork\)$' && bufname =~ bufnamemx
|
||||
let gistid = substitute(bufname, bufnamemx, '\1', '')
|
||||
let res = s:GistGetPage("https://gist.github.com/fork/".gistid, g:github_user, '', '')
|
||||
let loc = filter(res.header, 'v:val =~ "^Location:"')[0]
|
||||
let loc = substitute(loc, '^[^:]\+: ', '', '')
|
||||
let mx = '^https://gist.github.com/\(\d\+\)$'
|
||||
if loc =~ mx
|
||||
let gistid = substitute(loc, mx, '\1', '')
|
||||
else
|
||||
echoerr 'Fork failed'
|
||||
return
|
||||
endif
|
||||
elseif arg !~ '^-' && len(gistnm) == 0
|
||||
if editpost == 1 || deletepost == 1
|
||||
let gistnm = arg
|
||||
elseif len(gistls) > 0
|
||||
let gistls = arg
|
||||
else
|
||||
let gistid = arg
|
||||
endif
|
||||
elseif len(arg) > 0
|
||||
echoerr 'Invalid arguments'
|
||||
unlet args
|
||||
return 0
|
||||
endif
|
||||
endfor
|
||||
unlet args
|
||||
"echo "gistid=".gistid
|
||||
"echo "gistls=".gistls
|
||||
"echo "gistnm=".gistnm
|
||||
"echo "private=".private
|
||||
"echo "clipboard=".clipboard
|
||||
"echo "editpost=".editpost
|
||||
"echo "deletepost=".deletepost
|
||||
|
||||
if len(gistls) > 0
|
||||
call s:GistList(user, token, gistls, 1)
|
||||
elseif len(gistid) > 0 && editpost == 0 && deletepost == 0
|
||||
call s:GistGet(user, token, gistid, clipboard)
|
||||
else
|
||||
if multibuffer == 1
|
||||
let url = s:GistPostBuffers(user, token, private)
|
||||
else
|
||||
let content = join(getline(a:line1, a:line2), "\n")
|
||||
if editpost == 1
|
||||
let url = s:GistUpdate(user, token, content, gistid, gistnm)
|
||||
elseif deletepost == 1
|
||||
let url = s:GistDelete(user, token, gistid)
|
||||
else
|
||||
let url = s:GistPost(user, token, content, private)
|
||||
endif
|
||||
if len(url) > 0 && g:gist_open_browser_after_post
|
||||
let cmd = substitute(g:gist_browser_command, '%URL%', url, 'g')
|
||||
if cmd =~ '^!'
|
||||
silent! exec cmd
|
||||
else
|
||||
call system(cmd)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
if g:gist_put_url_to_clipboard_after_post == 1
|
||||
if exists('g:gist_clip_command')
|
||||
silent! 1sp
|
||||
silent! put! =url
|
||||
exec 'silent! 1,1w !'.g:gist_clip_command
|
||||
silent! bw!
|
||||
elseif has('unix') && !has('xterm_clipboard')
|
||||
let @" = url
|
||||
else
|
||||
let @+ = url
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
command! -nargs=? -range=% Gist :call Gist(<line1>, <line2>, <f-args>)
|
||||
" vim:set et:
|
||||
@@ -0,0 +1,325 @@
|
||||
" matrix.vim - Don Yang (uguu.org)
|
||||
"
|
||||
" Matrix screensaver for VIM.
|
||||
"
|
||||
"Usage:
|
||||
" After loading the script, use :Matrix to start.
|
||||
" Press any key a few times to exit.
|
||||
"
|
||||
" You will need to edit s:mindelay and s:maxdelay below to match your
|
||||
" machine speed and window size.
|
||||
"
|
||||
"Known Issues:
|
||||
" Sometimes you need to press keys a few times to exit instead of just
|
||||
" once. Press and hold is another way to go... feels like getchar is
|
||||
" checking for keypress state instead of keystroke availability.
|
||||
"
|
||||
" If the window is too small, script will not run. If the window is
|
||||
" resized and become too small (less than 8 rows or 10 columns) after
|
||||
" the script started, script will abort and *buffers may be lost*, so
|
||||
" don't do that. Resizing the window to most other sizes will be fine.
|
||||
"
|
||||
" Doesn't work if multiple windows exist before script started. In
|
||||
" that case the script will abort with error message.
|
||||
"
|
||||
" If the current buffer is modified, some error messages will appear
|
||||
" before the script starts, and an extra window is left behind after
|
||||
" the script exits. Workaround: save your buffers first.
|
||||
"
|
||||
"Other Info:
|
||||
" Inspired by cmatrix...
|
||||
" Didn't feel inspired enough to start using pico/nano, of course ^_^;
|
||||
"
|
||||
" 05/13/08 - disable cursorline, cursorcolumn and spell
|
||||
" (thanks to Diederick Niehorster for the suggestion).
|
||||
" 12/21/06 - multiwindow support by S. Lockwood-Childs.
|
||||
" 10/03/05 - added silent! to cursor positioning code to stop drawing
|
||||
" numbers during animation (thanks to David Eggum for the
|
||||
" suggestion).
|
||||
" 10/02/05 - disable showmatch
|
||||
" 03/16/05 - make new buffer modifiable before running
|
||||
" 01/27/05 - added sleep to consume less CPU
|
||||
" removed frame counter
|
||||
" 01/26/05 - initial version
|
||||
|
||||
|
||||
" Speed range, must be positive. Lower delay = faster.
|
||||
let s:mindelay = 1
|
||||
let s:maxdelay = 5
|
||||
|
||||
" Session file for preserving original window layout
|
||||
let s:session_file = tempname()
|
||||
|
||||
|
||||
function! s:Rand()
|
||||
let b:seed = b:seed * 22695477 + 1
|
||||
if b:seed < 0
|
||||
return -b:seed
|
||||
endif
|
||||
return b:seed
|
||||
endfunction
|
||||
|
||||
function! s:CreateObject(i)
|
||||
while 1
|
||||
let b:x{a:i} = s:Rand() % b:columns
|
||||
if b:reserve{b:x{a:i}} > 4
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
let b:y{a:i} = 1
|
||||
let b:t{a:i} = s:Rand() % b:s{b:x{a:i}}
|
||||
let b:head{a:i} = s:Rand() % 4
|
||||
let b:len{a:i} = s:Rand() % b:h + 3
|
||||
let b:reserve{b:x{a:i}} = 1 - b:len{a:i}
|
||||
endfunction
|
||||
|
||||
function! s:DrawObject(i)
|
||||
let x = b:x{a:i} * 2 + 1
|
||||
let y = b:y{a:i}
|
||||
|
||||
" Draw head
|
||||
if y <= b:h
|
||||
if b:head{a:i}
|
||||
silent! exec 'norm! :' . y . nr2char(13) . x . '|R' . b:d[s:Rand()%b:dl] . '_' . nr2char(27)
|
||||
if y > 1
|
||||
silent! exec 'norm! kR' . ((s:Rand() % 2) ? '`' : ' ') . nr2char(27)
|
||||
endif
|
||||
else
|
||||
let a = ((s:Rand() % 2) ? '`' : ' ') . nr2char(27)
|
||||
silent! exec 'norm! :'. y . nr2char(13) . x . '|R' . b:d[s:Rand() % b:dl] . a
|
||||
endif
|
||||
else
|
||||
if b:head{a:i} && y == b:h + 1
|
||||
silent! exec 'norm! :' . b:h . nr2char(13) . (x + 1) . '|R' . ((s:Rand() % 2) ? '`' : ' ') . nr2char(27)
|
||||
endif
|
||||
endif
|
||||
|
||||
" Draw tail
|
||||
let y = y - b:len{a:i}
|
||||
if 1 <= y && y <= b:h
|
||||
silent! exec 'norm! :'. y . nr2char(13) . x . '|R ' . nr2char(27)
|
||||
endif
|
||||
let b:reserve{b:x{a:i}} = y
|
||||
endfunction
|
||||
|
||||
function! s:Animate()
|
||||
let i = 0
|
||||
|
||||
while i < b:objcount
|
||||
" Animate object
|
||||
if b:t{i} <= 0
|
||||
if b:y{i} - b:len{i} <= b:h
|
||||
" Draw
|
||||
call s:DrawObject(i)
|
||||
let b:t{i} = b:s{b:x{i}}
|
||||
let b:y{i} = b:y{i} + 1
|
||||
else
|
||||
" Regenerate
|
||||
call s:CreateObject(i)
|
||||
endif
|
||||
endif
|
||||
|
||||
let b:t{i} = b:t{i} - 1
|
||||
let i = i + 1
|
||||
endwhile
|
||||
redraw
|
||||
if getchar(1)
|
||||
let b:run = 0
|
||||
endif
|
||||
sleep 20m
|
||||
endfunction
|
||||
|
||||
function! s:Reset()
|
||||
" Clear screen
|
||||
let b:w = winwidth(0)
|
||||
let b:h = winheight(0)
|
||||
exec 'norm! gg"_dG' . b:h . 'O' . nr2char(27) . 'gg'
|
||||
redraw
|
||||
if b:w < 10 || b:h < 8
|
||||
let b:run = 0
|
||||
return
|
||||
endif
|
||||
|
||||
" Set number of columns. This is rounded down due to line wrapping
|
||||
" at the last column if the screen width is even. So you end up
|
||||
" seeing the cursor blinking a lot at the right side of the screen.
|
||||
" Alternatively, ':set rl' before running the script to have it
|
||||
" blink on the left side.
|
||||
let b:columns = (b:w - 1) / 2
|
||||
|
||||
" Initialize columns.
|
||||
let i = 0
|
||||
while i < b:columns
|
||||
" Set delay time. Each column gets the same delay time.
|
||||
let b:s{i} = s:Rand() % (s:maxdelay - s:mindelay) + s:mindelay
|
||||
|
||||
" Unreserve column
|
||||
let b:reserve{i} = b:h
|
||||
let i = i + 1
|
||||
endwhile
|
||||
|
||||
" Initialize objects
|
||||
let b:objcount = b:columns - 2
|
||||
let i = 0
|
||||
while i < b:objcount
|
||||
call s:CreateObject(i)
|
||||
let i = i + 1
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! s:Init()
|
||||
" Create new buffer and hide the existing buffers. Hiding the
|
||||
" existing buffers without switching to a new buffer preserves
|
||||
" undo history.
|
||||
exec 'mksession! ' . s:session_file
|
||||
let s:num_orig_win = winnr("$")
|
||||
|
||||
" move to top window, so created window will become window 1,
|
||||
" then attempt to create new window
|
||||
1 wincmd w
|
||||
silent! new
|
||||
|
||||
" check that there really is an additional window
|
||||
if winnr("$") != s:num_orig_win + 1
|
||||
return 1
|
||||
endif
|
||||
let s:newbuf = bufnr('%')
|
||||
|
||||
" close all but window 1, which is the new window
|
||||
only
|
||||
|
||||
setl bh=delete bt=nofile ma nolist nonu noro noswf tw=0 nowrap
|
||||
|
||||
" Set GUI options
|
||||
if has('gui')
|
||||
let s:o_gcr = &gcr
|
||||
let s:o_go = &go
|
||||
set gcr=a:ver1-blinkon0 go=
|
||||
endif
|
||||
if has('cmdline_info')
|
||||
let s:o_ru = &ru
|
||||
let s:o_sc = &sc
|
||||
set noru nosc
|
||||
endif
|
||||
if has('title')
|
||||
let s:o_ts = &titlestring
|
||||
exec 'set titlestring=\ '
|
||||
endif
|
||||
if v:version >= 700
|
||||
let s:o_spell = &spell
|
||||
let s:o_cul = &cul
|
||||
let s:o_cuc = &cuc
|
||||
set nospell nocul nocuc
|
||||
endif
|
||||
let s:o_ch = &ch
|
||||
let s:o_ls = &ls
|
||||
let s:o_lz = &lz
|
||||
let s:o_siso = &siso
|
||||
let s:o_sm = &sm
|
||||
let s:o_smd = &smd
|
||||
let s:o_so = &so
|
||||
let s:o_ve = &ve
|
||||
set ch=1 ls=0 lz nosm nosmd siso=0 so=0 ve=all
|
||||
|
||||
" Initialize PRNG
|
||||
let b:seed = localtime()
|
||||
let b:run = 1
|
||||
|
||||
" Clear screen and initialize objects
|
||||
call s:Reset()
|
||||
|
||||
" Set colors. Output looks better if your color scheme has black
|
||||
" background. I would rather not have the script change the
|
||||
" current color scheme since there is no good way to restore them
|
||||
" afterwards.
|
||||
hi MatrixHidden ctermfg=Black ctermbg=Black guifg=#000000 guibg=#000000
|
||||
hi MatrixNormal ctermfg=DarkGreen ctermbg=Black guifg=#008000 guibg=#000000
|
||||
hi MatrixBold ctermfg=LightGreen ctermbg=Black guifg=#00ff00 guibg=#000000
|
||||
hi MatrixHead ctermfg=White ctermbg=Black guifg=#ffffff guibg=#000000
|
||||
sy match MatrixNormal /^.*/ contains=MatrixHidden
|
||||
sy match MatrixHidden contained /.`/ contains=MatrixBold
|
||||
sy match MatrixHidden contained /._/ contains=MatrixHead
|
||||
sy match MatrixBold contained /.\(`\)\@=/
|
||||
sy match MatrixHead contained /.\(_\)\@=/
|
||||
|
||||
" Create random char dictionary
|
||||
let b:d = ''
|
||||
let i = 33
|
||||
while i < 127
|
||||
if i != 95 && i != 96
|
||||
let b:d = b:d . nr2char(i)
|
||||
endif
|
||||
let i = i + 1
|
||||
endwhile
|
||||
let b:dl = strlen(b:d)
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! s:Cleanup()
|
||||
" Restore options
|
||||
if has('gui')
|
||||
let &gcr = s:o_gcr
|
||||
let &go = s:o_go
|
||||
unlet s:o_gcr s:o_go
|
||||
endif
|
||||
if has('cmdline_info')
|
||||
let &ru = s:o_ru
|
||||
let &sc = s:o_sc
|
||||
unlet s:o_ru s:o_sc
|
||||
endif
|
||||
if has('title')
|
||||
let &titlestring = s:o_ts
|
||||
unlet s:o_ts
|
||||
endif
|
||||
if v:version >= 700
|
||||
let &spell = s:o_spell
|
||||
let &cul = s:o_cul
|
||||
let &cuc = s:o_cuc
|
||||
unlet s:o_cul s:o_cuc
|
||||
endif
|
||||
let &ch = s:o_ch
|
||||
let &ls = s:o_ls
|
||||
let &lz = s:o_lz
|
||||
let &siso = s:o_siso
|
||||
let &sm = s:o_sm
|
||||
let &smd = s:o_smd
|
||||
let &so = s:o_so
|
||||
let &ve = s:o_ve
|
||||
unlet s:o_ch s:o_ls s:o_lz s:o_siso s:o_sm s:o_smd s:o_so s:o_ve
|
||||
|
||||
" Restore old buffers
|
||||
exec 'source ' . s:session_file
|
||||
exec 'bwipe ' . s:newbuf
|
||||
unlet s:newbuf
|
||||
|
||||
" Clear keystroke
|
||||
let c = getchar(0)
|
||||
endfunction
|
||||
|
||||
function! Matrix()
|
||||
if s:Init()
|
||||
echohl ErrorMsg
|
||||
echon 'Can not create window'
|
||||
echohl None
|
||||
return
|
||||
endif
|
||||
|
||||
while b:run
|
||||
if b:w != winwidth(0) || b:h != winheight(0)
|
||||
call s:Reset()
|
||||
else
|
||||
call s:Animate()
|
||||
endif
|
||||
endwhile
|
||||
|
||||
call s:Cleanup()
|
||||
endfunction
|
||||
|
||||
|
||||
if !has('virtualedit') || !has('windows') || !has('syntax')
|
||||
echohl ErrorMsg
|
||||
echon 'Not enough features, need at least +virtualedit, +windows and +syntax'
|
||||
echohl None
|
||||
else
|
||||
command! Matrix call Matrix()
|
||||
endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,127 @@
|
||||
" Vim compiler file for Python
|
||||
" Compiler: Style checking tool for Python
|
||||
" Maintainer: Oleksandr Tymoshenko <gonzo@univ.kiev.ua>
|
||||
" Last Change: 2009 Apr 19
|
||||
" Version: 0.5
|
||||
" Contributors:
|
||||
" Artur Wroblewski
|
||||
" Menno
|
||||
"
|
||||
" Installation:
|
||||
" Drop pylint.vim in ~/.vim/compiler directory. Ensure that your PATH
|
||||
" environment variable includes the path to 'pylint' executable.
|
||||
"
|
||||
" Add the following line to the autocmd section of .vimrc
|
||||
"
|
||||
" autocmd FileType python compiler pylint
|
||||
"
|
||||
" Usage:
|
||||
" Pylint is called after a buffer with Python code is saved. QuickFix
|
||||
" window is opened to show errors, warnings and hints provided by Pylint.
|
||||
" Code rate calculated by Pylint is displayed at the bottom of the
|
||||
" window.
|
||||
"
|
||||
" Above is realized with :Pylint command. To disable calling Pylint every
|
||||
" time a buffer is saved put into .vimrc file
|
||||
"
|
||||
" let g:pylint_onwrite = 0
|
||||
"
|
||||
" Displaying code rate calculated by Pylint can be avoided by setting
|
||||
"
|
||||
" let g:pylint_show_rate = 0
|
||||
"
|
||||
" Openning of QuickFix window can be disabled with
|
||||
"
|
||||
" let g:pylint_cwindow = 0
|
||||
"
|
||||
" Of course, standard :make command can be used as in case of every
|
||||
" other compiler.
|
||||
"
|
||||
|
||||
|
||||
if exists('current_compiler')
|
||||
finish
|
||||
endif
|
||||
let current_compiler = 'pylint'
|
||||
|
||||
if !exists('g:pylint_onwrite')
|
||||
let g:pylint_onwrite = 1
|
||||
endif
|
||||
|
||||
if !exists('g:pylint_show_rate')
|
||||
let g:pylint_show_rate = 1
|
||||
endif
|
||||
|
||||
if !exists('g:pylint_cwindow')
|
||||
let g:pylint_cwindow = 1
|
||||
endif
|
||||
|
||||
if exists(':Pylint') != 2
|
||||
command Pylint :call Pylint(0)
|
||||
endif
|
||||
|
||||
if exists(":CompilerSet") != 2 " older Vim always used :setlocal
|
||||
command -nargs=* CompilerSet setlocal <args>
|
||||
endif
|
||||
|
||||
" We should echo filename because pylint truncates .py
|
||||
" If someone know better way - let me know :)
|
||||
CompilerSet makeprg=(echo\ '[%]';\ pylint\ -r\ y\ %)
|
||||
|
||||
" We could omit end of file-entry, there is only one file
|
||||
" %+I... - include code rating information
|
||||
" %-G... - remove all remaining report lines from quickfix buffer
|
||||
CompilerSet efm=%+P[%f],%t:\ %#%l:%m,%Z,%+IYour\ code%m,%Z,%-G%.%#
|
||||
|
||||
if g:pylint_onwrite
|
||||
augroup python
|
||||
au!
|
||||
au BufWritePost * call Pylint(1)
|
||||
augroup end
|
||||
endif
|
||||
|
||||
function! Pylint(writing)
|
||||
if !a:writing && &modified
|
||||
" Save before running
|
||||
write
|
||||
endif
|
||||
|
||||
if has('win32') || has('win16') || has('win95') || has('win64')
|
||||
setlocal sp=>%s
|
||||
else
|
||||
setlocal sp=>%s\ 2>&1
|
||||
endif
|
||||
|
||||
" If check is executed by buffer write - do not jump to first error
|
||||
if !a:writing
|
||||
silent make
|
||||
else
|
||||
silent make!
|
||||
endif
|
||||
|
||||
if g:pylint_cwindow
|
||||
cwindow
|
||||
endif
|
||||
|
||||
call PylintEvaluation()
|
||||
|
||||
if g:pylint_show_rate
|
||||
echon 'code rate: ' b:pylint_rate ', prev: ' b:pylint_prev_rate
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! PylintEvaluation()
|
||||
let l:list = getqflist()
|
||||
let b:pylint_rate = '0.00'
|
||||
let b:pylint_prev_rate = '0.00'
|
||||
for l:item in l:list
|
||||
if l:item.type == 'I' && l:item.text =~ 'Your code has been rated'
|
||||
let l:re_rate = '\(-\?[0-9]\{1,2\}\.[0-9]\{2\}\)/'
|
||||
let b:pylint_rate = substitute(l:item.text, '.*rated at '.l:re_rate.'.*', '\1', 'g')
|
||||
" Only if there is information about previous run
|
||||
if l:item.text =~ 'previous run: '
|
||||
let b:pylint_prev_rate = substitute(l:item.text, '.*previous run: '.l:re_rate.'.*', '\1', 'g')
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
@@ -0,0 +1,55 @@
|
||||
"------------------------------------------------------------------------------
|
||||
" Description: Options setable by the rainbow_parenthsis plugin
|
||||
" $Id: rainbow_parenthsis_options.vim 29 2007-09-24 11:40:36Z krischik@users.sourceforge.net $
|
||||
" Copyright: Copyright (C) 2006 Martin Krischik
|
||||
" Maintainer: Martin Krischik (krischik@users.sourceforge.net)
|
||||
" $Author: krischik@users.sourceforge.net $
|
||||
" $Date: 2007-09-24 13:40:36 +0200 (Mo, 24 Sep 2007) $
|
||||
" Version: 4.0
|
||||
" $Revision: 29 $
|
||||
" $HeadURL: https://vim-scripts.googlecode.com/svn/trunk/1561%20Rainbow%20Parenthsis%20Bundle/rainbow_parenthsis_options.vim $
|
||||
" History: 17.11.2006 MK rainbow_parenthsis_Options
|
||||
" 01.01.2007 MK Bug fixing
|
||||
" 09.10.2007 MK Now with round, square brackets, curly and angle
|
||||
" brackets.
|
||||
" Usage: copy content into your .vimrc and change options to your
|
||||
" likeing.
|
||||
" Help Page: rainbow_parenthsis.txt
|
||||
"------------------------------------------------------------------------------
|
||||
|
||||
echoerr 'It is suggested to copy the content of ada_options into .vimrc!'
|
||||
finish " 1}}}
|
||||
|
||||
" Section: rainbow_parenthsis options {{{1
|
||||
|
||||
" }}}1
|
||||
|
||||
" Section: Vimball options {{{1
|
||||
:set noexpandtab fileformat=unix encoding=utf-8
|
||||
:31,34 MkVimball rainbow_parenthsis-4.0.vba
|
||||
|
||||
autoload/rainbow_parenthsis.vim
|
||||
doc/rainbow_parenthsis.txt
|
||||
plugin/rainbow_parenthsis.vim
|
||||
rainbow_parenthsis_options.vim
|
||||
|
||||
" }}}1
|
||||
|
||||
" Section: Tar options {{{1
|
||||
|
||||
tar --create --bzip2 \
|
||||
--file="rainbow_parenthsis-4.0.tar.bz2" \
|
||||
rainbow_parenthsis_options.vim \
|
||||
doc/rainbow_parenthsis.txt \
|
||||
autoload/rainbow_parenthsis.vim \
|
||||
plugin/rainbow_parenthsis.vim ;
|
||||
|
||||
" }}}1
|
||||
|
||||
"------------------------------------------------------------------------------
|
||||
" Copyright (C) 2006 Martin Krischik
|
||||
"
|
||||
" Vim is Charityware - see ":help license" or uganda.txt for licence derainbow_parenthsiss.
|
||||
"------------------------------------------------------------------------------
|
||||
" vim: textwidth=0 nowrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
|
||||
" vim: foldmethod=marker
|
||||
@@ -0,0 +1,330 @@
|
||||
" Vim syntax file
|
||||
" Language: Pandoc (superset of Markdown)
|
||||
" Maintainer: Jeremy Schultz <taozhyn@gmail.com>
|
||||
" URL:
|
||||
" Version: 2
|
||||
" Changes: 2008-11-04
|
||||
" - Fixed an issue with Block elements (header) not being highlighted when
|
||||
" placed on the first or second line of the file
|
||||
" - Fixed multi line HTML comment block
|
||||
" - Fixed lowercase list items
|
||||
" - Fixed list items gobbling to many empty lines
|
||||
" - Added highlight support to identify newline (2 spaces)
|
||||
" - Fixed HTML highlight, ignore if the first character in the
|
||||
" angle brackets is not a letter
|
||||
" - Fixed Emphasis highlighting when it contained multiple
|
||||
" spaces
|
||||
" Remark: Uses HTML and TeX syntax file
|
||||
|
||||
if version < 600
|
||||
syntax clear
|
||||
elseif exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
syn spell toplevel
|
||||
syn case ignore
|
||||
syn sync linebreaks=1
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Set embedded HTML highlighting
|
||||
syn include @HTML syntax/html.vim
|
||||
syn match pdcHTML /<\a[^>]\+>/ contains=@HTML
|
||||
|
||||
" Support HTML multi line comments
|
||||
syn region pdcHTMLComment start=/<!--/ end=/-->/
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Set embedded LaTex (pandox extension) highlighting
|
||||
" Unset current_syntax so the 2nd include will work
|
||||
unlet b:current_syntax
|
||||
syn include @LATEX syntax/tex.vim
|
||||
|
||||
" Single Tex command
|
||||
syn match pdcLatex /\\\w\+{[^}]\+}/ contains=@LATEX
|
||||
|
||||
" Tex Block (begin-end)
|
||||
syn region pdcLatex start=/\\begin{[^}]\+}\ze/ end=/\ze\\end{[^}]\+}/ contains=@LATEX
|
||||
|
||||
" Math Tex
|
||||
syn match pdcLatex /$[^$]\+\$/ contains=@LATEX
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Block Elements
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
" Needed by other elements
|
||||
syn match pdcBlankLine /\(^\s*\n\|\%^\)/ nextgroup=pdcHeader,pdcCodeBlock,pdcListItem,pdcListItem1,pdcHRule,pdcTableHeader,pdcTableMultiStart,pdcBlockquote transparent
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Title Block:
|
||||
syn match pandocTitleBlock /\%^\(%.*\n\)\{1,3}$/
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Headers:
|
||||
|
||||
" Underlined, using == or --
|
||||
syn match pdcHeader /^.\+\n[=-]\+$/ contains=@Spell nextgroup=pdcHeader contained skipnl
|
||||
|
||||
" Atx-style, Hash marks
|
||||
syn region pdcHeader start="^\s*#\{1,6}[^#]*" end="\($\|#\+\)" contains=@Spell contained nextgroup=pdcHeader skipnl
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Blockquotes:
|
||||
|
||||
syn match pdcBlockquote /\s*>.*$/ nextgroup=pdcBlockquote,pdcBlockquote2 contained skipnl
|
||||
syn match pdcBlockquote2 /[^>].*/ nextgroup=pdcBlockquote2 skipnl contained
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Code Blocks:
|
||||
|
||||
" Indent with at least 4 space or 1 tab
|
||||
" This rule must appear for pdcListItem, or highlighting gets messed up
|
||||
syn match pdcCodeBlock /\(\s\{4,}\|\t\{1,}\).*\n/ contained nextgroup=pdcCodeBlock
|
||||
|
||||
" HTML code blocks, pre and code
|
||||
syn match pdcCodeStartPre /<pre>/ nextgroup=pdcCodeHTMLPre skipnl transparent
|
||||
syn match pdcCodeHTMLPre /.*/ contained nextgroup=pdcCodeHTMLPre,pdcCodeEndPre skipnl
|
||||
syn match pdcCodeEndPre /\s*<\/pre>/ contained transparent
|
||||
|
||||
" HTML code blocks, code
|
||||
syn match pdcCodeStartCode /<code>/ nextgroup=pdcCodeHTMLCode skipnl transparent
|
||||
syn match pdcCodeHTMLCode /.*/ contained nextgroup=pdcCodeHTMLCode,pdcCodeEndCode skipnl
|
||||
syn match pdcCodeEndCode /\s*<\/code>/ contained transparent
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Lists:
|
||||
|
||||
" These first two rules need to be first or the highlighting will be
|
||||
" incorrect
|
||||
|
||||
" Continue a list on the next line
|
||||
syn match pdcListCont /\s*[^-+*].*\n/ contained nextgroup=pdcListCont,pdcListItem,pdcListSkipNL transparent
|
||||
|
||||
" Skip empty lines
|
||||
syn match pdcListSkipNL /\s*\n/ contained nextgroup=pdcListItem,pdcListSkipNL
|
||||
|
||||
" Unorder list
|
||||
syn match pdcListItem /\s*[-*+]\s\+/ contained nextgroup=pdcListSkipNL,pdcListCont skipnl
|
||||
|
||||
" Order list, numeric
|
||||
syn match pdcListItem /\s*(\?\(\d\+\|#\)[\.)]\s\+/ contained nextgroup=pdcListSkipNL,pdcListCont skipnl
|
||||
|
||||
" Order list, roman numerals (does not guarantee correct roman numerals)
|
||||
syn match pdcListItem /\s*(\?[ivxlcdm]\+[\.)]\s\+/ contained nextgroup=pdcListSkipNL,pdcListCont skipnl
|
||||
|
||||
" Order list, lowercase letters
|
||||
syn match pdcListItem /\s*(\?\l[\.)]\s\+/ contained nextgroup=pdcListSkipNL,pdcListCont skipnl
|
||||
|
||||
" Order list, uppercase letters, does not include '.'
|
||||
syn match pdcListItem /\s*(\?\u[\)]\s\+/ contained nextgroup=pdcListSkipNL,pdcListCont skipnl
|
||||
|
||||
" Order list, uppercase letters, special case using '.' and two or more spaces
|
||||
syn match pdcListItem /\s*\u\.\([ ]\{2,}\|\t\+\)/ contained nextgroup=pdcListSkipNL,pdcListCont skipnl
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Horizontal Rules:
|
||||
|
||||
" 3 or more * on a line
|
||||
syn match pdcHRule /\s\{0,3}\(-\s*\)\{3,}\n/ contained nextgroup=pdcHRule
|
||||
|
||||
" 3 or more - on a line
|
||||
syn match pdcHRule /\s\{0,3}\(\*\s*\)\{3,}\n/ contained nextgroup=pdcHRule
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Span Elements
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Links:
|
||||
|
||||
" Link Text
|
||||
syn match pdcLinkText /\[\zs[^\]]*\ze\]/ contains=@Spell
|
||||
|
||||
" Link ID
|
||||
syn match pdcLinkID /\][ ]\{0,1}\[\zs[^\]]*\ze\]/
|
||||
|
||||
" Skip [ so we do not highlight it
|
||||
syn match pdcSkip /^[ ]\{0,3}\[/ nextgroup=pdcLinkID
|
||||
|
||||
" Link ID - definition
|
||||
syn match pdcLinkID /[^\]]*\ze\]:/ nextgroup=pdcSkip skipwhite contained
|
||||
|
||||
" Skip ]: so we do not highlight it
|
||||
syn match pdcSkip /\]:/ contained nextgroup=pdcLinkURL skipwhite
|
||||
|
||||
" Link URL
|
||||
syn region pdcLinkURL start=/\](\zs/ end=/)/me=e-1
|
||||
|
||||
" Link URL on ID definition line
|
||||
syn match pdcLinkURL /\s\+.*\s\+\ze[("']/ nextgroup=pdcLinkTitle skipwhite contained
|
||||
syn match pdcLinkURL /\s*.*\s*[^)"']\s*$/ contained
|
||||
syn match pdcLinkURL /\s*.*\s*[^)"']\s*\n\s*\ze[("']/ contained nextgroup=pdcLinkTitle skipwhite
|
||||
|
||||
" Link URL for inline <> links
|
||||
syn match pdcLinkURL /<http[^>]*>/
|
||||
syn match pdcLinkURL /<[^>]*@[^>]*.[^>]*>/
|
||||
|
||||
" Link Title
|
||||
syn match pdcLinkTitle /\s*[("'].*[)"']/ contained contains=@Spell
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Emphasis:
|
||||
|
||||
" Using underscores
|
||||
syn match pdcEmphasis / \(_\|__\)\([^_ ]\|[^_]\( [^_]\)\+\)\+\1/ contains=@Spell
|
||||
|
||||
" Using Asterisks
|
||||
syn match pdcEmphasis / \(\*\|\*\*\)\([^\* ]\|[^\*]\( [^\*]\)\+\)\+\1/ contains=@Spell
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Inline Code:
|
||||
|
||||
" Using single back ticks
|
||||
syn region pdcCode start=/`/ end=/`\|^\s*$/
|
||||
|
||||
" Using double back ticks
|
||||
syn region pdcCode start=/``[^`]*/ end=/``\|^\s*$/
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Images:
|
||||
" Handled by link syntax
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Misc:
|
||||
|
||||
" Pandoc escapes all characters after a backslash
|
||||
syn match NONE /\\\W/
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Span Elements
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Subscripts:
|
||||
syn match pdcSubscript /\~\([^\~\\ ]\|\(\\ \)\)\+\~/ contains=@Spell
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Superscript:
|
||||
syn match pdcSuperscript /\^\([^\^\\ ]\|\(\\ \)\)\+\^/ contains=@Spell
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Strikeout:
|
||||
syn match pdcStrikeout /\~\~[^\~ ]\([^\~]\|\~ \)*\~\~/ contains=@Spell
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Definitions:
|
||||
syn match pdcDefinitions /:\(\t\|[ ]\{3,}\)/ nextgroup=pdcListItem,pdcCodeBlock,pdcBlockquote,pdcHRule
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Footnote:
|
||||
syn match pdcFootnoteID /\[\^[^\]]\+\]/ nextgroup=pdcFootnoteDef
|
||||
|
||||
" This does not work correctly
|
||||
syn region pdcFootnoteDef start=/:/ end=/^\n\+\(\(\t\+\|[ ]\{4,}\)\S\)\@!/ contained contains=pdcFootnoteDef
|
||||
|
||||
" Inline footnotes
|
||||
syn region pdcFootnoteDef matchgroup=pdcFootnoteID start=/\^\[/ matchgroup=pdcFootnoteID end=/\]/
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Tables:
|
||||
"
|
||||
" Regular Table
|
||||
syn match pdcTableHeader /\s*\w\+\(\s\+\w\+\)\+\s*\n\s*-\+\(\s\+-\+\)\+\s*\n/ contained nextgroup=pdcTableBody
|
||||
syn match pdcTableBody /\s*\w\+\(\s\+\w\+\)\+\s*\n/ contained nextgroup=pdcTableBody,pdcTableCaption skipnl
|
||||
syn match pdcTableCaption /\n\+\s*Table.*\n/ contained nextgroup=pdcTableCaptionCont
|
||||
syn match pdcTableCaptionCont /\s*\S.\+\n/ contained nextgroup=pdcTableCaptionCont
|
||||
|
||||
" Multi-line Table
|
||||
syn match pdcTableMultiStart /^\s\{0,3}-\+\s*\n\ze\(\s*\w\+\(\s\+\w\+\)\+\s*\n\)\+\s*-\+\(\s\+-\+\)\+\s*\n/ contained nextgroup=pdcTableMultiHeader
|
||||
syn match pdcTableMultiEnd /^\s\{0,3}-\+/ contained nextgroup=pdcTableMultiCaption skipnl
|
||||
syn match pdcTableMultiHeader /\(\s*\w\+\(\s\+\w\+\)\+\s*\n\)\+\s*-\+\(\s\+-\+\)\+\s*\n/ contained nextgroup=pdcTableMultiBody
|
||||
syn match pdcTableMultiBody /^\(\s\{3,}[^-]\|[^-\s]\).*$/ contained nextgroup=pdcTableMultiBody,pdcTableMultiSkipNL,pdcTableMultiEnd skipnl
|
||||
syn match pdcTableMultiSkipNL /^\s*\n/ contained nextgroup=pdcTableMultiBody,pdcTableMultiEnd skipnl
|
||||
syn match pdcTableMultiCaption /\n*\s*Table.*\n/ contained nextgroup=pdcTableCaptionCont
|
||||
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Delimited Code Block: (added in 1.0)
|
||||
syn region pdcCodeBlock matchgroup=pdcCodeStart start=/^\z(\~\{3,}\) \( {[^}]\+}\)\?/ matchgroup=pdcCodeEnd end=/^\z1\~*/
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
" Newline, 2 spaces at the end of line means newline
|
||||
syn match pdcNewLine / $/
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Highlight groups
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
hi link pdcHeader Title
|
||||
hi link pdcBlockquote Comment
|
||||
hi link pdcBlockquote2 Comment
|
||||
|
||||
hi link pdcHTMLComment Comment
|
||||
|
||||
hi link pdcHRule Underlined
|
||||
"hi link pdcHRule Special
|
||||
|
||||
hi link pdcListItem Operator
|
||||
hi link pdcDefinitions Operator
|
||||
|
||||
hi link pdcEmphasis Special
|
||||
hi link pdcSubscript Special
|
||||
hi link pdcSuperscript Special
|
||||
hi link pdcStrikeout Special
|
||||
|
||||
hi link pdcLinkText Underlined
|
||||
hi link pdcLinkID Identifier
|
||||
hi link pdcLinkURL Type
|
||||
hi link pdcLinkTitle Comment
|
||||
|
||||
hi link pdcFootnoteID Identifier
|
||||
hi link pdcFootnoteDef Comment
|
||||
hi link pandocFootnoteCont Error
|
||||
|
||||
hi link pdcCodeBlock String
|
||||
hi link pdcCodeHTMLPre String
|
||||
hi link pdcCodeHTMLCode String
|
||||
hi link pdcCode String
|
||||
hi link pdcCodeStart Comment
|
||||
hi link pdcCodeEnd Comment
|
||||
|
||||
hi link pandocTitleBlock Comment
|
||||
|
||||
hi link pdcTableMultiStart Comment
|
||||
hi link pdcTableMultiEnd Comment
|
||||
hi link pdcTableHeader Define
|
||||
hi link pdcTableMultiHeader Define
|
||||
hi link pdcTableBody Identifier
|
||||
hi link pdcTableMultiBody Identifier
|
||||
hi link pdcTableCaption Label
|
||||
hi link pdcTableMultiCaption Label
|
||||
hi link pdcTableCaptionCont Label
|
||||
|
||||
hi link pdcNewLine Error
|
||||
|
||||
|
||||
" For testing
|
||||
hi link pdctest Error
|
||||
|
||||
|
||||
let b:current_syntax = "pandoc"
|
||||
|
||||
@@ -0,0 +1,375 @@
|
||||
" Vim syntax file
|
||||
" Language: Python
|
||||
" Maintainer: Dmitry Vasiliev <dima@hlabs.spb.ru>
|
||||
" URL: http://www.hlabs.spb.ru/vim/python.vim
|
||||
" Last Change: 2010-04-09
|
||||
" Filenames: *.py
|
||||
" Version: 2.6.6
|
||||
"
|
||||
" Based on python.vim (from Vim 6.1 distribution)
|
||||
" by Neil Schemenauer <nas@python.ca>
|
||||
"
|
||||
" Thanks:
|
||||
"
|
||||
" Jeroen Ruigrok van der Werven
|
||||
" for the idea to highlight erroneous operators
|
||||
" Pedro Algarvio
|
||||
" for the patch to enable spell checking only for the right spots
|
||||
" (strings and comments)
|
||||
" John Eikenberry
|
||||
" for the patch fixing small typo
|
||||
" Caleb Adamantine
|
||||
" for the patch fixing highlighting for decorators
|
||||
" Andrea Riciputi
|
||||
" for the patch with new configuration options
|
||||
|
||||
"
|
||||
" Options:
|
||||
"
|
||||
" For set option do: let OPTION_NAME = 1
|
||||
" For clear option do: let OPTION_NAME = 0
|
||||
"
|
||||
" Option names:
|
||||
"
|
||||
" For highlight builtin functions and objects:
|
||||
" python_highlight_builtins
|
||||
"
|
||||
" For highlight builtin objects:
|
||||
" python_highlight_builtin_objs
|
||||
"
|
||||
" For highlight builtin funtions:
|
||||
" python_highlight_builtin_funcs
|
||||
"
|
||||
" For highlight standard exceptions:
|
||||
" python_highlight_exceptions
|
||||
"
|
||||
" For highlight string formatting:
|
||||
" python_highlight_string_formatting
|
||||
"
|
||||
" For highlight str.format syntax:
|
||||
" python_highlight_string_format
|
||||
"
|
||||
" For highlight string.Template syntax:
|
||||
" python_highlight_string_templates
|
||||
"
|
||||
" For highlight indentation errors:
|
||||
" python_highlight_indent_errors
|
||||
"
|
||||
" For highlight trailing spaces:
|
||||
" python_highlight_space_errors
|
||||
"
|
||||
" For highlight doc-tests:
|
||||
" python_highlight_doctests
|
||||
"
|
||||
" If you want all Python highlightings above:
|
||||
" python_highlight_all
|
||||
" (This option not override previously set options)
|
||||
"
|
||||
" For fast machines:
|
||||
" python_slow_sync
|
||||
"
|
||||
" For "print" builtin as function:
|
||||
" python_print_as_function
|
||||
|
||||
" For version 5.x: Clear all syntax items
|
||||
" For version 6.x: Quit when a syntax file was already loaded
|
||||
if version < 600
|
||||
syntax clear
|
||||
elseif exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
if exists("python_highlight_all") && python_highlight_all != 0
|
||||
" Not override previously set options
|
||||
if !exists("python_highlight_builtins")
|
||||
if !exists("python_highlight_builtin_objs")
|
||||
let python_highlight_builtin_objs = 1
|
||||
endif
|
||||
if !exists("python_highlight_builtin_funcs")
|
||||
let python_highlight_builtin_funcs = 1
|
||||
endif
|
||||
endif
|
||||
if !exists("python_highlight_exceptions")
|
||||
let python_highlight_exceptions = 1
|
||||
endif
|
||||
if !exists("python_highlight_string_formatting")
|
||||
let python_highlight_string_formatting = 1
|
||||
endif
|
||||
if !exists("python_highlight_string_format")
|
||||
let python_highlight_string_format = 1
|
||||
endif
|
||||
if !exists("python_highlight_string_templates")
|
||||
let python_highlight_string_templates = 1
|
||||
endif
|
||||
if !exists("python_highlight_indent_errors")
|
||||
let python_highlight_indent_errors = 1
|
||||
endif
|
||||
if !exists("python_highlight_space_errors")
|
||||
let python_highlight_space_errors = 1
|
||||
endif
|
||||
if !exists("python_highlight_doctests")
|
||||
let python_highlight_doctests = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
" Keywords
|
||||
syn keyword pythonStatement break continue del
|
||||
syn keyword pythonStatement exec return
|
||||
syn keyword pythonStatement pass raise
|
||||
syn keyword pythonStatement global assert
|
||||
syn keyword pythonStatement lambda yield
|
||||
syn keyword pythonStatement with
|
||||
syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite
|
||||
syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" display contained
|
||||
syn keyword pythonRepeat for while
|
||||
syn keyword pythonConditional if elif else
|
||||
syn keyword pythonPreCondit import from as
|
||||
syn keyword pythonException try except finally
|
||||
syn keyword pythonOperator and in is not or
|
||||
|
||||
if !exists("python_print_as_function") || python_print_as_function == 0
|
||||
syn keyword pythonStatement print
|
||||
endif
|
||||
|
||||
" Decorators (new in Python 2.4)
|
||||
syn match pythonDecorator "@" display nextgroup=pythonDottedName skipwhite
|
||||
syn match pythonDottedName "[a-zA-Z_][a-zA-Z0-9_]*\(\.[a-zA-Z_][a-zA-Z0-9_]*\)*" display contained
|
||||
syn match pythonDot "\." display containedin=pythonDottedName
|
||||
|
||||
" Comments
|
||||
syn match pythonComment "#.*$" display contains=pythonTodo,@Spell
|
||||
syn match pythonRun "\%^#!.*$"
|
||||
syn match pythonCoding "\%^.*\(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$"
|
||||
syn keyword pythonTodo TODO FIXME XXX contained
|
||||
|
||||
" Errors
|
||||
syn match pythonError "\<\d\+\D\+\>" display
|
||||
syn match pythonError "[$?]" display
|
||||
syn match pythonError "[&|]\{2,}" display
|
||||
syn match pythonError "[=]\{3,}" display
|
||||
|
||||
" TODO: Mixing spaces and tabs also may be used for pretty formatting multiline
|
||||
" statements. For now I don't know how to work around this.
|
||||
if exists("python_highlight_indent_errors") && python_highlight_indent_errors != 0
|
||||
syn match pythonIndentError "^\s*\( \t\|\t \)\s*\S"me=e-1 display
|
||||
endif
|
||||
|
||||
" Trailing space errors
|
||||
if exists("python_highlight_space_errors") && python_highlight_space_errors != 0
|
||||
syn match pythonSpaceError "\s\+$" display
|
||||
endif
|
||||
|
||||
" Strings
|
||||
syn region pythonString start=+[bB]\='+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonEscape,pythonEscapeError,@Spell
|
||||
syn region pythonString start=+[bB]\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonEscape,pythonEscapeError,@Spell
|
||||
syn region pythonString start=+[bB]\="""+ end=+"""+ keepend contains=pythonEscape,pythonEscapeError,pythonDocTest2,pythonSpaceError,@Spell
|
||||
syn region pythonString start=+[bB]\='''+ end=+'''+ keepend contains=pythonEscape,pythonEscapeError,pythonDocTest,pythonSpaceError,@Spell
|
||||
|
||||
syn match pythonEscape +\\[abfnrtv'"\\]+ display contained
|
||||
syn match pythonEscape "\\\o\o\=\o\=" display contained
|
||||
syn match pythonEscapeError "\\\o\{,2}[89]" display contained
|
||||
syn match pythonEscape "\\x\x\{2}" display contained
|
||||
syn match pythonEscapeError "\\x\x\=\X" display contained
|
||||
syn match pythonEscape "\\$"
|
||||
|
||||
" Unicode strings
|
||||
syn region pythonUniString start=+[uU]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,@Spell
|
||||
syn region pythonUniString start=+[uU]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,@Spell
|
||||
syn region pythonUniString start=+[uU]"""+ end=+"""+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
|
||||
syn region pythonUniString start=+[uU]'''+ end=+'''+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
|
||||
|
||||
syn match pythonUniEscape "\\u\x\{4}" display contained
|
||||
syn match pythonUniEscapeError "\\u\x\{,3}\X" display contained
|
||||
syn match pythonUniEscape "\\U\x\{8}" display contained
|
||||
syn match pythonUniEscapeError "\\U\x\{,7}\X" display contained
|
||||
syn match pythonUniEscape "\\N{[A-Z ]\+}" display contained
|
||||
syn match pythonUniEscapeError "\\N{[^A-Z ]\+}" display contained
|
||||
|
||||
" Raw strings
|
||||
syn region pythonRawString start=+[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell
|
||||
syn region pythonRawString start=+[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell
|
||||
syn region pythonRawString start=+[rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell
|
||||
syn region pythonRawString start=+[rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell
|
||||
|
||||
syn match pythonRawEscape +\\['"]+ display transparent contained
|
||||
|
||||
" Unicode raw strings
|
||||
syn region pythonUniRawString start=+[uU][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell
|
||||
syn region pythonUniRawString start=+[uU][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell
|
||||
syn region pythonUniRawString start=+[uU][rR]"""+ end=+"""+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest2,pythonSpaceError,@Spell
|
||||
syn region pythonUniRawString start=+[uU][rR]'''+ end=+'''+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest,pythonSpaceError,@Spell
|
||||
|
||||
syn match pythonUniRawEscape "\([^\\]\(\\\\\)*\)\@<=\\u\x\{4}" display contained
|
||||
syn match pythonUniRawEscapeError "\([^\\]\(\\\\\)*\)\@<=\\u\x\{,3}\X" display contained
|
||||
|
||||
if exists("python_highlight_string_formatting") && python_highlight_string_formatting != 0
|
||||
" String formatting
|
||||
syn match pythonStrFormatting "%\(([^)]\+)\)\=[-#0 +]*\d*\(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
|
||||
syn match pythonStrFormatting "%[-#0 +]*\(\*\|\d\+\)\=\(\.\(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
|
||||
endif
|
||||
|
||||
if exists("python_highlight_string_format") && python_highlight_string_format != 0
|
||||
" str.format syntax
|
||||
syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
|
||||
syn match pythonStrFormat "{\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)\(\.[a-zA-Z_][a-zA-Z0-9_]*\|\[\(\d\+\|[^!:\}]\+\)\]\)*\(![rs]\)\=\(:\({\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)}\|\([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*\(\.\d\+\)\=[bcdeEfFgGnoxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
|
||||
endif
|
||||
|
||||
if exists("python_highlight_string_templates") && python_highlight_string_templates != 0
|
||||
" String templates
|
||||
syn match pythonStrTemplate "\$\$" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
|
||||
syn match pythonStrTemplate "\${[a-zA-Z_][a-zA-Z0-9_]*}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
|
||||
syn match pythonStrTemplate "\$[a-zA-Z_][a-zA-Z0-9_]*" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
|
||||
endif
|
||||
|
||||
if exists("python_highlight_doctests") && python_highlight_doctests != 0
|
||||
" DocTests
|
||||
syn region pythonDocTest start="^\s*>>>" end=+'''+he=s-1 end="^\s*$" contained
|
||||
syn region pythonDocTest2 start="^\s*>>>" end=+"""+he=s-1 end="^\s*$" contained
|
||||
endif
|
||||
|
||||
" Numbers (ints, longs, floats, complex)
|
||||
syn match pythonHexError "\<0[xX]\x*[g-zG-Z]\x*[lL]\=\>" display
|
||||
|
||||
syn match pythonHexNumber "\<0[xX]\x\+[lL]\=\>" display
|
||||
syn match pythonOctNumber "\<0[oO]\o\+[lL]\=\>" display
|
||||
syn match pythonBinNumber "\<0[bB][01]\+[lL]\=\>" display
|
||||
|
||||
syn match pythonNumber "\<\d\+[lLjJ]\=\>" display
|
||||
|
||||
syn match pythonFloat "\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>" display
|
||||
syn match pythonFloat "\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display
|
||||
syn match pythonFloat "\<\d\+\.\d*\([eE][+-]\=\d\+\)\=[jJ]\=" display
|
||||
|
||||
syn match pythonOctError "\<0[oO]\=\o*[8-9]\d*[lL]\=\>" display
|
||||
syn match pythonBinError "\<0[bB][01]*[2-9]\d*[lL]\=\>" display
|
||||
|
||||
if exists("python_highlight_builtin_objs") && python_highlight_builtin_objs != 0
|
||||
" Builtin objects and types
|
||||
syn keyword pythonBuiltinObj True False Ellipsis None NotImplemented
|
||||
syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__
|
||||
endif
|
||||
|
||||
if exists("python_highlight_builtin_funcs") && python_highlight_builtin_funcs != 0
|
||||
" Builtin functions
|
||||
syn keyword pythonBuiltinFunc __import__ abs all any apply
|
||||
syn keyword pythonBuiltinFunc basestring bin bool buffer bytearray bytes callable
|
||||
syn keyword pythonBuiltinFunc chr classmethod cmp coerce compile complex
|
||||
syn keyword pythonBuiltinFunc delattr dict dir divmod enumerate eval
|
||||
syn keyword pythonBuiltinFunc execfile file filter float format frozenset getattr
|
||||
syn keyword pythonBuiltinFunc globals hasattr hash help hex id
|
||||
syn keyword pythonBuiltinFunc input int intern isinstance
|
||||
syn keyword pythonBuiltinFunc issubclass iter len list locals long map max
|
||||
syn keyword pythonBuiltinFunc min next object oct open ord
|
||||
syn keyword pythonBuiltinFunc pow property range
|
||||
syn keyword pythonBuiltinFunc raw_input reduce reload repr
|
||||
syn keyword pythonBuiltinFunc reversed round set setattr
|
||||
syn keyword pythonBuiltinFunc slice sorted staticmethod str sum super tuple
|
||||
syn keyword pythonBuiltinFunc type unichr unicode vars xrange zip
|
||||
|
||||
if exists("python_print_as_function") && python_print_as_function != 0
|
||||
syn keyword pythonBuiltinFunc print
|
||||
endif
|
||||
endif
|
||||
|
||||
if exists("python_highlight_exceptions") && python_highlight_exceptions != 0
|
||||
" Builtin exceptions and warnings
|
||||
syn keyword pythonExClass BaseException
|
||||
syn keyword pythonExClass Exception StandardError ArithmeticError
|
||||
syn keyword pythonExClass LookupError EnvironmentError
|
||||
|
||||
syn keyword pythonExClass AssertionError AttributeError BufferError EOFError
|
||||
syn keyword pythonExClass FloatingPointError GeneratorExit IOError
|
||||
syn keyword pythonExClass ImportError IndexError KeyError
|
||||
syn keyword pythonExClass KeyboardInterrupt MemoryError NameError
|
||||
syn keyword pythonExClass NotImplementedError OSError OverflowError
|
||||
syn keyword pythonExClass ReferenceError RuntimeError StopIteration
|
||||
syn keyword pythonExClass SyntaxError IndentationError TabError
|
||||
syn keyword pythonExClass SystemError SystemExit TypeError
|
||||
syn keyword pythonExClass UnboundLocalError UnicodeError
|
||||
syn keyword pythonExClass UnicodeEncodeError UnicodeDecodeError
|
||||
syn keyword pythonExClass UnicodeTranslateError ValueError VMSError
|
||||
syn keyword pythonExClass WindowsError ZeroDivisionError
|
||||
|
||||
syn keyword pythonExClass Warning UserWarning BytesWarning DeprecationWarning
|
||||
syn keyword pythonExClass PendingDepricationWarning SyntaxWarning
|
||||
syn keyword pythonExClass RuntimeWarning FutureWarning
|
||||
syn keyword pythonExClass ImportWarning UnicodeWarning
|
||||
endif
|
||||
|
||||
if exists("python_slow_sync") && python_slow_sync != 0
|
||||
syn sync minlines=2000
|
||||
else
|
||||
" This is fast but code inside triple quoted strings screws it up. It
|
||||
" is impossible to fix because the only way to know if you are inside a
|
||||
" triple quoted string is to start from the beginning of the file.
|
||||
syn sync match pythonSync grouphere NONE "):$"
|
||||
syn sync maxlines=200
|
||||
endif
|
||||
|
||||
if version >= 508 || !exists("did_python_syn_inits")
|
||||
if version <= 508
|
||||
let did_python_syn_inits = 1
|
||||
command -nargs=+ HiLink hi link <args>
|
||||
else
|
||||
command -nargs=+ HiLink hi def link <args>
|
||||
endif
|
||||
|
||||
HiLink pythonStatement Statement
|
||||
HiLink pythonPreCondit Statement
|
||||
HiLink pythonFunction Function
|
||||
HiLink pythonConditional Conditional
|
||||
HiLink pythonRepeat Repeat
|
||||
HiLink pythonException Exception
|
||||
HiLink pythonOperator Operator
|
||||
|
||||
HiLink pythonDecorator Define
|
||||
HiLink pythonDottedName Function
|
||||
HiLink pythonDot Normal
|
||||
|
||||
HiLink pythonComment Comment
|
||||
HiLink pythonCoding Special
|
||||
HiLink pythonRun Special
|
||||
HiLink pythonTodo Todo
|
||||
|
||||
HiLink pythonError Error
|
||||
HiLink pythonIndentError Error
|
||||
HiLink pythonSpaceError Error
|
||||
|
||||
HiLink pythonString String
|
||||
HiLink pythonUniString String
|
||||
HiLink pythonRawString String
|
||||
HiLink pythonUniRawString String
|
||||
|
||||
HiLink pythonEscape Special
|
||||
HiLink pythonEscapeError Error
|
||||
HiLink pythonUniEscape Special
|
||||
HiLink pythonUniEscapeError Error
|
||||
HiLink pythonUniRawEscape Special
|
||||
HiLink pythonUniRawEscapeError Error
|
||||
|
||||
HiLink pythonStrFormatting Special
|
||||
HiLink pythonStrFormat Special
|
||||
HiLink pythonStrTemplate Special
|
||||
|
||||
HiLink pythonDocTest Special
|
||||
HiLink pythonDocTest2 Special
|
||||
|
||||
HiLink pythonNumber Number
|
||||
HiLink pythonHexNumber Number
|
||||
HiLink pythonOctNumber Number
|
||||
HiLink pythonBinNumber Number
|
||||
HiLink pythonFloat Float
|
||||
HiLink pythonOctError Error
|
||||
HiLink pythonHexError Error
|
||||
HiLink pythonBinError Error
|
||||
|
||||
HiLink pythonBuiltinObj Structure
|
||||
HiLink pythonBuiltinFunc Function
|
||||
|
||||
HiLink pythonExClass Structure
|
||||
|
||||
delcommand HiLink
|
||||
endif
|
||||
|
||||
let b:current_syntax = "python"
|
||||
runtime plugin/rainbow_parenthsis.vim
|
||||
Reference in New Issue
Block a user