adding new stuff
This commit is contained in:
parent
f84d7183aa
commit
9ef8a96f9a
1580 changed files with 0 additions and 0 deletions
7
plugins/bundle/xptemplate/ftplugin/README
Normal file
7
plugins/bundle/xptemplate/ftplugin/README
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
You should *NOT* be here.
|
||||
|
||||
Please keep in mind that you should *NEVER* modify files in this folder.
|
||||
|
||||
I supposed you are here to add new snippets or refine some of them.
|
||||
Please do it in ./personal folder. See :h xpt-personal-folder .
|
||||
11
plugins/bundle/xptemplate/ftplugin/_comment/c.like.xpt.vim
Normal file
11
plugins/bundle/xptemplate/ftplugin/_comment/c.like.xpt.vim
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
" NOTE: You can include this file into which uses C comment format. But It is
|
||||
" recommended to include _comment/doubleSign (or singleSign,
|
||||
" singleDouble) directly.
|
||||
XPTemplate priority=like
|
||||
|
||||
XPTvar $CL /*
|
||||
XPTvar $CM *
|
||||
XPTvar $CR */
|
||||
|
||||
XPTinclude
|
||||
\ _comment/doubleSign
|
||||
13
plugins/bundle/xptemplate/ftplugin/_comment/cpp.like.xpt.vim
Normal file
13
plugins/bundle/xptemplate/ftplugin/_comment/cpp.like.xpt.vim
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
" NOTE: You can include this file into which uses CPP comment format. But It
|
||||
" is recommended to include _comment/doubleSign (or singleSign,
|
||||
" singleDouble) directly.
|
||||
XPTemplate priority=like-
|
||||
|
||||
XPTvar $CL /*
|
||||
XPTvar $CM *
|
||||
XPTvar $CR */
|
||||
|
||||
XPTvar $CS //
|
||||
|
||||
XPTinclude
|
||||
\ _comment/singleDouble
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
XPTemplate priority=all-
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
" snippets for language whose comment sign is 2 signs, like c:"/* */"
|
||||
" TODO friendly cursor place holder
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
|
||||
fun! s:f._xCommentMidIndent()
|
||||
let l = self.GetVar( '$CL' )
|
||||
let m = self.GetVar( '$CM' )
|
||||
|
||||
if len( l ) <= len( m )
|
||||
return ''
|
||||
else
|
||||
return ' '[ : len( l ) - len( m ) - 1 ]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
fun! s:f._xCommentLeftWithoutMid()
|
||||
let l = self.GetVar( '$CL' )
|
||||
let m = self.GetVar( '$CM' )
|
||||
|
||||
if l == '' || m == ''
|
||||
return l
|
||||
endif
|
||||
|
||||
if l[ -len( m ) : ] == m
|
||||
return l[ : -len( m ) -1 ]
|
||||
else
|
||||
return l
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
XPT _d_comment hidden wrap=what " $CL .. $CR
|
||||
`$CL^ `what^^ `$CR^`^
|
||||
|
||||
|
||||
XPT _d_commentBlock hidden wrap " $CL ..
|
||||
`$_xCommentLeftWithoutMid^`$CM `cursor^
|
||||
`$_xCommentMidIndent$CR^
|
||||
|
||||
|
||||
XPT _d_commentDoc hidden wrap " $CL$CM ..
|
||||
`$CL^`$CM^
|
||||
`$_xCommentMidIndent$CM `cursor^
|
||||
`$_xCommentMidIndent$CR^
|
||||
|
||||
|
||||
XPT _d_commentLine hidden wrap=what " $CL .. $CR
|
||||
XSET what=
|
||||
`$CL `what` $CR^`^
|
||||
|
||||
|
||||
XPT comment alias=_d_comment
|
||||
XPT commentBlock alias=_d_commentBlock
|
||||
XPT commentDoc alias=_d_commentDoc
|
||||
XPT commentLine alias=_d_commentLine
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
XPTemplate priority=all-2
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _comment/common
|
||||
\ _comment/singleSign
|
||||
\ _comment/doubleSign
|
||||
|
||||
|
||||
|
||||
|
||||
XPT comment alias=_d_comment
|
||||
XPT commentBlock alias=_d_commentBlock
|
||||
XPT commentDoc alias=_d_commentDoc
|
||||
XPT commentLine alias=_s_commentLine
|
||||
XPT commentLine2 alias=_d_commentLine
|
||||
|
||||
|
||||
|
||||
42
plugins/bundle/xptemplate/ftplugin/_comment/pattern.xpt.vim
Normal file
42
plugins/bundle/xptemplate/ftplugin/_comment/pattern.xpt.vim
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
" priority is a bit lower than 'spec'
|
||||
XPTemplate priority=spec+
|
||||
|
||||
echom "_comment/pattern is deprecated."
|
||||
|
||||
|
||||
" XPTvar $CL Warn_$CL_IS_NOT_SET
|
||||
" XPTvar $CM Warn_$CM_IS_NOT_SET
|
||||
" XPTvar $CR Warn_$CR_IS_NOT_SET
|
||||
" XPTvar $CS Warn_$CS_IS_NOT_SET
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
if has_key(s:v, '$CL') && has_key(s:v, '$CR')
|
||||
|
||||
call XPTdefineSnippet('cc', {'hint' : '$CL $CR'}, [ '`$CL^ `cursor^ `$CR^' ])
|
||||
call XPTdefineSnippet('cc_', {'hint' : '$CL ... $CR'}, [ '`$CL^ `wrapped^ `$CR^' ])
|
||||
|
||||
" block comment
|
||||
call XPTdefineSnippet('cb', {'hint' : '$CL ...'}, [
|
||||
\'`$CL^',
|
||||
\' `$CM^ `cursor^',
|
||||
\' `$CR^' ])
|
||||
|
||||
" block doc comment
|
||||
call XPTdefineSnippet('cd', {'hint' : '$CL$CM ...'}, [
|
||||
\'`$CL^`$CM^',
|
||||
\' `$CM^ `cursor^',
|
||||
\' `$CR^' ])
|
||||
|
||||
endif
|
||||
|
||||
" line comment
|
||||
if has_key(s:v, '$CS')
|
||||
call XPTdefineSnippet('cl', {'hint' : '$CS'}, [ '`$CS^ `cursor^' ])
|
||||
|
||||
else
|
||||
call XPTdefineSnippet('cl', {'hint' : '$CL .. $CR'}, [ '`$CL^ `cursor^ `$CR^' ])
|
||||
|
||||
endif
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
XPTemplate priority=all-2
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _comment/common
|
||||
\ _comment/singleSign
|
||||
\ _comment/doubleSign
|
||||
|
||||
|
||||
|
||||
|
||||
XPT comment alias=_s_comment
|
||||
XPT commentBlock alias=_s_commentBlock
|
||||
XPT commentDoc alias=_d_commentDoc
|
||||
XPT commentLine alias=_s_commentLine
|
||||
XPT commentLine2 alias=_d_commentLine
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
XPTemplate priority=all-
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _comment/common
|
||||
|
||||
|
||||
|
||||
XPT _s_comment hidden wrap " $CS ..
|
||||
`$CS `cursor^
|
||||
|
||||
|
||||
XPT _s_commentBlock hidden wrap " $CS ..
|
||||
`$CS `cursor^
|
||||
|
||||
|
||||
XPT _s_commentDoc hidden wrap " $CS ..
|
||||
`$CS^
|
||||
`$CS `cursor^
|
||||
`$CS^
|
||||
|
||||
XPT _s_commentLine hidden wrap " $CS ..
|
||||
`$CS `cursor^
|
||||
|
||||
|
||||
XPT comment alias=_s_comment
|
||||
XPT commentBlock alias=_s_commentBlock
|
||||
XPT commentDoc alias=_s_commentDoc
|
||||
XPT commentLine alias=_s_commentLine
|
||||
|
||||
11
plugins/bundle/xptemplate/ftplugin/_comment/xml.xpt.vim
Normal file
11
plugins/bundle/xptemplate/ftplugin/_comment/xml.xpt.vim
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
" NOTE: You can include this file into which uses XML comment format. But It is
|
||||
" recommended to include _comment/doubleSign (or singleSign,
|
||||
" singleDouble) directly.
|
||||
XPTemplate priority=spec
|
||||
|
||||
XPTvar $CL <!--
|
||||
XPTvar $CR -->
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _comment/doubleSign
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
XPTemplate priority=all-
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
" draft increment implementation
|
||||
fun! s:f.CntD() "{{{
|
||||
let ctx = self.renderContext
|
||||
if !has_key(ctx, '__counter')
|
||||
let ctx.__counter = {}
|
||||
endif
|
||||
return ctx.__counter
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:f.CntStart(name, ...) "{{{
|
||||
let d = self.CntD()
|
||||
let i = a:0 >= 1 ? 0 + a:1 : 0
|
||||
let d[a:name] = 0 + i
|
||||
return ""
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:f.Cnt(name) "{{{
|
||||
let d = self.CntD()
|
||||
return d[a:name]
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:f.CntIncr(name, ...)"{{{
|
||||
let i = a:0 >= 1 ? 0 + a:1 : 1
|
||||
let d = self.CntD()
|
||||
|
||||
let d[a:name] += i
|
||||
return d[a:name]
|
||||
endfunction"}}}
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,187 @@
|
|||
XPTemplate priority=all
|
||||
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
|
||||
let s:pairs = { 'left' : "'" . '"([{<|*`+ ',
|
||||
\ 'right': "'" . '")]}>|*`+ ', }
|
||||
|
||||
|
||||
" TODO not perfect: hide right part if found right is already in input area.
|
||||
" use searchpair() to improve
|
||||
|
||||
let s:crIndent = 0
|
||||
|
||||
fun! s:f.BracketRightPart( leftReg )
|
||||
|
||||
if has_key( self._ctx.renderContext, 'bracketComplete' )
|
||||
return ''
|
||||
endif
|
||||
|
||||
let v = self.V()
|
||||
let v0 = v
|
||||
|
||||
let v = matchstr( v, a:leftReg )
|
||||
if v == ''
|
||||
return ''
|
||||
endif
|
||||
|
||||
let v = join( reverse( split( v, '\V\s\{-}' ) ), '')
|
||||
let v = tr( v, s:pairs.left, s:pairs.right )
|
||||
|
||||
if v0 =~ '\V\n\s\*\$'
|
||||
let v = matchstr( v, '\V\S\+' )
|
||||
return { "action" : "text", "nIndent" : -s:crIndent, "text" : "\n".v }
|
||||
else
|
||||
return v
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
fun! s:f.bkt_cmpl()
|
||||
return self.BracketRightPart( self._ctx.renderContext.leftReg )
|
||||
endfunction
|
||||
|
||||
fun! s:f.quote_cmpl()
|
||||
let r = self._ctx.renderContext
|
||||
let v = self.V()
|
||||
let v = matchstr( v, r.leftReg )
|
||||
|
||||
if has_key( r, 'bracketComplete' )
|
||||
return ''
|
||||
elseif v == ''
|
||||
return ''
|
||||
else
|
||||
return r.charRight
|
||||
endif
|
||||
endfunction
|
||||
|
||||
fun! s:f.quote_ontype()
|
||||
|
||||
let v = self.V()
|
||||
|
||||
if v == ''
|
||||
return self.Finish()
|
||||
|
||||
elseif v =~ '\V\n'
|
||||
|
||||
return self.FinishOuter( v )
|
||||
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
fun! s:f.bkt_ontype()
|
||||
|
||||
|
||||
let v = self.V()
|
||||
|
||||
if v == ''
|
||||
return self.Finish()
|
||||
|
||||
elseif v =~ '\V\n\s\*\$'
|
||||
|
||||
if &indentexpr != ''
|
||||
let indentexpr = substitute( &indentexpr, '\Vv:lnum', 'line(".")', '' )
|
||||
try
|
||||
let nNewLineIndent = eval( indentexpr )
|
||||
let s:crIndent = nNewLineIndent - indent( line( "." ) - 1 )
|
||||
catch /.*/
|
||||
let s:crIndent = self.NIndent()
|
||||
endtry
|
||||
else
|
||||
let s:crIndent = self.NIndent()
|
||||
endif
|
||||
|
||||
" create snippet indent. filter does not use actual indent string
|
||||
let n_indent = xpt#indent#ActualToSnippetNr(s:crIndent)
|
||||
let indent_str = repeat( ' ', n_indent )
|
||||
|
||||
let v = substitute( v, '\V\s\*\n\.\*', "\n", 'g' )
|
||||
|
||||
return self.FinishOuter( v . indent_str )
|
||||
|
||||
else
|
||||
" nothing todo
|
||||
return 0
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
fun! s:f.bkt_init( followingChar )
|
||||
let r = self._ctx.renderContext
|
||||
|
||||
let r.char = self.GetVar( '$_xSnipName' )
|
||||
let r.followingChar = a:followingChar
|
||||
let r.leftReg = '\V\^' . r.char . r.followingChar . '\?'
|
||||
|
||||
|
||||
let i = stridx( s:pairs.left, r.char )
|
||||
|
||||
if i != -1
|
||||
let r.charRight = s:pairs.right[ i ]
|
||||
|
||||
call XPTmapKey( r.charRight, 'bkt_finish(' . string( r.charRight ) . ')' )
|
||||
else
|
||||
let r.charRight = ''
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
fun! s:f.bkt_finish( keyPressed )
|
||||
|
||||
let r = self._ctx.renderContext
|
||||
|
||||
if a:keyPressed != r.charRight
|
||||
" may be outer snippet key bind
|
||||
return a:keyPressed
|
||||
endif
|
||||
|
||||
let r.bracketComplete = 1
|
||||
|
||||
let v = self.V()
|
||||
|
||||
if self.GetVar( '$SParg' ) == ' '
|
||||
|
||||
if v == r.char . r.followingChar
|
||||
return self.FinishOuter( r.char . r.charRight )
|
||||
else
|
||||
return self.FinishOuter( v . r.charRight )
|
||||
endif
|
||||
|
||||
else
|
||||
return self.FinishOuter( v . r.charRight )
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
|
||||
XPT _bracket hidden
|
||||
XSET s|pre=Echo('')
|
||||
XSET s|ontype=bkt_ontype()
|
||||
XSET s=bkt_init(' ')
|
||||
`$_xSnipName$SParg`s^`s^bkt_cmpl()^
|
||||
|
||||
XPT _quote hidden
|
||||
XSET s|pre=Echo('')
|
||||
XSET s|ontype=quote_ontype()
|
||||
XSET s=bkt_init('')
|
||||
`$_xSnipName`s^`s^quote_cmpl()^
|
||||
|
||||
|
||||
XPT ( hidden alias=_bracket
|
||||
XPT [ hidden alias=_bracket
|
||||
XPT { hidden alias=_bracket
|
||||
XPT < hidden alias=_bracket
|
||||
XPT ' hidden alias=_quote
|
||||
XPT " hidden alias=_quote
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
" disabled
|
||||
finish
|
||||
|
||||
|
||||
XPTemplate priority=all
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
fun! s:f.PathPumFrom( where )
|
||||
let paths = split( globpath( a:where, '*' ), "\n" )
|
||||
let paths = map( paths, 'v:val[len(' . string( a:where ) . '):]' )
|
||||
|
||||
return paths
|
||||
endfunction
|
||||
|
||||
fun! s:f.ExpPathPumFrom( base )
|
||||
" let prev = a:base . '/' . R( "p" )
|
||||
let p = self.R( "p" )
|
||||
let prev = a:base . p
|
||||
return prev == ''
|
||||
\ ? ''
|
||||
\ : self.Build( p . '`p^Choose( PathPumFrom( ' . string(prev) . ' ) )^' )
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
XPT FromHome " path starts from $HOME
|
||||
XSET p|post=ExpPathPumFrom($HOME)
|
||||
`p^Choose(PathPumFrom($HOME))^
|
||||
|
||||
|
||||
|
||||
XPT FromPwd " path starts from $PWD
|
||||
XSET p|post=Echo(R( "p" ) == '' ? '' : Build( R( "p" ) . '`p^Choose( PathPumFrom( $PWD . R( "p" ), 0 ) )^' ) )
|
||||
`p^Choose(PathPumFrom($PWD))^
|
||||
|
||||
|
||||
665
plugins/bundle/xptemplate/ftplugin/_common/common.xpt.vim
Normal file
665
plugins/bundle/xptemplate/ftplugin/_common/common.xpt.vim
Normal file
|
|
@ -0,0 +1,665 @@
|
|||
" Default settings and functions used in every snippet file.
|
||||
XPTemplate priority=all
|
||||
|
||||
" containers
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $author $author is not set, you need to set g:xptemplate_vars="$author=your_name" in .vimrc
|
||||
XPTvar $email $email is not set, you need to set g:xptemplate_vars="$email=your_email@com" in .vimrc
|
||||
|
||||
XPTvar $VOID
|
||||
|
||||
" if () ** {
|
||||
" else ** {
|
||||
XPTvar $BRif ' '
|
||||
|
||||
" } ** else {
|
||||
XPTvar $BRel \n
|
||||
|
||||
" for () ** {
|
||||
" while () ** {
|
||||
" do ** {
|
||||
XPTvar $BRloop ' '
|
||||
|
||||
" struct name ** {
|
||||
XPTvar $BRstc ' '
|
||||
|
||||
" int fun() ** {
|
||||
" class name ** {
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
|
||||
" int fun ** (
|
||||
" class name ** (
|
||||
XPTvar $SPfun ''
|
||||
|
||||
" int fun( ** arg ** )
|
||||
" if ( ** condition ** )
|
||||
" for ( ** statement ** )
|
||||
" [ ** a, b ** ]
|
||||
" { ** 'k' : 'v' ** }
|
||||
XPTvar $SParg ' '
|
||||
|
||||
" if ** (
|
||||
" while ** (
|
||||
" for ** (
|
||||
XPTvar $SPcmd ' '
|
||||
|
||||
" a ** = ** b
|
||||
" a = a ** + ** 1
|
||||
" (a, ** b, ** )
|
||||
XPTvar $SPop ' '
|
||||
|
||||
|
||||
XPTvar $DATE_FMT '%Y %b %d'
|
||||
XPTvar $TIME_FMT '"%H:%M:%S"'
|
||||
XPTvar $DATETIME_FMT '%c'
|
||||
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL 0
|
||||
XPTvar $UNDEFINED 0
|
||||
|
||||
XPTvar $VOID_LINE
|
||||
XPTvar $CURSOR_PH CURSOR
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _common/personal
|
||||
\ _common/inlineComplete
|
||||
\ _common/common.*
|
||||
|
||||
let s:f_prototype = xpt#snipfunction#funcs
|
||||
call extend( s:f, s:f_prototype, 'error' )
|
||||
|
||||
|
||||
fun! s:f._xSnipName()
|
||||
return self._ctx.renderContext.snipObject.name
|
||||
endfunction
|
||||
|
||||
|
||||
fun! s:f.GetWrappedText()
|
||||
let wrap = self._ctx.renderContext.wrap
|
||||
|
||||
let [ l, r ] = self.ItemEdges()
|
||||
|
||||
if !has_key( wrap, 'text' )
|
||||
return 0
|
||||
endif
|
||||
|
||||
if l == '' && r == ''
|
||||
return { 'nIndent' : wrap.indent,
|
||||
\ 'action' : 'text',
|
||||
\ 'parseIndent' : 0,
|
||||
\ 'text' : wrap.text }
|
||||
else
|
||||
|
||||
let wrap.curline = wrap.lines[ 0 ]
|
||||
let wrap.lines = wrap.lines[ 1 : ]
|
||||
|
||||
return wrap.curline
|
||||
endif
|
||||
endfunction
|
||||
|
||||
fun! s:f.WrapAlignAfter( min )
|
||||
let wrap = self._ctx.renderContext.wrap
|
||||
let n = max( [ a:min, wrap.max ] ) - len( wrap.curline )
|
||||
return repeat( ' ', n )
|
||||
endfunction
|
||||
|
||||
fun! s:f.WrapAlignBefore( min )
|
||||
let wrap = self._ctx.renderContext.wrap
|
||||
let n = max( [ a:min, wrap.max ] ) - len( wrap.lines[ 0 ] )
|
||||
return repeat( ' ', n )
|
||||
endfunction
|
||||
|
||||
fun! s:f.Item()
|
||||
return get( self._ctx.renderContext, 'item', {} )
|
||||
endfunction
|
||||
|
||||
" current name
|
||||
fun! s:f.ItemName() "{{{
|
||||
return get( self.Item(), 'name', '' )
|
||||
endfunction "}}}
|
||||
let s:f.N = s:f.ItemName
|
||||
|
||||
" name with edge
|
||||
fun! s:f.ItemFullname() "{{{
|
||||
return get( self.Item(), 'fullname', '')
|
||||
endfunction "}}}
|
||||
let s:f.NN = s:f.ItemFullname
|
||||
|
||||
" current value user typed
|
||||
fun! s:f.ItemValue() dict "{{{
|
||||
return self.GetVar( '$UserInput' )
|
||||
endfunction "}}}
|
||||
let s:f.V = s:f.ItemValue
|
||||
|
||||
fun! s:f.PrevItem( n )
|
||||
let hist = get( self._ctx.renderContext, 'history', [] )
|
||||
return get( hist, a:n, {} )
|
||||
endfunction
|
||||
|
||||
fun! s:f.ItemInitValue()
|
||||
return get( self.Item(), 'initValue', '' )
|
||||
endfunction
|
||||
let s:f.IV = s:f.ItemInitValue
|
||||
|
||||
fun! s:f.ItemValueStripped( ... )
|
||||
let ptn = a:0 == 0 || a:1 =~ 'lr'
|
||||
\ ? '\V\^\s\*\|\s\*\$'
|
||||
\ : ( a:1 == 'l'
|
||||
\ ? '\V\^\s\*'
|
||||
\ : '\V\s\*\$' )
|
||||
return substitute( self.ItemValue(), ptn, '', 'g' )
|
||||
endfunction
|
||||
let s:f.VS = s:f.ItemValueStripped
|
||||
|
||||
|
||||
fun! s:f.ItemPos()
|
||||
return XPMposStartEnd( self._ctx.renderContext.leadingPlaceHolder.mark )
|
||||
endfunction
|
||||
|
||||
fun! s:f.ItemInitValueWithEdge()
|
||||
let [ l, r ] = self.ItemEdges()
|
||||
return l . self.IV() . r
|
||||
endfunction
|
||||
let s:f.IVE = s:f.ItemInitValueWithEdge
|
||||
|
||||
" if value match one of the regexps
|
||||
fun! s:f.Vmatch( ... )
|
||||
let v = self.V()
|
||||
for reg in a:000
|
||||
if match(v, reg) != -1
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" value matchstr
|
||||
fun! s:f.VMS( reg )
|
||||
return matchstr(self.V(), a:reg)
|
||||
endfunction
|
||||
|
||||
" edge stripped value
|
||||
fun! s:f.ItemStrippedValue()
|
||||
let v = self.V()
|
||||
|
||||
let [edgeLeft, edgeRight] = self.ItemEdges()
|
||||
|
||||
let v = substitute( v, '\V\^' . edgeLeft, '', '' )
|
||||
let v = substitute( v, '\V' . edgeRight . '\$', '', '' )
|
||||
|
||||
return v
|
||||
endfunction
|
||||
let s:f.V0 = s:f.ItemStrippedValue
|
||||
|
||||
fun! s:f.Phase() dict
|
||||
return get( self._ctx.renderContext, 'phase', '' )
|
||||
endfunction
|
||||
|
||||
" TODO this is not needed at all except as a shortcut.
|
||||
" equals to expand()
|
||||
fun! s:f.E(s) "{{{
|
||||
return expand(a:s)
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
" return the context
|
||||
fun! s:f.Context() "{{{
|
||||
return self._ctx.renderContext
|
||||
endfunction "}}}
|
||||
let s:f.C = s:f.Context
|
||||
|
||||
|
||||
" TODO this is not needed at all except as a shortcut.
|
||||
" post filter substitute
|
||||
fun! s:f.S(str, ptn, rep, ...) "{{{
|
||||
let flg = a:0 >= 1 ? a:1 : 'g'
|
||||
return substitute(a:str, a:ptn, a:rep, flg)
|
||||
endfunction "}}}
|
||||
|
||||
" equals to S(C().value, ...)
|
||||
fun! s:f.SubstituteWithValue(ptn, rep, ...) "{{{
|
||||
let flg = a:0 >= 1 ? a:1 : 'g'
|
||||
return substitute(self.V(), a:ptn, a:rep, flg)
|
||||
endfunction "}}}
|
||||
let s:f.SV = s:f.SubstituteWithValue
|
||||
|
||||
|
||||
fun! s:f.HasStep( name )
|
||||
let namedStep = get( self._ctx.renderContext, 'namedStep', {} )
|
||||
return has_key( namedStep, a:name )
|
||||
endfunction
|
||||
|
||||
" reference to another finished item value
|
||||
fun! s:f.Reference(name) "{{{
|
||||
let namedStep = get( self._ctx.renderContext, 'namedStep', {} )
|
||||
return get( namedStep, a:name, '' )
|
||||
endfunction "}}}
|
||||
let s:f.R = s:f.Reference
|
||||
|
||||
fun! s:f.Snippet( name )
|
||||
return get( self._ctx.renderContext.ftScope.allTemplates, a:name, { 'tmpl' : '' } )[ 'tmpl' ]
|
||||
endfunction
|
||||
|
||||
" black hole
|
||||
fun! s:f.Void(...) "{{{
|
||||
return ""
|
||||
endfunction "}}}
|
||||
let s:f.VOID = s:f.Void
|
||||
|
||||
" Echo several expression and concat them.
|
||||
" That's the way to use normal vim script expression instead of mixed string
|
||||
fun! s:f.Echo( ... )
|
||||
let text = ''
|
||||
if a:0 > 0
|
||||
let text = a:1
|
||||
endif
|
||||
return { 'action': 'text', 'text': text }
|
||||
endfunction
|
||||
|
||||
fun! s:f.EchoIf( isTrue, ... )
|
||||
if a:isTrue
|
||||
return join( a:000, '' )
|
||||
else
|
||||
return self.V()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
fun! s:f.EchoIfEq( expected, ... )
|
||||
if self.V() ==# a:expected
|
||||
return join( a:000, '' )
|
||||
else
|
||||
return self.V()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
fun! s:f.EchoIfNoChange( ... )
|
||||
if self.V0() ==# self.ItemName()
|
||||
return join( a:000, '' )
|
||||
else
|
||||
return self.V()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
fun! s:f.Commentize( text )
|
||||
if has_key( self, '$CL' )
|
||||
return self[ '$CL' ] . ' ' . a:text . ' ' . self[ '$CR' ]
|
||||
|
||||
elseif has_key( self, '$CS' )
|
||||
return self[ '$CS' ] . ' ' . a:text
|
||||
|
||||
endif
|
||||
|
||||
return a:text
|
||||
endfunction
|
||||
|
||||
fun! s:f.VoidLine()
|
||||
return self.Commentize( 'void' )
|
||||
endfunction
|
||||
|
||||
" Same with Echo* except echoed text is to be build to generate dynamic place
|
||||
" holders
|
||||
fun! s:f.Build( ... )
|
||||
return { 'action' : 'build', 'text' : join( a:000, '' ) }
|
||||
endfunction
|
||||
|
||||
let s:f.Embed = s:f.Build
|
||||
|
||||
fun! s:f.BuildSnippet( snipname )
|
||||
return { 'action' : 'build', 'snippet' : a:snipname }
|
||||
endfunction
|
||||
|
||||
fun! s:f.BuildIfChanged( ... )
|
||||
let v = substitute( self.V(), "\\V\n\\|\\s", '', 'g')
|
||||
" let fn = substitute( self.ItemFullname(), "\\V\n\\|\\s", '', 'g')
|
||||
let fn = substitute( self.ItemInitValueWithEdge(), "\\V\n\\|\\s", '', 'g')
|
||||
|
||||
if v ==# fn || v == ''
|
||||
return ''
|
||||
else
|
||||
return { 'action' : 'build', 'text' : join( a:000, '' ) }
|
||||
endif
|
||||
endfunction
|
||||
|
||||
fun! s:f.BuildIfNoChange( ... )
|
||||
let v = substitute( self.V(), "\\V\n\\|\\s", '', 'g')
|
||||
" let fn = substitute( self.ItemFullname(), "\\V\n\\|\\s", '', 'g')
|
||||
let fn = substitute( self.ItemInitValueWithEdge(), "\\V\n\\|\\s", '', 'g')
|
||||
|
||||
|
||||
if v ==# fn
|
||||
return { 'action' : 'build', 'text' : join( a:000, '' ) }
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" trigger nested template
|
||||
fun! s:f.Trigger( name ) "{{{
|
||||
return {'action' : 'expandTmpl', 'tmplName' : a:name}
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! s:f.Finish(...)
|
||||
|
||||
let opt = {}
|
||||
if a:0 > 0
|
||||
let opt.text = a:1
|
||||
endif
|
||||
return self.Fin(opt)
|
||||
endfunction
|
||||
|
||||
fun! s:f.FinishOuter( ... )
|
||||
|
||||
let opt = {"marks" : "mark"}
|
||||
if a:0 > 0
|
||||
let opt.text = a:1
|
||||
endif
|
||||
return self.Fin(opt)
|
||||
endfunction
|
||||
|
||||
fun! s:f.FinishInner( ... )
|
||||
|
||||
let opt = {"marks" : "innerMarks"}
|
||||
if a:0 > 0
|
||||
let opt.text = a:1
|
||||
endif
|
||||
return self.Fin(opt)
|
||||
endfunction
|
||||
|
||||
fun! s:f.Fin(opt)
|
||||
" there is still items left
|
||||
if ! empty( self._ctx.renderContext.itemList )
|
||||
return get(a:opt, 'text', 0)
|
||||
endif
|
||||
|
||||
let r = {'action' : 'finishTemplate'}
|
||||
if has_key(a:opt, 'text')
|
||||
let r.text = a:opt.text
|
||||
endif
|
||||
if has_key(a:opt, 'marks')
|
||||
let r.marks = a:opt.marks
|
||||
endif
|
||||
|
||||
return r
|
||||
endfunction
|
||||
|
||||
fun! s:f.Next( ... )
|
||||
if a:0 == 0
|
||||
return { 'nav' : 'next' }
|
||||
else
|
||||
return { 'nav' : 'next', 'text' : join( a:000, '' ) }
|
||||
endif
|
||||
endfunction
|
||||
|
||||
fun! s:f.Remove()
|
||||
return { 'action' : 'text', 'nav' : 'next', 'text' : '' }
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
" This function is intended to be used for popup selection :
|
||||
" XSET bidule=Choose([' ','dabadi','dabada'])
|
||||
fun! s:f.Choose( lst, ... ) "{{{
|
||||
let val = { 'action' : 'pum', 'pum' : a:lst }
|
||||
|
||||
if a:0 == 1
|
||||
let val.acceptEmpty = a:1 != 0
|
||||
endif
|
||||
|
||||
return val
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:f.ChooseStr(...) "{{{
|
||||
return copy( a:000 )
|
||||
endfunction "}}}
|
||||
|
||||
" XXX
|
||||
" Fill in postType, and finish template rendering at once.
|
||||
" This make nested template rendering go back to upper level, top-level
|
||||
" template rendering quit.
|
||||
fun! s:f.xptFinishTemplateWith(postType) dict
|
||||
endfunction
|
||||
|
||||
" XXX
|
||||
" Fill in postType, jump to next item. For creating item being able to be
|
||||
" automatically filled in
|
||||
fun! s:f.xptFinishItemWith(postType) dict
|
||||
endfunction
|
||||
|
||||
" TODO test me
|
||||
fun! s:f.UnescapeMarks(string) dict
|
||||
let patterns = self._ctx.renderContext.snipObject.ptn
|
||||
let charToEscape = '\(\[' . patterns.l . patterns.r . ']\)'
|
||||
|
||||
let r = substitute( a:string, '\v(\\*)\1\\?\V' . charToEscape, '\1\2', 'g')
|
||||
|
||||
return r
|
||||
endfunction
|
||||
let s:f.UE = s:f.UnescapeMarks
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
fun! s:f.headerSymbol(...) "{{{
|
||||
let h = expand('%:t')
|
||||
let h = substitute(h, '\.', '_', 'g') " replace . with _
|
||||
let h = substitute(h, '.', '\U\0', 'g') " make all characters upper case
|
||||
|
||||
return '__'.h.'__'
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
|
||||
fun! s:f.date(...) "{{{
|
||||
return strftime( self.GetVar( '$DATE_FMT' ) )
|
||||
endfunction "}}}
|
||||
fun! s:f.datetime(...) "{{{
|
||||
return strftime( self.GetVar( '$DATETIME_FMT' ) )
|
||||
endfunction "}}}
|
||||
fun! s:f.time(...) "{{{
|
||||
return strftime( self.GetVar( '$TIME_FMT' ) )
|
||||
endfunction "}}}
|
||||
fun! s:f.file(...) "{{{
|
||||
return expand("%:t")
|
||||
endfunction "}}}
|
||||
fun! s:f.fileRoot(...) "{{{
|
||||
return expand("%:t:r")
|
||||
endfunction "}}}
|
||||
fun! s:f.fileExt(...) "{{{
|
||||
return expand("%:t:e")
|
||||
endfunction "}}}
|
||||
fun! s:f.path(...) "{{{
|
||||
return expand("%:p")
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! s:f.UpperCase( v )
|
||||
return substitute(a:v, '.', '\u&', 'g')
|
||||
endfunction
|
||||
|
||||
fun! s:f.LowerCase( v )
|
||||
return substitute(a:v, '.', '\l&', 'g')
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
" Return Item Edges
|
||||
fun! s:f.ItemEdges() "{{{
|
||||
let leader = get( self._ctx.renderContext, 'leadingPlaceHolder', {} )
|
||||
if has_key( leader, 'leftEdge' )
|
||||
return [ leader.leftEdge, leader.rightEdge ]
|
||||
else
|
||||
return [ '', '' ]
|
||||
endif
|
||||
endfunction "}}}
|
||||
let s:f.Edges = s:f.ItemEdges
|
||||
|
||||
|
||||
fun! s:f.ItemCreate( name, edges, filters )
|
||||
let [ ml, mr ] = XPTmark()
|
||||
|
||||
|
||||
let item = ml . a:name
|
||||
|
||||
if has_key( a:edges, 'left' )
|
||||
let item = ml . a:edges.left . item
|
||||
endif
|
||||
|
||||
if has_key( a:edges, 'right' )
|
||||
let item .= ml . a:edges.right
|
||||
endif
|
||||
|
||||
let item .= mr
|
||||
|
||||
if has_key( a:filters, 'post' )
|
||||
let item .= a:filters.post . mr . mr
|
||||
endif
|
||||
|
||||
return item
|
||||
|
||||
endfunction
|
||||
|
||||
" {{{ Quick Repetition
|
||||
" If something typed, <tab>ing to next generate another item other than the
|
||||
" typed.
|
||||
"
|
||||
" If nothing typed but only <tab> to next, clear it.
|
||||
"
|
||||
" Normal clear typed, also clear it
|
||||
" TODO escape mark character in a:sep or a:item
|
||||
" }}}
|
||||
fun! s:f.ExpandIfNotEmpty( sep, item, ... ) "{{{
|
||||
let v = self.V()
|
||||
|
||||
let [ ml, mr ] = XPTmark()
|
||||
|
||||
if a:0 != 0
|
||||
let r = a:1
|
||||
else
|
||||
let r = ''
|
||||
endif
|
||||
|
||||
" let t = ( v == '' || v == a:item || v == ( a:sep . a:item . r ) )
|
||||
let t = ( v == '' || v =~ '\V' . a:item )
|
||||
\ ? ''
|
||||
\ : self.Build( v
|
||||
\ . ml . a:sep . ml . a:item . ml . r . mr
|
||||
\ . 'ExpandIfNotEmpty(' . string( a:sep ) . ', ' . string( a:item ) . ')' . mr . mr )
|
||||
|
||||
return t
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:f.ExpandInsideEdge( newLeftEdge, newRightEdge )
|
||||
let v = self.V()
|
||||
let fullname = self.ItemFullname()
|
||||
|
||||
let [ el, er ] = self.ItemEdges()
|
||||
|
||||
if v ==# fullname || v == ''
|
||||
return ''
|
||||
endif
|
||||
|
||||
return substitute( v, '\V' . er . '\$' , '' , '' )
|
||||
\. self.ItemCreate( self.ItemName(), { 'left' : a:newLeftEdge, 'right' : a:newRightEdge }, {} )
|
||||
\. er
|
||||
endfunction
|
||||
|
||||
fun! s:f.NIndent()
|
||||
return &shiftwidth
|
||||
endfunction
|
||||
|
||||
fun! s:f.ResetIndent( nIndent, text )
|
||||
return { 'action' : 'resetIndent', 'resetIndent' : 1, 'nIndent' : a:nIndent, 'text' : a:text }
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
fun! s:f.CmplQuoter_pre() dict
|
||||
if !g:xptemplate_brace_complete
|
||||
return ''
|
||||
endif
|
||||
|
||||
let v = substitute( self.ItemStrippedValue(), '\V\^\s\*', '', '' )
|
||||
|
||||
let first = matchstr( v, '\V\^\[''"]' )
|
||||
if first == ''
|
||||
return ''
|
||||
endif
|
||||
|
||||
let v = substitute( v, '\V\[^' . first . ']', '', 'g' )
|
||||
if v == first
|
||||
" only 1 quoter
|
||||
return first
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
fun! s:f.AutoCmpl( keepInPost, list, ... )
|
||||
|
||||
if !a:keepInPost && self.Phase() == 'post'
|
||||
return ''
|
||||
endif
|
||||
|
||||
if type( a:list ) == type( [] )
|
||||
let list = a:list
|
||||
else
|
||||
let list = [ a:list ] + a:000
|
||||
endif
|
||||
|
||||
|
||||
let v = self.V0()
|
||||
if v == ''
|
||||
return ''
|
||||
endif
|
||||
|
||||
|
||||
for word in list
|
||||
if word =~ '\V\^' . v
|
||||
return word[ len( v ) : ]
|
||||
endif
|
||||
endfor
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
" Short names are normally not good. Some alias to those short name functions are
|
||||
" made, with meaningful names.
|
||||
"
|
||||
" They all start with prefix 'xpt'.
|
||||
"
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
" Shortcuts
|
||||
call XPTdefineSnippet('Author', {}, '`$author^')
|
||||
call XPTdefineSnippet('Email', {}, '`$email^')
|
||||
call XPTdefineSnippet("Date", {}, "`date()^")
|
||||
call XPTdefineSnippet("File", {}, "`file()^")
|
||||
call XPTdefineSnippet("Path", {}, "`path()^")
|
||||
|
||||
|
||||
call XPTdefineSnippet('"_', {'hint' : '" .. "', 'wraponly' : 'w' }, '"`w^"')
|
||||
call XPTdefineSnippet("'_", {'hint' : "' .. '", 'wraponly' : 'w' }, "'`w^'")
|
||||
call XPTdefineSnippet("<_", {'hint' : '< .. >', 'wraponly' : 'w' }, '<`w^>')
|
||||
call XPTdefineSnippet("(_", {'hint' : '( .. )', 'wraponly' : 'w' }, '(`w^)')
|
||||
call XPTdefineSnippet("[_", {'hint' : '[ .. ]', 'wraponly' : 'w' }, '[`w^]')
|
||||
call XPTdefineSnippet("{_", {'hint' : '{ .. }', 'wraponly' : 'w' }, '{`w^}')
|
||||
call XPTdefineSnippet("`_", {'hint' : '` .. `', 'wraponly' : 'w' }, '\``w^\`')
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
XPTemplate priority=all
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
|
||||
fun! s:Init()
|
||||
let s:xptCompleteMap = [
|
||||
\"''",
|
||||
\'""',
|
||||
\'()',
|
||||
\'[]',
|
||||
\'{}',
|
||||
\'<>',
|
||||
\'||',
|
||||
\'**',
|
||||
\'``',
|
||||
\'++',
|
||||
\' ',
|
||||
\]
|
||||
|
||||
let s:xptCompleteLeft = join( map( deepcopy( s:xptCompleteMap ), 'v:val[0:0]' ), '' )
|
||||
let s:xptCompleteRight = join( map( deepcopy( s:xptCompleteMap ), 'v:val[1:1]' ), '' )
|
||||
endfunction
|
||||
|
||||
call s:Init()
|
||||
delfunc s:Init
|
||||
|
||||
|
||||
|
||||
|
||||
fun! s:f.CompleteRightPart( leftReg ) dict
|
||||
if !g:xptemplate_brace_complete
|
||||
return ''
|
||||
endif
|
||||
|
||||
let v = self.V()
|
||||
|
||||
|
||||
let v = matchstr( v, a:leftReg )
|
||||
if v == ''
|
||||
return ''
|
||||
endif
|
||||
|
||||
let v = join( reverse( split( v, '\V\s\{-}' ) ), '')
|
||||
let v = tr( v, s:xptCompleteLeft, s:xptCompleteRight )
|
||||
return v
|
||||
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
73
plugins/bundle/xptemplate/ftplugin/_condition/c.like.xpt.vim
Normal file
73
plugins/bundle/xptemplate/ftplugin/_condition/c.like.xpt.vim
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
XPTemplate priority=like
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
|
||||
|
||||
" if () ** {
|
||||
XPTvar $BRif ' '
|
||||
|
||||
" } ** else {
|
||||
XPTvar $BRel \n
|
||||
|
||||
|
||||
|
||||
" int fun( ** arg ** )
|
||||
" if ( ** condition ** )
|
||||
XPTvar $SParg ''
|
||||
|
||||
" if ** (
|
||||
XPTvar $SPcmd ' '
|
||||
|
||||
" a = a ** + ** 1
|
||||
XPTvar $SPop ' '
|
||||
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $CURSOR_PH /* cursor */
|
||||
|
||||
XPT _if hidden
|
||||
if`$SPcmd^(`$SParg^`condition^`$SParg^)`$BRif^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT if wrap " if ( .. ) { .. }
|
||||
`Include:_if^
|
||||
|
||||
XPT elif wrap " else if ( .. ) { .. }
|
||||
else `Include:_if^
|
||||
|
||||
XPT else wrap " else { ... }
|
||||
else`$BRif^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT ifn alias=if " if (.. == $NULL) {..} else...
|
||||
XSET condition=Embed('`a^`$SPop^==`$SPop^`$NULL^')
|
||||
|
||||
XPT ifnn alias=if " if (.. != $NULL) {..} else...
|
||||
XSET condition=Embed('`a^`$SPop^!=`$SPop^`$NULL^')
|
||||
|
||||
XPT if0 alias=if " if (.. == 0) {..} else...
|
||||
XSET condition=Embed('`a^`$SPop^==`$SPop^0')
|
||||
|
||||
XPT ifn0 alias=if " if (.. != 0) {..} else...
|
||||
XSET condition=Embed('`a^`$SPop^!=`$SPop^0')
|
||||
|
||||
XPT ifee " if (..) {..} else if...
|
||||
`:_if:^` `else_if...{{^`$BRel^`Include:elif^` `else_if...^`}}^
|
||||
|
||||
XPT switch wrap " switch (..) {case..}
|
||||
switch (`$SParg^`var^`$SParg^)`$BRif^{
|
||||
`Include:case^
|
||||
}
|
||||
..XPT
|
||||
|
||||
XPT case wrap " case ..:
|
||||
case `constant^:
|
||||
`cursor^
|
||||
break;
|
||||
|
||||
XPT default " default ..:
|
||||
default:
|
||||
`cursor^
|
||||
28
plugins/bundle/xptemplate/ftplugin/_condition/ecma.xpt.vim
Normal file
28
plugins/bundle/xptemplate/ftplugin/_condition/ecma.xpt.vim
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
XPTemplate priority=spec
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE true
|
||||
XPTvar $FALSE false
|
||||
XPTvar $NULL null
|
||||
XPTvar $UNDEFINED undefined
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $BRif \n
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _condition/c.like
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
XPT ifu alias=if " if ($UNDEFINED == ..) {..} else...
|
||||
XSET condition=Embed('`$UNDEFINED^`$SPop^==`$SPop^`var^')
|
||||
|
||||
|
||||
XPT ifnu alias=if " if ($UNDEFINED == ..) {..} else...
|
||||
XSET condition=Embed('`$UNDEFINED^`$SPop^!=`$SPop^`var^')
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
XPTemplate priority=like
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $BRif \n
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
|
||||
XPT if hint=(if\ (then)\ (else))
|
||||
(if [`condition^]
|
||||
(`then^)
|
||||
`else...{{^(`cursor^)`}}^)
|
||||
|
||||
XPT when hint=(when\ cond\ ..)
|
||||
(when (`cond^)
|
||||
(`todo0^)` `...^
|
||||
(`todon^)` `...^)
|
||||
|
||||
|
||||
XPT unless hint=(unless\ cond\ ..)
|
||||
(unless (`cond^)
|
||||
(`todo0^)` `...^
|
||||
(`todon^)` `...^)
|
||||
|
||||
51
plugins/bundle/xptemplate/ftplugin/_func/c.like.xpt.vim
Normal file
51
plugins/bundle/xptemplate/ftplugin/_func/c.like.xpt.vim
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
XPTemplate priority=like
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
|
||||
XPTvar $BRif ' '
|
||||
XPTvar $BRloop ' '
|
||||
XPTvar $BRstc ' '
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $CURSOR_PH /* cursor */
|
||||
|
||||
XPTvar $CL /*
|
||||
XPTvar $CM *
|
||||
XPTvar $CR */
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
fun! s:f.c_fun_type_indent()
|
||||
if self[ '$BRfun' ] == "\n"
|
||||
" let sts = &softtabstop == 0 ? &tabstop : &softtabstop
|
||||
return ' '
|
||||
else
|
||||
return ""
|
||||
endif
|
||||
endfunction
|
||||
|
||||
fun! s:f.c_fun_body_indent()
|
||||
if self[ '$BRfun' ] == "\n"
|
||||
" let sts = &softtabstop == 0 ? &tabstop : &softtabstop
|
||||
return self.ResetIndent( -&shiftwidth, "\n" )
|
||||
else
|
||||
return " "
|
||||
endif
|
||||
endfunction
|
||||
|
||||
XPT main hint=main\ (argc,\ argv)
|
||||
`c_fun_type_indent()^int`c_fun_body_indent()^main(`$SParg^int argc,`$SPop^char **argv`$SParg^)`$BRfun^{
|
||||
`cursor^
|
||||
return 0;
|
||||
}
|
||||
|
||||
XPT fun wrap=curosr hint=func..\ (\ ..\ )\ {...
|
||||
`c_fun_type_indent()^`int^`c_fun_body_indent()^`name^(`$SParg`param?`$SParg^)`$BRfun^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
0
plugins/bundle/xptemplate/ftplugin/_func/ecma.xpt.vim
Normal file
0
plugins/bundle/xptemplate/ftplugin/_func/ecma.xpt.vim
Normal file
39
plugins/bundle/xptemplate/ftplugin/_loops/c.for.like.xpt.vim
Normal file
39
plugins/bundle/xptemplate/ftplugin/_loops/c.for.like.xpt.vim
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
XPTemplate priority=like
|
||||
|
||||
XPTvar $BRloop ' '
|
||||
|
||||
" int fun( ** arg ** )
|
||||
" if ( ** condition ** )
|
||||
" for ( ** statement ** )
|
||||
" [ ** a, b ** ]
|
||||
" { ** 'k' : 'v' ** }
|
||||
XPTvar $SParg ''
|
||||
|
||||
" if ** (
|
||||
" while ** (
|
||||
" for ** (
|
||||
XPTvar $SPcmd ' '
|
||||
|
||||
" a ** = ** a ** + ** 1
|
||||
" (a, ** b, ** )
|
||||
XPTvar $SPop ' '
|
||||
|
||||
fun! s:f.c_strip_type()
|
||||
let v = self.ItemValue()
|
||||
echom v
|
||||
echom substitute(v, '\V\^\_.*\s', 'g')
|
||||
return substitute(v, '\V\^\_.*\s', 'g')
|
||||
endfunction
|
||||
|
||||
XPT for wrap " for (..;..;++)
|
||||
for`$SPcmd^(`$SParg^`i^`$SPop^=`$SPop^`0^; `i^c_strip_type()^`$SPop^<`$SPop^`len^; `i^c_strip_type()^++`$SParg^)`$BRloop^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT forr wrap " for (..;..;--)
|
||||
for`$SPcmd^(`$SParg^`i^`$SPop^=`$SPop^`n^; `i^`$SPop^>`=$SPop`0^; `i^--`$SParg^)`$BRloop^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT forever " for (;;) ..
|
||||
for`$SPcmd^(;;) `cursor^
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
XPTemplate priority=like
|
||||
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
|
||||
XPTvar $BRloop ' '
|
||||
|
||||
XPTvar $SParg ' '
|
||||
XPTvar $SPcmd ' '
|
||||
XPTvar $SPop ' '
|
||||
|
||||
|
||||
|
||||
|
||||
XPT while wrap " while ( .. )
|
||||
while`$SPcmd^(`$SParg^`condition^`$SParg^)`$BRloop^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT do wrap " do { .. } while ( .. )
|
||||
do`$BRloop^{
|
||||
`cursor^
|
||||
}`$BRloop^while`$SPcmd^(`$SParg^`condition^`$SParg^);
|
||||
|
||||
|
||||
XPT while0 alias=do " do { .. } while ( $FALSE )
|
||||
XSET condition=Embed( $FALSE )
|
||||
|
||||
|
||||
XPT while1 alias=while " while ( $TRUE ) { .. }
|
||||
XSET condition=Embed( $TRUE )
|
||||
|
||||
|
||||
XPT whilenn alias=while " while ( $NULL != .. ) { .. }
|
||||
XSET condition=Embed( $NULL . $SPop . '!=' . $SPop . '`x^' )
|
||||
68
plugins/bundle/xptemplate/ftplugin/_loops/for.xpt.vim
Normal file
68
plugins/bundle/xptemplate/ftplugin/_loops/for.xpt.vim
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
"
|
||||
" standard for( i = 0; i < 10; i++ ) snippets
|
||||
"
|
||||
XPTemplate priority=all-
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $BRloop ' '
|
||||
|
||||
|
||||
XPTvar $SParg ''
|
||||
XPTvar $SPcmd ' '
|
||||
XPTvar $SPop ' '
|
||||
|
||||
XPTvar $VAR_PRE ''
|
||||
XPTvar $FOR_SCOPE ''
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
fun! s:f.c_strip_type()
|
||||
let v = self.ItemValue()
|
||||
return substitute(v, '\V\^\_.\*\s', '', 'g')
|
||||
endfunction
|
||||
|
||||
XPT for wrap " for (..;..;++)
|
||||
for`$SPcmd^(`$SParg^`$FOR_SCOPE^`$VAR_PRE`i^`$SPop^=`$SPop^`0^; `i^c_strip_type()^`$SPop^<`$SPop^`len^; `i^c_strip_type()^++`$SParg^)`$BRloop^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT forr wrap " for (..;..;--)
|
||||
for`$SPcmd^(`$SParg^`$FOR_SCOPE^`$VAR_PRE`i^`$SPop^=`$SPop^`0^; `i^c_strip_type()^`$SPop^>`=$SPop`end^; `i^c_strip_type()^--`$SParg^)`$BRloop^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT fornn wrap " for (..; $NULL != var; .. )
|
||||
for`$SPcmd^(`$SParg^`$FOR_SCOPE^`$VAR_PRE`ptr^`$SPop^=`$SPop^`init^; `$NULL^`$SPop^!=`$SPop^`ptr^; `^R('ptr')^`$SParg^)`$BRloop^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT forever " for (;;) ..
|
||||
for`$SPcmd^(;;) `cursor^
|
||||
..XPT
|
||||
|
||||
" Simplify
|
||||
" XSET i|edgeLeft=$VAR_PRE
|
||||
" XSET i|edgeRight=$VAR_PRE
|
||||
" XSET $(= ($SParg
|
||||
" XSET $)= $SParg)
|
||||
" XSET $== $SPop=$SPop
|
||||
" XSET $>= $SPop>
|
||||
" XSET $e= =$SPop
|
||||
|
||||
" for`$SPcmd`$(`$FOR_SCOPE``i`$=`0; `i`$>`$e`end; `i++`$)`$BRloop{
|
||||
" ^
|
||||
" ..XPT
|
||||
"
|
||||
" for`SP(`SP`FOR_SCOPE`i`SP=`SP`0;`SP`i`SP>`SP`end;`SP`i++`SP)`SP{
|
||||
"
|
||||
" for$ ($ $FOR_SCOPE$i$ =$ $0;$ $i$ >$ $end;$ $i++$ )$ {
|
||||
"
|
||||
" for$ ($ $FOR_SCOPE${$VAR_PRE `i`}$ =$ $0;$ $i$ >$ $end;$ $i++$ )$ {
|
||||
"
|
||||
" for` (` `FOR_SCOPE`{$VAR_PRE `i`}` =` `0;` `{i/\v(\S+)$/\1/}` >` `{end:0::post=::focus=::live=};` `i++` )` {
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
XPTemplate priority=like-
|
||||
|
||||
" containers
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE true
|
||||
XPTvar $FALSE false
|
||||
XPTvar $NULL null
|
||||
XPTvar $BRif
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
XPT for " for i++
|
||||
for`$SPcmd^(`$SParg^`int^ `i^`$SPop^=`$SPop^`0^; `i^`$SPop^<`$SPop^`len^; ++`i^`$SParg^)`$BRloop^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT forr "for i--
|
||||
for`$SPcmd^(`$SParg^`int^ `i^`$SPop^=`$SPop^`n^; `i^`$SPop^>`=^`$SPop^`end^; --`i^`$SParg^)`$BRloop^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
XPTemplate priority=like
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
|
||||
|
||||
|
||||
XPT #inc " include <>
|
||||
#include <`^.h>
|
||||
|
||||
|
||||
XPT #include_user " include ""
|
||||
XSET me=fileRoot()
|
||||
#include "`me^.h"
|
||||
|
||||
|
||||
XPT #ind alias=#include_user
|
||||
|
||||
|
||||
XPT #if wrap " #if ..
|
||||
#if `0^
|
||||
`cursor^
|
||||
#endif
|
||||
|
||||
|
||||
XPT #ifdef wrap " #ifdef ..
|
||||
#ifdef `symbol^
|
||||
`cursor^
|
||||
#endif `$CL^ `symbol^ `$CR^
|
||||
|
||||
|
||||
XPT #ifndef wrap " #ifndef ..
|
||||
#ifndef `symbol^
|
||||
`cursor^
|
||||
#endif `$CL^ `symbol^ `$CR^
|
||||
|
||||
|
||||
XPT once wrap " #ifndef .. #define ..
|
||||
XSET symbol=headerSymbol()
|
||||
#ifndef `symbol^
|
||||
# define `symbol^
|
||||
|
||||
`cursor^
|
||||
#endif `$CL^ `symbol^ `$CR^
|
||||
105
plugins/bundle/xptemplate/ftplugin/_printf/c.like.xpt.vim
Normal file
105
plugins/bundle/xptemplate/ftplugin/_printf/c.like.xpt.vim
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
XPTemplate priorit=like
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
|
||||
" a ** = ** a ** + ** 1
|
||||
" (a, ** b, ** )
|
||||
XPTvar $SPop ' '
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
" if () ** {
|
||||
" else ** {
|
||||
XPTvar $BRif ' '
|
||||
|
||||
" } ** else {
|
||||
XPTvar $BRel \n
|
||||
|
||||
" for () ** {
|
||||
" while () ** {
|
||||
" do ** {
|
||||
XPTvar $BRloop ' '
|
||||
|
||||
" struct name ** {
|
||||
XPTvar $BRstc ' '
|
||||
|
||||
" int fun() ** {
|
||||
" class name ** {
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
let s:printfElts = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
|
||||
" %[flags][width][.precision][length]specifier
|
||||
let s:printfItemPattern = '\V\C' . '%' . '\[+\- 0#]\*' . '\%(*\|\d\+\)\?' . '\(.*\|.\d\+\)\?' . '\[hlL]\?' . '\(\[cdieEfgGosuxXpn]\)'
|
||||
|
||||
let s:printfSpecifierMap = {
|
||||
\'c' : 'char',
|
||||
\'d' : 'int',
|
||||
\'i' : 'int',
|
||||
\'e' : 'scientific',
|
||||
\'E' : 'scientific',
|
||||
\'f' : 'float',
|
||||
\'g' : 'float',
|
||||
\'G' : 'float',
|
||||
\'o' : 'octal',
|
||||
\'s' : 'str',
|
||||
\'u' : 'unsigned',
|
||||
\'x' : 'decimal',
|
||||
\'X' : 'Decimal',
|
||||
\'p' : 'pointer',
|
||||
\'n' : 'numWritten',
|
||||
\}
|
||||
|
||||
fun! s:f.c_printf_elts( v, sep )
|
||||
|
||||
" remove '%%' representing a single '%'
|
||||
|
||||
let v = substitute( a:v, '\V%%', '', 'g' )
|
||||
|
||||
let [ ml, mr ] = XPTmark()
|
||||
|
||||
if v =~ '\V%'
|
||||
|
||||
let start = 0
|
||||
let post = ''
|
||||
let i = -1
|
||||
while 1
|
||||
let i += 1
|
||||
|
||||
let start = match( v, s:printfItemPattern, start )
|
||||
if start < 0
|
||||
break
|
||||
endif
|
||||
|
||||
let eltList = matchlist( v, s:printfItemPattern, start )
|
||||
|
||||
if eltList[1] == '.*'
|
||||
" need to specifying string length before string pointer
|
||||
let post .= a:sep . self.GetVar( '$SPop' ) . ml . s:printfElts[ i ] . '_len' . mr
|
||||
endif
|
||||
|
||||
let post .= a:sep . self.GetVar( '$SPop' ) . ml . s:printfElts[ i ] . '_' . s:printfSpecifierMap[ eltList[2] ] . mr
|
||||
|
||||
let start += len( eltList[0] )
|
||||
|
||||
endwhile
|
||||
return post
|
||||
|
||||
else
|
||||
return self.Next( '' )
|
||||
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
XPTemplate priority=like
|
||||
|
||||
|
||||
XPTvar $BRstc ' '
|
||||
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
|
||||
|
||||
|
||||
XPT enum hint=enum\ {\ ..\ }
|
||||
XSET postQuoter={,}
|
||||
enum `name^`$BRstc^{
|
||||
`^
|
||||
}
|
||||
|
||||
|
||||
XPT struct hint=struct\ {\ ..\ }
|
||||
struct `structName^`$BRstc^{
|
||||
`^
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
" XPTvar $TRUE 1
|
||||
" XPTvar $FALSE 0
|
||||
" XPTvar $NULL NULL
|
||||
" XPTvar $UNDEFINED NULL
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
XPTvar $CL /*
|
||||
XPTvar $CM *
|
||||
XPTvar $CR */
|
||||
XPTvar $CS //
|
||||
XPTinclude
|
||||
\ _comment/singleDouble
|
||||
|
||||
XPTinclude
|
||||
\ _condition/ecma
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
XPT fun wrap " function ..( .. ) {..}
|
||||
XSET arg*|post=ExpandIfNotEmpty(', ', 'arg*')
|
||||
function` `name^ (`arg*^) {
|
||||
`cursor^
|
||||
}
|
||||
|
||||
134
plugins/bundle/xptemplate/ftplugin/ada/ada.xpt.vim
Normal file
134
plugins/bundle/xptemplate/ftplugin/ada/ada.xpt.vim
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $BRif \n
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
XPT acc " access
|
||||
access
|
||||
..XPT
|
||||
|
||||
XPT ali " aliased
|
||||
aliased
|
||||
..XPT
|
||||
|
||||
XPT beg " begin .. end;
|
||||
begin
|
||||
`cursor^
|
||||
end;
|
||||
..XPT
|
||||
|
||||
XPT case " case .. is .. end case;
|
||||
case `1^ is
|
||||
`cursor^
|
||||
end case;
|
||||
..XPT
|
||||
|
||||
XPT eli " elsif .. then ...
|
||||
elsif `1^ then
|
||||
`cursor^
|
||||
..XPT
|
||||
|
||||
XPT for " for .. in .. loop ... end loop;
|
||||
for `1^ in `2^ loop
|
||||
`cursor^
|
||||
end loop;
|
||||
..XPT
|
||||
|
||||
XPT fun " function .. return .. is ..._ end;
|
||||
function `1^name^ return `2^ is
|
||||
`3^
|
||||
begin -- `1^
|
||||
`cursor^
|
||||
end `1^;
|
||||
..XPT
|
||||
|
||||
XPT if " if .. then ... end if;
|
||||
if `1^ then
|
||||
`cursor^
|
||||
end if;
|
||||
..XPT
|
||||
|
||||
XPT loop " loop .. end loop;
|
||||
loop
|
||||
`cursor^
|
||||
end loop;
|
||||
..XPT
|
||||
|
||||
XPT pbo " package body .. is .. end ;
|
||||
package body `1^name^ is
|
||||
`cursor^
|
||||
end `1^;
|
||||
..XPT
|
||||
|
||||
XPT pac " package .. is .. end;
|
||||
package `1^name^ is
|
||||
`cursor^
|
||||
end `1^;
|
||||
..XPT
|
||||
|
||||
XPT pne " package .. is ..
|
||||
package `1^ is `cursor^
|
||||
..XPT
|
||||
|
||||
XPT pro " procedure .. begin .. end;
|
||||
procedure `1^Procedure^ is
|
||||
`2^
|
||||
begin -- `mark^S(R('1'),'([a-zA-Z0-9_]*).*$','\1')^
|
||||
`cursor^
|
||||
end `mark^;
|
||||
..XPT
|
||||
|
||||
XPT rec " record .. end record;
|
||||
record
|
||||
`cursor^
|
||||
end record;
|
||||
..XPT
|
||||
|
||||
XPT ret " return ..;
|
||||
return `1^;
|
||||
..XPT
|
||||
|
||||
XPT ty " type .. is ..;
|
||||
type `1^ is `cursor^
|
||||
..XPT
|
||||
|
||||
XPT u " use ..;
|
||||
use `1^;
|
||||
..XPT
|
||||
|
||||
XPT when " when .. => ..
|
||||
when `1^ =>
|
||||
`cursor^
|
||||
..XPT
|
||||
|
||||
XPT whi " while .. loop .. end loop;
|
||||
while `1^ loop
|
||||
`cursor^
|
||||
end loop;
|
||||
..XPT
|
||||
|
||||
XPT wu " with ..; use ..;
|
||||
with `what^; use `1^;
|
||||
`cursor^
|
||||
..XPT
|
||||
|
||||
XPT w " with ..;
|
||||
with `1^;
|
||||
..XPT
|
||||
|
||||
78
plugins/bundle/xptemplate/ftplugin/c/autoimplem.xpt.vim
Normal file
78
plugins/bundle/xptemplate/ftplugin/c/autoimplem.xpt.vim
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
" finish " not finished
|
||||
if !g:XPTloadBundle( 'c', 'autoimplem' ) && !exists('g:cppautoimplemneedc') && !exists('g:objcautoimlemneedc')
|
||||
finish
|
||||
endif
|
||||
|
||||
XPTemplate priority=lang-2
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
" ========================== Support functions ======================
|
||||
let s:defaultImpl = { 'void' : ''
|
||||
\, 'int' : "\treturn 0;"
|
||||
\, 'unsigned int' : "\treturn 0;"
|
||||
\, 'short' : "\treturn 0;"
|
||||
\, 'unsigned short' : "\treturn 0;"
|
||||
\, 'char' : "\treturn '\0';"
|
||||
\, 'unsigned char' : "\treturn '\0';"
|
||||
\, 'double': "\treturn 0.0;"
|
||||
\, 'float' : "\treturn 0.0f;"
|
||||
\, 'bool' : "\treturn false;"
|
||||
\}
|
||||
|
||||
let s:f.todoText = "\t/* TODO : implement here */"
|
||||
|
||||
fun! s:f.GetDefaultImplementation( type )
|
||||
|
||||
if has_key( s:defaultImpl, a:type )
|
||||
return s:defaultImpl[ a:type ]
|
||||
endif
|
||||
|
||||
" check if type is a pointer.
|
||||
if a:type =~ '.*\*$'
|
||||
return "\treturn NULL;"
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
fun! s:f.GetImplementationFile() "{{{
|
||||
let name = expand('%:p')
|
||||
|
||||
if name =~ '\.h$'
|
||||
let name = substitute( name, 'h$', '[cC]*', '' )
|
||||
elseif name =~ '\.hpp$'
|
||||
let name = substitute( name, 'hpp$', '[cC]*', '' )
|
||||
endif
|
||||
|
||||
return glob( name )
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:f.WriteFunToCpp() " {{{
|
||||
let imple = s:f.GetImplementationFile()
|
||||
if imple == ''
|
||||
return
|
||||
endif
|
||||
|
||||
let retType = self.R('retType')
|
||||
let funName = self.R('funName')
|
||||
|
||||
let args = self.R( 'args' )
|
||||
let methodBody = [ retType . ' ' . funName . '(' . args . ')'
|
||||
\ , '{'
|
||||
\ , s:f.todoText
|
||||
\ , s:f.GetDefaultImplementation( retType )
|
||||
\ , '}'
|
||||
\ , '' ]
|
||||
|
||||
let txt = extend( readfile( imple ), methodBody )
|
||||
call writefile( txt, imple )
|
||||
|
||||
return args
|
||||
endfunction " }}}
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
XPT hfun " create proto in h and implementation in .c/.cc/.cpp
|
||||
`retType^ `funName^( `args^WriteFunToCpp()^^);
|
||||
..XPT
|
||||
|
||||
110
plugins/bundle/xptemplate/ftplugin/c/c.xpt.vim
Normal file
110
plugins/bundle/xptemplate/ftplugin/c/c.xpt.vim
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
|
||||
XPTvar $BRif ' '
|
||||
XPTvar $BRloop ' '
|
||||
XPTvar $BRstc ' '
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $CURSOR_PH /* cursor */
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
XPTvar $CL /*
|
||||
XPTvar $CM *
|
||||
XPTvar $CR */
|
||||
XPTinclude
|
||||
\ _comment/doubleSign
|
||||
|
||||
XPTinclude
|
||||
\ _condition/c.like
|
||||
\ _func/c.like
|
||||
\ _loops/c.while.like
|
||||
\ _preprocessor/c.like
|
||||
\ _structures/c.like
|
||||
\ _printf/c.like
|
||||
|
||||
XPTinclude
|
||||
\ _loops/for
|
||||
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
|
||||
|
||||
XPT _printfElts hidden
|
||||
XSET elts|pre=Echo('')
|
||||
XSET elts=c_printf_elts( R( 'pattern' ), ',' )
|
||||
"`pattern^"`elts^
|
||||
|
||||
|
||||
XPT printf " printf\(...)
|
||||
printf(`$SParg^`:_printfElts:^`$SParg^)
|
||||
|
||||
|
||||
XPT sprintf " sprintf\(...)
|
||||
sprintf(`$SParg^`str^,`$SPop^`:_printfElts:^`$SParg^)
|
||||
|
||||
|
||||
XPT snprintf " snprintf\(...)
|
||||
snprintf(`$SParg^`str^,`$SPop^`size^,`$SPop^`:_printfElts:^`$SParg^)
|
||||
|
||||
|
||||
XPT fprintf " fprintf\(...)
|
||||
fprintf(`$SParg^`stream^,`$SPop^`:_printfElts:^`$SParg^)
|
||||
|
||||
XPT memcpy " memcpy (..., ..., sizeof (...) ... )
|
||||
memcpy(`$SParg^`dest^,`$SPop^`source^,`$SPop^sizeof(`type^int^)`$SPop^*`$SPop^`count^`$SParg^)
|
||||
|
||||
XPT memset " memset (..., ..., sizeof (...) ... )
|
||||
memset(`$SParg^`buffer^,`$SPop^`what^0^,`$SPop^sizeof(`$SParg^`type^int^`$SParg^)`$SPop^*`$SPop^`count^`$SParg^)
|
||||
|
||||
XPT malloc " malloc ( ... );
|
||||
(`type^int^*)malloc(`$SParg^sizeof(`$SParg^`type^`$SParg^)`$SPop^*`$SPop^`count^`$SParg^)
|
||||
|
||||
XPT assert " assert (.., msg)
|
||||
assert(`$SParg^`isTrue^,`$SPop^"`text^"`$SParg^)
|
||||
|
||||
|
||||
XPT fcomment
|
||||
/**
|
||||
* @author : `$author^ | `$email^
|
||||
* @description
|
||||
* `cursor^
|
||||
* @return {`int^} `desc^
|
||||
*/
|
||||
|
||||
|
||||
XPT para syn=comment " comment parameter
|
||||
@param {`Object^} `name^ `desc^
|
||||
|
||||
XPT filehead
|
||||
XSET cursor|pre=CURSOR
|
||||
/**-------------------------/// `sum^ \\\---------------------------
|
||||
*
|
||||
* <b>`function^</b>
|
||||
* @version : `1.0^
|
||||
* @since : `date()^
|
||||
*
|
||||
* @description :
|
||||
* `cursor^
|
||||
* @usage :
|
||||
*
|
||||
* @author : `$author^ | `$email^
|
||||
* @copyright `.com.cn^
|
||||
* @TODO :
|
||||
*
|
||||
*--------------------------\\\ `sum^ ///---------------------------*/
|
||||
|
||||
..XPT
|
||||
|
||||
|
||||
XPT call wraponly=param " ..( .. )
|
||||
`name^(`$SParg^`param^`$SParg^)
|
||||
|
||||
12
plugins/bundle/xptemplate/ftplugin/c/c99.xpt.vim
Normal file
12
plugins/bundle/xptemplate/ftplugin/c/c99.xpt.vim
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
" C99 relax some variable definition rules
|
||||
" allowing to use C++/Java style for loop
|
||||
if !g:XPTloadBundle( 'c', 'c99' )
|
||||
finish
|
||||
endif
|
||||
|
||||
XPTemplate priority=sub
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _loops/java.for.like
|
||||
|
||||
58
plugins/bundle/xptemplate/ftplugin/cabal/cabal.xpt.vim
Normal file
58
plugins/bundle/xptemplate/ftplugin/cabal/cabal.xpt.vim
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $BRif \n
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
XPT infos hint=Name:\ Version\:\ Synopsys:\ Descr:\ Author:\ ...
|
||||
XSET Description...|post=\nDescription: `_^
|
||||
XSET Author...|post=\nAuthor: `_^
|
||||
XSET Maintainer...|post=\nMaintainer: `_^
|
||||
Name: `name^
|
||||
Version: `version^
|
||||
Synopsis: `synop^
|
||||
Build-Type: `Simple^
|
||||
Cabal-Version: >= `ver^1.2^`
|
||||
`Description...^`
|
||||
`Author...^`
|
||||
`Maintainer...^
|
||||
|
||||
XPT if hint=if\ ...\ else\ ...
|
||||
if `cond^
|
||||
`what^
|
||||
`else...{{^else
|
||||
`cursor^`}}^
|
||||
|
||||
|
||||
XPT lib hint=library\ Exposed-Modules...
|
||||
XSET another*|post=ExpandIfNotEmpty( ', ', 'another*' )
|
||||
library
|
||||
Exposed-Modules: `job^`
|
||||
`more...{{^
|
||||
`job^`
|
||||
`...{{^
|
||||
`job^`
|
||||
`...^`}}^`}}^
|
||||
Build-Depends: base >= `ver^2.0^`, `another*^
|
||||
|
||||
XPT exe hint=Main-Is:\ ..\ Build-Depends
|
||||
XSET another*|post=ExpandIfNotEmpty( ', ', 'another*' )
|
||||
Executable `execName^
|
||||
Main-Is: `mainFile^
|
||||
Build-Depends: base >= `ver^2.0^`, `another*^
|
||||
|
||||
105
plugins/bundle/xptemplate/ftplugin/cg/cg.xpt.vim
Normal file
105
plugins/bundle/xptemplate/ftplugin/cg/cg.xpt.vim
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
|
||||
" if () ** {
|
||||
" else ** {
|
||||
XPTvar $BRif '\n'
|
||||
|
||||
" } ** else {
|
||||
XPTvar $BRel \n
|
||||
|
||||
" for () ** {
|
||||
" while () ** {
|
||||
" do ** {
|
||||
XPTvar $BRloop '\n'
|
||||
|
||||
" struct name ** {
|
||||
XPTvar $BRstc '\n'
|
||||
|
||||
" int fun() ** {
|
||||
" class name ** {
|
||||
XPTvar $BRfun '\n'
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _condition/c.like
|
||||
\ _loops/c.for.like
|
||||
\ _loops/c.while.like
|
||||
\ _preprocessor/c.like
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
XPT fun " fun ( .. )
|
||||
`type^ `name^(
|
||||
)
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT tech " technique ..
|
||||
technique `techName^
|
||||
{
|
||||
`cursor^
|
||||
};
|
||||
|
||||
|
||||
XPT pass " pass ..
|
||||
XSET vtarget=Choose(['arbvp1', 'vs_2_x', 'vs_3_0', 'vs_4_0', 'vp20', 'vp30', 'vp40', 'gp4vp', 'hlslv', 'glslv'])
|
||||
XSET ftarget=Choose(['arbfp1', 'ps_2_x', 'ps_3_0', 'ps_4_0', 'fp20', 'fp30', 'fp40', 'gp4fp', 'hlslf', 'glslf'])
|
||||
XSET gtarget=Choos(['gp4gp', 'gs_4_0', 'glslg'])
|
||||
pass `passName^ {`common...{{^
|
||||
VertexProgram = `compilev...{{^compile `vtarget^ `main^main^`}}^;
|
||||
FragmentProgram = `compilef...{{^compile `ftarget^ `main^main^`}}^;`GeometryProgram...{{^
|
||||
GeometryProgram = `compilef...{{^compile `gtarget^ `main^main^`}}^;`}}^
|
||||
`}}^`cursor^
|
||||
};
|
||||
|
||||
|
||||
XPT interface " interface .. { .. }
|
||||
interface `interfaceName^
|
||||
{
|
||||
`cursor^
|
||||
};
|
||||
|
||||
|
||||
XPT vertexProg " main vertex programm
|
||||
XSET vout=Choose(['COLOR0', 'COLOR1', 'TEXCOORD0', 'TEXCOORD1', 'PSIZE'])
|
||||
XSET vin=Choose(['POSITION', 'NORMAL', 'DIFFUSE', 'SPECULAR', 'TEXCOORD0', 'TEXCOORD1', 'TANGENT', 'BINORMAL', 'FOGCOORD'])
|
||||
void main( `inputs...^ float`n^ `name^ : `vin^,
|
||||
`inputs...^float4 `position^ : POSITION`outputs...^,
|
||||
out float4 `name^ : `vout^`outputs...^ )
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT fragProg " main vertex programm
|
||||
XSET vin=Choose(['COLOR0', 'COLOR1', 'TEXCOORD0', 'TEXCOORD1', 'WPOS'])
|
||||
void main( `inputs...^ float`n^ `name^ : `vin^,
|
||||
`inputs...^float4 `color^ : COLOR`depth...{{^,
|
||||
out float4 `name^ : DEPTH`}}^ )
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
|
||||
XPT struct " struct .. { .. }
|
||||
struct `structName^`inherit...{{^ : `interfaceName^`}}^
|
||||
{
|
||||
`cursor^
|
||||
};
|
||||
|
||||
|
||||
|
||||
" ================================= Wrapper ===================================
|
||||
|
||||
38
plugins/bundle/xptemplate/ftplugin/cmake/cmake.xpt.vim
Normal file
38
plugins/bundle/xptemplate/ftplugin/cmake/cmake.xpt.vim
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
XPT if " if ( cond )...
|
||||
if ( `cond^ )
|
||||
`cursor^
|
||||
`else...{{^else( `cond^ )
|
||||
`}}^endif( `cond^ )
|
||||
..XPT
|
||||
|
||||
XPT foreach " foreach\(...) ... endofreach\( ... )
|
||||
foreach (`varname^ `collection^)
|
||||
`cursor^
|
||||
endforeach(`varname^)
|
||||
|
||||
XPT set " set\(... ...)
|
||||
set(`varname^ `cursor^)
|
||||
|
||||
XPT msg " message\("...")
|
||||
message("`cursor^")
|
||||
|
||||
XPT function " function\(...) ... endfunction\(...)
|
||||
function(`funcName^ `params^)
|
||||
`cursor^
|
||||
endfunction(`funcName^)
|
||||
|
||||
XPT macro " macro\(...) ... endmacro\(...)
|
||||
macro( `macroName^ `params^ )
|
||||
`cursor^
|
||||
endmacro( `macroName^ )
|
||||
|
||||
XPT while " while\(...) ... endwhile\(...)
|
||||
while( `condition^ )
|
||||
`cursor^
|
||||
enwhile( `condition^ )
|
||||
|
||||
256
plugins/bundle/xptemplate/ftplugin/cpp/autoimplem.xpt.vim
Normal file
256
plugins/bundle/xptemplate/ftplugin/cpp/autoimplem.xpt.vim
Normal file
|
|
@ -0,0 +1,256 @@
|
|||
" finish " not finished
|
||||
if !g:XPTloadBundle( 'cpp', 'autoimplem' )
|
||||
finish
|
||||
endif
|
||||
|
||||
XPTemplate priority=lang-2
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
" To force loading the version (we need it)
|
||||
let g:cppautoimplemneedc = 1
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ c/autoimplem
|
||||
|
||||
" ========================== Support functions ======================
|
||||
" Count the number of blanck character before anything interesting
|
||||
" has happened
|
||||
fun! s:CalculateIndentation( ln ) "{{{
|
||||
let i = 0
|
||||
let spacecount = 0
|
||||
let maxi = len( a:ln )
|
||||
|
||||
while i < maxi
|
||||
let c = (a:ln)[i]
|
||||
if c == ' '
|
||||
let spacecount = spacecount + 1
|
||||
elseif c == '\t'
|
||||
let spacecount = spacecount + &tabstop
|
||||
else
|
||||
break
|
||||
endif
|
||||
|
||||
let i = i + 1
|
||||
endwhile
|
||||
|
||||
return i
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:f.GetLastStructClassDeclaration() "{{{
|
||||
let lineNum = line('.')
|
||||
let ourIndentation = s:CalculateIndentation( getline( lineNum ))
|
||||
|
||||
let lineNum = lineNum - 1
|
||||
|
||||
while lineNum >= 0
|
||||
let txt = getline( lineNum )
|
||||
|
||||
if txt =~ '\(struct\)\|\(class\)'
|
||||
if s:CalculateIndentation( txt ) < ourIndentation
|
||||
return substitute( txt, '\s*\(\(struct\)\|\(class\)\)\s\+\(\S\+\).*', '\4', '' )
|
||||
endif
|
||||
endif
|
||||
|
||||
let lineNum = lineNum - 1
|
||||
endwhile
|
||||
|
||||
return ""
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:f.WriteCtorToCpp() " {{{
|
||||
let imple = s:f.GetImplementationFile()
|
||||
if imple == ''
|
||||
return
|
||||
endif
|
||||
|
||||
let englobingClass = self.R('className')
|
||||
|
||||
let args = self.R( 'ctorArgs' )
|
||||
let methodBody = [ englobingClass . '::' . englobingClass . '(' . args . ')'
|
||||
\ , '{'
|
||||
\ , s:f.todoText
|
||||
\ , '}'
|
||||
\ , '' ]
|
||||
|
||||
let txt = extend( readfile( imple ), methodBody )
|
||||
call writefile( txt, imple )
|
||||
|
||||
return args
|
||||
endfunction " }}}
|
||||
|
||||
fun! s:f.WriteDtorToCpp() " {{{
|
||||
let imple = s:f.GetImplementationFile()
|
||||
if imple == ''
|
||||
return
|
||||
endif
|
||||
|
||||
let englobingClass = self.R('className')
|
||||
|
||||
let methodBody = [ englobingClass . '::~' . englobingClass . '()'
|
||||
\ , '{'
|
||||
\ , s:f.todoText
|
||||
\ , '}'
|
||||
\ , '' ]
|
||||
|
||||
let txt = extend( readfile( imple ), methodBody )
|
||||
call writefile( txt, imple )
|
||||
|
||||
return ''
|
||||
endfunction " }}}
|
||||
|
||||
fun! s:f.WriteStaticToCpp()
|
||||
let name = self.R('name')
|
||||
|
||||
let imple = s:f.GetImplementationFile()
|
||||
if imple == ''
|
||||
return name
|
||||
endif
|
||||
|
||||
let englobingClass = self.GetLastStructClassDeclaration()
|
||||
if englobingClass == ''
|
||||
return name
|
||||
endif
|
||||
|
||||
let methodBody = [ self.R('fieldType') . ' ' . englobingClass . '::' . name . ';' ]
|
||||
|
||||
let txt = extend( readfile( imple ), methodBody )
|
||||
call writefile( txt, imple )
|
||||
|
||||
return name
|
||||
endfunction
|
||||
|
||||
fun! s:f.WriteCopyCtorToCpp() " {{{
|
||||
let cpy = self.R('cpy')
|
||||
|
||||
let imple = s:f.GetImplementationFile()
|
||||
if imple == ''
|
||||
return cpy
|
||||
endif
|
||||
|
||||
let englobingClass = self.R('className')
|
||||
|
||||
let methodBody = [ englobingClass . '::' . englobingClass . '( const ' . englobingClass . ' &' . cpy . ' )'
|
||||
\ , '{'
|
||||
\ , s:f.todoText
|
||||
\ , '}'
|
||||
\ , '' ]
|
||||
|
||||
let txt = extend( readfile( imple ), methodBody )
|
||||
call writefile( txt, imple )
|
||||
|
||||
return cpy
|
||||
endfunction " }}}
|
||||
|
||||
fun! s:f.WriteMethodToCpp() "{{{
|
||||
let imple = s:f.GetImplementationFile()
|
||||
if imple == ''
|
||||
return ''
|
||||
endif
|
||||
|
||||
let englobingClass = self.GetLastStructClassDeclaration()
|
||||
if englobingClass == ''
|
||||
return ''
|
||||
endif
|
||||
|
||||
let args = self.R( 'args' )
|
||||
let constness = self.R( 'const?...' )
|
||||
let retType = self.R( 'retType' )
|
||||
let methodBody = [ retType . ' ' . englobingClass . '::' . self.R('funcName')
|
||||
\ . '(' . args . ')' . constness
|
||||
\ , '{'
|
||||
\ , s:f.todoText
|
||||
\ , s:f.GetDefaultImplementation( retType )
|
||||
\ , '}'
|
||||
\ , '' ]
|
||||
|
||||
let txt = extend( readfile( imple ), methodBody )
|
||||
call writefile( txt, imple )
|
||||
|
||||
return ''
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:f.WriteOpOverloadToCpp()
|
||||
let imple = s:f.GetImplementationFile()
|
||||
if imple == ''
|
||||
return ''
|
||||
endif
|
||||
|
||||
let englobingClass = self.GetLastStructClassDeclaration()
|
||||
if englobingClass == ''
|
||||
return ''
|
||||
endif
|
||||
|
||||
let inputType = self.R( 'inputType' )
|
||||
let argName = self.R('inName' )
|
||||
let constness = self.R( 'const?...' )
|
||||
let retType = self.R( 'retType' )
|
||||
let methodBody = [ retType . ' ' . englobingClass . '::operator ' . self.R('opName')
|
||||
\ . '( const ' . inputType . ' ' . argName . ' )' . constness
|
||||
\ , '{'
|
||||
\ , s:f.todoText
|
||||
\ , s:f.GetDefaultImplementation( retType )
|
||||
\ , '}'
|
||||
\ , '' ]
|
||||
|
||||
let txt = extend( readfile( imple ), methodBody )
|
||||
call writefile( txt, imple )
|
||||
|
||||
return ''
|
||||
|
||||
endfunction
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
XPT hstatic " Static field + implementation
|
||||
XSET name|post=WriteStaticToCpp()
|
||||
static `fieldType^ `name^;
|
||||
..XPT
|
||||
|
||||
XPT hmethod " class method + implementation
|
||||
XSET cursor=WriteMethodToCpp()
|
||||
`retType^ `funcName^( `args^ )`const?...{{^ const`}}^;`cursor^
|
||||
..XPT
|
||||
|
||||
XPT hstruct " struct with skeletons written into .cpp
|
||||
struct `className^
|
||||
{
|
||||
`constructor...{{^`^R('className')^( `ctorArgs^WriteCtorToCpp()^^ );
|
||||
`}}^`destructor...{{^~`^R('className')^(`^WriteDtorToCpp()^^);
|
||||
`}}^`copy constructor...{{^`^R('className')^( const `^R('className')^ &`cpy^WriteCopyCtorToCpp()^^ );
|
||||
`}}^`cursor^
|
||||
};
|
||||
..XPT
|
||||
|
||||
XPT hclass " class with skeletons written into .cpp
|
||||
XSET heritageQualifier=Choose(['public', 'private', 'protected'])
|
||||
class `className^`inherit?...{{^ : `heritageQualifier^ `fatherName^`}}^
|
||||
{
|
||||
public:
|
||||
`constructor...{{^`^R('className')^( `ctorArgs^WriteCtorToCpp()^^ );
|
||||
`}}^`destructor...{{^~`^R('className')^(`^WriteDtorToCpp()^^);
|
||||
`}}^`copy constructor...{{^`^R('className')^( const `^R('className')^ &`cpy^WriteCopyCtorToCpp()^^ );
|
||||
`}}^`cursor^
|
||||
private:
|
||||
};
|
||||
..XPT
|
||||
|
||||
XPT hctor " Class constructor writing skeleton to cpp
|
||||
`className^GetLastStructClassDeclaration()^( `ctorArgs^WriteCtorToCpp()^^ );
|
||||
..XPT
|
||||
|
||||
XPT hdtor " Class destructor writing skeleton to cpp
|
||||
XSET cursor=WriteDtorToCpp()
|
||||
~`className^GetLastStructClassDeclaration()^();`cursor^
|
||||
..XPT
|
||||
|
||||
XPT hcopyctor " Class copy constructor writing skeleton to cpp
|
||||
`className^GetLastStructClassDeclaration()^( const `className^& `cpy^WriteCopyCtorToCpp()^^ );
|
||||
..XPT
|
||||
|
||||
XPT hoperator " operator overloading writing skeleton to cpp
|
||||
XSET cursor=WriteOpOverloadToCpp()
|
||||
`retType^GetLastStructClassDeclaration()&^ operator `opName^( const `inputType^GetLastStructClassDeclaration()&^ `inName^ )`const?...{{^ const`}}^;`cursor^
|
||||
..XPT
|
||||
|
||||
177
plugins/bundle/xptemplate/ftplugin/cpp/cpp.xpt.vim
Executable file
177
plugins/bundle/xptemplate/ftplugin/cpp/cpp.xpt.vim
Executable file
|
|
@ -0,0 +1,177 @@
|
|||
XPTemplate priority=sub
|
||||
|
||||
" Setting priority of cpp to "sub" or "subset of language", makes it override
|
||||
" all c snippet if conflict
|
||||
|
||||
|
||||
|
||||
XPTvar $TRUE true
|
||||
XPTvar $FALSE false
|
||||
XPTvar $NULL NULL
|
||||
|
||||
XPTvar $BRif \n
|
||||
XPTvar $BRloop \n
|
||||
XPTvar $BRloop \n
|
||||
XPTvar $BRstc \n
|
||||
XPTvar $BRfun \n
|
||||
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $CURSOR_PH /* cursor */
|
||||
|
||||
XPTvar $CL /*
|
||||
XPTvar $CM *
|
||||
XPTvar $CR */
|
||||
|
||||
XPTvar $CS //
|
||||
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _comment/singleDouble
|
||||
\ _condition/c.like
|
||||
\ _func/c.like
|
||||
\ _loops/c.while.like
|
||||
\ _loops/java.for.like
|
||||
\ _preprocessor/c.like
|
||||
\ _structures/c.like
|
||||
XPTinclude
|
||||
\ c/c
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
function! s:f.cleanTempl( ctx, ... )
|
||||
let cleaned = substitute( a:ctx, '\s*\(class\|typename\|int\|long\)\s*', '', 'g' )
|
||||
return cleaned
|
||||
endfunction
|
||||
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
XPT all " ..begin, ..end,
|
||||
`v^.begin(), `v^.end(), `cursor^
|
||||
|
||||
|
||||
XPT vector " std::vector<..> ..;
|
||||
std::vector<`type^> `var^;
|
||||
`cursor^
|
||||
|
||||
|
||||
XPT map " std::map<..,..> ..;
|
||||
std::map<`typeKey^,`val^> `name^;
|
||||
`cursor^
|
||||
|
||||
XPT class " class ..
|
||||
class `className^`$BRfun^{
|
||||
public:
|
||||
`className^(`$SParg`ctorParam?`$SParg^);
|
||||
~`className^();
|
||||
`className^(`$SParg^const `className^ &cpy`$SParg^);
|
||||
`cursor^
|
||||
private:
|
||||
};
|
||||
|
||||
`className^::`className^(`ctorParam?^)`$BRfun^{
|
||||
}
|
||||
|
||||
`className^::~`className^()`$BRfun^{
|
||||
}
|
||||
|
||||
`className^::`className^(`$SParg^gconst `className^ &cpy`$SParg^)`$BRfun^{
|
||||
}
|
||||
..XPT
|
||||
|
||||
XPT functor " class operator..
|
||||
struct `className^
|
||||
{
|
||||
`closure...{{^`type^ `what^;
|
||||
`_^R('className')^( `type^ n`what^ ) : `what^( n`what^ ) {}
|
||||
|
||||
`}}^`outType^ operator() ( `params^ )
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
};
|
||||
..XPT
|
||||
|
||||
XPT namespace " namespace {}
|
||||
namespace `name^
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
..XPT
|
||||
|
||||
XPT icastop " operator type ..
|
||||
operator `typename^ ()
|
||||
{ return `cursor^; }
|
||||
..XPT
|
||||
|
||||
XPT castop " operator type ..
|
||||
operator `typename^ ();
|
||||
|
||||
|
||||
`className^::operator `typename^ ();
|
||||
{ return `cursor^; }
|
||||
..XPT
|
||||
|
||||
XPT iop " t operator .. ()
|
||||
`type^ operator `opName^ ( `args^ )`$BRfun^{
|
||||
`cursor^
|
||||
}
|
||||
..XPT
|
||||
|
||||
XPT op " t operator .. ()
|
||||
`type^ operator `opName^ ( `args^ );
|
||||
|
||||
`type^ `className^::operator `opName^ ( `args^ )`$BRfun^{
|
||||
}
|
||||
..XPT
|
||||
|
||||
XPT templateclass " template <> class
|
||||
template
|
||||
<`templateParam^>
|
||||
class `className^`$BRfun^{
|
||||
public:
|
||||
`className^(`$SParg`ctorParam?`$SParg^);
|
||||
~`className^();
|
||||
`className^(`$SParg^const `className^ &cpy`$SParg^);
|
||||
`cursor^
|
||||
private:
|
||||
};
|
||||
|
||||
template <`templateParam^>
|
||||
`className^<`_^cleanTempl(R('templateParam'))^^>::`className^(`ctorParam?^)`$BRfun^{
|
||||
}
|
||||
|
||||
template <`templateParam^>
|
||||
`className^<`_^cleanTempl(R('templateParam'))^^>::~`className^()`$BRfun^{
|
||||
}
|
||||
|
||||
template <`templateParam^>
|
||||
`className^<`_^cleanTempl(R('templateParam'))^^>::`className^(`$SParg^gconst `className^ &cpy`$SParg^)`$BRfun^{
|
||||
}
|
||||
..XPT
|
||||
|
||||
XPT try wrap=what " try .. catch..
|
||||
try
|
||||
{
|
||||
`what^
|
||||
}`$BRel^`Include:catch^
|
||||
|
||||
XPT catch " catch\( .. )
|
||||
catch ( `except^ )
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT externc wrap " #ifdef C++.... extern "c"...
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
`cursor^
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
..XPT
|
||||
|
||||
113
plugins/bundle/xptemplate/ftplugin/cs/cs.xpt.vim
Executable file
113
plugins/bundle/xptemplate/ftplugin/cs/cs.xpt.vim
Executable file
|
|
@ -0,0 +1,113 @@
|
|||
XPTemplate priority=lang-
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE true
|
||||
XPTvar $FALSE false
|
||||
XPTvar $NULL null
|
||||
|
||||
XPTvar $BRif \n
|
||||
XPTvar $BRloop \n
|
||||
XPTvar $BRloop \n
|
||||
XPTvar $BRstc \n
|
||||
XPTvar $BRfun \n
|
||||
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $CURSOR_PH /* cursor */
|
||||
|
||||
XPTvar $CL /*
|
||||
XPTvar $CM *
|
||||
XPTvar $CR */
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _comment/doubleSign
|
||||
\ _condition/c.like
|
||||
\ _loops/c.while.like
|
||||
\ _loops/java.for.like
|
||||
\ _structures/c.like
|
||||
|
||||
XPTinclude
|
||||
\ c/c
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
XPT foreach " foreach (.. in ..) {..}
|
||||
foreach ( `var^ `e^ in `what^ )`$BRloop^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT struct " struct { .. }
|
||||
`public^ struct `structName^
|
||||
{
|
||||
`fieldAccess^public^ `type^ `name^;`...^
|
||||
`fieldAccess^public^ `type^ `name^;`...^
|
||||
}
|
||||
|
||||
|
||||
XPT class " class +ctor
|
||||
class `className^
|
||||
{
|
||||
public `className^(` `ctorParam` ^)
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
XPT main " static main string[]
|
||||
public static void Main( string[] args )
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT prop " .. .. {get set}
|
||||
public `type^ `Name^
|
||||
{`
|
||||
`get...{{^
|
||||
get { return `what^; }`}}^`
|
||||
`set...{{^
|
||||
set { `what^ = `value^; }`}}^
|
||||
}
|
||||
|
||||
|
||||
XPT namespace " namespace {}
|
||||
namespace `name^
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT try wrap=what " try .. catch .. finally
|
||||
XSET handler=$CL handler $CR
|
||||
try
|
||||
{
|
||||
`what^
|
||||
}`
|
||||
`...^
|
||||
catch (`except^ e)
|
||||
{
|
||||
`handler^
|
||||
}`
|
||||
`...^`
|
||||
`finally...{{^
|
||||
finally
|
||||
{
|
||||
`cursor^
|
||||
}`}}^
|
||||
|
||||
|
||||
|
||||
" ================================= Wrapper ===================================
|
||||
XPT region_ wraponly=wrapped " #region #endregion
|
||||
#region `regionText^
|
||||
`wrapped^
|
||||
`cursor^
|
||||
#endregion /* `regionText^ */
|
||||
|
||||
521
plugins/bundle/xptemplate/ftplugin/css/css.xpt.vim
Normal file
521
plugins/bundle/xptemplate/ftplugin/css/css.xpt.vim
Normal file
|
|
@ -0,0 +1,521 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $CURSOR_PH /* cursor */
|
||||
|
||||
XPTvar $CL /*
|
||||
XPTvar $CM *
|
||||
XPTvar $CR */
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _comment/doubleSign
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
fun! s:f.css_braced_post()
|
||||
let v = self.V()
|
||||
let v = substitute( v, '^\s*$', '', 'g' )
|
||||
|
||||
if v =~ '^\s*\w\+('
|
||||
let name = matchstr( v, '^\s*\zs\w\+(' )
|
||||
return self.Build( ' ' . name . self.ItemCreate( '', {}, {} ) . ')' )
|
||||
else
|
||||
return v
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
XPT globalcn " global css from Sina
|
||||
body,ul,ol,li,p,h1,h2,h3,h4,h5,h6,form,fieldset,table,td,img,div{margin:0;padding:0;border:0;}
|
||||
body{background:#fff;color:#333;font-size:12px; margin-top:5px;font-family:"宋体";}
|
||||
|
||||
ul,ol{list-style-type:none;}
|
||||
select,input,img,select{vertical-align:middle;}
|
||||
|
||||
a{text-decoration:underline;}
|
||||
a:link{color:#009;}
|
||||
a:visited{color:#800080;}
|
||||
a:hover,a:active,a:focus{color:#c00;}
|
||||
|
||||
.clearit{clear:both;}
|
||||
|
||||
XPT globalen " global css from Yahoo
|
||||
html{color:#000;background:#FFF}
|
||||
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0}
|
||||
table{border-collapse:collapse;border-spacing:0}
|
||||
fieldset,img{border:0}
|
||||
address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal}
|
||||
li{list-style:none}
|
||||
caption,th{text-align:left}
|
||||
h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal}
|
||||
q:before,q:after{content:''}
|
||||
abbr,acronym{border:0;font-variant:normal}
|
||||
sup{vertical-align:text-top}
|
||||
sub{vertical-align:text-bottom}
|
||||
input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit}
|
||||
input,textarea,select{*font-size:100%}
|
||||
legend{color:#000}
|
||||
|
||||
body{font:13px/1.231 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small}
|
||||
select,input,button,textarea{font:99% arial,helvetica,clean,sans-serif}
|
||||
table{font-size:inherit;font:100%}
|
||||
pre,code,kbd,samp,tt{font-family:monospace;*font-size:108%;line-height:100%}
|
||||
|
||||
a{text-decoration:none}
|
||||
a:hover,a:focus{text-decoration:underline}
|
||||
strong{font-weight:bold}
|
||||
input[type=submit]{cursor:pointer}
|
||||
button{cursor:pointer}
|
||||
|
||||
XPT padding " padding:
|
||||
padding: `v^`v^AutoCmpl( 1, 'auto', '0px' )^;
|
||||
|
||||
XPT width " width :
|
||||
width: `^;
|
||||
|
||||
|
||||
XPT height " height :
|
||||
height: `^;
|
||||
|
||||
|
||||
XPT backrep " background-repeat
|
||||
XSET rep=Choose(['repeat', 'repeat-x','repeat-y','no-repeat'])
|
||||
background-repeat: `rep^;
|
||||
|
||||
|
||||
XPT azimuth " azimuth
|
||||
XSET azim=Choose(['left-side', 'far-left', 'left', 'center-left', 'center', 'center-right', 'right', 'far-right', 'right-side', 'behind', 'leftwards', 'rightwards'])
|
||||
azimuth: `azim^;
|
||||
|
||||
|
||||
XPT backpos " background-position
|
||||
XSET horiz=Choose(['left', 'center', 'right'])
|
||||
XSET horiz|post=SV('^\s*$', '', 'g')
|
||||
XSET vert=Choose(['top', 'center', 'bottom'])
|
||||
XSET vert|post=SV('^\s*$', '', 'g')
|
||||
background-position:` `vert`^` `horiz`^;
|
||||
|
||||
|
||||
XPT border " border
|
||||
XSET pos=ChooseStr( '-top', '-right', '-bottom', '-left' )
|
||||
XSET thick=Choose(['thin', 'thick', 'medium'])
|
||||
XSET thick|post=SV('^\s*$', '', 'g')
|
||||
XSET kind=Choose(['none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset'])
|
||||
XSET kind|post=SV('^\s*$', '', 'g')
|
||||
XSET color=Choose(['rgb()', '#', 'transparent'])
|
||||
XSET color|post=css_braced_post()
|
||||
border`pos^:` `thick^` `kind^` `color^;
|
||||
|
||||
|
||||
XPT backgroundattachment " background-attachment
|
||||
XSET selec=Choose(['scroll', 'fixed'])
|
||||
background-attachment: `selec^;
|
||||
|
||||
|
||||
XPT backgroundcolor " background-color
|
||||
XSET selec=Choose(['transparent', 'rgb()', '#'])
|
||||
XSET selec|post=css_braced_post()
|
||||
background-color:` `selec^;
|
||||
|
||||
|
||||
XPT backgroundimage " background-image
|
||||
XSET selec=Choose(['url()', 'none'])
|
||||
XSET selec|post=css_braced_post()
|
||||
background-image:` `selec^;
|
||||
|
||||
|
||||
XPT backgroundrepeat " background-repeat
|
||||
XSET selec=Choose(['repeat', 'repeat-x','repeat-y','no-repeat'])
|
||||
background-repeat: `selec^;
|
||||
|
||||
|
||||
XPT background " background
|
||||
XSET selec=Choose(['url()', 'scroll', 'fixed', 'transparent', 'rgb()', '#', 'none', 'top', 'center', 'bottom' , 'left', 'right', 'repeat', 'repeat-x', 'repeat-y', 'no-repeat'])
|
||||
XSET selec|post=css_braced_post()
|
||||
background:` `selec^;
|
||||
|
||||
|
||||
XPT bordercollapse " border-collapse
|
||||
XSET selec=Choose(['collapse', 'separate'])
|
||||
border-collapse: `selec^;
|
||||
|
||||
|
||||
XPT bordercolor " border-color
|
||||
XSET selec=Choose(['rgb()', '#', 'transparent'])
|
||||
XSET selec|post=css_braced_post()
|
||||
border-color:` `selec^;
|
||||
|
||||
|
||||
XPT borderspacing " border-spacing
|
||||
XSET select_disabled=Choose([''])
|
||||
border-spacing: `select^;
|
||||
|
||||
|
||||
XPT borderstyle " border-style
|
||||
XSET selec=Choose(['none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset'])
|
||||
border-style: `selec^;
|
||||
|
||||
|
||||
XPT borderwidth " border-width
|
||||
XSET selec=Choose(['thin', 'thick', 'medium'])
|
||||
border-width: `selec^;
|
||||
|
||||
|
||||
XPT bottom " bottom
|
||||
XSET selec=Choose(['auto'])
|
||||
bottom: `selec^;
|
||||
|
||||
|
||||
XPT captionside " caption-side
|
||||
XSET selec=Choose(['top', 'bottom'])
|
||||
caption-side: `selec^;
|
||||
|
||||
|
||||
XPT clear " clear
|
||||
XSET selec=Choose(['none', 'left', 'right', 'both'])
|
||||
clear: `selec^;
|
||||
|
||||
|
||||
XPT clip " clip
|
||||
XSET selec=Choose(['auto', 'rect('])
|
||||
clip: `selec^;
|
||||
|
||||
|
||||
XPT color " color
|
||||
XSET selec=Choose(['rgb()', '#'])
|
||||
XSET selec|post=css_braced_post()
|
||||
color:` `selec^;
|
||||
|
||||
|
||||
XPT content " content
|
||||
XSET selec=Choose(['normal', 'attr(', 'open-quote', 'close-quote', 'no-open-quote', 'no-close-quote'])
|
||||
content: `selec^;
|
||||
|
||||
|
||||
XPT cursor " cursor
|
||||
XSET selec=Choose(['url()', 'auto', 'crosshair', 'default', 'pointer', 'move', 'e-resize', 'ne-resize', 'nw-resize', 'n-resize', 'se-resize', 'sw-resize', 's-resize', 'w-resize', 'text', 'wait', 'help', 'progress'])
|
||||
XSET selec|post=css_braced_post()
|
||||
cursor:` `selec^;
|
||||
|
||||
|
||||
XPT direction " direction
|
||||
XSET selec=Choose(['ltr', 'rtl'])
|
||||
direction: `selec^;
|
||||
|
||||
|
||||
XPT display " display
|
||||
XSET selec=Choose(['inline', 'block', 'list-item', 'run-in', 'inline-block', 'table', 'inline-table', 'table-row-group', 'table-header-group', 'table-footer-group', 'table-row', 'table-column-group', 'table-column', 'table-cell', 'table-caption', 'none'])
|
||||
display: `selec^;
|
||||
|
||||
|
||||
XPT elevation " elevation
|
||||
XSET selec=Choose(['below', 'level', 'above', 'higher', 'lower'])
|
||||
elevation: `selec^;
|
||||
|
||||
|
||||
XPT emptycells " empty-cells
|
||||
XSET selec=Choose(['show', 'hide'])
|
||||
empty-cells: `selec^;
|
||||
|
||||
|
||||
XPT float " float
|
||||
XSET selec=Choose(['left', 'right', 'none'])
|
||||
float: `selec^;
|
||||
|
||||
|
||||
XPT fontfamily " font-family
|
||||
XSET selec=Choose(['sans-serif', 'serif', 'monospace', 'cursive', 'fantasy'])
|
||||
font-family: `selec^;
|
||||
|
||||
|
||||
XPT fontsize " font-size
|
||||
XSET selec=Choose(['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', 'larger', 'smaller'])
|
||||
font-size: `selec^;
|
||||
|
||||
|
||||
XPT fontstyle " font-style
|
||||
XSET selec=Choose(['normal', 'italic', 'oblique'])
|
||||
font-style: `selec^;
|
||||
|
||||
|
||||
XPT fontvariant " font-variant
|
||||
XSET selec=Choose(['normal', 'small-caps'])
|
||||
font-variant: `selec^;
|
||||
|
||||
|
||||
XPT fontweight " font-weight
|
||||
XSET selec=Choose(['normal', 'bold', 'bolder', 'lighter'])
|
||||
font-weight: `selec^;
|
||||
|
||||
|
||||
XPT font " font
|
||||
XSET kind=Choose(['normal', 'italic', 'oblique', 'small-caps', 'bold', 'bolder', 'lighter'])
|
||||
XSET kind|post=SV('^\s*$', '', 'g')
|
||||
XSET size=Choose(['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', 'larger', 'smaller'])
|
||||
XSET size|post=SV('^\s*$', '', 'g')
|
||||
XSET font=Choose(['sans-serif', 'serif', 'monospace', 'cursive', 'fantasy', 'caption', 'icon', 'menu', 'message-box', 'small-caption', 'status-bar'])
|
||||
XSET font|post=SV('^\s*$', '', 'g')
|
||||
font:` `kind`^` `size`^` `font`^;
|
||||
|
||||
|
||||
XPT letterspacing " letter-spacing
|
||||
XSET selec=Choose(['normal'])
|
||||
letter-spacing: `selec^;
|
||||
|
||||
|
||||
XPT lineheight " line-height
|
||||
XSET selec=Choose(['normal'])
|
||||
line-height: `selec^;
|
||||
|
||||
|
||||
XPT liststyleimage " list-style-image
|
||||
XSET selec=Choose(['url()', 'none'])
|
||||
XSET selec|post=css_braced_post()
|
||||
list-style-image:` `selec^;
|
||||
|
||||
|
||||
XPT liststyleposition " list-style-position
|
||||
XSET selec=Choose(['inside', 'outside'])
|
||||
list-style-position: `selec^;
|
||||
|
||||
|
||||
XPT liststyletype " list-style-type
|
||||
XSET selec=Choose(['disc', 'circle', 'square', 'decimal', 'decimal-leading-zero', 'lower-roman', 'upper-roman', 'lower-latin', 'upper-latin', 'none'])
|
||||
list-style-type: `selec^;
|
||||
|
||||
|
||||
XPT margin " margin
|
||||
XSET selec=Choose(['auto'])
|
||||
margin: `selec^;
|
||||
|
||||
|
||||
XPT maxheight " max-height
|
||||
XSET selec=Choose(['auto'])
|
||||
max-height: `selec^;
|
||||
|
||||
|
||||
XPT maxwidth " max-width
|
||||
XSET selec=Choose(['none'])
|
||||
max-width: `selec^;
|
||||
|
||||
|
||||
XPT minheight " min-height
|
||||
XSET selec=Choose(['none'])
|
||||
min-height: `selec^;
|
||||
|
||||
|
||||
XPT minwidth " min-width
|
||||
XSET selec=Choose(['none'])
|
||||
min-width: `selec^;
|
||||
|
||||
XPT outline " outline
|
||||
XSET color=Choose(['rgb()', '#'])
|
||||
XSET color|post=css_braced_post()
|
||||
XSET style=Choose(['none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset'])
|
||||
XSET style|post=SV('^\s*$', '', 'g')
|
||||
XSET width=Choose(['thin', 'thick', 'medium'])
|
||||
XSET width|post=SV('^\s*$', '', 'g')
|
||||
outline:` `width`^` `style`^` `color`^;
|
||||
|
||||
XPT outlinecolor " outline-color
|
||||
XSET selec=Choose(['rgb()', '#'])
|
||||
XSET selec|post=css_braced_post()
|
||||
outline-color:` `selec^;
|
||||
|
||||
|
||||
XPT outlinestyle " outline-style
|
||||
XSET selec=Choose(['none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset'])
|
||||
outline-style: `selec^;
|
||||
|
||||
|
||||
XPT outlinewidth " outline-width
|
||||
XSET selec=Choose(['thin', 'thick', 'medium'])
|
||||
outline-width: `selec^;
|
||||
|
||||
|
||||
XPT overflow " overflow
|
||||
XSET selec=Choose(['visible', 'hidden', 'scroll', 'auto'])
|
||||
overflow: `selec^;
|
||||
|
||||
|
||||
XPT pagebreakinside " page-break-inside
|
||||
XSET selec=Choose(['auto', 'avoid'])
|
||||
page-break-inside: `selec^;
|
||||
|
||||
|
||||
XPT pitch " pitch
|
||||
XSET selec=Choose(['x-low', 'low', 'medium', 'high', 'x-high'])
|
||||
pitch: `selec^;
|
||||
|
||||
|
||||
XPT playduring " play-during
|
||||
XSET selec=Choose(['url()', 'mix', 'repeat', 'auto', 'none'])
|
||||
XSET selec|post=css_braced_post()
|
||||
play-during:` `selec^;
|
||||
|
||||
|
||||
XPT position " position
|
||||
XSET selec=Choose(['static', 'relative', 'absolute', 'fixed'])
|
||||
position: `selec^;
|
||||
|
||||
|
||||
XPT quotes " quotes
|
||||
XSET selec=Choose(['none'])
|
||||
quotes: `selec^;
|
||||
|
||||
|
||||
XPT speakheader " speak-header
|
||||
XSET selec=Choose(['once', 'always'])
|
||||
speak-header: `selec^;
|
||||
|
||||
|
||||
XPT speaknumeral " speak-numeral
|
||||
XSET selec=Choose(['digits', 'continuous'])
|
||||
speak-numeral: `selec^;
|
||||
|
||||
|
||||
XPT speakpunctuation " speak-punctuation
|
||||
XSET selec=Choose(['code', 'none'])
|
||||
speak-punctuation: `selec^;
|
||||
|
||||
|
||||
XPT speak " speak
|
||||
XSET selec=Choose(['normal', 'none', 'spell-out'])
|
||||
speak: `selec^;
|
||||
|
||||
|
||||
XPT speechrate " speech-rate
|
||||
XSET selec=Choose(['x-slow', 'slow', 'medium', 'fast', 'x-fast', 'faster', 'slower'])
|
||||
speech-rate: `selec^;
|
||||
|
||||
|
||||
XPT tablelayout " table-layout
|
||||
XSET selec=Choose(['auto', 'fixed'])
|
||||
table-layout: `selec^;
|
||||
|
||||
|
||||
XPT textindent " text-indent
|
||||
text-indent: `^;
|
||||
|
||||
XPT textalign " text-align
|
||||
XSET selec=Choose(['left', 'right', 'center', 'justify'])
|
||||
text-align: `selec^;
|
||||
|
||||
|
||||
XPT textdecoration " text-decoration
|
||||
XSET selec=Choose(['none', 'underline', 'overline', 'line-through', 'blink'])
|
||||
text-decoration: `selec^;
|
||||
|
||||
|
||||
XPT texttransform " text-transform
|
||||
XSET selec=Choose(['capitalize', 'uppercase', 'lowercase', 'none'])
|
||||
text-transform: `selec^;
|
||||
|
||||
|
||||
XPT top " top
|
||||
XSET selec=Choose(['auto'])
|
||||
top: `selec^;
|
||||
|
||||
|
||||
XPT unicodebidi " unicode-bidi
|
||||
XSET selec=Choose(['normal', 'embed', 'bidi-override'])
|
||||
unicode-bidi: `selec^;
|
||||
|
||||
|
||||
XPT verticalalign " vertical-align
|
||||
XSET selec=Choose(['baseline', 'sub', 'super', 'top', 'text-top', 'middle', 'bottom', 'text-bottom'])
|
||||
vertical-align: `selec^;
|
||||
|
||||
|
||||
XPT visibility " visibility
|
||||
XSET selec=Choose(['visible', 'hidden', 'collapse'])
|
||||
visibility: `selec^;
|
||||
|
||||
|
||||
XPT volume " volume
|
||||
XSET selec=Choose(['silent', 'x-soft', 'soft', 'medium', 'loud', 'x-loud'])
|
||||
volume: `selec^;
|
||||
|
||||
|
||||
XPT whitespace " white-space
|
||||
XSET selec=Choose(['normal', 'pre', 'nowrap', 'pre-wrap', 'pre-line'])
|
||||
white-space: `selec^;
|
||||
|
||||
|
||||
XPT wordspacing " word-spacing
|
||||
XSET selec=Choose(['normal'])
|
||||
word-spacing: `selec^;
|
||||
|
||||
|
||||
XPT zindex " z-index
|
||||
XSET selec=Choose(['auto'])
|
||||
z-index: `selec^;
|
||||
|
||||
|
||||
XPT bordertopcolor " border-top-color
|
||||
XSET col=Choose(['rgb()', '#', 'transparent'])
|
||||
XSET col|post=css_braced_post()
|
||||
border-top-color:` `col^;
|
||||
|
||||
XPT borderbottomcolor " border-bottom-color
|
||||
XSET col=Choose(['rgb()', '#', 'transparent'])
|
||||
XSET col|post=css_braced_post()
|
||||
border-bottom-color:` `col^;
|
||||
|
||||
XPT borderrightcolor " border-right-color
|
||||
XSET col=Choose(['rgb()', '#', 'transparent'])
|
||||
XSET col|post=css_braced_post()
|
||||
border-right-color:` `col^;
|
||||
|
||||
XPT borderleftcolor " border-left-color
|
||||
XSET col=Choose(['rgb()', '#', 'transparent'])
|
||||
XSET col|post=css_braced_post()
|
||||
border-left-color:` `col^;
|
||||
|
||||
XPT bordertopstyle " border-top-style
|
||||
XSET col=Choose(['none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset'])
|
||||
border-top-style: `col^;
|
||||
|
||||
XPT borderbottomstyle " border-bottom-style
|
||||
XSET col=Choose(['none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset'])
|
||||
border-bottom-style: `col^;
|
||||
|
||||
XPT borderrightstyle " border-right-style
|
||||
XSET col=Choose(['none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset'])
|
||||
border-right-style: `col^;
|
||||
|
||||
XPT borderleftstyle " border-left-style
|
||||
XSET col=Choose(['none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset'])
|
||||
border-left-style: `col^;
|
||||
|
||||
XPT bordertopwidth " border-top-width
|
||||
XSET col=Choose(['rgb()', '#', 'transparent'])
|
||||
XSET col|post=css_braced_post()
|
||||
border-top-width:` `col^;
|
||||
|
||||
XPT borderbottomwidth " border-bottom-width
|
||||
XSET col=Choose(['thin', 'thick', 'medium'])
|
||||
border-bottom-width: `col^;
|
||||
|
||||
XPT borderrightwidth " border-right-width
|
||||
XSET col=Choose(['thin', 'thick', 'medium'])
|
||||
border-right-width: `col^;
|
||||
|
||||
XPT borderleftwidth " border-left-width
|
||||
XSET col=Choose(['thin', 'thick', 'medium'])
|
||||
border-left-width: `col^;
|
||||
|
||||
XPT pagebreakafter " page-break-after
|
||||
XSET what=Choose(['auto', 'always', 'avoid', 'left', 'right'])
|
||||
page-break-after: `what^;
|
||||
|
||||
XPT pagebreakbefore " page-break-before
|
||||
XSET what=Choose(['auto', 'always', 'avoid', 'left', 'right'])
|
||||
page-break-before: `what^;
|
||||
|
||||
116
plugins/bundle/xptemplate/ftplugin/dot/dot.xpt.vim
Normal file
116
plugins/bundle/xptemplate/ftplugin/dot/dot.xpt.vim
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $VOID_LINE /* void */
|
||||
XPTvar $CURSOR_PH /* cursor */
|
||||
|
||||
XPTvar $CL /*
|
||||
XPTvar $CM
|
||||
XPTvar $CR */
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _comment/doubleSign
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
XPT digraph " digraph .. { .. }
|
||||
digraph `graphName^
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
..XPT
|
||||
|
||||
|
||||
XPT graph " graph .. { .. }
|
||||
graph `graphName^
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
..XPT
|
||||
|
||||
XPT subgraph " subgraph .. { .. }
|
||||
subgraph `clusterName^
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
..XPT
|
||||
|
||||
XPT node " .. [...]
|
||||
XSET shape=Choose(['box', 'polygon', 'ellipse', 'circle', 'point', 'egg', 'triangle', 'plaintext', 'diamond', 'trapezium', 'parallelogram', 'house', 'pentagon', 'hexagon', 'septagon', 'octagon', 'doublecircle', 'doubleoctagon', 'tripleoctagon', 'invtriangle', 'invtrapezium', 'invhouse', 'Mdiamond', 'Msquare', 'Mcircle', 'rect', 'rectangle', 'none', 'note', 'tab', 'folder', 'box3d', 'component'])
|
||||
`node^` `details...{{^ [shape=`shape^, label="`^"]`}}^
|
||||
..XPT
|
||||
|
||||
XPT lbl " [label=".."]
|
||||
[label="`cursor^"]
|
||||
|
||||
|
||||
XPT shapeNode "
|
||||
`node^ [shape=`shape^` `label...{{^, label="`lbl^"`}}^]
|
||||
|
||||
..XPT
|
||||
|
||||
XPT circle alias=shapeNode " ..\[shape="circle"..]
|
||||
XSET shape|pre=circle
|
||||
XSET shape=Next()
|
||||
|
||||
|
||||
XPT diamond alias=shapeNode " ..\[shape="diamond"..]
|
||||
XSET shape|pre=diamond
|
||||
XSET shape=Next()
|
||||
|
||||
|
||||
XPT box alias=shapeNode " ..\[shape="box"..]
|
||||
XSET shape|pre=box
|
||||
XSET shape=Next()
|
||||
|
||||
|
||||
XPT ellipse alias=shapeNode " ..\[shape="ellipse"..]
|
||||
XSET shape|pre=ellipse
|
||||
XSET shape=Next()
|
||||
|
||||
|
||||
XPT record " ..\[shape="record", label=".."]
|
||||
`node^ [shape=record, label="`<`id`>^ `lbl^`...^| `<`id`>^ `lbl^`...^"]
|
||||
|
||||
..XPT
|
||||
|
||||
|
||||
XPT triangle " ..\[shape="triangle", label=".."]
|
||||
`node^ [shape=triangle, label="`<`id`>^ `lbl^`...^| `<`id`>^ `lbl^`...^"]
|
||||
|
||||
..XPT
|
||||
|
||||
|
||||
XPT row " {..|... }
|
||||
{`<`id`>^ `lbl^`...^| `<`id`>^ `lbl^`...^}
|
||||
|
||||
..XPT
|
||||
|
||||
|
||||
|
||||
XPT col " {..|... }
|
||||
{`<`id`>^ `lbl^`...^| `<`id`>^ `lbl^`...^}
|
||||
|
||||
..XPT
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
XPT subgraph_ wraponly=wrapped " subgraph .. { SEL }
|
||||
subgraph `clusterName^
|
||||
{
|
||||
`wrapped^
|
||||
}
|
||||
..XPT
|
||||
|
||||
135
plugins/bundle/xptemplate/ftplugin/erlang/erlang.xpt.vim
Executable file
135
plugins/bundle/xptemplate/ftplugin/erlang/erlang.xpt.vim
Executable file
|
|
@ -0,0 +1,135 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $CURSOR_PH cursor
|
||||
|
||||
XPTvar $BRif ' '
|
||||
XPTvar $BRel \n
|
||||
XPTvar $BRloop ' '
|
||||
XPTvar $BRstc ' '
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
XPT inc " -include ..
|
||||
-include( "`cursor^.hrl").
|
||||
|
||||
|
||||
XPT def " -define ..
|
||||
-define( `what^, `def^ ).
|
||||
|
||||
|
||||
XPT ifdef " -ifdef ..\-endif..
|
||||
-ifdef( `what^ ).
|
||||
`thenmacro^
|
||||
``else...`
|
||||
{{^-else.
|
||||
`cursor^
|
||||
`}}^-endif().
|
||||
|
||||
|
||||
XPT ifndef " -ifndef ..\-endif
|
||||
-ifndef( `what^ ).
|
||||
`thenmacro^
|
||||
``else...`
|
||||
{{^-else.
|
||||
`cursor^
|
||||
`}}^-endif().
|
||||
|
||||
|
||||
XPT record " -record ..,{..}
|
||||
-record( `recordName^
|
||||
,{ `field1^`...^
|
||||
, `fieldn^`...^
|
||||
}).
|
||||
|
||||
|
||||
XPT if " if .. -> .. end
|
||||
if
|
||||
`cond^ ->
|
||||
`body^` `...^;
|
||||
`cond2^ ->
|
||||
`bodyn^` `...^
|
||||
end `cursor^
|
||||
|
||||
|
||||
XPT case " case .. of .. -> .. end
|
||||
case `matched^ of
|
||||
`pattern^ ->
|
||||
`body^`...^;
|
||||
`patternn^ ->
|
||||
`bodyn^`...^
|
||||
end `cursor^
|
||||
|
||||
|
||||
XPT receive " receive .. -> .. end
|
||||
receive
|
||||
`pattern^ ->
|
||||
`body^` `...^;
|
||||
`patternn^ ->
|
||||
`body^` `...^`
|
||||
`after...{{^
|
||||
after
|
||||
`afterBody^`}}^
|
||||
end
|
||||
|
||||
|
||||
|
||||
XPT fun " fun .. -> .. end
|
||||
fun (`params^) `_^ -> `body^`
|
||||
`more...{{^;
|
||||
(`params^) `_^ -> `body^`
|
||||
`...{{^;
|
||||
(`params^) `_^ -> `body^`
|
||||
`...^`}}^`}}^
|
||||
end `cursor^
|
||||
|
||||
|
||||
XPT try wrap=what " try .. catch .. end
|
||||
try `what^
|
||||
catch
|
||||
`except^ -> `toRet^`
|
||||
`...^;
|
||||
`except^ -> `toRet^`
|
||||
`...^`
|
||||
`after...{{^
|
||||
after
|
||||
`afterBody^`}}^
|
||||
end `cursor^
|
||||
|
||||
|
||||
XPT tryof " try .. of ..
|
||||
try `what^ of
|
||||
`pattern^ ->
|
||||
`body^` `more...^;
|
||||
`patternn^ ->
|
||||
`body^` `more...^
|
||||
catch
|
||||
`excep^ -> `toRet^` `...^;
|
||||
`except^ -> `toRet^` `...^`
|
||||
`after...{{^
|
||||
after
|
||||
`afterBody^`}}^
|
||||
end `cursor^
|
||||
|
||||
|
||||
XPT function " f \( .. \) -> ..
|
||||
`funName^ ( `args0^ ) `_^ ->
|
||||
`body0^ `...^;
|
||||
`name^R('funName')^ ( `argsn^ ) `_^ ->
|
||||
`bodyn^`...^
|
||||
.
|
||||
71
plugins/bundle/xptemplate/ftplugin/eruby/eruby.ftdetect.vim
Normal file
71
plugins/bundle/xptemplate/ftplugin/eruby/eruby.ftdetect.vim
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
if exists("b:__ERUBY_FTDETECT_VIM__")
|
||||
finish
|
||||
endif
|
||||
let b:__ERUBY_FTDETECT_VIM__ = 1
|
||||
|
||||
|
||||
if &filetype !~ 'eruby'
|
||||
finish
|
||||
endif
|
||||
|
||||
|
||||
|
||||
let s:skipPattern = 'synIDattr(synID(line("."), col("."), 0), "name") =~? "\\vstring|comment"'
|
||||
let s:pattern = {
|
||||
\ 'ruby' : {
|
||||
\ 'start' : '\V\c<%',
|
||||
\ 'mid' : '',
|
||||
\ 'end' : '\V\c%>',
|
||||
\ 'skip' : s:skipPattern,
|
||||
\ },
|
||||
\ 'javascript' : {
|
||||
\ 'start' : '\V\c<script\_[^>]\*>',
|
||||
\ 'mid' : '',
|
||||
\ 'end' : '\V\c</script>',
|
||||
\ 'skip' : s:skipPattern,
|
||||
\ },
|
||||
\ 'css' : {
|
||||
\ 'start' : '\V\c<style\_[^>]\*>',
|
||||
\ 'mid' : '',
|
||||
\ 'end' : '\V\c</style>',
|
||||
\ 'skip' : s:skipPattern,
|
||||
\ },
|
||||
\}
|
||||
|
||||
let s:topFT = 'eruby'
|
||||
|
||||
fun! XPT_erubyFiletypeDetect() "{{{
|
||||
let pos = [ line( "." ), col( "." ) ]
|
||||
|
||||
let synName = xpt#util#NearestSynName()
|
||||
|
||||
if synName == ''
|
||||
" top level ft is html
|
||||
return s:topFT
|
||||
|
||||
else
|
||||
|
||||
for [ name, ftPattern ] in items( s:pattern )
|
||||
let pos = searchpairpos( ftPattern.start, ftPattern.mid, ftPattern.end, 'nbW', ftPattern.skip )
|
||||
if pos != [0, 0]
|
||||
return name
|
||||
endif
|
||||
endfor
|
||||
|
||||
if synName =~ '^\cjavascript'
|
||||
return 'javascript'
|
||||
elseif synName =~ '^\ccss'
|
||||
return 'css'
|
||||
endif
|
||||
|
||||
return s:topFT
|
||||
|
||||
endif
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
if exists( 'b:XPTfiletypeDetect' )
|
||||
unlet b:XPTfiletypeDetect
|
||||
endif
|
||||
let b:XPTfiletypeDetect = function( 'XPT_erubyFiletypeDetect' )
|
||||
|
||||
21
plugins/bundle/xptemplate/ftplugin/eruby/eruby.xpt.vim
Normal file
21
plugins/bundle/xptemplate/ftplugin/eruby/eruby.xpt.vim
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
XPTemplate priority=lang-
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ html/html
|
||||
\ html/eruby*
|
||||
|
||||
XPTembed
|
||||
\ ruby/ruby
|
||||
\ javascript/javascript
|
||||
\ css/css
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
|
||||
|
||||
" ================================= Wrapper ===================================
|
||||
|
||||
93
plugins/bundle/xptemplate/ftplugin/factor/factor.xpt.vim
Normal file
93
plugins/bundle/xptemplate/ftplugin/factor/factor.xpt.vim
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
fun! s:f.ModuleName()
|
||||
let rootfolder = substitute(getcwd(), '^.*[\\/]\([^\\/]\+\)$', '\1', '')
|
||||
let filename = rootfolder . '/' . expand('%:h:h') . '/' . expand('%:t:r')
|
||||
let stripped = substitute( filename, '[\\/]', '.', 'g' )
|
||||
|
||||
return substitute( stripped, "-tests$", ".tests", '' )
|
||||
endfunction
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
XPT alias "ALIAS: ... ...
|
||||
ALIAS: `newword^ `oldword^
|
||||
|
||||
XPT const "CONSTANT: ... ...
|
||||
CONSTANT: `word^ `constantValue^
|
||||
|
||||
XPT if "... [ ... ] [ ... ] if
|
||||
`cond^ [ `then^ ] [ `else^ ] if
|
||||
|
||||
XPT times "... [ ... ] times
|
||||
`count^ [ `what^ ] times
|
||||
|
||||
XPT mod " USING: ... IN: ...
|
||||
XSET moduleName=ModuleName()
|
||||
USING: kernel sequences accessors ;
|
||||
IN: `moduleName^
|
||||
|
||||
XPT quote " [ ... ]
|
||||
[ `cursor^ ]
|
||||
|
||||
XPT arr " { ... }
|
||||
{ `cursor^ }
|
||||
|
||||
XPT vec " V{ ... }
|
||||
V{ `cursor^ }
|
||||
|
||||
XPT bi " [ ... ] [ ... ] bi
|
||||
[ `first^ ] [ `cursor^ ] bi
|
||||
|
||||
XPT tri " [ ... ] [ ... ] [ ... ] tri
|
||||
[ `first^ ] [ `second^ ] [ `cursor^ ] tri
|
||||
|
||||
XPT map " [ ... ] map
|
||||
[ `cursor^ ] map
|
||||
|
||||
XPT filter " [ ... ] filter
|
||||
[ `cursor^ ] filter
|
||||
|
||||
XPT dip " [ ... ] dip
|
||||
[ `cursor^ ] dip
|
||||
|
||||
XPT cleave " { [ ... ] ... } cleave
|
||||
{ [ `code^ ]`...^
|
||||
[ `code^ ]`...^
|
||||
} cleave
|
||||
|
||||
XPT when " [ ... ] when
|
||||
[ `cursor^ ] when
|
||||
|
||||
XPT unless " [ ... ] unless
|
||||
[ `cursor^ ] unless
|
||||
|
||||
XPT keep " [ ... ] keep
|
||||
[ `cursor^ ] keep
|
||||
|
||||
XPT cond " { { [ ... ] [ ... ] } } cond
|
||||
{ { [ `cond^ ] [ `code^ ] }`...^
|
||||
{ [ `cond^ ] [ `code^ ] }`...^`default...{{^
|
||||
[ `cursor^ ]`}}^
|
||||
} cond
|
||||
|
||||
XPT case " { { ... [ ... ] } } case
|
||||
{ { `case^ [ `code^ ] }`...^
|
||||
{ `case^ [ `code^ ] }`...^`default...{{^
|
||||
[ `cursor^ ]`}}^
|
||||
} case
|
||||
|
||||
XPT test "[ ... ] [ ... ] unit-test
|
||||
{ `ret^ } [ `test^ ] unit-test
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
|
||||
XPT branch " [branch "..."]
|
||||
[branch "`branchName^"]`remote...{{^
|
||||
remote = `remote^`}}^`merge...{{^
|
||||
merge = refs/heads/`branchName^`}}^
|
||||
|
||||
XPT remote " [remote "..."]
|
||||
[remote "`remoteName^"]
|
||||
url = `fetchUrl^
|
||||
fetch = `fetchRef^
|
||||
|
||||
XPT user " Basic user configuration
|
||||
[user]
|
||||
name = `$Author^
|
||||
email = `$Email^
|
||||
|
||||
34
plugins/bundle/xptemplate/ftplugin/gnuplot/gnuplot.xpt.vim
Normal file
34
plugins/bundle/xptemplate/ftplugin/gnuplot/gnuplot.xpt.vim
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
XPT skeleton " basic file skeleton
|
||||
set title "`plotTitle^"
|
||||
set xlabel "`axisLabel^"
|
||||
set ylabel "`ordinateLabel^"
|
||||
|
||||
plot "`valueFile^" title "`valueTitle^" `using...{{^using `columns^ `}}^ with linespoint
|
||||
|
||||
XPT label " axis labels
|
||||
set xlabel "`axisLabel^"
|
||||
set ylabel "`ordinateLabel^"
|
||||
|
||||
XPT fun " ... ( ... ) = ...
|
||||
`funName^( `args^ )=`cursor^
|
||||
|
||||
XPT range " set xrange ...; set yrange ...
|
||||
set xrange [`xMin^:`xMax^]
|
||||
set yrange [`yMin^:`yMay^]
|
||||
|
||||
XPT tics " set xtics & ytics
|
||||
set xtics `xTics^
|
||||
set ytics `yTics^
|
||||
|
||||
XPT term " Change output terminal
|
||||
XSET termMode=Choose(['svg', 'canvas','latex', 'postscript', 'x11','eps', 'xterm'])
|
||||
set terminal `termMode^ enhanced`size...{{^ size `width^ `height^`}}^
|
||||
set output "`filename^"
|
||||
|
||||
179
plugins/bundle/xptemplate/ftplugin/go/go.xpt.vim
Normal file
179
plugins/bundle/xptemplate/ftplugin/go/go.xpt.vim
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
fun! s:f.MakeIntType( n )
|
||||
let n = a:n
|
||||
return matchstr(n, '\v^u') . "int" . matchstr(n, '\v\d+$' )
|
||||
endfunction
|
||||
|
||||
XPTvar $TRUE true
|
||||
XPTvar $FALSE false
|
||||
XPTvar $NULL nil
|
||||
XPTvar $UNDEFINED nil
|
||||
|
||||
XPTvar $SParg ''
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _comment/c.like
|
||||
|
||||
|
||||
XPT _dec hidden " $_xSnipName
|
||||
`$_xSnipName^
|
||||
|
||||
XPT package alias=_dec
|
||||
XPT import alias=_dec
|
||||
XPT type alias=_dec
|
||||
XPT const alias=_dec
|
||||
XPT var alias=_dec
|
||||
|
||||
XPT _int " MakeIntType($_xSnipName)
|
||||
`MakeIntType($_xSnipName)^
|
||||
|
||||
XPT i8 alias=_int
|
||||
XPT i16 alias=_int
|
||||
XPT i32 alias=_int
|
||||
XPT i64 alias=_int
|
||||
XPT u8 alias=_int
|
||||
XPT u16 alias=_int
|
||||
XPT u32 alias=_int
|
||||
XPT u64 alias=_int
|
||||
|
||||
XPT struct " struct {
|
||||
struct {
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT func wrap " func () int {
|
||||
func `n^(`p?^)` `int?^ {
|
||||
`cursor^
|
||||
}
|
||||
XPT meth wrap " func (*T) () int {
|
||||
func (`^) `n^(`p?^)` `int?^ {
|
||||
`cursor^
|
||||
}
|
||||
XPT go " go func (){}()
|
||||
go func (`p?^) {
|
||||
`cursor^
|
||||
}()
|
||||
XPT tfunc " func Test
|
||||
func Test`^(t *testing.T) {
|
||||
`cursor^
|
||||
}
|
||||
XPT bfunc " func Test
|
||||
func Benchmark`^(b *testing.B) {
|
||||
`cursor^
|
||||
|
||||
for ii := 0; i < b.N; i++ {
|
||||
}
|
||||
}
|
||||
XPT main " func main\()
|
||||
func main() {
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT println " fmt.Println\()
|
||||
fmt.Println( `^ )
|
||||
XPT sprintf " fmt.Sprintf\()
|
||||
fmt.Sprintf( `^ )
|
||||
|
||||
XPT forever " for ;;
|
||||
for ;; {
|
||||
`cursor^
|
||||
}
|
||||
XPT for wrap " for i=0; i<10; i++
|
||||
for `i^ := `0^; `i^ < `10^; `i^++ {
|
||||
`cursor^
|
||||
}
|
||||
XPT forr wrap " for i=10; i>=0; i--
|
||||
for `i^ := `10^; `i^ >= `0^; `i^-- {
|
||||
`cursor^
|
||||
}
|
||||
XPT forrange wrap " for range
|
||||
for `_^, `^ := range `^ {
|
||||
`cursor^
|
||||
}
|
||||
XPT forin wrap alias=forrange
|
||||
|
||||
XPT if wrap " if {
|
||||
if `^ {
|
||||
`cursor^
|
||||
}
|
||||
XPT iftype wrap " if _, ok := x.(type); ok { ... }
|
||||
if _, ok := `x^.( `tp^ ); ok {
|
||||
`cursor^
|
||||
}
|
||||
XPT _ifeq wrap hidden " if x == $v {
|
||||
XSET $v=0
|
||||
if `^ == `$v^ {
|
||||
`cursor^
|
||||
}
|
||||
XPT _ifne wrap hidden " if x != $v {
|
||||
XSET $v=0
|
||||
if `x^ != `$v^ {
|
||||
`cursor^
|
||||
}
|
||||
XPT iferr " if err != nil {
|
||||
if err != nil {
|
||||
`cursor^
|
||||
}
|
||||
XPT ifn alias=_ifeq
|
||||
XSET $v=nil
|
||||
XPT ifnn alias=_ifne
|
||||
XSET $v=nil
|
||||
XPT if0 alias=_ifeq
|
||||
XSET $v=0
|
||||
XPT ifn0 alias=_ifne
|
||||
XSET $v=0
|
||||
XPT else
|
||||
else {
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT mps " map[string]
|
||||
map[`string^]`T^
|
||||
XPT mpi " map[string]
|
||||
map[`int^]`T^
|
||||
|
||||
XPT mkc " make\(chan X, n, capa?)
|
||||
make(chan `bool^, `0^`, `capa?^)
|
||||
XPT mks " make\([]X, n, capa?)
|
||||
make([]`bool^, `0^`, `capa?^)
|
||||
XPT mkm " make\(map[X]Y, n, capa?)
|
||||
make(map[`string^]`bool^`, `capa?^)
|
||||
XPT mkms " make\(map[string]Y, n, capa?)
|
||||
make(map[string]`bool^`, `capa?^)
|
||||
|
||||
XPT sel " select
|
||||
select {
|
||||
case `^:
|
||||
`cursor^
|
||||
}
|
||||
XPT selc " select x <-ch
|
||||
select {
|
||||
case ``x?` := ^<-`ch^:
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT switch " switch x {
|
||||
switch `^ {
|
||||
case `^:
|
||||
`cursor^
|
||||
}
|
||||
XPT default " default:
|
||||
default:
|
||||
`cursor^
|
||||
|
||||
XPT test " if .. t.Errorf
|
||||
if `^ {} else {
|
||||
t.Errorf( `^ )
|
||||
}
|
||||
XPT ttype " if _, ok := x.(type); ok { ... }
|
||||
if _, ok := `x^.( `tp^ ); ok {} else {
|
||||
t.Errorf( "Expect `x^ to be `tp^ but: %v", `x^ )
|
||||
}
|
||||
XPT assert " if .. t.Errorf
|
||||
if `^ {} else {
|
||||
t.Fatalf( `^ )
|
||||
}
|
||||
164
plugins/bundle/xptemplate/ftplugin/haskell/haskell.xpt.vim
Executable file
164
plugins/bundle/xptemplate/ftplugin/haskell/haskell.xpt.vim
Executable file
|
|
@ -0,0 +1,164 @@
|
|||
XPTemplate priority=lang mark=`~
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $BRif \n
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _preprocessor/c.like
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
XPT head " -----------------------------
|
||||
--------------------------------------------------
|
||||
---- `headName~
|
||||
--------------------------------------------------
|
||||
|
||||
XPT class " class .. where..
|
||||
class `context...{{~(`ctxt~) => `}}~`className~ `types~a~ where
|
||||
`ar~ :: `type~ `...~
|
||||
`methodName~ :: `methodType~`...~
|
||||
`cursor~
|
||||
|
||||
XPT classcom " -- | class..
|
||||
-- | `classDescr~
|
||||
class `context...{{~(`ctxt~) => `}}~`className~ `types~a~ where
|
||||
-- | `methodDescr~
|
||||
`ar~ :: `type~ `...~
|
||||
-- | `method_Descr~
|
||||
`methodName~ :: `methodType~`...~
|
||||
`cursor~
|
||||
|
||||
XPT datasum " data .. = ..|..|..
|
||||
data `context...{{~(`ctxt~) => `}}~`typename~`typeParams~ ~=
|
||||
`Constructor~ `ctorParams~VOID()~`
|
||||
`...~
|
||||
| `Ctor~ `params~VOID()~
|
||||
`...~
|
||||
`deriving...{{~deriving (`Eq,Show~)`}}~
|
||||
`cursor~
|
||||
|
||||
|
||||
XPT datasumcom " -- | data .. = ..|..|..
|
||||
-- | `typeDescr~VOID()~
|
||||
data `context...{{~(`ctxt~) => `}}~`typename~` `typeParams~ ~=
|
||||
-- | `ConstructorDescr~
|
||||
`Constructor~ `ctorParams~VOID()~`
|
||||
`...~
|
||||
-- | `Ctor descr~VOID()~
|
||||
| `Ctor~ `params~VOID()~`
|
||||
`...~
|
||||
`deriving...{{~deriving (`Eq,Show~)`}}~
|
||||
`cursor~
|
||||
|
||||
XPT parser " .. = .. <|> .. <|> .. <?>
|
||||
`funName~ = `rule~`
|
||||
`another_rule...{{~
|
||||
<|> `rule~`
|
||||
`more...{{~
|
||||
<|> `rule~`
|
||||
`more...~`}}~`}}~
|
||||
`err...{{~<?> "`descr~"`}}~
|
||||
`cursor~
|
||||
|
||||
XPT datarecord " data .. ={}
|
||||
data `context...{{~(`ctxt~) => `}}~`typename~`typeParams~ ~=
|
||||
`Constructor~ {
|
||||
`field~ :: `type~`
|
||||
`...{{~,
|
||||
`fieldn~ :: `typen~`
|
||||
`...~`}}~
|
||||
}
|
||||
`deriving...{{~deriving (`Eq, Show~)`}}~
|
||||
`cursor~
|
||||
|
||||
XPT datarecordcom " -- | data .. ={}
|
||||
-- | `typeDescr~
|
||||
data `context...{{~(`ctxt~) => `}}~`typename~`typeParams~ ~=
|
||||
`Constructor~ {
|
||||
`field~ :: `type~ -- ^ `fieldDescr~`
|
||||
`...{{~,
|
||||
`fieldn~ :: `typen~ -- ^ `fielddescr~`
|
||||
`...~`}}~
|
||||
}
|
||||
`deriving...{{~deriving (`Eq,Show~)`}}~
|
||||
`cursor~
|
||||
|
||||
XPT instance " instance .. .. where
|
||||
instance `className~ `instanceTypes~ where
|
||||
`methodName~ `~ = `decl~ `...~
|
||||
`method~ `~ = `declaration~`...~
|
||||
`cursor~
|
||||
|
||||
XPT if " if .. then .. else
|
||||
if `expr~
|
||||
then `thenCode~
|
||||
else `cursor~
|
||||
|
||||
XPT fun " fun pat = ..
|
||||
`funName~ `pattern~ = `def~`
|
||||
`...{{~
|
||||
`name~R("funName")~ `pattern~ = `def~`
|
||||
`...~`}}~
|
||||
|
||||
XPT funcom " -- | fun pat = ..
|
||||
-- | `function_description~
|
||||
`funName~ :: `type~
|
||||
`name~R("funName")~ `pattern~ = `def~`
|
||||
`...{{~
|
||||
`name~R("funName")~ `pattern~ = `def~`
|
||||
`...~`}}~
|
||||
|
||||
XPT funtype " .. :: .. => .. -> .. ->
|
||||
`funName~ :: `context...{{~(`ctxt~)
|
||||
=>`}}~ `type~ -- ^ `is~`
|
||||
`...{{~
|
||||
-> `type~ -- ^ `is~`
|
||||
`...~`}}~
|
||||
|
||||
XPT options " {-# OPTIONS_GHC .. #-}
|
||||
{-# OPTIONS_GHC `options~ #-}
|
||||
|
||||
XPT lang " {-# LANGUAGE .. #-}
|
||||
{-# LANGUAGE `langName~ #-}
|
||||
|
||||
XPT inline " {-# INLINE .. #-}
|
||||
{-# INLINE `phase...{{~[`2~] `}}~`funName~ #-}
|
||||
|
||||
XPT noninline " {-# NOINLINE .. #-}
|
||||
{-# NOINLINE `funName~ #-}
|
||||
|
||||
XPT type " .. -> .. ->....
|
||||
`context...{{~(`ctxt~) => `}}~`t1~ -> `t2~`...~ -> `t3~`...~
|
||||
|
||||
XPT deriving " deriving (...)
|
||||
deriving (`classname~`...~,`classname~`...~)
|
||||
|
||||
XPT derivingstand " deriving instance ...
|
||||
deriving instance `context...{{~`ctxt~ => `}}~`class~ `type~
|
||||
|
||||
XPT module " module .. () where ...
|
||||
XSET moduleName=S(S(E('%:r'),'^.','\u&', ''), '[\\/]\(.\)', '.\u\1', 'g')
|
||||
module `moduleName~ `exports...{{~( `cursor~
|
||||
) `}}~where
|
||||
|
||||
XPT foldr " foldr (.... -> ...)
|
||||
foldr (\ `e~ `acc~ -> `expr~) `init~ `lst~
|
||||
|
||||
XPT foldl " foldl' (.... -> ...)
|
||||
foldl' (\ `acc~ `elem~ -> `expr~) `init~ `lst~
|
||||
|
||||
XPT map " map (... -> ...)
|
||||
map (`elem~ -> `expr~) `list~
|
||||
|
||||
31
plugins/bundle/xptemplate/ftplugin/help/help.xpt.vim
Normal file
31
plugins/bundle/xptemplate/ftplugin/help/help.xpt.vim
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
|
||||
" containers
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
" inclusion
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
XPT ln " ========...
|
||||
==============================================================================
|
||||
|
||||
|
||||
XPT fmt " vim: options...
|
||||
vim:tw=78:ts=8:sw=8:sts=8:noet:ft=help:norl:
|
||||
|
||||
|
||||
XPT q " : > ... <
|
||||
: >
|
||||
`cursor^
|
||||
<
|
||||
|
||||
|
||||
XPT r " |...|
|
||||
|`content^|
|
||||
|
||||
24
plugins/bundle/xptemplate/ftplugin/html/eruby.xpt.vim
Normal file
24
plugins/bundle/xptemplate/ftplugin/html/eruby.xpt.vim
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
" These snippets work only in html context of a eruby file
|
||||
if &filetype != 'eruby'
|
||||
finish
|
||||
endif
|
||||
|
||||
XPTemplate priority=lang-
|
||||
|
||||
|
||||
XPT ruby " <% ...
|
||||
<%
|
||||
`cursor^
|
||||
%>
|
||||
|
||||
|
||||
XPT r " <% ... %>
|
||||
<% `cursor^ %>
|
||||
|
||||
|
||||
XPT re " <%= ...
|
||||
<%= `expr^ %>
|
||||
|
||||
|
||||
XPT rc " <%# ...
|
||||
<%# `cursor^ %>
|
||||
63
plugins/bundle/xptemplate/ftplugin/html/html.ftdetect.vim
Normal file
63
plugins/bundle/xptemplate/ftplugin/html/html.ftdetect.vim
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
if exists("b:__HTML_FTDETECT_VIM__")
|
||||
finish
|
||||
endif
|
||||
let b:__HTML_FTDETECT_VIM__ = 1
|
||||
|
||||
|
||||
" TODO xhtml support
|
||||
|
||||
if &filetype !~ 'html'
|
||||
finish
|
||||
endif
|
||||
|
||||
|
||||
let s:skipPattern = 'synIDattr(synID(line("."), col("."), 0), "name") =~? "\\vstring|comment"'
|
||||
let s:pattern = {
|
||||
\ 'javascript' : {
|
||||
\ 'start' : '\V\c<script\_[^>]\*>',
|
||||
\ 'mid' : '',
|
||||
\ 'end' : '\V\c</script>',
|
||||
\ 'skip' : s:skipPattern,
|
||||
\ },
|
||||
\ 'css' : {
|
||||
\ 'start' : '\V\c<style\_[^>]\*>',
|
||||
\ 'mid' : '',
|
||||
\ 'end' : '\V\c</style>',
|
||||
\ 'skip' : s:skipPattern,
|
||||
\ },
|
||||
\}
|
||||
|
||||
fun! XPT_htmlFiletypeDetect() "{{{
|
||||
let pos = [ line( "." ), col( "." ) ]
|
||||
let synName = xpt#util#NearestSynName()
|
||||
|
||||
if synName == ''
|
||||
" no character at current position or before curernt position
|
||||
return &filetype
|
||||
|
||||
else
|
||||
|
||||
for [ name, ftPattern ] in items( s:pattern )
|
||||
let pos = searchpairpos( ftPattern.start, ftPattern.mid, ftPattern.end, 'nbW', ftPattern.skip )
|
||||
if pos != [0, 0]
|
||||
return name
|
||||
endif
|
||||
endfor
|
||||
|
||||
if synName =~ '^\cjavascript'
|
||||
return 'javascript'
|
||||
elseif synName =~ '^\ccss'
|
||||
return 'css'
|
||||
endif
|
||||
|
||||
return &filetype
|
||||
|
||||
endif
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
if exists( 'b:XPTfiletypeDetect' )
|
||||
unlet b:XPTfiletypeDetect
|
||||
endif
|
||||
let b:XPTfiletypeDetect = function( 'XPT_htmlFiletypeDetect' )
|
||||
|
||||
412
plugins/bundle/xptemplate/ftplugin/html/html.xpt.vim
Normal file
412
plugins/bundle/xptemplate/ftplugin/html/html.xpt.vim
Normal file
|
|
@ -0,0 +1,412 @@
|
|||
" TODO entity char
|
||||
" TODO back at 'base'
|
||||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ xml/xml
|
||||
|
||||
|
||||
|
||||
XPTvar $CURSOR_PH
|
||||
|
||||
XPTvar $CL <!--
|
||||
XPTvar $CM
|
||||
XPTvar $CR -->
|
||||
XPTinclude
|
||||
\ _comment/doubleSign
|
||||
|
||||
XPTembed
|
||||
\ javascript/javascript
|
||||
\ css/css
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
|
||||
|
||||
fun! s:f.createTable(...) "{{{
|
||||
let nrow_str = inputdialog("num of row:")
|
||||
let nrow = nrow_str + 0
|
||||
|
||||
let ncol_str = inputdialog("num of column:")
|
||||
let ncol = ncol_str + 0
|
||||
|
||||
let l = ""
|
||||
let i = 0 | while i < nrow | let i += 1
|
||||
let j = 0 | while j < ncol | let j += 1
|
||||
let l .= "<tr>\n<td id=\"`pre^_".i."_".j."\"></td>\n</tr>\n"
|
||||
endwhile
|
||||
endwhile
|
||||
return "<table id='`id^'>\n".l."</table>"
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
let s:doctypes = {
|
||||
\ 'HTML 3.2 Final' : 'html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"',
|
||||
\ 'HTML 4.0 Frameset' : 'html PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN" "http://www.w3.org/TR/REC-html40/frameset.dtd"',
|
||||
\ 'HTML 4.0 Transitional' : 'html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"',
|
||||
\ 'HTML 4.0' : 'html PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"',
|
||||
\ 'HTML 4.01 Frameset' : 'html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"',
|
||||
\ 'HTML 4.01 Transitional' : 'html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"',
|
||||
\ 'HTML 4.01' : 'html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"',
|
||||
\ 'HTML 5' : 'HTML',
|
||||
\ 'XHTML 1.0 Frameset' : 'html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"',
|
||||
\ 'XHTML 1.0 Strict' : 'html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"',
|
||||
\ 'XHTML 1.0 Transitional' : 'html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"',
|
||||
\ 'XHTML 1.1' : 'html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"',
|
||||
\ 'XHTML Basic 1.0' : 'html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd"',
|
||||
\ 'XHTML Basic 1.1' : 'html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd"',
|
||||
\ 'XHTML Mobile 1.0' : 'html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"',
|
||||
\ 'XHTML Mobile 1.1' : 'html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.1//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd"',
|
||||
\ 'XHTML Mobile 1.2' : 'html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd"',
|
||||
\}
|
||||
|
||||
|
||||
fun! s:f.html_doctype_list()
|
||||
return keys( s:doctypes )
|
||||
endfunction
|
||||
|
||||
fun! s:f.html_doctype_post(v)
|
||||
if has_key( s:doctypes, a:v )
|
||||
return s:doctypes[ a:v ]
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
fun! s:f.html_enc()
|
||||
return &fenc == '' ? &encoding : &fenc
|
||||
endfunction
|
||||
|
||||
let s:nIndent = 0
|
||||
fun! s:f.html_cont_ontype()
|
||||
let v = self.V()
|
||||
if v =~ '\V\n'
|
||||
let v = matchstr( v, '\V\.\*\ze\n' )
|
||||
let s:nIndent = &indentexpr != ''
|
||||
\ ? eval( substitute( &indentexpr, '\Vv:lnum', 'line(".")', '' ) ) - indent( line( "." ) - 1 )
|
||||
\ : self.NIndent()
|
||||
|
||||
return self.Finish( v . "\n" . repeat( ' ', s:nIndent ) )
|
||||
else
|
||||
return v
|
||||
endif
|
||||
endfunction
|
||||
|
||||
fun! s:f.html_cont_helper()
|
||||
let v = self.V()
|
||||
if v =~ '\V\n'
|
||||
return self.ResetIndent( -s:nIndent, "\n" )
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
fun! s:f.html_tag_cmpl()
|
||||
if !exists( 'b:xpt_html_tags' )
|
||||
call htmlcomplete#LoadData()
|
||||
let tagnames = sort( keys( b:html_omni ) )
|
||||
let b:xpt_html_tags = []
|
||||
let dict = {
|
||||
\ 'vimxmlattrinfo' : 1,
|
||||
\ 'vimxmlentities' : 1,
|
||||
\ 'vimxmlroot' : 1,
|
||||
\ 'vimxmltaginfo' : 1,
|
||||
\ }
|
||||
for t in tagnames
|
||||
if !has_key( dict, t )
|
||||
call add(b:xpt_html_tags, t)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
return b:xpt_html_tags
|
||||
|
||||
endfunction
|
||||
|
||||
fun! s:f.html_close_tag()
|
||||
let v = self.V()
|
||||
if v =~ '\v/\s*$|^!'
|
||||
return ''
|
||||
else
|
||||
return '</' . matchstr( v, '\v^\S+' ) . '>'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
call XPTdefineSnippet("id", {'syn' : 'tag'}, 'id="`^"')
|
||||
call XPTdefineSnippet("class", {'syn' : 'tag'}, 'class="`^"')
|
||||
|
||||
|
||||
|
||||
" TODO map < to tag
|
||||
|
||||
|
||||
XPT tag hidden " <$_xSnipName>..</$_xSnipName>
|
||||
XSET content|def=Echo( R( 't' ) =~ '\v/\s*$' ? Finish() : '' )
|
||||
XSET content|ontype=html_cont_ontype()
|
||||
<`t^$_xSnipName^>`content^`content^html_cont_helper()^`t^html_close_tag()^
|
||||
..XPT
|
||||
|
||||
|
||||
XPT _tag wrap=content hidden " <$_xSnipName >..</$_xSnipName>
|
||||
XSET content|ontype=html_cont_ontype()
|
||||
<`$_xSnipName^>`content^^`content^html_cont_helper()^</`$_xSnipName^>
|
||||
..XPT
|
||||
|
||||
" XPT _t hidden " ..
|
||||
" <`$_xSnipName^>`cont^</`$_xSnipName^>
|
||||
|
||||
|
||||
XPT _tagAttr wrap=content hidden " <$_xSnipName >..</$_xSnipName>
|
||||
XSET content|ontype=html_cont_ontype()
|
||||
XSET att?=Echo('')
|
||||
XSET att?|post=Echo(V()=~'\V\^ \$\|att?' ? '' : V())
|
||||
<`$_xSnipName^` `att?^>`content^^`content^html_cont_helper()^</`$_xSnipName^>
|
||||
..XPT
|
||||
|
||||
|
||||
XPT _tagblock hidden " <$_xSnipName >\n .. \n</$_xSnipName>
|
||||
<`$_xSnipName^>
|
||||
`cursor^^
|
||||
</`$_xSnipName^>
|
||||
|
||||
|
||||
XPT _tagblockAttr hidden " <$_xSnipName >\n .. \n</$_xSnipName>
|
||||
<`$_xSnipName^` `attr^>
|
||||
`cursor^^
|
||||
</`$_xSnipName^>
|
||||
|
||||
|
||||
XPT _shorttag hidden " <$_xSnipName />
|
||||
<`$_xSnipName^ />
|
||||
|
||||
|
||||
XPT _shorttagAttr hidden " <$_xSnipName />
|
||||
XSET att?=Echo('')
|
||||
XSET att?|post=Echo(V()=~'\V\^ \$\|att?' ? '' : V())
|
||||
<`$_xSnipName^` `att?^/>
|
||||
..XPT
|
||||
|
||||
|
||||
XPT doctype " <!DOCTYPE ***
|
||||
XSET doctype=html_doctype_list()
|
||||
XSET doctype|post=html_doctype_post( V() )
|
||||
<!DOCTYPE `doctype^>
|
||||
|
||||
|
||||
XPT html " <html><head>..<head><body>...
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
`:head:^
|
||||
<body>
|
||||
`cursor^
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
XPT head " <head>..</head>
|
||||
<head>
|
||||
`:contenttype:^
|
||||
`:title:^
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
XPT contenttype " <meta http-equiv="Content-Type" content="...
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=`encoding^html_enc()^"/>
|
||||
|
||||
|
||||
XPT title " <title>..</title>
|
||||
<title>`title^expand('%:t:r')^</title>
|
||||
|
||||
|
||||
XPT style " <style>..</style>
|
||||
<style type="text/css" media="screen">
|
||||
`cursor^
|
||||
</style>
|
||||
|
||||
|
||||
XPT meta " <meta ..>
|
||||
<meta name="`meta_name^" content="`meta_content^" />
|
||||
|
||||
|
||||
XPT link " <link rel=".." ..>
|
||||
<link rel="`stylesheet^" type="`type^text/css^" href="`url^" />
|
||||
|
||||
|
||||
XPT script " <script language="javascript"...
|
||||
<script language="javascript" type="text/javascript">
|
||||
`cursor^
|
||||
</script>
|
||||
..XPT
|
||||
|
||||
|
||||
XPT scriptsrc " <script .. src=...
|
||||
<script language="javascript" type="text/javascript" src="`js^"></script>
|
||||
|
||||
|
||||
XPT body " <body>..</body>
|
||||
<body>
|
||||
`cursor^
|
||||
</body>
|
||||
|
||||
|
||||
|
||||
XPT table alias=_tag
|
||||
XPT tr alias=_tag
|
||||
XPT td alias=_tag
|
||||
XPT th alias=_tag
|
||||
|
||||
|
||||
XPT fulltable hidden " create a full table
|
||||
`createTable()^
|
||||
|
||||
|
||||
XPT a wrap " <a href...
|
||||
<a href="`href^">`cursor^</a>
|
||||
..XPT
|
||||
|
||||
|
||||
XPT div alias=_tag
|
||||
XPT p alias=_tag
|
||||
XPT ul alias=_tag
|
||||
XPT ol alias=_tag
|
||||
XPT li alias=_tag
|
||||
XPT span alias=_tag
|
||||
|
||||
|
||||
|
||||
XPT br alias=_shorttag
|
||||
XPT img alias=_shorttagAttr
|
||||
XSET att?=Embed( 'src="`where^" alt="`alt^"' )
|
||||
|
||||
|
||||
|
||||
XPT h1 alias=_tag
|
||||
XPT h2 alias=_tag
|
||||
XPT h3 alias=_tag
|
||||
XPT h4 alias=_tag
|
||||
XPT h5 alias=_tag
|
||||
XPT h6 alias=_tag
|
||||
|
||||
XPT iframe alias=_tagAttr
|
||||
XSET att?=Embed( 'name="`name^"' )
|
||||
|
||||
|
||||
|
||||
" TODO enctype list : application/x-www-form-urlencoded
|
||||
XPT form wrap " <form ..>..</form>
|
||||
XSET method=ChooseStr( 'GET', 'POST' )
|
||||
<form action="`action^" method="`method^" accept-charset="`html_enc()^" enctype="multipart/form-data">
|
||||
`cursor^
|
||||
</form>
|
||||
|
||||
XPT textarea alias=_tagAttr
|
||||
XSET att?=Embed( 'name="`name^"' )
|
||||
|
||||
|
||||
XPT input alias=_shorttagAttr
|
||||
XSET att?=Embed( 'type="`type^" name="`name^" value="`value^"' )
|
||||
XSET type=ChooseStr( 'text', 'password', 'checkbox', 'radio', 'submit', 'reset', 'file', 'hidden', 'image', 'button' )
|
||||
|
||||
|
||||
" TODO other optional attribute like "checked", "readonly"
|
||||
XPT _input_tmpl hidden " <input type=Echo($_xSnipName[1:]) ... />
|
||||
<input type="`Echo($_xSnipName[1:])^" name="`name^" value="`value^" />
|
||||
|
||||
XPT itext alias=_input_tmpl
|
||||
XPT ipassword alias=_input_tmpl
|
||||
XPT icheckbox alias=_input_tmpl
|
||||
XPT iradio alias=_input_tmpl
|
||||
XPT isubmit alias=_input_tmpl
|
||||
XPT ireset alias=_input_tmpl
|
||||
XPT ifile alias=_input_tmpl
|
||||
XPT ihidden alias=_input_tmpl
|
||||
XPT iimage alias=_input_tmpl
|
||||
XPT ibutton alias=_input_tmpl
|
||||
|
||||
|
||||
XPT label alias=_tagAttr
|
||||
XSET att?=Embed( 'for="`which^"' )
|
||||
|
||||
|
||||
XPT select alias=_tagAttr
|
||||
XSET att?=Embed( 'name="`name^"' )
|
||||
|
||||
|
||||
XPT option alias=_tagAttr
|
||||
XSET att?=Embed( 'value="`value^"' )
|
||||
|
||||
|
||||
XPT fieldset " <fieldset ..
|
||||
<fieldset>
|
||||
<legend></legend>
|
||||
`cursor^
|
||||
</fieldset>
|
||||
..XPT
|
||||
|
||||
" XPT sdiv alias=_t
|
||||
|
||||
" XPT diva " tips
|
||||
" `:div( { 'content' : ':a:' } ):^
|
||||
|
||||
|
||||
" html 5
|
||||
" http://dev.w3.org/html5/html4-differences/Overview.html#character-encoding
|
||||
|
||||
" XPT section alias=_tag
|
||||
" XPT article alias=_tag
|
||||
" XPT aside alias=_tag
|
||||
" XPT hgroup alias=_tag
|
||||
" XPT header alias=_tag
|
||||
" XPT footer alias=_tag
|
||||
" XPT nav alias=_tag
|
||||
|
||||
" XPT figure alias=_tag
|
||||
" XPT figcaption alias=_tag
|
||||
|
||||
" XPT video alias=_tag
|
||||
" XPT audio alias=_tag
|
||||
" XPT source alias=_tag
|
||||
|
||||
" XPT embed alias=_tag
|
||||
|
||||
" XPT mark alias=_tag
|
||||
" XPT progress alias=_tag
|
||||
" XPT meter alias=_tag
|
||||
" XPT time alias=_tag
|
||||
|
||||
|
||||
" XPT canvas alias=_tag
|
||||
" XPT comand alias=_tag
|
||||
" XPT details alias=_tag
|
||||
" XPT datalist alias=_tag
|
||||
|
||||
" XPT keygen alias=_tag
|
||||
" XPT output alias=_tag
|
||||
|
||||
" XPT ruby alias=_tag
|
||||
|
||||
" input type=
|
||||
" tel
|
||||
" search
|
||||
" url
|
||||
" email
|
||||
" datetime
|
||||
" date
|
||||
" month
|
||||
" week
|
||||
" time
|
||||
" datetime-local
|
||||
" number
|
||||
" range
|
||||
" color
|
||||
|
||||
|
||||
|
||||
31
plugins/bundle/xptemplate/ftplugin/html/php.xpt.vim
Normal file
31
plugins/bundle/xptemplate/ftplugin/html/php.xpt.vim
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
" These snippets work only in html context of php file
|
||||
if &filetype != 'php'
|
||||
finish
|
||||
endif
|
||||
|
||||
XPTemplate priority=lang-2
|
||||
|
||||
" this is html-scope variable independent
|
||||
if exists( 'php_noShortTags' )
|
||||
XPTvar $PHP_TAG php
|
||||
else
|
||||
XPTvar $PHP_TAG
|
||||
endif
|
||||
|
||||
|
||||
XPT shebang " #!/usr/bin/env php
|
||||
#!/usr/bin/env php
|
||||
|
||||
..XPT
|
||||
|
||||
XPT sb alias=shebang
|
||||
|
||||
|
||||
XPT php " <?$PHP_TAG ?>
|
||||
<?`$PHP_TAG^ `cursor^ ?>
|
||||
|
||||
XPT pe " <?= ?>
|
||||
<?=`cursor^?>
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
if exists( "g:__HTMLDJANGO_FTDETECT_VIM__" )
|
||||
finish
|
||||
endif
|
||||
let g:__HTMLDJANGO_FTDETECT_VIM__ = 1
|
||||
|
||||
|
||||
if &filetype !~ 'htmldjango'
|
||||
finish
|
||||
endif
|
||||
|
||||
|
||||
" TODO use array instead of dict because of duplicated key could be possible
|
||||
let s:skipPattern = 'synIDattr(synID(line("."), col("."), 0), "name") =~? "\\vstring|comment"'
|
||||
let s:pattern = {
|
||||
\ 'django' : {
|
||||
\ 'start' : '\V\c{%',
|
||||
\ 'mid' : '',
|
||||
\ 'end' : '\V\c%}',
|
||||
\ 'skip' : s:skipPattern,
|
||||
\ },
|
||||
\ 'django_expr' : {
|
||||
\ 'start' : '\V\c{{',
|
||||
\ 'mid' : '',
|
||||
\ 'end' : '\V\c}}',
|
||||
\ 'skip' : s:skipPattern,
|
||||
\ },
|
||||
\ 'javascript' : {
|
||||
\ 'start' : '\V\c<script\_[^>]\*>',
|
||||
\ 'mid' : '',
|
||||
\ 'end' : '\V\c</script>',
|
||||
\ 'skip' : s:skipPattern,
|
||||
\ },
|
||||
\ 'css' : {
|
||||
\ 'start' : '\V\c<style\_[^>]\*>',
|
||||
\ 'mid' : '',
|
||||
\ 'end' : '\V\c</style>',
|
||||
\ 'skip' : s:skipPattern,
|
||||
\ },
|
||||
\}
|
||||
|
||||
let s:topFT = 'htmldjango'
|
||||
|
||||
fun! XPT_htmldjangoFiletypeDetect() "{{{
|
||||
let pos = [ line( "." ), col( "." ) ]
|
||||
|
||||
let synName = xpt#util#NearestSynName()
|
||||
|
||||
if synName == ''
|
||||
|
||||
return s:topFT
|
||||
|
||||
else
|
||||
|
||||
for [ name, ftPattern ] in items( s:pattern )
|
||||
let pos = searchpairpos( ftPattern.start, ftPattern.mid, ftPattern.end, 'nbW', ftPattern.skip )
|
||||
if pos != [0, 0]
|
||||
return name
|
||||
endif
|
||||
endfor
|
||||
|
||||
if synName =~ '\v^\cjavascript'
|
||||
return 'javascript'
|
||||
elseif synName =~ '\v^\ccss'
|
||||
return 'css'
|
||||
endif
|
||||
|
||||
return s:topFT
|
||||
|
||||
endif
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
if exists( 'b:XPTfiletypeDetect' )
|
||||
unlet b:XPTfiletypeDetect
|
||||
endif
|
||||
let b:XPTfiletypeDetect = function( 'XPT_htmldjangoFiletypeDetect' )
|
||||
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
XPTemplate priority=lang-
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ html/html
|
||||
|
||||
|
||||
XPT _simpletag hidden " {% $_xSnipName %}
|
||||
{% `$_xSnipName^ %}
|
||||
..XPT
|
||||
|
||||
|
||||
XPT _tag hidden " {% $_xSnipName params %}
|
||||
{% `$_xSnipName^ `params^ %}
|
||||
..XPT
|
||||
|
||||
|
||||
XPT _qtag hidden " {% $_xSnipName "params" %}
|
||||
{% `$_xSnipName^ "`params^" %}
|
||||
..XPT
|
||||
|
||||
|
||||
XPT _simpleblock hidden " {% $_xSnipName %}..{% end$_xSnipName %}
|
||||
{% `$_xSnipName^ %}`content^{% end`$_xSnipName^ %}
|
||||
..XPT
|
||||
|
||||
|
||||
XPT _block wrap=content hidden " {% $_xSnipName params %}..{% end$_xSnipName %}
|
||||
{% `$_xSnipName^ `params^ %}
|
||||
`content^
|
||||
{% end`$_xSnipName^ %}
|
||||
..XPT
|
||||
|
||||
|
||||
XPT _qblock wrap=content hidden " {% $_xSnipName "params" %}..{% end$_xSnipName %}
|
||||
{% `$_xSnipName^ "`params^" %}
|
||||
`content^
|
||||
{% end`$_xSnipName^ %}
|
||||
..XPT
|
||||
|
||||
|
||||
XPT _if wrap=content " $_xSnipName .. else .. end$_xSnipName
|
||||
{% `$_xSnipName^ `param^ %}
|
||||
`content^
|
||||
`else...{{^{% else %}
|
||||
`content^`}}^
|
||||
{% end`$_xSnipName^ %}
|
||||
..XPT
|
||||
|
||||
|
||||
XPT var " {{ var }}
|
||||
{{ `var^ }}
|
||||
..XPT
|
||||
|
||||
|
||||
XPT autoescape alias=_block
|
||||
XPT block alias=_block
|
||||
XPT comment alias=_simpleblock
|
||||
XPT csrf_token alias=_simpletag
|
||||
XPT cycle alias=_tag
|
||||
XPT debug alias=_simpletag
|
||||
XPT extends alias=_qtag
|
||||
XPT filter alias=_block
|
||||
XPT firstof alias=_tag
|
||||
XPT for alias=_block
|
||||
XPT empty alias=_simpletag
|
||||
XPT else alias=_simpletag
|
||||
XPT if alias=_if
|
||||
XPT ifchanged alias=_if
|
||||
XPT ifequal alias=_if
|
||||
XPT ifnotequal alias=_if
|
||||
XPT include alias=_qtag
|
||||
XPT load alias=_tag
|
||||
XPT now alias=_tag
|
||||
XPT regroup alias=_tag
|
||||
XPT url alias=_tag
|
||||
XPT spaceless alias=_simpleblock
|
||||
XPT ssi alias=_tag
|
||||
XPT with alias=_block
|
||||
113
plugins/bundle/xptemplate/ftplugin/java/java.xpt.vim
Executable file
113
plugins/bundle/xptemplate/ftplugin/java/java.xpt.vim
Executable file
|
|
@ -0,0 +1,113 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE true
|
||||
XPTvar $FALSE false
|
||||
XPTvar $NULL null
|
||||
XPTvar $UNDEFINED null
|
||||
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $CURSOR_PH /* cursor */
|
||||
|
||||
XPTvar $BRif ' '
|
||||
XPTvar $BRloop ' '
|
||||
XPTvar $BRstc ' '
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
XPTvar $CL /*
|
||||
XPTvar $CM *
|
||||
XPTvar $CR */
|
||||
XPTinclude
|
||||
\ _comment/doubleSign
|
||||
|
||||
XPTinclude
|
||||
\ _condition/c.like
|
||||
\ _loops/java.for.like
|
||||
\ _loops/c.while.like
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
|
||||
|
||||
XPT foreach " for \( .. : .. \)
|
||||
for (`$SParg^`type^ `var^ : `inWhat^`$SParg^)`$BRloop^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT private " private .. ..
|
||||
private `type^ `varName^;
|
||||
|
||||
XPT public " private .. ..
|
||||
public `type^ `varName^;
|
||||
|
||||
XPT protected " private .. ..
|
||||
protected `type^ `varName^;
|
||||
|
||||
XPT class " class .. ctor
|
||||
public class `className^ {
|
||||
public `className^(`$SParg^`ctorParam^`$SParg^)`$BRfun^{
|
||||
`cursor^
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
XPT main " main ( String )
|
||||
public static void main(`$SParg^String[] args`$SParg^)`$BRfun^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT enum " public enum { .. }
|
||||
`public^ enum `enumName^
|
||||
{
|
||||
`elem^` `...^,
|
||||
`subElem^` `...^
|
||||
};
|
||||
`cursor^
|
||||
|
||||
XPT prop " var getVar () setVar ()
|
||||
`type^ `varName^;
|
||||
|
||||
`get...^
|
||||
XSETm get...|post
|
||||
public `R("type")^ get`S(R("varName"),'.','\u&',"")^()
|
||||
{ return `R("varName")^; }
|
||||
|
||||
XSETm END
|
||||
`set...^
|
||||
XSETm set...|post
|
||||
public `R("type")^ set`S(R("varName"),'.','\u&',"")^( `R('type')^ val )
|
||||
{ `R("varName")^ = val; return `R( 'varName' )^; }
|
||||
|
||||
XSETm END
|
||||
|
||||
|
||||
XPT try wrap=what " try .. catch (..) .. finally
|
||||
XSET handler=$CL handling $CR
|
||||
try
|
||||
{
|
||||
`what^
|
||||
}` `catch...^
|
||||
XSETm catch...|post
|
||||
|
||||
catch (`Exception^ `e^)
|
||||
{
|
||||
`handler^
|
||||
}` `catch...^
|
||||
XSETm END
|
||||
`finally...{{^finally
|
||||
{
|
||||
`cursor^
|
||||
}`}}^
|
||||
|
||||
|
||||
|
||||
163
plugins/bundle/xptemplate/ftplugin/javascript/javascript.xpt.vim
Normal file
163
plugins/bundle/xptemplate/ftplugin/javascript/javascript.xpt.vim
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
|
||||
XPTvar $TRUE true
|
||||
XPTvar $FALSE false
|
||||
XPTvar $NULL null
|
||||
XPTvar $UNDEFINED undefined
|
||||
|
||||
XPTvar $BRif ' '
|
||||
XPTvar $BRel \n
|
||||
XPTvar $BRloop ' '
|
||||
XPTvar $BRstc ' '
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $CURSOR_PH /* cursor */
|
||||
|
||||
|
||||
XPTvar $CL /*
|
||||
XPTvar $CM *
|
||||
XPTvar $CR */
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _comment/doubleSign
|
||||
\ _condition/ecma
|
||||
|
||||
|
||||
XPTvar $VAR_PRE
|
||||
XPTvar $FOR_SCOPE 'var '
|
||||
XPTinclude
|
||||
\ _loops/for
|
||||
|
||||
XPTinclude
|
||||
\ javascript/jquery
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
|
||||
XPT bench " Benchmark
|
||||
XSET log=console.log
|
||||
XSET job=$VOID_LINE
|
||||
XSET jobn=$VOID_LINE
|
||||
var t0 = new Date().getTime();
|
||||
for (var i = 0; i < `times^; ++i){
|
||||
`job^
|
||||
}
|
||||
var t1 = new Date().getTime();
|
||||
for (var i = 0; i < `times^; ++i){
|
||||
`jobn^
|
||||
}
|
||||
var t2 = new Date().getTime();
|
||||
`log^(t1-t0, t2-t1);
|
||||
|
||||
..XPT
|
||||
|
||||
XPT asoe " assertObjectEquals
|
||||
assertObjectEquals(`mess^
|
||||
, `arr^
|
||||
, `expr^)
|
||||
|
||||
|
||||
XPT cmt " /** @auth... */
|
||||
XSET author=$author
|
||||
XSET email=$email
|
||||
/**
|
||||
* @author : `author^ | `email^
|
||||
* @description
|
||||
* `cursor^
|
||||
* @return {`Object^} `desc^
|
||||
*/
|
||||
|
||||
|
||||
XPT cpr " @param
|
||||
@param {`Object^} `name^ `desc^
|
||||
|
||||
|
||||
" file comment
|
||||
" 4 back slash represent 1 after rendering.
|
||||
XPT fcmt " full doxygen comment
|
||||
/**-------------------------/// `sum^ \\\---------------------------
|
||||
*
|
||||
* <b>`function^</b>
|
||||
* @version : `1.0^
|
||||
* @since : `date^
|
||||
*
|
||||
* @description :
|
||||
* `cursor^
|
||||
* @usage :
|
||||
*
|
||||
* @author : `$author^ | `$email^
|
||||
* @copyright :
|
||||
* @TODO :
|
||||
*
|
||||
*--------------------------\\\ `sum^ ///---------------------------*/
|
||||
|
||||
|
||||
XPT fun " function ..( .. ) {..}
|
||||
XSET arg*|post=ExpandIfNotEmpty(', ', 'arg*')
|
||||
function` `name^ (`arg*^) {
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT forin " for (var .. in ..) {..}
|
||||
for ( var `i^ in `array^ )`$BRloop^{
|
||||
var `e^ = `array^[`i^];
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT new " var .. = new ..\(..)
|
||||
XSET arg*|post=ExpandIfNotEmpty(', ', 'arg*')
|
||||
var `instant^ = new `Constructor^(`arg*^)
|
||||
|
||||
|
||||
XPT proto " ...prototype... = function\(..) { .. }
|
||||
XSET arg*|post=ExpandIfNotEmpty(', ', 'arg*')
|
||||
`Class^.prototype.`method^ = function(`arg*^)`$BRfun^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT setTimeout " setTimeout\(function\() { .. }, ..)
|
||||
XSET job=$VOID_LINE
|
||||
setTimeout(function() { `job^ }, `milliseconds^)
|
||||
|
||||
|
||||
XPT try wrap=job " try {..} catch {..} finally
|
||||
XSET dealError=/* error handling */
|
||||
XSET job=$VOID_LINE
|
||||
try`$BRif^{
|
||||
`job^
|
||||
}
|
||||
catch (`err^)`$BRif^{
|
||||
`dealError^
|
||||
}`...^
|
||||
catch (`err^)`$BRif^{
|
||||
`dealError^
|
||||
}`...^`
|
||||
`finally...{{^
|
||||
finally`$BRif^{
|
||||
`cursor^
|
||||
}`}}^
|
||||
|
||||
|
||||
XPT bench_ wraponly=wrapped " Benchmark
|
||||
XSET log=console.log
|
||||
var t0 = new Date().getTime();
|
||||
for (var i = 0; i < `times^; ++i){
|
||||
`wrapped^
|
||||
}
|
||||
var t1 = new Date().getTime();
|
||||
`log^(t1-t0);
|
||||
|
||||
|
||||
|
||||
558
plugins/bundle/xptemplate/ftplugin/javascript/jquery.xpt.vim
Normal file
558
plugins/bundle/xptemplate/ftplugin/javascript/jquery.xpt.vim
Normal file
|
|
@ -0,0 +1,558 @@
|
|||
" finish " not finished
|
||||
if !g:XPTloadBundle( 'javascript', 'jquery' )
|
||||
finish
|
||||
endif
|
||||
|
||||
XPTemplate priority=lang-2
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE true
|
||||
XPTvar $FALSE false
|
||||
XPTvar $NULL null
|
||||
XPTvar $UNDEFINED undefined
|
||||
|
||||
XPTvar $BRif ' '
|
||||
XPTvar $BRel \n
|
||||
XPTvar $BRloop ' '
|
||||
XPTvar $BRloop ' '
|
||||
XPTvar $BRstc ' '
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
" XPTvar $JQ jQuery
|
||||
XPTvar $JQ $
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
let s:options = {
|
||||
\'async' : 1,
|
||||
\'beforeSend' : 1,
|
||||
\'cache' : 1,
|
||||
\'complete' : 1,
|
||||
\'contentType' : 1,
|
||||
\'data' : 1,
|
||||
\'dataFilter' : 1,
|
||||
\'dataType' : 1,
|
||||
\'error' : 1,
|
||||
\'global' : 1,
|
||||
\'ifModified' : 1,
|
||||
\'jsonp' : 1,
|
||||
\'password' : 1,
|
||||
\'processData' : 1,
|
||||
\'scriptCharset' : 1,
|
||||
\'success' : 1,
|
||||
\'timeout' : 1,
|
||||
\'type' : 1,
|
||||
\'url' : 1,
|
||||
\'username' : 1,
|
||||
\'xhr' : 1,
|
||||
\}
|
||||
fun! s:f.jquery_ajaxOptions()
|
||||
|
||||
endfunction
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
" ===============
|
||||
" Snippet Pieces
|
||||
" ===============
|
||||
|
||||
XPT optionalExpr hidden
|
||||
(`$SParg^`expr?^`expr?^CmplQuoter_pre()^`$SParg^)
|
||||
|
||||
XPT expr hidden
|
||||
(`$SParg^`expr^`expr^CmplQuoter_pre()^`$SParg^)
|
||||
|
||||
XPT maybeFunction hidden
|
||||
(`$SParg^`function...{{^function(`i^`, `e?^) { `cursor^ }`}}^`$SParg^)
|
||||
|
||||
XPT optionalVal hidden
|
||||
(`$SParg`val?`$SParg^)
|
||||
|
||||
XPT _funExp hidden
|
||||
`function...{{^function(`i^`, `e?^) { `cursor^ }`}}^
|
||||
..XPT
|
||||
|
||||
" ============
|
||||
" jQuery Core
|
||||
" ============
|
||||
|
||||
XPT $ " $\()
|
||||
$(`$SParg^`e^`e^CmplQuoter_pre()^`, `context?^`$SParg^)
|
||||
|
||||
XPT jq " jQuery\()
|
||||
jQuery(`$SParg^`e^`e^CmplQuoter_pre()^`, `context?^`$SParg^)
|
||||
|
||||
XPT each " each\(...
|
||||
each`:maybeFunction:^
|
||||
|
||||
XPT sz " size\()
|
||||
size()
|
||||
|
||||
XPT eq " eq\(...)
|
||||
eq(`$SParg^`^`$SParg^)
|
||||
|
||||
XPT get " get\(...)
|
||||
get(`$SParg^`^`$SParg^)
|
||||
|
||||
XPT ind " index\(...)
|
||||
index(`$SParg^`^`$SParg^)
|
||||
|
||||
XPT da " data\(.., ..)
|
||||
data(`$SParg^`name^`, `value?^`$SParg^)
|
||||
|
||||
XPT rmd " removeData\(..)
|
||||
removeData(`$SParg^`name^`$SParg^)
|
||||
|
||||
XPT qu " queue\(.., ..)
|
||||
queue(`$SParg^`name^`, `toAdd?^`$SParg^)
|
||||
|
||||
XPT dq " dequeue\(...)
|
||||
dequeue(`$SParg^`name^`$SParg^)
|
||||
..XPT
|
||||
|
||||
|
||||
|
||||
|
||||
" ==================
|
||||
" jQuery Attributes
|
||||
" ==================
|
||||
|
||||
XPT attr " attr\(..
|
||||
attr(`$SParg^`name^`$SParg^)
|
||||
|
||||
XPT rma " removeAttr\(..
|
||||
removeAttr(`$SParg^`name^`$SParg^)
|
||||
|
||||
XPT ac " addClass\(..
|
||||
addClass(`$SParg^`class^`$SParg^)
|
||||
|
||||
XPT hc " hasClass\(..
|
||||
hasClass(`$SParg^`class^`$SParg^)
|
||||
|
||||
XPT tc " toggleClass\(..
|
||||
toggleClass(`$SParg^`class^`, `switch?^`$SParg^)
|
||||
|
||||
XPT html " html\(..
|
||||
html`:optionalVal:^
|
||||
|
||||
XPT text " text\(..
|
||||
text`:optionalVal:^
|
||||
|
||||
XPT val " val\(..
|
||||
val`:optionalVal:^
|
||||
..XPT
|
||||
|
||||
|
||||
|
||||
|
||||
" ===================
|
||||
" CSS
|
||||
" ===================
|
||||
|
||||
XPT css " css\(..
|
||||
css`:optionalVal:^
|
||||
|
||||
XPT os " offset\()
|
||||
offset()
|
||||
|
||||
XPT osp " offsetParent\()
|
||||
offsetParent()
|
||||
|
||||
XPT pos " position\()
|
||||
position()
|
||||
|
||||
XPT scrt " scrollTop\()
|
||||
scrollTop`:optionalVal:^
|
||||
|
||||
XPT scrl " scrollLeft\()
|
||||
scrollLeft`:optionalVal:^
|
||||
|
||||
XPT ht " height\(..)
|
||||
height`:optionalVal:^
|
||||
|
||||
XPT wth " width\(..)
|
||||
width`:optionalVal:^
|
||||
|
||||
XPT ih " innerHeight\()
|
||||
innerHeight()
|
||||
|
||||
XPT iw " innerWidth\()
|
||||
innerWidth()
|
||||
|
||||
XPT oh " outerHeight\(..)
|
||||
outerHeight(`$SParg^`margin^`$SParg^)
|
||||
|
||||
XPT ow " outerWidth\(..)
|
||||
outerWidth(`$SParg^`margin^`$SParg^)
|
||||
..XPT
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
" ===================
|
||||
" Traversing
|
||||
" ===================
|
||||
|
||||
XPT flt " filter\(..
|
||||
filter`:maybeFunction:^
|
||||
|
||||
XPT is " is\(..
|
||||
is`:expr:^
|
||||
|
||||
XPT map " map\(..
|
||||
map`:maybeFunction:^
|
||||
|
||||
XPT not " not\(..)
|
||||
not`:expr:^
|
||||
|
||||
XPT slc " slice\(start, end)
|
||||
slice(`$SParg^`start^`, `end?^`$SParg^)
|
||||
|
||||
XPT add " add\(..)
|
||||
add`:expr:^
|
||||
|
||||
XPT chd " children\(..)
|
||||
children`:optionalExpr:^
|
||||
|
||||
XPT cls " closest\(..)
|
||||
closest`:expr:^
|
||||
|
||||
XPT con " content\()
|
||||
content()
|
||||
|
||||
XPT fd " find\(..)
|
||||
find`:expr:^
|
||||
|
||||
XPT ne " next\(..)
|
||||
next`:optionalExpr:^
|
||||
|
||||
XPT na " nextAll\(..)
|
||||
nextAll`:optionalExpr:^
|
||||
|
||||
XPT pr " parent\(..)
|
||||
parent`:optionalExpr:^
|
||||
|
||||
XPT prs " parents\(..)
|
||||
parents`:optionalExpr:^
|
||||
|
||||
XPT prv " prev\(..)
|
||||
prev`:optionalExpr:^
|
||||
|
||||
XPT pra " prevAll\(..)
|
||||
prevAll`:optionalExpr:^
|
||||
|
||||
XPT sib " sibling\(..)
|
||||
sibling`:optionalExpr:^
|
||||
|
||||
XPT as " andSelf\()
|
||||
andSelf()
|
||||
|
||||
XPT end " end\()
|
||||
end()
|
||||
..XPT
|
||||
|
||||
|
||||
|
||||
" ===================
|
||||
" Manipulation
|
||||
" ===================
|
||||
XPT ap " append\(..)
|
||||
append`:expr:^
|
||||
|
||||
XPT apt " appendTo\(..)
|
||||
appendTo`:expr:^
|
||||
|
||||
XPT pp " prepend\(..)
|
||||
prepend`:expr:^
|
||||
|
||||
XPT ppt " prependTo\(..)
|
||||
prependTo`:expr:^
|
||||
|
||||
XPT af " after\(..)
|
||||
after`:expr:^
|
||||
|
||||
XPT bf " before\(..)
|
||||
before`:expr:^
|
||||
|
||||
XPT insa " insertAfter\(..)
|
||||
insertAfter`:expr:^
|
||||
|
||||
XPT insb " insertBefore\(..)
|
||||
insertBefore`:expr:^
|
||||
|
||||
XPT wr " wrap\(..)
|
||||
wrap`:expr:^
|
||||
|
||||
XPT wra " wrapAll\(..)
|
||||
wrapAll`:expr:^
|
||||
|
||||
XPT wri " wrapInner\(..)
|
||||
wrapInner`:expr:^
|
||||
|
||||
XPT rep " replaceWith\(..)
|
||||
replaceWith`:expr:^
|
||||
|
||||
XPT repa " replaceAll\(..)
|
||||
replaceAll`:expr:^
|
||||
|
||||
XPT emp " empty\()
|
||||
empty()
|
||||
|
||||
XPT rm " remove\(..)
|
||||
remove`:optionalExpr:^
|
||||
|
||||
XPT cl " clone\(..)
|
||||
cloen`:optionalExpr:^
|
||||
..XPT
|
||||
|
||||
" =========================
|
||||
" Ajax
|
||||
" =========================
|
||||
" TODO callback
|
||||
" TODO ajax option
|
||||
" TODO universial behavior for clearing optional argument
|
||||
|
||||
XPT _ld_callback hidden
|
||||
function(`$SParg^`resText^`, `textStatus^`, `xhr^`$SParg^) { `cursor^ }
|
||||
|
||||
XPT _aj_type hidden
|
||||
XSET type=ChooseStr( '"xml"', '"html"', '"script"', '"json"', '"jsonp"', '"text"' )
|
||||
`, `type^
|
||||
|
||||
XPT _fun0 hidden
|
||||
function() { `cursor^ }
|
||||
|
||||
|
||||
|
||||
XPT aj " $JQ.ajax\(..)
|
||||
`$JQ^.ajax(`$SParg^`opt^`$SParg^)
|
||||
|
||||
XPT load " load\(url, ...)
|
||||
load(`$SParg^`url^`url^CmplQuoter_pre()^`, `data^`data^CmplQuoter_pre()^`, `function...{{^, `:_ld_callback:^`}}^`$SParg^)
|
||||
|
||||
XPT ag " $JQ.get\(url, ...)
|
||||
`$JQ^.get(`$SParg^`url^`url^CmplQuoter_pre()^`, `data^`data^CmplQuoter_pre()^`, `callback^`:_aj_type:^`$SParg^)
|
||||
|
||||
XPT agj " $JQ.getJSON\(url, ...)
|
||||
`$JQ^.getJSON(`$SParg^`url^`url^CmplQuoter_pre()^`, `data^`, `callback^`$SParg^)
|
||||
|
||||
XPT ags " $JQ.getScript\(url, ...)
|
||||
`$JQ^.getScript(`$SParg^`url^`url^CmplQuoter_pre()^`, `callback^`$SParg^)
|
||||
|
||||
XPT apost " $JQ.post\(url, ...)
|
||||
`$JQ^.post(`$SParg^`url^`url^CmplQuoter_pre()^`, `data^`data^CmplQuoter_pre()^`, `callback^`:_aj_type:^`$SParg^)
|
||||
|
||||
|
||||
|
||||
XPT ajaxComplete " ajaxComplete\(callback)
|
||||
ajaxComplete(`$SParg^`fun...{{^function (`$SParg^`event^`, `xhr^`, `ajaxOption^`$SParg^){ `cursor^ }`}}^`$SParg^)
|
||||
|
||||
XPT ajaxError " ajaxError\(callback)
|
||||
ajaxError(`$SParg^`fun...{{^function (`$SParg^`event^`, `xhr^`, `ajaxOption^`, `err^`$SParg^){ `cursor^ }`}}^`$SParg^)
|
||||
|
||||
XPT ajaxSend " ajaxSend\(callback)
|
||||
ajaxSend(`$SParg^`fun...{{^function (`$SParg^`event^`, `xhr^`, `ajaxOption^`$SParg^){ `cursor^ }`}}^`$SParg^)
|
||||
|
||||
XPT ajaxStart " ajaxStart\(callback)
|
||||
ajaxStart(`$SParg^`fun...{{^`:_fun0:^`}}^`$SParg^)
|
||||
|
||||
XPT ajaxStop " ajaxStop\(callback)
|
||||
ajaxStop(`$SParg^`fun...{{^`:_fun0:^`}}^`$SParg^)
|
||||
|
||||
XPT ajaxSuccess " ajaxSuccess\(callback)
|
||||
ajaxSuccess(`$SParg^`fun...{{^function (`$SParg^`event^`, `xhr^`, `ajaxOption^`$SParg^){ `cursor^ }`}}^`$SParg^)
|
||||
|
||||
|
||||
|
||||
XPT asetup " $JQ.ajaxSetup\(opt)
|
||||
`$JQ^.ajaxSetup(`$SParg^`opt^`$SParg^)
|
||||
|
||||
XPT ser " serialize\()
|
||||
serialize()
|
||||
|
||||
XPT sera " serializeArray\()
|
||||
serializeArray()
|
||||
..XPT
|
||||
|
||||
|
||||
" ===================
|
||||
" Events
|
||||
" ===================
|
||||
XPT _ev_fun_a hidden
|
||||
XSET job=VoidLine()
|
||||
function (`$SParg^`ev^`$SParg^) { `job^ }
|
||||
|
||||
XPT _ev_fun hidden
|
||||
function (`$SParg^`ev^`$SParg^) { `cursor^ }
|
||||
|
||||
XPT _ev_arg hidden
|
||||
(`$SParg^`type^`type^CmplQuoter_pre()^`, `data^`, `fun...{{^, `:_ev_fun:^`}}^`$SParg^)
|
||||
|
||||
XPT _ev_tr_arg hidden
|
||||
(`$SParg^`ev^`ev^CmplQuoter_pre()^`, `data^`$SParg^)
|
||||
|
||||
XPT _ev_arg_fun hidden
|
||||
(`$SParg^`fun...{{^`:_ev_fun:^`}}^`$SParg^)
|
||||
|
||||
|
||||
|
||||
XPT rd " ready\(fun)
|
||||
ready(`$SParg^`fun...{{^`:_fun0:^`}}^`$SParg^)
|
||||
|
||||
XPT bd " bind\(type, data, fun)
|
||||
bind`:_ev_arg:^
|
||||
|
||||
XPT one " one\(type, data, fun)
|
||||
one`:_ev_arg:^
|
||||
|
||||
XPT tr " trigger\(ev, data)
|
||||
trigger`:_ev_tr_arg:^
|
||||
|
||||
XPT trh " triggerHandler\(ev, data)
|
||||
triggerHandler`:_ev_tr_arg:^
|
||||
|
||||
XPT ub " unbind\(type, fun)
|
||||
unbind(`$SParg^`type^`type^CmplQuoter_pre()^`, `fun^`$SParg^)
|
||||
|
||||
XPT lv " live\(type, fun)
|
||||
live`:_ev_arg:^
|
||||
|
||||
XPT die " die\(type, fun)
|
||||
die(`$SParg^`type^`type^CmplQuoter_pre()^`, `fun^`$SParg^)
|
||||
|
||||
XPT ho " hover\(over, out)
|
||||
hover(`$SParg^`over...{{^, `:_ev_fun_a:^`}}^`, `out..{{^, `:_ev_fun:^`}}^`$SParg^)
|
||||
|
||||
XPT tg " toggle\(fn1, fn2, ...)
|
||||
toggle(`$SParg^`fn1...{{^, `:_ev_fun_a:^`}}^`, `fn2...{{^, `:_ev_fun:^`}}^`$SParg^)
|
||||
|
||||
|
||||
|
||||
XPT bl " blur\(fun)
|
||||
blur`:_ev_arg_fun:^
|
||||
|
||||
XPT res " resize\(fun)
|
||||
resize`:_ev_arg_fun:^
|
||||
|
||||
XPT scr " scroll\(fun)
|
||||
scroll`:_ev_arg_fun:^
|
||||
|
||||
XPT sel " select\(fun)
|
||||
select`:_ev_arg_fun:^
|
||||
|
||||
XPT sub " submit\(fun)
|
||||
submit`:_ev_arg_fun:^
|
||||
|
||||
XPT unl " unload\(fun)
|
||||
unload`:_ev_arg_fun:^
|
||||
|
||||
|
||||
|
||||
XPT kdown " keydown\(fun)
|
||||
keydown`:_ev_arg_fun:^
|
||||
|
||||
XPT kup " keyup\(fun)
|
||||
keyup`:_ev_arg_fun:^
|
||||
|
||||
XPT kpress " keypress\(fun)
|
||||
keypress`:_ev_arg_fun:^
|
||||
|
||||
XPT clk " click\(fun)
|
||||
click`:_ev_arg_fun:^
|
||||
|
||||
XPT dclk " dbclick\(fun)
|
||||
dbclick`:_ev_arg_fun:^
|
||||
|
||||
|
||||
|
||||
XPT foc " focus\(fun)
|
||||
focus`:_ev_arg_fun:^
|
||||
|
||||
XPT err " error\(fun)
|
||||
error`:_ev_arg_fun:^
|
||||
|
||||
|
||||
|
||||
XPT mup " mouseup\(fun)
|
||||
mouseup`:_ev_arg_fun:^
|
||||
|
||||
XPT mdown " mousedown\(fun)
|
||||
mousedown`:_ev_arg_fun:^
|
||||
|
||||
XPT mmove " mousemove\(fun)
|
||||
mousemove`:_ev_arg_fun:^
|
||||
|
||||
XPT menter " mouseenter\(fun)
|
||||
mouseenter`:_ev_arg_fun:^
|
||||
|
||||
XPT mleave " mouseleave\(fun)
|
||||
mouseleave`:_ev_arg_fun:^
|
||||
|
||||
XPT mout " mouseout\(fun)
|
||||
mouseout`:_ev_arg_fun:^
|
||||
|
||||
|
||||
|
||||
|
||||
XPT ld " load\(fun)
|
||||
load`:_ev_arg_fun:^
|
||||
|
||||
XPT ch " change\(fun)
|
||||
change`:_ev_arg_fun:^
|
||||
..XPT
|
||||
|
||||
|
||||
|
||||
" ===================
|
||||
" Effects
|
||||
" ===================
|
||||
|
||||
XPT _ef_arg hidden
|
||||
(`$SParg^`speed^`speed^CmplQuoter_pre()^`, `fun...{{^, `:_fun0:^`}}^`$SParg^)
|
||||
|
||||
XPT sh " show\(speed, callback)
|
||||
show`:_ef_arg:^
|
||||
|
||||
XPT hd " hide\(speed, callback)
|
||||
hide`:_ef_arg:^
|
||||
|
||||
XPT sld " slideDown\(speed, callback)
|
||||
slideDown`:_ef_arg:^
|
||||
|
||||
XPT slu " slideUp\(speed, callback)
|
||||
slideUp`:_ef_arg:^
|
||||
|
||||
XPT slt " slideToggle\(speed, callback)
|
||||
slideToggle`:_ef_arg:^
|
||||
|
||||
|
||||
|
||||
XPT fi " fadeIn\(speed, callback)
|
||||
fadeIn`:_ef_arg:^
|
||||
|
||||
XPT fo " fadeOut\(speed, callback)
|
||||
fadeOut`:_ef_arg:^
|
||||
|
||||
XPT ft " fadeTo\(speed, callback)
|
||||
fadeTo(`$SParg^`speed^`speed^CmplQuoter_pre()^`, `opacity^`opacity^CmplQuoter_pre()^`, `fun...{{^, `:_fun0:^`}}^`$SParg^)
|
||||
|
||||
XPT ani " animate\(params, ...)
|
||||
animate(`$SParg^`params^`, `param^`$SParg^)
|
||||
|
||||
XPT stop " stop\()
|
||||
stop()
|
||||
..XPT
|
||||
|
||||
" ===================
|
||||
" TODO select helper
|
||||
" ===================
|
||||
|
||||
|
||||
|
||||
" ================================= Wrapper ===================================
|
||||
|
||||
23
plugins/bundle/xptemplate/ftplugin/json/json.xpt.vim
Normal file
23
plugins/bundle/xptemplate/ftplugin/json/json.xpt.vim
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
" use snippet 'varConst' to generate contant variables
|
||||
" use snippet 'varFormat' to generate formatting variables
|
||||
" use snippet 'varSpaces' to generate spacing variables
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
XPT array " [ ..., ... ]
|
||||
[ `val^`...^, `val^`...^ ]
|
||||
|
||||
XPT obj " { "...":... }
|
||||
{ "`key^":`val^`...^, "`key^":`val^`...^ }
|
||||
|
||||
XPT dic " { "...":..., ... }
|
||||
{ "`key^":`val^`...^,
|
||||
"`key^":`val^`...^
|
||||
}
|
||||
|
||||
45
plugins/bundle/xptemplate/ftplugin/lex/lex.xpt.vim
Normal file
45
plugins/bundle/xptemplate/ftplugin/lex/lex.xpt.vim
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $CURSOR_PH cursor
|
||||
|
||||
XPTvar $BRif ' '
|
||||
XPTvar $BRel \n
|
||||
XPTvar $BRloop ' '
|
||||
XPTvar $BRstc ' '
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ c/c
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
XPT lex " Basic lex file
|
||||
%{
|
||||
/* includes */
|
||||
%}
|
||||
/* options */
|
||||
%%
|
||||
/* rules */
|
||||
%%
|
||||
/* C code */
|
||||
|
||||
|
||||
XPT ruleList " .. {..} ...
|
||||
`reg^ { `return^ }`...^
|
||||
`reg^ { `return^ }`...^
|
||||
|
||||
|
||||
|
||||
143
plugins/bundle/xptemplate/ftplugin/lua/lua.xpt.vim
Normal file
143
plugins/bundle/xptemplate/ftplugin/lua/lua.xpt.vim
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $CURSOR_PH -- cursor
|
||||
|
||||
XPTvar $BRif \n
|
||||
XPTvar $BRloop \n
|
||||
XPTvar $BRloop \n
|
||||
XPTvar $BRstc \n
|
||||
XPTvar $BRfun \n
|
||||
|
||||
XPTvar $CS --
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _comment/singleSign
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
" Remove an item if its value hasn't change
|
||||
fun! s:f.RemoveIfUnchanged() "{{{
|
||||
let v = self.V()
|
||||
let [lft, rt] = self.ItemEdges()
|
||||
if v == lft . self.N() . rt
|
||||
return ''
|
||||
else
|
||||
return v
|
||||
end
|
||||
endfunction "}}}
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
|
||||
XPT do " do ... end
|
||||
do
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT fn " function \(..) .. end
|
||||
XSET arg*|post=ExpandIfNotEmpty(', ', 'arg*')
|
||||
function (`arg*^) `cursor^ end
|
||||
|
||||
|
||||
XPT for " for ..=..,.. do ... end
|
||||
XSET step?|post=EchoIfNoChange('')
|
||||
for `var^ = `0^, `10^`, `step?^ do
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT forin " for .. in .. do ... end
|
||||
XSET var*|post=ExpandIfNotEmpty(', ', 'var*')
|
||||
for `var*^ in `expr^ do
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT forip " for ..,.. in ipairs\(..) do ... end
|
||||
for `key^, `value^ in ipairs(`table^) do
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT forp " for ..,.. in pairs\(..) do ... end
|
||||
for `key^, `value^ in pairs(`table^) do
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT fun " function ..\(..) .. end
|
||||
XSET arg*|post=ExpandIfNotEmpty(', ', 'arg*')
|
||||
function `name^(`arg*^)
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT if " if .. then .. end
|
||||
if `cond^ then
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT ife " if .. then .. else .. end
|
||||
XSET job=$CS job
|
||||
if `cond^ then
|
||||
`job^
|
||||
else
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT ifei " if .. then .. elseif .. else .. end
|
||||
XSET job=$CS job
|
||||
if `cond^ then`
|
||||
`job^
|
||||
``elseif...`
|
||||
{{^elseif `comparison^ then
|
||||
`job^
|
||||
``elseif...`
|
||||
^`}}^``else...`
|
||||
{{^else
|
||||
`cursor^
|
||||
`}}^end
|
||||
|
||||
|
||||
XPT locf " local function ..\(..) ... end
|
||||
XSET arg*|post=ExpandIfNotEmpty(', ', 'arg*')
|
||||
local function `name^(`arg*^)
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
" !!! snippet ends with a space !!!
|
||||
XPT locv " local .. = ..
|
||||
local `var^ =
|
||||
|
||||
|
||||
XPT p " print\(..)
|
||||
print(`cursor^)
|
||||
|
||||
|
||||
XPT repeat " repeat .. until ..
|
||||
repeat
|
||||
`cursor^
|
||||
until
|
||||
|
||||
|
||||
XPT while " while .. do ... end
|
||||
while `cond^ do
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
76
plugins/bundle/xptemplate/ftplugin/make/make.xpt.vim
Normal file
76
plugins/bundle/xptemplate/ftplugin/make/make.xpt.vim
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
|
||||
XPTvar $VOID_LINE # void
|
||||
XPTvar $CURSOR_PH # cursor
|
||||
|
||||
XPTvar $CS #
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _comment/singleSign
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
XPT addprefix " $(addprefix ...)
|
||||
$(addprefix `prefix^, `elemList^)
|
||||
|
||||
|
||||
XPT addsuffix " $(addsuffix ...)
|
||||
$(addsuffix `suffix^, `elemList^)
|
||||
|
||||
|
||||
XPT filterout " $(filter-out ...)
|
||||
$(filter-out `toRemove^, `elemList^)
|
||||
|
||||
|
||||
XPT patsubst " $(patsubst ...)
|
||||
$(patsubst `sourcePattern^%.c^, `destPattern^%.o^, `list^)
|
||||
|
||||
|
||||
XPT shell " $(shell ...)
|
||||
$(shell `command^)
|
||||
|
||||
|
||||
XPT subst " $(subst ...)
|
||||
$(subst `sourceString^, `destString^, `string^)
|
||||
|
||||
|
||||
XPT wildcard " $(wildcard ...)
|
||||
$(wildcard `globpattern^)
|
||||
|
||||
|
||||
XPT ifneq " ifneq ... else ... endif
|
||||
ifneq (`what^, `with^)
|
||||
`job^
|
||||
``else...`
|
||||
{{^else
|
||||
`cursor^
|
||||
`}}^endif
|
||||
|
||||
|
||||
XPT ifeq " ifneq ... else ... endif
|
||||
XSET job=$CS job
|
||||
ifeq (`what^, `with^)
|
||||
`job^
|
||||
``else...`
|
||||
{{^else
|
||||
`cursor^
|
||||
`}}^endif
|
||||
|
||||
|
||||
XPT basevar " CC ... CFLAG ..
|
||||
`lang^C^C := `compiler^gcc^
|
||||
`lang^C^FLAGS := `switches^-Wall -Wextra^
|
||||
|
||||
|
||||
95
plugins/bundle/xptemplate/ftplugin/markdown/markdown.xpt.vim
Normal file
95
plugins/bundle/xptemplate/ftplugin/markdown/markdown.xpt.vim
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
XPTemplate priority=lang mark=~^
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
fun! s:f.HeaderPref()
|
||||
let snipname = self.GetVar('$_xSnipName')
|
||||
let nr = snipname[ 1 : 1 ] * 1
|
||||
return repeat('#', nr)
|
||||
endfunction
|
||||
|
||||
fun! s:f.UnderLine(char)
|
||||
let v = self.ItemValue()
|
||||
if v == ''
|
||||
return ''
|
||||
else
|
||||
" line break before "===" and after "==="
|
||||
return "\n" . repeat(a:char, len(v)) . "\n"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
fun! s:f.QuitContition()
|
||||
let v = self.ItemValue()
|
||||
if v == '' || v =~ '\V\n'
|
||||
let q = self.Next(substitute(v, '\V\n', '', 'g'))
|
||||
return q
|
||||
endif
|
||||
endfunction
|
||||
|
||||
fun! s:f.BuildRef()
|
||||
let title = ''
|
||||
let id = self.R( 'refId' )
|
||||
|
||||
let url = s:f[ '_markdown_snipp_url' ]
|
||||
unlet s:f[ '_markdown_snipp_url' ]
|
||||
|
||||
if has_key( s:f, '_markdown_snipp_title' )
|
||||
let title = '"' . s:f[ '_markdown_snipp_title' ] . '"'
|
||||
unlet s:f[ '_markdown_snipp_title' ]
|
||||
endif
|
||||
|
||||
call append( line('$'), '[' . id . ']: <' . url . '> ' . title )
|
||||
return '\n'
|
||||
endfunction
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
XPT sharp_header hidden " HeaderPref() title
|
||||
~HeaderPref() ~t^
|
||||
|
||||
XPT h1 alias=sharp_header
|
||||
XPT h2 alias=sharp_header
|
||||
XPT h3 alias=sharp_header
|
||||
XPT h4 alias=sharp_header
|
||||
XPT h5 alias=sharp_header
|
||||
XPT h6 alias=sharp_header
|
||||
|
||||
XPT header_alt hidden " ... repeat($decoration,3)
|
||||
XSET $decoration==
|
||||
XSET t|ontype=QuitContition()
|
||||
~t^~t^UnderLine($decoration)^~^
|
||||
|
||||
XPT ha1 alias=header_alt
|
||||
XSET $decoration==
|
||||
|
||||
XPT ha2 alias=header_alt
|
||||
XSET $decoration=-
|
||||
|
||||
XPT title alias=ha1
|
||||
XPT section alias=ha2
|
||||
XPT subsection alias=h3
|
||||
|
||||
|
||||
XPT link " [...](...)
|
||||
[~text^](~url^~ ~title?^)
|
||||
|
||||
XPT img " 
|
||||

|
||||
|
||||
XPT ref " [...][...]
|
||||
[~text^][~refid^]
|
||||
|
||||
XPT def " [name]: url
|
||||
[~refid^]: ~url^
|
||||
|
||||
XPT hr " -----
|
||||
---
|
||||
|
||||
XPT ruler alias=hr
|
||||
|
||||
XPT table " | header | ... |
|
||||
| | |
|
||||
| :-- | --: |
|
||||
| | |
|
||||
|
||||
12
plugins/bundle/xptemplate/ftplugin/objc/autoimplem.xpt.vim
Normal file
12
plugins/bundle/xptemplate/ftplugin/objc/autoimplem.xpt.vim
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
" Steal autoimplem from C snippets.
|
||||
if !g:XPTloadBundle( 'objc', 'autoimplem' )
|
||||
finish
|
||||
endif
|
||||
XPTemplate priority=lang-2
|
||||
|
||||
let g:objcautoimlemneedc = 1
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ c/autoimplem
|
||||
|
||||
66
plugins/bundle/xptemplate/ftplugin/objc/objc.xpt.vim
Normal file
66
plugins/bundle/xptemplate/ftplugin/objc/objc.xpt.vim
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
" Objective C can reuse all the C snippets, so include
|
||||
" them by default.
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ c/c
|
||||
|
||||
XPT msg " [to ...]
|
||||
[`to^ `msg^`args...{{^:`arg^`...{{^ `argName^:`argVal^`...^`}}^`}}^]
|
||||
|
||||
XPT forin " for (... in ...) { ... }
|
||||
for (`type^id^ `var^ in `collection^)
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT import " #import "..."
|
||||
#import "`hfile^"
|
||||
|
||||
XPT #import " #import <...>
|
||||
#import <`hfile^>
|
||||
|
||||
XPT protocol " @protocol ... @end
|
||||
@protocol `protocolName^
|
||||
`cursor^
|
||||
@end
|
||||
|
||||
XPT interface " @interface ... : ... ...
|
||||
@interface `interfaceName^ `inherit...{{^ : `father^ `}}^{
|
||||
// put instances variable here
|
||||
`cursor^
|
||||
}
|
||||
// put methods here
|
||||
@end
|
||||
|
||||
XPT implementation " @implementation ... @end
|
||||
@implementation `className^
|
||||
`cursor^
|
||||
@end
|
||||
|
||||
XPT categorie " @interface ... (...) ... @end
|
||||
@interface `existingClass^ (`categorieName^)
|
||||
`cursor^
|
||||
@end
|
||||
|
||||
XPT catimplem " @implementation ... (...) ... @end
|
||||
@implementation `existingClass^ (`categorieName^)
|
||||
`cursor^
|
||||
@end
|
||||
|
||||
XPT alloc " [[... alloc] ...]
|
||||
[[`className^ alloc] `cursor^]
|
||||
|
||||
XPT method " - (...) ....: ...
|
||||
- (`retType^void^) `methodName^`args...{{^`...^ (`type^)name`...^`}}^;
|
||||
|
||||
XPT implmethod " - (...) ... { ... }
|
||||
- (`retType^) `methodName^ {
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT alloc " [[... alloc] ...]
|
||||
[[`className^ alloc] `cursor^]
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
|
||||
XPTvar $VOID_LINE (* void *)
|
||||
XPTvar $CURSOR_PH (* cursor *)
|
||||
|
||||
XPTvar $BRif ' '
|
||||
XPTvar $BRloop ' '
|
||||
XPTvar $BRstc ' '
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
XPTvar $CL (*
|
||||
XPTvar $CM *
|
||||
XPTvar $CR *)
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _comment/doubleSign
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
XPT if " if .. then .. else ..
|
||||
if `cond^
|
||||
then `cursor^
|
||||
|
||||
|
||||
XPT match " match .. with [.. -> .. | ..]
|
||||
match `expr^ with
|
||||
[ `what0^ -> `with0^`...^
|
||||
| `what^ -> `with^`...^
|
||||
]
|
||||
|
||||
|
||||
XPT moduletype " module type .. = sig .. end
|
||||
module type `name^ `^ = sig
|
||||
`cursor^
|
||||
end;
|
||||
|
||||
|
||||
XPT module " module .. = struct .. end
|
||||
XSET name|post=SV( '^\w', '\u&' )
|
||||
module `name^ `^ = struct
|
||||
`cursor^
|
||||
end;
|
||||
|
||||
XPT while " while .. do .. done
|
||||
while `cond^ do
|
||||
`cursor^
|
||||
done
|
||||
|
||||
XPT for " for .. to .. do .. done
|
||||
XSET side=Choose(['to', 'downto'])
|
||||
for `var^ = `val^ `side^ `expr^ do
|
||||
`cursor^
|
||||
done
|
||||
|
||||
XPT class " class .. = object .. end
|
||||
class `_^^ `name^ =
|
||||
object (self)
|
||||
`cursor^
|
||||
end;
|
||||
|
||||
|
||||
XPT classtype " class type .. = object .. end
|
||||
class type `name^ =
|
||||
object
|
||||
method `field^ : `type^` `...^
|
||||
method `field^ : `type^` `...^
|
||||
end;
|
||||
|
||||
|
||||
XPT classtypecom " (** .. *) class type .. = object .. end
|
||||
(** `class_descr^^ *)
|
||||
class type `name^ =
|
||||
object
|
||||
(** `method_descr^^ *)
|
||||
method `field^ : `type^` `...^
|
||||
(** `method_descr^^ *)
|
||||
method `field^ : `type^` `...^
|
||||
end;
|
||||
|
||||
|
||||
XPT typesum " type .. = .. | ..
|
||||
XSET typeParams?|post=EchoIfNoChange( '' )
|
||||
type `typename^` `typeParams?^ =
|
||||
[ `constructor^`...^
|
||||
| `constructor^`...^
|
||||
];
|
||||
|
||||
|
||||
XPT typesumcom " (** .. *) type .. = .. | ..
|
||||
XSET typeParams?|post=EchoIfNoChange( '' )
|
||||
(** `typeDescr^ *)
|
||||
type `typename^` `typeParams?^ =
|
||||
[ `constructor^ (** `ctordescr^ *)`...^
|
||||
| `constructor^ (** `ctordescr^ *)`...^
|
||||
];
|
||||
|
||||
|
||||
XPT typerecord " type .. = { .. }
|
||||
XSET typeParams?|post=EchoIfNoChange( '' )
|
||||
type `typename^` `typeParams?^ =
|
||||
{ `recordField^ : `fType^` `...^
|
||||
; `recordField^ : `fType^` `...^
|
||||
};
|
||||
|
||||
|
||||
XPT typerecordcom " (** .. *)type .. = { .. }
|
||||
(** `type_descr^ *)
|
||||
type `typename^ `_^^=
|
||||
{ `recordField^ : `fType^ (** `desc^ *)`...^
|
||||
; `otherfield^ : `othertype^ (** `desc^ *)`...^
|
||||
};
|
||||
|
||||
|
||||
XPT try wrap=expr " try .. with .. -> ..
|
||||
try `expr^
|
||||
with [ `exc^ -> `rez^
|
||||
` `...`
|
||||
{{^ | `exc2^ -> `rez2^
|
||||
` `...`
|
||||
^`}}^ ]
|
||||
|
||||
XPT val " value .. : ..
|
||||
value `thing^ : `cursor^
|
||||
|
||||
XPT ty " .. -> ..
|
||||
`t^`...^ -> `t2^`...^
|
||||
|
||||
XPT do " do { .. }
|
||||
do {
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT begin " begin .. end
|
||||
begin
|
||||
`cursor^
|
||||
end
|
||||
|
||||
XPT fun " (fun .. -> ..)
|
||||
(fun `args^ -> `^)
|
||||
|
||||
XPT func " value .. : .. = fun .. ->
|
||||
value `funName^ : `ty^ =
|
||||
fun `args^ ->
|
||||
`cursor^;
|
||||
|
||||
|
||||
XPT letin " let .. = .. in
|
||||
let `name^ `_^^ =
|
||||
`what^ `...^
|
||||
and `subname^ `_^^ =
|
||||
`subwhat^`...^
|
||||
in
|
||||
|
||||
|
||||
XPT letrecin " let rec .. = .. in
|
||||
let rec `name^ `_^^ =
|
||||
`what^ `...^
|
||||
and `subname^ `_^^ =
|
||||
`subwhat^`...^
|
||||
in
|
||||
|
||||
181
plugins/bundle/xptemplate/ftplugin/ocaml/ocaml.xpt.vim
Executable file
181
plugins/bundle/xptemplate/ftplugin/ocaml/ocaml.xpt.vim
Executable file
|
|
@ -0,0 +1,181 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
|
||||
XPTvar $VOID_LINE (* void *)
|
||||
XPTvar $CURSOR_PH (* cursor *)
|
||||
|
||||
XPTvar $BRif ' '
|
||||
XPTvar $BRloop ' '
|
||||
XPTvar $BRstc ' '
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
XPTvar $CL (*
|
||||
XPTvar $CM *
|
||||
XPTvar $CR *)
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _comment/doubleSign
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
XPT if " if .. then .. else ..
|
||||
if `cond^
|
||||
then `cursor^`else...{{^
|
||||
else`}}^
|
||||
|
||||
|
||||
" NOTE: the first repetition indent is different from the second one. Thus we
|
||||
" need two part repetition
|
||||
XPT match " match .. with .. -> .. | ..
|
||||
match `expr^ with
|
||||
`what^ -> `with^` `...{{^
|
||||
| `what^ -> `with^` `more...{{^
|
||||
| `what^ -> `with^` `more...^`}}^`}}^
|
||||
|
||||
|
||||
XPT moduletype " module type .. = sig .. end
|
||||
module type `name^ `^ = sig
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT module " module .. = struct .. end
|
||||
XSET name|post=SV( '^\w', '\u&' )
|
||||
module `name^ `^ = struct
|
||||
`cursor^
|
||||
end
|
||||
|
||||
XPT while " while .. do .. done
|
||||
while `cond^ do
|
||||
`cursor^
|
||||
done
|
||||
|
||||
XPT for " for .. to .. do .. done
|
||||
XSET side=Choose(['to', 'downto'])
|
||||
for `var^ = `val^ `side^ `expr^ do
|
||||
`cursor^
|
||||
done
|
||||
|
||||
XPT class " class .. = object .. end
|
||||
class `_^^ `name^ =
|
||||
object (self)
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT classtype " class type .. = object .. end
|
||||
class type `name^ =
|
||||
object
|
||||
method `field^ : `type^` `...^
|
||||
method `field^ : `type^` `...^
|
||||
end
|
||||
|
||||
|
||||
XPT classtypecom " (** .. *) class type .. = object .. end
|
||||
(** `class_descr^^ *)
|
||||
class type `name^ =
|
||||
object
|
||||
(** `method_descr^^ *)
|
||||
method `field^ : `type^` `...^
|
||||
(** `method_descr^^ *)
|
||||
method `field^ : `type^` `...^
|
||||
end
|
||||
|
||||
|
||||
" NOTE: the first repetition indent is different from the second one. Thus we
|
||||
" need two part repetition
|
||||
XPT typesum " type .. = .. | ..
|
||||
XSET typeParams?|post=EchoIfNoChange( '' )
|
||||
type `typename^` `typeParams?^ =
|
||||
`constructor^` `...{{^
|
||||
| `constructor^` `more...{{^
|
||||
| `constructor^` `more...^`}}^`}}^
|
||||
|
||||
|
||||
XPT typesumcom " (** .. *) type .. = .. | ..
|
||||
XSET typeParams?|post=EchoIfNoChange( '' )
|
||||
(** `typeDescr^ *)
|
||||
type `typename^` `typeParams?^ =
|
||||
`constructor^ (** `ctordescr^ *)` `...{{^
|
||||
| `constructor^ (** `ctordescr^ *)` `more...{{^
|
||||
| `constructor^ (** `ctordescr^ *)` `more...^`}}^`}}^
|
||||
|
||||
|
||||
XPT typerecord " type .. = { .. }
|
||||
XSET typeParams?|post=EchoIfNoChange( '' )
|
||||
type `typename^` `typeParams?^ =
|
||||
{ `recordField^ : `fType^` `...^
|
||||
; `recordField^ : `fType^` `...^
|
||||
}
|
||||
|
||||
|
||||
XPT typerecordcom " (** .. *)type .. = { .. }
|
||||
(** `type_descr^ *)
|
||||
type `typename^ `_^^=
|
||||
{ `recordField^ : `fType^ (** `desc^ *)` `...^
|
||||
; `otherfield^ : `othertype^ (** `desc^ *)` `...^
|
||||
}
|
||||
|
||||
|
||||
XPT try wrap=expr " try .. with .. -> ..
|
||||
try `expr^
|
||||
with `exc^ -> `rez^
|
||||
` `...`
|
||||
{{^ | `exc2^ -> `rez2^
|
||||
` `...`
|
||||
^`}}^
|
||||
|
||||
XPT val " value .. : ..
|
||||
value `thing^ : `cursor^
|
||||
|
||||
XPT ty " .. -> ..
|
||||
`t^`...^ -> `t2^`...^
|
||||
|
||||
XPT do " do { .. }
|
||||
do {
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT begin " begin .. end
|
||||
begin
|
||||
`cursor^
|
||||
end
|
||||
|
||||
XPT fun " (fun .. -> ..)
|
||||
(fun `args^ -> `^)
|
||||
|
||||
XPT func " value .. : .. = fun .. ->
|
||||
let `funName^ : `ty^ =
|
||||
fun `args^ ->
|
||||
`cursor^
|
||||
|
||||
|
||||
XPT letin " let .. = .. in
|
||||
let `name^ `_^^ =
|
||||
`what^` `...^
|
||||
and `subname^ `_^^ =
|
||||
`subwhat^` `...^
|
||||
in
|
||||
|
||||
|
||||
XPT letrecin " let rec .. = .. in
|
||||
let rec `name^ `_^^ =
|
||||
`what^` `...^
|
||||
and `subname^ `_^^ =
|
||||
`subwhat^` `...^
|
||||
in
|
||||
|
||||
151
plugins/bundle/xptemplate/ftplugin/perl/perl.xpt.vim
Normal file
151
plugins/bundle/xptemplate/ftplugin/perl/perl.xpt.vim
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL
|
||||
XPTvar $UNDEFINED
|
||||
|
||||
XPTvar $VOID_LINE # void;
|
||||
XPTvar $CURSOR_PH # cursor
|
||||
|
||||
XPTvar $BRif ' '
|
||||
XPTvar $BRel \n
|
||||
XPTvar $BRloop ' '
|
||||
XPTvar $BRstc ' '
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
XPTvar $CS #
|
||||
XPTinclude
|
||||
\ _comment/singleSign
|
||||
|
||||
XPTvar $VAR_PRE $
|
||||
XPTvar $FOR_SCOPE 'my '
|
||||
XPTinclude
|
||||
\ _loops/for
|
||||
|
||||
XPTinclude
|
||||
\ _loops/c.while.like
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
" perl has no NULL value
|
||||
XPT fornn hidden=1
|
||||
|
||||
XPT whilenn hidden=1
|
||||
|
||||
|
||||
XPT perl " #!/usr/bin/env perl
|
||||
#!/usr/bin/env perl
|
||||
|
||||
..XPT
|
||||
|
||||
|
||||
XPT xif " .. if ..;
|
||||
`expr^ if `cond^;
|
||||
|
||||
|
||||
XPT xwhile " .. while ..;
|
||||
`expr^ while `cond^;
|
||||
|
||||
|
||||
XPT xunless " .. unless ..;
|
||||
`expr^ unless `cond^;
|
||||
|
||||
|
||||
XPT xforeach " .. foreach ..;
|
||||
`expr^ foreach @`array^;
|
||||
|
||||
|
||||
XPT sub " sub .. { .. }
|
||||
sub `fun_name^`$BRfun^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT unless " unless ( .. ) { .. }
|
||||
unless`$SPcmd^(`$SParg^`cond^`$SParg^)`$BRif^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT eval wrap=risky " eval { .. };if...
|
||||
eval`$BRif^{
|
||||
`risky^
|
||||
};
|
||||
if`$SPcmd^(`$SParg^$@`$SParg^)`$BRif^{
|
||||
`handle^
|
||||
}
|
||||
|
||||
XPT try alias=eval " eval { .. }; if ...
|
||||
|
||||
|
||||
XPT whileeach " while \( \( key, val ) = each\( %** ) )
|
||||
while`$SPcmd^(`$SParg^(`$SParg^$`key^,`$SPop^$`val^`$SParg^) = each(`$SParg^%`array^`$SParg^)`$SParg^)`$BRloop^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT whileline " while \( defined\( \$line = <FILE> ) )
|
||||
while`$SPcmd^(`$SParg^defined(`$SParg^$`line^`$SPop^=`$SPop^<`STDIN^>`$SParg^)`$SParg^)`$BRloop^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT foreach " foreach my .. (..){}
|
||||
foreach`$SPcmd^my $`var^ (`$SParg^@`array^`$SParg^)`$BRloop^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT forkeys " foreach my var \( keys %** )
|
||||
foreach`$SPcmd^my $`var^ (`$SParg^keys @`array^`$SParg^)`$BRloop^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT forvalues " foreach my var \( keys %** )
|
||||
foreach`$SPcmd^my $`var^ (`$SParg^values @`array^`$SParg^)`$BRloop^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT if wrap=job " if ( .. ) { .. } ...
|
||||
XSET job=$CS job
|
||||
if`$SPcmd^(`$SParg^`cond^`$SParg^)`$BRif^{
|
||||
`job^
|
||||
}`
|
||||
`elsif...^`$BRel^elsif`$SPcmd^(`$SParg^`cond2^`$SParg^)`$BRif^{
|
||||
`job^
|
||||
}`
|
||||
`elsif...^`
|
||||
`else...{{^`$BRel^else`$BRif^{
|
||||
`cursor^
|
||||
}`}}^
|
||||
|
||||
XPT package "
|
||||
package `className^;
|
||||
|
||||
use base qw(`parent^);
|
||||
|
||||
sub new`$BRfun^{
|
||||
my $class = shift;
|
||||
$class = ref $class if ref $class;
|
||||
my $self = bless {}, $class;
|
||||
$self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
..XPT
|
||||
|
||||
|
||||
|
||||
75
plugins/bundle/xptemplate/ftplugin/php/php.ftdetect.vim
Normal file
75
plugins/bundle/xptemplate/ftplugin/php/php.ftdetect.vim
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
if exists("b:__PHP_FTDETECT_VIM__")
|
||||
finish
|
||||
endif
|
||||
let b:__PHP_FTDETECT_VIM__ = 1
|
||||
|
||||
|
||||
if &filetype !~ 'php'
|
||||
finish
|
||||
endif
|
||||
|
||||
|
||||
|
||||
let s:skipPattern = 'synIDattr(synID(line("."), col("."), 0), "name") =~? "\\vstring|comment"'
|
||||
let s:pattern = {
|
||||
\ 'php' : {
|
||||
\ 'start' : '\V\c<?\%(php\>\)\?',
|
||||
\ 'mid' : '',
|
||||
\ 'end' : '\V\c?>',
|
||||
\ 'skip' : s:skipPattern,
|
||||
\ },
|
||||
\ 'javascript' : {
|
||||
\ 'start' : '\V\c<script\_[^>]\*>',
|
||||
\ 'mid' : '',
|
||||
\ 'end' : '\V\c</script>',
|
||||
\ 'skip' : s:skipPattern,
|
||||
\ },
|
||||
\ 'css' : {
|
||||
\ 'start' : '\V\c<style\_[^>]\*>',
|
||||
\ 'mid' : '',
|
||||
\ 'end' : '\V\c</style>',
|
||||
\ 'skip' : s:skipPattern,
|
||||
\ },
|
||||
\}
|
||||
|
||||
if exists( 'php_noShortTags' )
|
||||
let s:pattern.php.start = '\V\c<?php\>'
|
||||
endif
|
||||
|
||||
let s:topFT = 'html'
|
||||
|
||||
fun! XPT_phpFiletypeDetect() "{{{
|
||||
let pos = [ line( "." ), col( "." ) ]
|
||||
|
||||
let synName = xpt#util#NearestSynName()
|
||||
|
||||
if synName == ''
|
||||
" top level ft is html
|
||||
return s:topFT
|
||||
|
||||
else
|
||||
|
||||
for [ name, ftPattern ] in items( s:pattern )
|
||||
let pos = searchpairpos( ftPattern.start, ftPattern.mid, ftPattern.end, 'nbW', ftPattern.skip )
|
||||
if pos != [0, 0]
|
||||
return name
|
||||
endif
|
||||
endfor
|
||||
|
||||
if synName =~ '^\cjavascript'
|
||||
return 'javascript'
|
||||
elseif synName =~ '^\ccss'
|
||||
return 'css'
|
||||
endif
|
||||
|
||||
return s:topFT
|
||||
|
||||
endif
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
if exists( 'b:XPTfiletypeDetect' )
|
||||
unlet b:XPTfiletypeDetect
|
||||
endif
|
||||
let b:XPTfiletypeDetect = function( 'XPT_phpFiletypeDetect' )
|
||||
|
||||
81
plugins/bundle/xptemplate/ftplugin/php/php.xpt.vim
Normal file
81
plugins/bundle/xptemplate/ftplugin/php/php.xpt.vim
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE true
|
||||
XPTvar $FALSE false
|
||||
XPTvar $NULL null
|
||||
XPTvar $UNDEFINED null
|
||||
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $CURSOR_PH /* cursor */
|
||||
|
||||
XPTvar $BRif ' '
|
||||
XPTvar $BRel \n
|
||||
XPTvar $BRloop ' '
|
||||
XPTvar $BRstc ' '
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
XPTvar $CL /*
|
||||
XPTvar $CM *
|
||||
XPTvar $CR */
|
||||
XPTinclude
|
||||
\ _comment/doubleSign
|
||||
|
||||
XPTvar $VAR_PRE $
|
||||
XPTvar $FOR_SCOPE
|
||||
XPTinclude
|
||||
\ _loops/for
|
||||
|
||||
XPTinclude
|
||||
\ _condition/c.like
|
||||
\ _loops/c.while.like
|
||||
|
||||
XPTembed
|
||||
\ html/html
|
||||
\ html/php*
|
||||
|
||||
|
||||
|
||||
if exists( 'php_noShortTags' )
|
||||
XPTvar $PHP_TAG php
|
||||
else
|
||||
XPTvar $PHP_TAG
|
||||
endif
|
||||
|
||||
XPT html " <?$PHP_TAG ... ?>
|
||||
?>`html^<?`$PHP_TAG^
|
||||
|
||||
|
||||
XPT foreach " foreach (.. as ..) {..}
|
||||
foreach ($`var^ as `container^)`$BRloop^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT fun " function ..( .. ) {..}
|
||||
XSET params=Void()
|
||||
XSET params|post=EchoIfEq(' ', '')
|
||||
function `funName^(` `params` ^)`$BRfun^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT class " class .. { .. }
|
||||
class `className^`$BRfun^{
|
||||
function __construct( `args^ )`$BRfun^{
|
||||
`cursor^
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
XPT interface " interface .. { .. }
|
||||
interface `interfaceName^`$BRfun^{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT $ " make dollar a keyword
|
||||
$
|
||||
104
plugins/bundle/xptemplate/ftplugin/ps1/ps1.xpt.vim
Normal file
104
plugins/bundle/xptemplate/ftplugin/ps1/ps1.xpt.vim
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
XPT cmdlet " cmdlet ..-.. {}
|
||||
Cmdlet `verb^-`noun^
|
||||
{
|
||||
`Param...{{^Param(
|
||||
`^
|
||||
)`}}^
|
||||
`Begin...{{^Begin
|
||||
{
|
||||
}`}}^
|
||||
Process
|
||||
{
|
||||
}
|
||||
`End...{{^End
|
||||
{
|
||||
}`}}^
|
||||
}
|
||||
|
||||
|
||||
XPT if wrap=code " if ( .. ) { .. } ...
|
||||
if ( `cond^ )
|
||||
{
|
||||
`code^
|
||||
}`
|
||||
`...^
|
||||
elseif ( `cond2^ )
|
||||
{
|
||||
`body^
|
||||
}`
|
||||
`...^`
|
||||
`else...{{^
|
||||
else
|
||||
{
|
||||
`body^
|
||||
}`}}^
|
||||
|
||||
|
||||
XPT fun " function ..(..) { .. }
|
||||
function `funName^( `params^ )
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT function " function { BEGIN PROCESS END }
|
||||
function `funName^( `params^ )
|
||||
{
|
||||
`Begin...{{^Begin
|
||||
{
|
||||
`^
|
||||
}`}}^
|
||||
`Process...{{^Process
|
||||
{
|
||||
`^
|
||||
}`}}^
|
||||
`End...{{^End
|
||||
{
|
||||
`^
|
||||
}`}}^
|
||||
}
|
||||
|
||||
|
||||
XPT foreach " foreach (.. in ..)
|
||||
foreach ($`var^ in `other^)
|
||||
{ `cursor^ }
|
||||
|
||||
|
||||
XPT switch " switch (){ .. {..} }
|
||||
switch `option^^ (`what^)
|
||||
{
|
||||
`pattern^ { `action^ }`...^
|
||||
`pattern^ { `action^ }`...^
|
||||
`Default...{{^Default { `action^ }`}}^
|
||||
}
|
||||
|
||||
|
||||
XPT trap " trap [..] { .. }
|
||||
trap [`Exception^]
|
||||
{
|
||||
`body^
|
||||
}
|
||||
|
||||
|
||||
XPT for " for (..;..;++)
|
||||
for ($`var^ = `init^; $`var^ -ge `val^; $`var^--)
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT forr " for (..;..;--)
|
||||
for ($`var^ = `init^; $`var^ -ge `val^; $`var^--)
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
332
plugins/bundle/xptemplate/ftplugin/python/python.xpt.vim
Normal file
332
plugins/bundle/xptemplate/ftplugin/python/python.xpt.vim
Normal file
|
|
@ -0,0 +1,332 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
" Set your python version with this variable in .vimrc or your own python
|
||||
" snippet:
|
||||
" XPTvar $PYTHON_EXC /usr/bin/python
|
||||
" XPTvar $PYTHON_EXC /usr/bin/env python2.6
|
||||
XPTvar $PYTHON_EXC /usr/bin/env python
|
||||
|
||||
" 3 single quotes quoted by single quote
|
||||
XPTvar $PYTHON_DOC_MARK '''''
|
||||
" XPTvar $PYTHON_DOC_MARK '"""'
|
||||
|
||||
" for python 2.5 and older
|
||||
XPTvar $PYTHON_EXP_SYM ', '
|
||||
" " for python 2.6 and newer
|
||||
" XPTvar $PYTHON_EXP_SYM ' as '
|
||||
|
||||
|
||||
XPTvar $TRUE True
|
||||
XPTvar $FALSE False
|
||||
XPTvar $NULL None
|
||||
XPTvar $UNDEFINED None
|
||||
|
||||
|
||||
XPTvar $VOID_LINE # nothing
|
||||
XPTvar $CURSOR_PH CURSOR
|
||||
|
||||
|
||||
" int fun ** (
|
||||
" class name ** (
|
||||
XPTvar $SPfun ''
|
||||
|
||||
" int fun( ** arg ** )
|
||||
" if ( ** condition ** )
|
||||
" for ( ** statement ** )
|
||||
" [ ** a, b ** ]
|
||||
" { ** 'k' : 'v' ** }
|
||||
XPTvar $SParg ''
|
||||
|
||||
" if ** (
|
||||
" while ** (
|
||||
" for ** (
|
||||
XPTvar $SPcmd ' '
|
||||
|
||||
" a ** = ** a ** + ** 1
|
||||
" (a, ** b, ** )
|
||||
XPTvar $SPop ' '
|
||||
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
|
||||
XPTvar $CS #
|
||||
XPTvar $CL '''''
|
||||
XPTvar $CM ''
|
||||
XPTvar $CR '''''
|
||||
|
||||
XPTinclude
|
||||
\ _comment/singleDouble
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
fun! s:f.python_wrap_args_if_func( args )
|
||||
let v = self.V()
|
||||
if v != ''
|
||||
return v . '(' . a:args . ')'
|
||||
else
|
||||
return a:args
|
||||
endif
|
||||
endfunction
|
||||
|
||||
fun! s:f.python_genexpr_cmpl( itemName )
|
||||
let v = self.V()
|
||||
if v =~ '\V(\$'
|
||||
let args = self.R( a:itemName )
|
||||
return self[ '$SParg' ] . args . self[ '$SParg' ] . ')'
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let s:rangePattern = '\V\^r\%[ange(]\$'
|
||||
|
||||
fun! s:f.python_seq_cmpl()
|
||||
let v = self.V()
|
||||
|
||||
if v == ''
|
||||
return ''
|
||||
endif
|
||||
|
||||
|
||||
if v =~ s:rangePattern
|
||||
if self.Phase() == 'post'
|
||||
return ''
|
||||
endif
|
||||
|
||||
let ends = matchstr( v, s:rangePattern )
|
||||
let rv = printf( 'range(%s0?,%send%s)'
|
||||
\ , self[ '$SParg' ], self[ '$SPop' ], self[ '$SParg' ] )
|
||||
return rv[ len( ends ) : ]
|
||||
endif
|
||||
|
||||
|
||||
let ends = matchstr( v, '\V.\w\+\$' )
|
||||
if ends =~ '\V.\%[keys]\$'
|
||||
return ".keys()"[ len( ends ) : ]
|
||||
|
||||
elseif ends =~ '\V.\%[values]\$'
|
||||
return ".values()"[ len( ends ) : ]
|
||||
|
||||
elseif ends =~ '\V.\%[items]\$'
|
||||
return ".items()"[ len( ends ) : ]
|
||||
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
fun! s:f.python_sp_arg()
|
||||
let sp = self[ '$SParg' ]
|
||||
|
||||
if self.Phase() == 'rendering'
|
||||
return sp
|
||||
elseif self.Phase() == 'post'
|
||||
return self.V() == '' || self.V() == 'arg*' ? '' : sp
|
||||
endif
|
||||
|
||||
return sp
|
||||
endfunction
|
||||
|
||||
|
||||
fun! s:f.python_find_class( default )
|
||||
" TODO simplify and do more strict search
|
||||
let indentNr = indent( line( "." ) )
|
||||
let defIndent = searchpos( '\V\^\s\*\%<' . indentNr . 'vdef\>', 'bWcn' )
|
||||
if defIndent == [0, 0]
|
||||
return a:default
|
||||
endif
|
||||
|
||||
let di = indent( defIndent[ 0 ] )
|
||||
|
||||
let clsPos = searchpos( '\V\^\s\*\%<' . di . 'vclass\s\+\zs\w\+', 'bWcn' )
|
||||
if clsPos == [0, 0]
|
||||
return a:default
|
||||
endif
|
||||
|
||||
return matchstr( getline( clsPos[0] ), '\Vclass\s\+\zs\w\+' )
|
||||
|
||||
endfunction
|
||||
|
||||
fun! s:f.python_find_func( default )
|
||||
let indentNr = indent( line( "." ) )
|
||||
let defIndent = searchpos( '\V\^\s\*\%<' . indentNr . 'vdef\>', 'bWcn' )
|
||||
if defIndent == [0, 0]
|
||||
return a:default
|
||||
endif
|
||||
|
||||
return matchstr( getline( defIndent[0] ), '\Vdef\s\+\zs\w\+' )
|
||||
|
||||
endfunction
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
XPT _if hidden
|
||||
if `cond^:
|
||||
`pass^
|
||||
|
||||
|
||||
XPT _generator hidden " generator
|
||||
XSET ComeFirst=elem seq func
|
||||
`func^`func^python_genexpr_cmpl('elem')^ for `elem^ in `seq^` if `condition?^
|
||||
|
||||
|
||||
XPT _args hidden " expandable arguments
|
||||
XSET arg*|post=ExpandInsideEdge( ',$SPop', '' )
|
||||
`$SParg`arg*`$SParg^
|
||||
|
||||
XPT _args2 hidden " expandable arguments
|
||||
XSET arg*|post=ExpandInsideEdge( ',$SPop', '' )
|
||||
`,$SPop`arg*^
|
||||
|
||||
|
||||
|
||||
|
||||
XPT python " #!$PYTHON_EXC
|
||||
XSET encoding=Echo(&fenc != '' ? &fenc : &enc)
|
||||
#!`$PYTHON_EXC^
|
||||
# coding: `encoding^
|
||||
|
||||
..XPT
|
||||
|
||||
XPT shebang alias=python
|
||||
|
||||
XPT sb alias=python
|
||||
|
||||
|
||||
XPT p " pass
|
||||
pass
|
||||
|
||||
|
||||
XPT s " self.
|
||||
self.
|
||||
|
||||
|
||||
XPT filehead " file description
|
||||
`$PYTHON_DOC_MARK^
|
||||
File : `file()^
|
||||
Author : `$author^
|
||||
Contact : `$email^
|
||||
Date : `date()^
|
||||
|
||||
Description : `cursor^
|
||||
`$PYTHON_DOC_MARK^
|
||||
|
||||
|
||||
XPT if " if ..: .. else...
|
||||
`:_if:^
|
||||
|
||||
|
||||
XPT else " else:
|
||||
else:
|
||||
`cursor^
|
||||
|
||||
|
||||
XPT elif " else:
|
||||
elif `cond^:
|
||||
`cursor^
|
||||
|
||||
|
||||
XPT range " range\( .. )
|
||||
range(`$SParg^``0?`,$SPop^`end^`$SParg^)
|
||||
|
||||
|
||||
XPT forrange " for var in range\( .. )
|
||||
for `i^ in `:range:^:
|
||||
`cursor^
|
||||
|
||||
|
||||
XPT for " for .. in ..: ..
|
||||
XSET seq|post=Build( V() =~ '\V\^r\%[ange(]\$' ? '`:range:^' : ItemValueStripped() )
|
||||
for `var^ in `seq^`seq^python_seq_cmpl()^:
|
||||
`cursor^
|
||||
|
||||
|
||||
XPT while " while ..:
|
||||
while `condition^:
|
||||
`cursor^
|
||||
|
||||
|
||||
XPT def " def ..( .. ): ...
|
||||
XSET a=arg*
|
||||
XSET a|post=Build( V() == 'arg*' ? '' : VS() . AutoCmpl( 1, 'self' ) . '`:_args2:^' )
|
||||
def `name^`$SPfun^(`a^python_sp_arg()^``a^`a^AutoCmpl(0,'self')^`a^python_sp_arg()^):
|
||||
`cursor^
|
||||
|
||||
|
||||
" TODO use ontype/map instead
|
||||
XPT lambda " (lambda .. : ..)
|
||||
XSET arg*|post=ExpandInsideEdge( ',$SPop', '' )
|
||||
lambda `arg*^: `expr^
|
||||
|
||||
|
||||
XPT try wrap=job " try: .. except: ...
|
||||
try:
|
||||
`job^
|
||||
`:except:^
|
||||
|
||||
|
||||
XPT except " except ..
|
||||
except `Exception^`$PYTHON_EXP_SYM`e^:
|
||||
`cursor^
|
||||
|
||||
|
||||
XPT finally " finally:
|
||||
finally:
|
||||
`cursor^
|
||||
|
||||
|
||||
XPT class " class .. : def __init__ ...
|
||||
class `ClassName^`$SPfun^(`$SParg`object`$SParg^):
|
||||
`pass^
|
||||
|
||||
|
||||
XPT init " def __init__
|
||||
XSET arg*|post=ExpandInsideEdge( ',$SPop', '' )
|
||||
def __init__`$SPfun^(`$SParg^self`,$SPop`arg*^`$SParg^):
|
||||
`cursor^
|
||||
|
||||
|
||||
" TODO guess method name for example __init__
|
||||
XPT super " super\( Clz, self ).
|
||||
super(`$SParg^`clz^python_find_class('Me')^,`$SPop^self`$SParg^).`method^python_find_func('what')^(`:_args:^)
|
||||
|
||||
|
||||
XPT ifmain " if __name__ == __main__
|
||||
if __name__`$SPop^==`$SPop^"__main__":
|
||||
`cursor^
|
||||
|
||||
XPT with " with .. as .. :
|
||||
with `opener^` as `name?^:
|
||||
`cursor^
|
||||
|
||||
|
||||
XPT import " import ..
|
||||
import `mod^` as `name?^
|
||||
|
||||
|
||||
XPT from " from .. import ..
|
||||
from `module^ import `item^` as `name?^
|
||||
|
||||
|
||||
XPT fromfuture " from __future__ import ..
|
||||
from __future__ import `name^
|
||||
|
||||
|
||||
XPT str wrap=s " str\( .. )
|
||||
str(`$SParg^`s^`$SParg^)
|
||||
|
||||
|
||||
XPT genExp " \(func\(x) for x in seq)
|
||||
(`$SParg^`:_generator:^`$SParg^)
|
||||
|
||||
|
||||
XPT listComp " \[func\(x) for x in seq]
|
||||
[`$SParg^`:_generator:^`$SParg^]
|
||||
36
plugins/bundle/xptemplate/ftplugin/r/r.xpt.vim
Normal file
36
plugins/bundle/xptemplate/ftplugin/r/r.xpt.vim
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _condition/c.like
|
||||
|
||||
|
||||
XPT for " for (... in ...) { ... }
|
||||
for (`name^ in `vec^)
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT while " while ( ... ) { ... }
|
||||
while ( `cond^ )
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT fun " ... <- function ( ... , ... ) { ... }
|
||||
`funName^ <- function( `args^ )
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT operator " %...% <- function ( ... , ... ) { ... }
|
||||
%`funName^% <- function( `args^ )
|
||||
{
|
||||
`cursor^
|
||||
}
|
||||
|
||||
XPT head " #! /usr/bin/env/Rscript
|
||||
#! /usr/bin/env Rscript
|
||||
|
||||
70
plugins/bundle/xptemplate/ftplugin/rst/rst.xpt.vim
Normal file
70
plugins/bundle/xptemplate/ftplugin/rst/rst.xpt.vim
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
" snippets for reStructuredText (.rst)
|
||||
XPTemplate priority=lang mark=~^
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
fun! s:f.ExpandRstTitle()
|
||||
let txt = self.R( 'title' )
|
||||
let bar = repeat( '=', len( txt ) )
|
||||
return bar . "\n" . txt . "\n" . bar . "\n"
|
||||
endfunction
|
||||
|
||||
fun! s:f.ExpandRstSection( char )
|
||||
let txt = self.R( 'sectionName' )
|
||||
let bar = repeat( a:char, len( txt ) )
|
||||
return txt . "\n" . bar . "\n"
|
||||
endfunction
|
||||
|
||||
XPT index " all stuff to create basic index
|
||||
XSET sectionName|post=ExpandRstSection('=')
|
||||
~sectionName^
|
||||
|
||||
Contents:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:numbered:
|
||||
~cursor^
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
|
||||
|
||||
XPT title synonym=h1 " === ... ===
|
||||
XSET title|post=ExpandRstTitle()
|
||||
~title^
|
||||
|
||||
|
||||
XPT section synonym=h2 " ... ====
|
||||
XSET sectionName|post=ExpandRstSection('=')
|
||||
~sectionName^
|
||||
|
||||
XPT subsection synonym=h3 " .... -------
|
||||
XSET sectionName|post=ExpandRstSection('-')
|
||||
~sectionName^
|
||||
|
||||
|
||||
XPT code " ```...```
|
||||
``~cursor^``
|
||||
|
||||
XPT italic " *...*
|
||||
*~cursor^*
|
||||
|
||||
XPT bold " **...**
|
||||
**~cursor^**
|
||||
|
||||
XPT link " .. _a link: ...
|
||||
.. _a link: ~url^
|
||||
|
||||
XPT func " .. function:: ...
|
||||
.. function:: ~funDesc^
|
||||
|
||||
~cursor^
|
||||
|
||||
821
plugins/bundle/xptemplate/ftplugin/ruby/ruby.xpt.vim
Normal file
821
plugins/bundle/xptemplate/ftplugin/ruby/ruby.xpt.vim
Normal file
|
|
@ -0,0 +1,821 @@
|
|||
XPTemplate priority=lang keyword=:%#
|
||||
|
||||
" containers
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
" inclusion
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
fun! s:f.RubyCamelCase(...) "{{{
|
||||
let str = a:0 == 0 ? self.V() : a:1
|
||||
let r = substitute(substitute(str, "[\/ _]", ' ', 'g'), '\<.', '\u&', 'g')
|
||||
return substitute(r, " ", '', 'g')
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:f.RubySnakeCase(...) "{{{
|
||||
let str = a:0 == 0 ? self.V() : a:1
|
||||
return substitute(str," ",'_','g')
|
||||
endfunction "}}}
|
||||
|
||||
" Multiple each snippet {{{
|
||||
"{{{ s:each_list
|
||||
let s:each_list = [ 'byte', 'char', 'cons', 'index', 'key',
|
||||
\'line', 'pair', 'slice', 'value' ]
|
||||
"}}}
|
||||
|
||||
fun! s:f.RubyEachPopup() "{{{
|
||||
let l = []
|
||||
for i in s:each_list
|
||||
let l += [{'word': i, 'menu': 'each_' . i . '{ |..| ... }'}]
|
||||
endfor
|
||||
return l
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:f.RubyEachBrace() "{{{
|
||||
let v = self.SV('^_','','')
|
||||
if v == ''
|
||||
return ''
|
||||
elseif v =~# 'slice\|cons'
|
||||
return '_' . v.'(`val^3^)'
|
||||
else
|
||||
return '_' . v
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:f.RubyEachPair() "{{{
|
||||
let v = self.R('what')
|
||||
if v =~# 'pair'
|
||||
return '`el1^, `el2^'
|
||||
elseif v == ''
|
||||
return '`el^'
|
||||
else
|
||||
if v =~ 'slice\|cons'
|
||||
let v = substitute(v,'val','','')
|
||||
endif
|
||||
return '`' . substitute(v,'[^a-z]','','g') . '^'
|
||||
endif
|
||||
endfunction "}}}
|
||||
" End multiple each snippet }}}
|
||||
|
||||
" Multiple assert snippet {{{
|
||||
"{{{ s:assert_map
|
||||
let s:assert_map = {
|
||||
\'block' : '' . ' { `cursor^ }',
|
||||
\'equals' : '(`expected^, `actual^`, `message^)' . '',
|
||||
\'in_delta' : '(`expected float^, `actual float^, `delta^`, `message^)' . '',
|
||||
\'instance_of' : '(`klass^, `object to compare^`, `message^)' . '',
|
||||
\'kind_of' : '(`klass^, `object to compare^`, `message^)' . '',
|
||||
\'match' : '(/`regexp^/`^, `string^`, `message^)' . '',
|
||||
\'not_equal' : '(`expected^, `actual^`, `message^)' . '',
|
||||
\'nil' : '(`object^`, `message^)' . '',
|
||||
\'no_match' : '(/`regexp^/`^, `string^`, `message^)' . '',
|
||||
\'not_nil' : '(`object^`, `message^)' . '',
|
||||
\'nothing_raised' : '(`exception^)' . ' { `cursor^ }',
|
||||
\'not_same' : '(`expected^, `actual^`, `message^)' . '',
|
||||
\'nothing_thrown' : '`(`message`)^' . ' { `cursor^ }',
|
||||
\'operator' : '(`obj1^, `operator^, `obj2^`, `message^)' . '',
|
||||
\'raise' : '(`exception^)' . ' { `cursor^ }',
|
||||
\'respond_to' : '(`object^, `respond to this message^`, `message^)' . '',
|
||||
\'same' : '(`expected^, `actual^`, `message^)' . '',
|
||||
\'send' : '([`receiver^, `method^, `args^]`, `message^)' . '',
|
||||
\'throws' : '(`expected symbol^`, `message^)' . ' { `cursor^ }',
|
||||
\}
|
||||
"}}}
|
||||
|
||||
fun! s:RubyAssertPopupSort(a, b) "{{{
|
||||
return a:a.word == a:b.word ? 0 : a:a.word > a:b.word ? 1 : -1
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:f.RubyAssertPopup() "{{{
|
||||
let list = []
|
||||
for [k, v] in items(s:assert_map)
|
||||
let list += [{ 'word' : k, 'menu' : 'assert_' . k . substitute(v, '`.\{-}^', '..', 'g') }]
|
||||
endfor
|
||||
return sort(list, 's:RubyAssertPopupSort')
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:f.RubyAssertMethod() "{{{
|
||||
let v = self.SV('^_', '', '')
|
||||
if v == ''
|
||||
return v . '(`^`, `message^)'
|
||||
endif
|
||||
if has_key(s:assert_map, v)
|
||||
return '_' . v . s:assert_map[v]
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction "}}}
|
||||
" End multiple assert snippet }}}
|
||||
|
||||
" Repeat an item inside its edges.
|
||||
" Behave like ExpandIfNotEmpty() but within edges
|
||||
fun! s:f.RepeatInsideEdges(sep) "{{{
|
||||
let [edgeLeft, edgeRight] = self.ItemEdges()
|
||||
let v = self.V()
|
||||
let n = self.N()
|
||||
if v == '' || v == self.ItemFullname()
|
||||
return ''
|
||||
endif
|
||||
|
||||
|
||||
let v = self.ItemStrippedValue()
|
||||
let [ markLeft, markRight ] = XPTmark()
|
||||
|
||||
let newName = 'n' . n
|
||||
let res = edgeLeft . v
|
||||
let res .= markLeft . a:sep . markLeft . newName . markRight
|
||||
let res .= 'ExpandIfNotEmpty("' . a:sep . '", "' . newName . '")' . markRight . markRight
|
||||
let res .= edgeRight
|
||||
|
||||
|
||||
return res
|
||||
endfunction "}}}
|
||||
|
||||
" Remove an item if its value hasn't change
|
||||
fun! s:f.RemoveIfUnchanged() "{{{
|
||||
let v = self.V()
|
||||
let [lft, rt] = self.ItemEdges()
|
||||
if v == lft . self.N() . rt
|
||||
return ''
|
||||
else
|
||||
return v
|
||||
end
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
XPT # syn=string " #{..}
|
||||
#{`^}
|
||||
|
||||
|
||||
XPT : " :... => ...
|
||||
:`key^ => `value^
|
||||
|
||||
|
||||
XPT % " %**[..]
|
||||
XSET _=Choose(['w', 'W', 'q', 'Q'])
|
||||
%`_^[`^]
|
||||
|
||||
|
||||
XPT BEG " BEGIN { .. }
|
||||
BEGIN {
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT Comp " include Comparable def <=> ...
|
||||
include Comparable
|
||||
|
||||
def <=>(other)
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT END " END { .. }
|
||||
END {
|
||||
`cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT Enum " include Enumerable def each ...
|
||||
include Enumerable
|
||||
|
||||
def each(&block)
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT Forw " extend Forwardable
|
||||
extend Forwardable
|
||||
|
||||
|
||||
XPT Md " Marshall Dump
|
||||
File.open(`filename^, "wb") { |`file^| Marshal.dump(`obj^, `file^) }
|
||||
|
||||
|
||||
XPT Ml " Marshall Load
|
||||
File.open(`filename^, "rb") { |`file^| Marshal.load(`file^) }
|
||||
|
||||
|
||||
XPT Pn " PStore.new\(..)
|
||||
PStore.new(`filename^)
|
||||
|
||||
|
||||
XPT Yd " YAML dump
|
||||
File.open("`filename^.yaml", "wb") { |`file^| YAML.dump(`obj^,`file^) }
|
||||
|
||||
|
||||
XPT Yl " YAML load
|
||||
File.open("`filename^.yaml") { |`file^| YAML.load(`file^) }
|
||||
|
||||
|
||||
XPT _d " __DATA__
|
||||
__DATA__
|
||||
|
||||
|
||||
XPT _e " __END__
|
||||
__END__
|
||||
|
||||
|
||||
XPT _f " __FILE__
|
||||
__FILE__
|
||||
|
||||
|
||||
XPT ali " alias : .. : ..
|
||||
XSET new.post=RubySnakeCase()
|
||||
XSET old=old_{R("new")}
|
||||
XSET old.post=RubySnakeCase()
|
||||
alias :`new^ :`old^
|
||||
|
||||
|
||||
XPT all " all? { .. }
|
||||
all? { |`element^| `cursor^ }
|
||||
|
||||
|
||||
XPT amm " alias_method : .. : ..
|
||||
XSET new.post=RubySnakeCase()
|
||||
XSET old=old_{R("new")}
|
||||
XSET old.post=RubySnakeCase()
|
||||
alias_method :`new^, :`old^
|
||||
|
||||
|
||||
XPT any " any? { |..| .. }
|
||||
any? { |`element^| `cursor^ }
|
||||
|
||||
|
||||
XPT app " if __FILE__ == $PROGRAM_NAME ...
|
||||
if __FILE__ == $PROGRAM_NAME
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT array " Array.new\(..) { ... }
|
||||
Array.new(`size^) { |`i^| `cursor^ }
|
||||
|
||||
XPT ass " assert**\(..) ...
|
||||
XSET what=RubyAssertPopup()
|
||||
XSET what|post=RubyAssertMethod()
|
||||
XSET message|post=RemoveIfUnchanged()
|
||||
assert`_`what^
|
||||
|
||||
|
||||
XPT attr " attr_** :...
|
||||
XSET what=Choose(["accessor", "reader", "writer"])
|
||||
XSET what|post=SV("^_$",'','')
|
||||
XSET attr*|post=ExpandIfNotEmpty(', :', 'attr*')
|
||||
attr`_`what^ :`attr*^
|
||||
|
||||
XPT begin " begin .. rescue .. else .. end
|
||||
XSET block=# block
|
||||
XSET Exception|post=RubyCamelCase()
|
||||
begin
|
||||
`expr^
|
||||
``rescue...`
|
||||
{{^rescue `Exception^` => `e^
|
||||
`block^
|
||||
``rescue...`
|
||||
^`}}^``else...`
|
||||
{{^else
|
||||
`block^
|
||||
`}}^``ensure...`
|
||||
{{^ensure
|
||||
`cursor^
|
||||
`}}^end
|
||||
|
||||
XPT bm " Benchmark.bmbm do ... end
|
||||
XSET times=10_000
|
||||
TESTS = `times^
|
||||
|
||||
Benchmark.bmbm do |result|
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT case " case .. when .. end
|
||||
XSET block=# block
|
||||
case `target^`
|
||||
when `comparison^
|
||||
`block^
|
||||
``when...`
|
||||
{{^when `comparison^
|
||||
`block^
|
||||
``when...`
|
||||
^`}}^``else...`
|
||||
{{^else
|
||||
`cursor^
|
||||
`}}^end
|
||||
|
||||
|
||||
XPT cfy " classify { |..| .. }
|
||||
classify { |`element^| `cursor^ }
|
||||
|
||||
|
||||
XPT cl " class .. end
|
||||
XSET ClassName.post=RubyCamelCase()
|
||||
class `ClassName^
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT cld " class .. < DelegateClass .. end
|
||||
XSET ClassName.post=RubyCamelCase()
|
||||
XSET ParentClass.post=RubyCamelCase()
|
||||
XSET arg*|post=RepeatInsideEdges(', ')
|
||||
class `ClassName^ < DelegateClass(`ParentClass^)
|
||||
def initialize`(`arg*`)^
|
||||
super(`delegate object^)
|
||||
|
||||
`cursor^
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
XPT cli " class .. def initialize\(..) ...
|
||||
XSET ClassName|post=RubyCamelCase()
|
||||
XSET name|post=RubySnakeCase()
|
||||
XSET init=Trigger('defi')
|
||||
XSET def=Trigger('def')
|
||||
class `ClassName^
|
||||
`init^`
|
||||
`def...^
|
||||
|
||||
`def^`
|
||||
`def...^
|
||||
end
|
||||
|
||||
|
||||
XPT cls " class << .. end
|
||||
XSET self=self
|
||||
class << `self^
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT clstr " .. = Struct.new ...
|
||||
XSETm do...|post
|
||||
do
|
||||
`cursor^
|
||||
end
|
||||
XSETm END
|
||||
XSET ClassName|post=RubyCamelCase()
|
||||
XSET attr*|post=RepeatInsideEdges(', :')
|
||||
`ClassName^ = Struct.new`(:`attr*`)^` `do...^
|
||||
|
||||
|
||||
XPT col " collect { .. }
|
||||
collect { |`obj^| `cursor^ }
|
||||
|
||||
|
||||
XPT deec " Deep copy
|
||||
Marshal.load(Marshal.dump(`obj^))
|
||||
|
||||
|
||||
XPT def " def .. end
|
||||
XSET method|post=RubySnakeCase()
|
||||
XSET arg*|post=RepeatInsideEdges(', ')
|
||||
def `method^`(`arg*`)^
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT defd " def_delegator : ...
|
||||
def_delegator :`del obj^, :`del meth^, :`new name^
|
||||
|
||||
|
||||
XPT defds " def_delegators : ...
|
||||
def_delegators :`del obj^, :`del methods^
|
||||
|
||||
|
||||
XPT defi " def initialize .. end
|
||||
XSET arg*|post=RepeatInsideEdges(', ')
|
||||
def initialize`(`arg*`)^
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT defmm " def method_missing\(..) .. end
|
||||
def method_missing(meth, *args, &block)
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT defs " def self... end
|
||||
XSET method.post=RubySnakeCase()
|
||||
XSET arg*|post=RepeatInsideEdges(', ')
|
||||
def self.`method^`(`arg*`)^
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT deft " def test_.. .. end
|
||||
XSET name|post=RubySnakeCase()
|
||||
XSET arg*|post=RepeatInsideEdges(', ')
|
||||
def test_`name^
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT deli " delete_if { |..| .. }
|
||||
delete_if { |`arg^| `cursor^ }
|
||||
|
||||
|
||||
XPT det " detect { .. }
|
||||
detect { |`obj^| `cursor^ }
|
||||
|
||||
|
||||
XPT dir " Dir[..]
|
||||
XSET _='/**/*'
|
||||
Dir[`_^]
|
||||
|
||||
|
||||
XPT dirg " Dir.glob\(..) { |..| .. }
|
||||
Dir.glob(`dir^) { |`file^| `cursor^ }
|
||||
|
||||
|
||||
XPT do " do |..| .. end
|
||||
XSET arg*|post=RepeatInsideEdges(', ')
|
||||
do` |`arg*`|^
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT dow " downto\(..) { .. }
|
||||
XSET arg=i
|
||||
XSET lbound=0
|
||||
downto(`lbound^) { |`arg^| `cursor^ }
|
||||
|
||||
|
||||
XPT each " each_** { .. }
|
||||
XSET what=RubyEachPopup()
|
||||
XSET what|post=RubyEachBrace()
|
||||
XSET vars=RubyEachPair()
|
||||
each`_`what^ { |`vars^| `cursor^ }
|
||||
|
||||
|
||||
XPT fdir " File.dirname\(..)
|
||||
File.dirname(`^)
|
||||
|
||||
|
||||
XPT fet " fetch\(..) { |..| .. }
|
||||
fetch(`name^) { |`key^| `cursor^ }
|
||||
|
||||
|
||||
XPT file " File.foreach\(..) ...
|
||||
File.foreach('`filename^') { |`line^| `cursor^ }
|
||||
|
||||
|
||||
XPT fin " find { |..| .. }
|
||||
find { |`element^| `cursor^ }
|
||||
|
||||
|
||||
XPT fina " find_all { |..| .. }
|
||||
find_all { |`element^| `cursor^ }
|
||||
|
||||
|
||||
XPT fjoin " File.join\(..)
|
||||
File.join(`dir^, `path^)
|
||||
|
||||
|
||||
XPT fla " flatten_once
|
||||
inject(Array.new) { |`arr^, `a^| `arr^.push(*`a^) }
|
||||
|
||||
|
||||
XPT fread " File.read\(..)
|
||||
File.read(`filename^)
|
||||
|
||||
|
||||
XPT grep " grep\(..) { |..| .. }
|
||||
grep(/`pattern^/) { |`match^| `cursor^ }
|
||||
|
||||
|
||||
XPT gsub " gsub\(..) { |..| .. }
|
||||
gsub(/`pattern^/) { |`match^| `cursor^ }
|
||||
|
||||
|
||||
XPT hash " Hash.new { ... }
|
||||
Hash.new { |`hash^,`key^| `hash^[`key^] = `cursor^ }
|
||||
|
||||
XPT if " if .. end
|
||||
if `boolean exp^
|
||||
`cursor^
|
||||
end
|
||||
|
||||
XPT ife " if .. else .. end
|
||||
XSET block=# block
|
||||
if `boolean exp^
|
||||
`block^
|
||||
else
|
||||
`cursor^
|
||||
end
|
||||
|
||||
XPT ifei " if .. elsif .. else .. end
|
||||
XSET block=# block
|
||||
if `boolean exp^`
|
||||
`block^
|
||||
``elsif...`
|
||||
{{^elsif `comparison^
|
||||
`block^
|
||||
``elsif...`
|
||||
^`}}^``else...`
|
||||
{{^else
|
||||
`cursor^
|
||||
`}}^end
|
||||
|
||||
|
||||
XPT inj " inject\(..) { |..| .. }
|
||||
inject`(`arg`)^ { |`accumulator^, `element^| `cursor^ }
|
||||
|
||||
|
||||
XPT lam " lambda { .. }
|
||||
XSET arg*|post=RepeatInsideEdges(', ')
|
||||
lambda {` |`arg*`|^ `cursor^ }
|
||||
|
||||
|
||||
XPT loop " loop do ... end
|
||||
loop do
|
||||
`cursor^
|
||||
end
|
||||
|
||||
XPT map " map { |..| .. }
|
||||
map { |`arg^| `cursor^ }
|
||||
|
||||
|
||||
XPT max " max { |..| .. }
|
||||
max { |`element1^, `element2^| `cursor^ }
|
||||
|
||||
|
||||
XPT min " min { |..| .. }
|
||||
min { |`element1^, `element2^| `cursor^ }
|
||||
|
||||
|
||||
XPT mod " module .. .. end
|
||||
XSET module name|post=RubyCamelCase()
|
||||
module `module name^
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT modf " module .. module_function .. end
|
||||
XSET module name|post=RubyCamelCase()
|
||||
module `module name^
|
||||
module_function
|
||||
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT nam " Rake Namespace
|
||||
XSET ns=fileRoot()
|
||||
namespace :`ns^ do
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT new " Instanciate new object
|
||||
XSET Object|post=RubyCamelCase()
|
||||
XSET arg*|post=RepeatInsideEdges(', ')
|
||||
`var^ = `Object^.new`(`arg*`)^
|
||||
|
||||
|
||||
XPT open " open\(..) { |..| .. }
|
||||
XSET mode...|post=, '`wb^'
|
||||
open(`filename^`, `mode...^) { |`io^| `cursor^ }
|
||||
|
||||
|
||||
XPT par " partition { |..| .. }
|
||||
partition { |`element^| `cursor^ }
|
||||
|
||||
|
||||
XPT pathf " Path from here
|
||||
XSET path=../lib
|
||||
File.join(File.dirname(__FILE__), "`path^")
|
||||
|
||||
|
||||
XPT rdoc syn=comment " RDoc description
|
||||
=begin rdoc
|
||||
# `cursor^
|
||||
#=end
|
||||
|
||||
|
||||
XPT rej " reject { |..| .. }
|
||||
reject { |`element^| `cursor^ }
|
||||
|
||||
|
||||
XPT rep " Benchmark report
|
||||
result.report("`name^: ") { TESTS.times { `cursor^ } }
|
||||
|
||||
|
||||
XPT req " require ..
|
||||
require '`lib^'
|
||||
|
||||
|
||||
XPT reqs " %w[..].map { |lib| require lib }
|
||||
XSET lib*|post=ExpandIfNotEmpty(' ', 'lib*')
|
||||
%w[`lib*^].map { |lib| require lib }
|
||||
|
||||
..XPT
|
||||
|
||||
|
||||
XPT reve " reverse_each { .. }
|
||||
reverse_each { |`element^| `cursor^ }
|
||||
|
||||
|
||||
XPT ruby " #!/usr/bin/env ruby
|
||||
XSET enc=Echo(&fenc ? &fenc : &enc)
|
||||
#!/usr/bin/env ruby
|
||||
# -*- encoding: `enc^ -*-
|
||||
|
||||
XPT shebang alias=ruby
|
||||
|
||||
XPT sb alias=ruby
|
||||
|
||||
|
||||
|
||||
XPT scan " scan\(..) { |..| .. }
|
||||
scan(/`pattern^/) { |`match^| `cursor^ }
|
||||
|
||||
|
||||
XPT sel " select { |..| .. }
|
||||
select { |`element^| `cursor^ }
|
||||
|
||||
|
||||
XPT sinc " class << self; self; end
|
||||
class << self; self; end
|
||||
|
||||
|
||||
XPT sor " sort { |..| .. }
|
||||
sort { |`element1^, `element2^| `element1^ <=> `element2^ }
|
||||
|
||||
|
||||
XPT sorb " sort_by { |..| .. }
|
||||
sort_by {` |`arg`|^ `cursor^ }
|
||||
|
||||
|
||||
XPT ste " step\(..) { .. }
|
||||
step(`count^`, `step^) { |`i^| `cursor^ }
|
||||
|
||||
|
||||
XPT sub " sub\(..) { |..| .. }
|
||||
sub(/`pattern^/) { |`match^| `cursor^ }
|
||||
|
||||
|
||||
XPT subcl " class .. < .. end
|
||||
XSET ClassName.post=RubyCamelCase()
|
||||
XSET Parent.post=RubyCamelCase()
|
||||
class `ClassName^ < `Parent^
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT tas " Rake Task
|
||||
XSET task name|post=RubySnakeCase()
|
||||
XSET dep*|post=RepeatInsideEdges(', :')
|
||||
desc "`task description^"
|
||||
task :`task name^` => [:`dep*`]^ do
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT tc " require 'test/unit' ... class Test.. < Test::Unit:TestCase ...
|
||||
XSET ClassName=RubyCamelCase(R("module"))
|
||||
XSET ClassName.post=RubyCamelCase()
|
||||
XSET deft=Trigger('deft')
|
||||
require "test/unit"
|
||||
require "`module^"
|
||||
|
||||
class Test`ClassName^ < Test::Unit::TestCase
|
||||
`deft^`
|
||||
|
||||
`deft...`{{^
|
||||
|
||||
`deft^`
|
||||
|
||||
`deft...`^`}}^
|
||||
end
|
||||
|
||||
|
||||
XPT tif " .. ? .. : ..
|
||||
(`boolean exp^) ? `exp if true^ : `exp if false^
|
||||
|
||||
|
||||
XPT tim " times { .. }
|
||||
times {` |`i`|^ `cursor^ }
|
||||
|
||||
|
||||
XPT tra " transaction\(..) { ... }
|
||||
transaction(`true^) { `cursor^ }
|
||||
|
||||
|
||||
XPT unif " Unix Filter
|
||||
ARGF.each_line do |`line^|
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT unless " unless .. end
|
||||
unless `boolean cond^
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT until " until .. end
|
||||
until `boolean cond^
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT upt " upto\(..) { .. }
|
||||
upto(`ubound^) { |`i^| `cursor^ }
|
||||
|
||||
|
||||
XPT usai " if ARGV.. abort\("Usage...
|
||||
XSET args=[options]
|
||||
if ARGV`^
|
||||
abort "Usage: #{$PROGRAM_NAME} `args^"
|
||||
end
|
||||
|
||||
|
||||
XPT usau " unless ARGV.. abort\("Usage...
|
||||
XSET args=[options]
|
||||
unless ARGV`^
|
||||
abort "Usage: #{$PROGRAM_NAME} `args^"
|
||||
end
|
||||
|
||||
|
||||
XPT while " while .. end
|
||||
while `boolean cond^
|
||||
`cursor^
|
||||
end
|
||||
|
||||
|
||||
XPT wid " with_index { .. }
|
||||
with_index { |`element^, `index^| `cursor^ }
|
||||
|
||||
|
||||
XPT xml " REXML::Document.new\(..)
|
||||
REXML::Document.new(File.read(`filename^))
|
||||
|
||||
|
||||
XPT y syn=comment " :yields:
|
||||
:yields:
|
||||
|
||||
|
||||
XPT zip " zip\(..) { |..| .. }
|
||||
zip(`enum^) { |`row^| `cursor^ }
|
||||
|
||||
|
||||
|
||||
|
||||
" ================================= Wrapper ===================================
|
||||
|
||||
|
||||
|
||||
XPT invoke_ wraponly=wrapped " ..(SEL)
|
||||
XSET name|post=RubySnakeCase()
|
||||
`name^(`wrapped^)
|
||||
|
||||
|
||||
XPT def_ wraponly=wrapped " def ..() SEL end
|
||||
XSET method_name|post=RubySnakeCase()
|
||||
XSET arg*|post=RepeatInsideEdges(', ')
|
||||
def `method_name^`(`arg*`)^
|
||||
`wrapped^
|
||||
end
|
||||
|
||||
|
||||
XPT class_ wraponly=wrapped " class .. SEL end
|
||||
XSET _|post=RubyCamelCase()
|
||||
class `_^
|
||||
`wrapped^
|
||||
end
|
||||
|
||||
|
||||
XPT module_ wraponly=wrapped " module .. SEL end
|
||||
XSET _|post=RubyCamelCase()
|
||||
module `_^
|
||||
`wrapped^
|
||||
end
|
||||
|
||||
|
||||
XPT begin_ wraponly=wrapped " begin SEL rescue .. else .. end
|
||||
XSET Exception|post=RubyCamelCase()
|
||||
XSET block=# block
|
||||
begin
|
||||
`wrapped^
|
||||
``rescue...`
|
||||
{{^rescue `Exception^` => `e^
|
||||
`block^
|
||||
``rescue...`
|
||||
^`}}^``else...`
|
||||
{{^else
|
||||
`block^
|
||||
`}}^``ensure...`
|
||||
{{^ensure
|
||||
`cursor^
|
||||
`}}^end
|
||||
|
||||
71
plugins/bundle/xptemplate/ftplugin/scheme/scheme.xpt.vim
Executable file
71
plugins/bundle/xptemplate/ftplugin/scheme/scheme.xpt.vim
Executable file
|
|
@ -0,0 +1,71 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $BRif \n
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _condition/lisp.like
|
||||
|
||||
|
||||
XPT begin " (begin .. )
|
||||
(begin
|
||||
(`todo0^)` `...^
|
||||
(`todon^)` `...^)
|
||||
|
||||
|
||||
XPT case " (case (of) ((match) (expr)) ..)
|
||||
(case (`of^)
|
||||
({`match^} `expr1^)` `...^
|
||||
({`matchn^} `exprn^)` `...^
|
||||
`else...^\(else \`cursor\^)^^)
|
||||
|
||||
|
||||
XPT cond " (cond ([condi] (expr)) ..)
|
||||
(cond ([`condition^] `expr1^)` `...^
|
||||
` ([`condition^] `exprn^)` `...^
|
||||
`else...^\(else \`cursor\^)^^)
|
||||
|
||||
|
||||
XPT let " (let [(var (val)) ..] (body))
|
||||
(let [(`newVar^ `value^` `...^)
|
||||
` (`newVarn^ `valuen^` `...^)]
|
||||
(`cursor^))
|
||||
|
||||
|
||||
XPT letrec " (letrec [(var (val)) ..] (body))
|
||||
(letrec [(`newVar^ `value^` `...^)
|
||||
` (`newVarn^ `valuen^` `...^)]
|
||||
(`cursor^))
|
||||
|
||||
|
||||
XPT lambda " (lambda [params] (body))
|
||||
(lambda [`params^]
|
||||
(`cursor^))
|
||||
|
||||
|
||||
XPT defun " (define var (lambda ..))
|
||||
(define `funName^
|
||||
(lambda [`params^]
|
||||
(`cursor^))
|
||||
)
|
||||
|
||||
|
||||
XPT def " (define var (ex))
|
||||
(define `varName^ `cursor^)
|
||||
|
||||
|
||||
XPT do " (do ..)
|
||||
(do {(`var^ `init^ `step^)` `...0^
|
||||
` (`var^ `init^ `step^)` `...0^}
|
||||
([`test^] `exprs^)
|
||||
(`command^)` `...2^
|
||||
(`command^)` `...2^)
|
||||
|
||||
|
||||
179
plugins/bundle/xptemplate/ftplugin/sh/sh.xpt.vim
Normal file
179
plugins/bundle/xptemplate/ftplugin/sh/sh.xpt.vim
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
XPTemplate priority=lang mark=~^
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
|
||||
XPTvar $VOID_LINE # void
|
||||
XPTvar $CURSOR_PH # cursor
|
||||
|
||||
|
||||
XPTvar $BRif ' '
|
||||
XPTvar $BRel \n
|
||||
XPTvar $BRloop ' '
|
||||
XPTvar $BRstc ' '
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
XPTvar $SPop ''
|
||||
XPTvar $SParg ''
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _printf/c.like
|
||||
|
||||
XPTvar $CS #
|
||||
XPTinclude
|
||||
\ _comment/singleSign
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
let s:braceMap = {
|
||||
\ '`' : '`',
|
||||
\ '{' : '}',
|
||||
\ '[' : ']',
|
||||
\ '(' : ')',
|
||||
\ '{{' : '}}',
|
||||
\ '[[' : ']]',
|
||||
\ '((' : '))',
|
||||
\ '{ ' : ' }',
|
||||
\ '[ ' : ' ]',
|
||||
\ '( ' : ' )',
|
||||
\ '{{ ' : ' }}',
|
||||
\ '[[ ' : ' ]]',
|
||||
\ '(( ' : ' ))',
|
||||
\}
|
||||
|
||||
fun! s:f.sh_complete_brace()
|
||||
|
||||
let v = self.V()
|
||||
let br = matchstr( v, '\V\^\[\[({`]\{1,2} \?' )
|
||||
if br == ''
|
||||
return ''
|
||||
elseif br == '`'
|
||||
return s:braceMap[ br ]
|
||||
else
|
||||
try
|
||||
let cmpl = s:braceMap[ br ]
|
||||
let cmplEsc = substitute( cmpl, ']', '\\[]]', 'g' )
|
||||
let tail = matchstr( v, '\V\%[' . cmplEsc . ']\$' )
|
||||
if tail == ' ' && br =~ ' '
|
||||
let tail = ''
|
||||
endif
|
||||
return cmpl[ len( tail ) : ]
|
||||
catch /.*/
|
||||
echom v:exception
|
||||
endtry
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
|
||||
|
||||
XPT shebang " #!/bin/[ba|z|c]sh
|
||||
XSET sh=ChooseStr( 'sh', 'bash', 'zsh', 'csh' )
|
||||
#!/bin/~sh^
|
||||
|
||||
..XPT
|
||||
|
||||
XPT sb alias=shebang
|
||||
|
||||
XPT _shebang hidden " #!/bin/$_xSnipName
|
||||
#!/bin/~$_xSnipName^
|
||||
|
||||
..XPT
|
||||
|
||||
|
||||
XPT sh alias=_shebang
|
||||
XPT bash alias=_shebang
|
||||
XPT zsh alias=_shebang
|
||||
XPT csh alias=_shebang
|
||||
|
||||
|
||||
XPT echodate " echo `date +%...`
|
||||
echo `date~ +~fmt^`
|
||||
|
||||
XPT _cond hidden
|
||||
XSET condition|map=[ [
|
||||
XSET condition|map=( (
|
||||
~condition^~condition^sh_complete_brace()^
|
||||
|
||||
|
||||
XPT printf " printf\(...)
|
||||
XSET elts|pre=Echo('')
|
||||
XSET elts=c_printf_elts( R( 'pattern' ), ' '[ len( $SPop ) : ] )
|
||||
printf "~pattern^"~elts^
|
||||
|
||||
|
||||
|
||||
XPT forin wrap " for .. in ..; do
|
||||
for ~i^ in ~list^;~$BRloop^do
|
||||
~cursor^
|
||||
done
|
||||
|
||||
XPT for wrap " for (( i=0; i<len; i++ )); do
|
||||
for ((~i^ = ~0^; ~i^ < ~len^; ~i^++));~$BRloop^do
|
||||
~cursor^
|
||||
done
|
||||
|
||||
XPT forr wrap " for (( i=n; i>=start; i++ )); do
|
||||
for ((~i^ = ~n^; ~i^ >~=^ ~start^0^; ~i^--));~$BRloop^do
|
||||
~cursor^
|
||||
done
|
||||
|
||||
XPT here wrap " << END ..
|
||||
<<~-~END^
|
||||
~cursor^
|
||||
~END^substitute( V(), '\v\^-', '', '' )^
|
||||
|
||||
XPT until wrap " until ..; do
|
||||
until ~:_cond:^;~$BRloop^;do
|
||||
~cursor^
|
||||
done
|
||||
|
||||
XPT while wrap " while ..; do
|
||||
while ~:_cond:^;~$BRloop^do
|
||||
~cursor^
|
||||
done
|
||||
|
||||
XPT while1 alias=while " while [ 1 ]; do
|
||||
XSET condition=Next( '[ ~$TRUE^ ]' )
|
||||
|
||||
XPT case wrap " case .. in ..
|
||||
case ~$~var^ in
|
||||
~pattern^)
|
||||
~cursor^
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
XPT if wrap " if ..; then
|
||||
if ~:_cond:^;~$BRif^then
|
||||
~cursor^
|
||||
fi
|
||||
|
||||
XPT else wrap " else ..
|
||||
else
|
||||
~cursor^
|
||||
|
||||
XPT ife wrap=job " if ..; then .. else ..
|
||||
if ~:_cond:^;~$BRif^then
|
||||
~job^
|
||||
else
|
||||
~cursor^
|
||||
fi
|
||||
|
||||
XPT elif wrap " elif .. ; then
|
||||
elif ~:_cond:^;~$BRif^then
|
||||
~cursor^
|
||||
|
||||
XPT fun wrap " .. () { .. }
|
||||
~name^ ()~$BRfun^{
|
||||
~cursor^
|
||||
}
|
||||
80
plugins/bundle/xptemplate/ftplugin/sql/sql.xpt.vim
Normal file
80
plugins/bundle/xptemplate/ftplugin/sql/sql.xpt.vim
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
|
||||
" if () ** {
|
||||
" else ** {
|
||||
XPTvar $BRif ' '
|
||||
|
||||
" } ** else {
|
||||
XPTvar $BRel \n
|
||||
|
||||
" for () ** {
|
||||
" while () ** {
|
||||
" do ** {
|
||||
XPTvar $BRloop ' '
|
||||
|
||||
" struct name ** {
|
||||
XPTvar $BRstc ' '
|
||||
|
||||
" int fun() ** {
|
||||
" class name ** {
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
|
||||
|
||||
|
||||
" ============================================================================
|
||||
" cursor - CURSOR logic
|
||||
" ============================================================================
|
||||
XPT cursor hint=CURSOR\ logic
|
||||
DECLARE @iFetchCount INT
|
||||
DECLARE `<CursorName>^ CURSOR STATIC
|
||||
FOR SELECT `<Expression1>^`
|
||||
`Expression2...^
|
||||
` ,`<Expression2>^`
|
||||
`Expression2...^
|
||||
FROM `<Table>^ WITH (NOLOCK)
|
||||
WHERE (`<Expression3>^)`
|
||||
`Expression4...^
|
||||
` AND (`<Expression4>^)`
|
||||
`Expression4...^
|
||||
ORDER BY `<Expression5>^`
|
||||
`Expression6...^
|
||||
` ,`<Expression6>^`
|
||||
`Expression6...^
|
||||
SET @iFetchCount = 0
|
||||
OPEN `<CursorName>^
|
||||
FETCH NEXT
|
||||
FROM `<CursorName>^
|
||||
INTO `<Variable1>^`
|
||||
`Variable2...^
|
||||
` ,`<Variable2>^`
|
||||
`Variable2...^
|
||||
WHILE (@@FETCH_STATUS = 0)
|
||||
BEGIN
|
||||
SET @iFetchCount = @iFetchCount + 1
|
||||
IF ((@iFetchCount % 1000) = 0)
|
||||
BEGIN
|
||||
SET @sMsg = '@iFetchCount = ' + ltrim(dbo.udfFormatNumber(@iFetchCount,18,0))
|
||||
EXEC dbadb.dbo.uspLogMessage @sJob, @sMsg
|
||||
END
|
||||
FETCH NEXT
|
||||
FROM `<CursorName>^
|
||||
INTO `<Variable3>^`
|
||||
`Variable4...^
|
||||
` ,`<Variable4>^`
|
||||
`Variable4...^
|
||||
END
|
||||
CLOSE `<CursorName>^
|
||||
DEALLOCATE `<CursorName>^
|
||||
..XPT
|
||||
|
||||
65
plugins/bundle/xptemplate/ftplugin/svg/svg.xpt.vim
Normal file
65
plugins/bundle/xptemplate/ftplugin/svg/svg.xpt.vim
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ xml/xml
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
XPT svg " Start an svg document
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="`width^100%^" height="`height^100%^" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
||||
`cursor^
|
||||
</svg>
|
||||
..XPT
|
||||
|
||||
XPT line " Create an svg line
|
||||
<line x1="`xStart^" y1="`yStart^" x2="`xEnd^" y2="`yEnd^" `style...^ />
|
||||
XSET style...|post= style="`cursor^"
|
||||
..XPT
|
||||
|
||||
XPT circle " Create an svg circle
|
||||
<circle cx="`xCenter^" cy="`yCenter^" r="`radius^" `style...^ />
|
||||
XSET style...|post= style="`cursor^"
|
||||
..XPT
|
||||
|
||||
XPT ellipse " Create an svg ellipse
|
||||
<ellipse cx="`xCenter^" cy="`yCenter^" rx="`horizontalRadius^" ry="`verticalRadius^" `style...^ />
|
||||
XSET style...|post= style="`cursor^"
|
||||
..XPT
|
||||
|
||||
XPT rect " Create an svg rectangle
|
||||
<rect x="`xStart^" y="`yStart^" width="`width^" height="`height^" `style...^ />
|
||||
XSET style...|post= style="`cursor^"
|
||||
..XPT
|
||||
|
||||
XPT polygon " Create an svg polygon
|
||||
<polygon points="`x^,`y^`...^ `x^,`y^`...^" `style...^ />
|
||||
XSET style...|post= style="`cursor^"
|
||||
..XPT
|
||||
|
||||
XPT polyline " Create an svg polyline
|
||||
<polyline points="`x^,`y^`...^ `x^,`y^`...^" `style...^ />
|
||||
XSET style...|post= style="`cursor^"
|
||||
..XPT
|
||||
|
||||
XPT line " Create an svg line
|
||||
<text x="`xStart^" y="`yStart^" x2="`xEnd^" y2="`yEnd^" `style...^>
|
||||
`cursor^
|
||||
</text>
|
||||
XSET style...|post= style="`style^"
|
||||
..XPT
|
||||
|
||||
" ================================= Wrapper ===================================
|
||||
|
||||
93
plugins/bundle/xptemplate/ftplugin/tcl/tcl.xpt.vim
Normal file
93
plugins/bundle/xptemplate/ftplugin/tcl/tcl.xpt.vim
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
XPTemplate priority=lang mark=~^
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $CURSOR_PH
|
||||
|
||||
XPTvar $BRif \n
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
|
||||
XPT shebang " #!/bin/sh .. exec tclsh..
|
||||
#!/bin/sh
|
||||
#\
|
||||
exec tclsh "$0" "$@""
|
||||
|
||||
..XPT
|
||||
|
||||
XPT sb alias=shebang
|
||||
|
||||
|
||||
XPT for " for {...}
|
||||
for {set ~i^ ~x^} {$~i^ <= ~len^} {incr ~i^} {
|
||||
~cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT foreach " foreach i var {...
|
||||
foreach ~i^ ~var^ {
|
||||
~cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT while " while {i <= ?} {...
|
||||
while {~i^ <= ~len^} {
|
||||
~cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT if " if { ... } { ...
|
||||
if {~a^} {
|
||||
~cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT elseif " elseif {...
|
||||
elseif {~a^} {
|
||||
~cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT else " else {...
|
||||
else {
|
||||
~cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT switch " switch ... {...
|
||||
switch ~var^ {
|
||||
~1^ { ~body1^ }
|
||||
~2^ { ~body2^ }
|
||||
~3^ { ~body3^ }
|
||||
default { ~body4^ }
|
||||
}
|
||||
|
||||
|
||||
XPT proc " proc *** {...
|
||||
proc ~name^ {~args^} {
|
||||
~cursor^
|
||||
}
|
||||
|
||||
|
||||
XPT regexp " regexp ... match
|
||||
regexp ~r^ ~str^ match ~vars^
|
||||
|
||||
|
||||
XPT regsub " regsub ...
|
||||
regsub ~in^ ~str^ ~out^
|
||||
|
||||
|
||||
137
plugins/bundle/xptemplate/ftplugin/tex/tex.xpt.vim
Normal file
137
plugins/bundle/xptemplate/ftplugin/tex/tex.xpt.vim
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
XPTemplate priority=lang mark=`~
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
XPT _arg1 hidden " \\$_xSnipName\{..}
|
||||
\\`$_xSnipName~{`cursor~}
|
||||
|
||||
XPT _arg2 hidden " \\$_xSnipName\{..}\{..}
|
||||
\\`$_xSnipName~{`a~}{`b~}
|
||||
|
||||
XPT _sub hidden " \\{$_xSnipName}_..
|
||||
\\`$_xSnipName~_`sub~
|
||||
|
||||
XPT _sub_super hidden " \\{$_xSnipName}_..^..
|
||||
\\`$_xSnipName~_`sub~^`super~
|
||||
|
||||
XPT _begin wrap hidden " \begin{..} .. end{..}
|
||||
\begin{`sth~}`{`what?`}~
|
||||
`cursor~
|
||||
\end{`sth~}
|
||||
|
||||
XPT _block wrap hidden " \begin\{$_xSnipName} .. \end\{$_xSnipName}
|
||||
\begin{`$_xSnipName~}
|
||||
`cursor~
|
||||
\end{`$_xSnipName~}
|
||||
|
||||
XPT _block_t wrap hidden " \begin\{$_xSnipName} .. \end\{$_xSnipName}
|
||||
\begin{`$_xSnipName~}{`title~}
|
||||
`cursor~
|
||||
\end{`$_xSnipName~}
|
||||
|
||||
XPT section alias=_arg1
|
||||
XPT label alias=_arg1
|
||||
XPT ref alias=_arg1
|
||||
|
||||
XPT frac alias=_arg2
|
||||
|
||||
XPT abstract alias=_block
|
||||
XPT document alias=_block
|
||||
XPT equation alias=_block
|
||||
XPT slide alias=_block
|
||||
|
||||
XPT frame alias=_block_t
|
||||
XPT block alias=_block_t
|
||||
|
||||
XPT lim alias=_sub
|
||||
|
||||
XPT int alias=_sub_super
|
||||
|
||||
XPT info " title author date
|
||||
\title{`title~}
|
||||
\author{`$author~}
|
||||
\date{`date()~}
|
||||
|
||||
XPT array " begin{array}{..}... end{array}
|
||||
\begin{array}{`kind~rcl~}
|
||||
`what~` `...0~ & `what~` `...0~ \\\\` `...1~
|
||||
`what~` `...2~ & `what~` `...2~ \\\\` `...1~
|
||||
\end{array}
|
||||
|
||||
XPT table " begin{tabular}{..}... end{tabular}
|
||||
XSET hline..|post=\hline
|
||||
XSET what*|post=ExpandIfNotEmpty( ' & ', 'what*' )
|
||||
\begin{tabular}{`kind~|r|c|l|~}
|
||||
`hline..~
|
||||
`what*~ \\\\` `...1~
|
||||
`hline..~
|
||||
`what*~ \\\\` `...1~
|
||||
\end{tabular}
|
||||
|
||||
|
||||
" backward compatible
|
||||
XPT lbl " label{..}
|
||||
\label{`cursor~}
|
||||
|
||||
" backward compatible
|
||||
XPT integral " int_..^..
|
||||
\int_`begin~^`end~{`cursor~}
|
||||
|
||||
XPT itemize " begin{itemize} ... end{itemize}
|
||||
\begin{itemize}
|
||||
\item `what~~`...~
|
||||
\item `what~~`...~
|
||||
\end{itemize}
|
||||
|
||||
XPT enumerate " begin{enumerate} ... end{enumerate}
|
||||
\begin{enumerate}
|
||||
\item `what~~`...~
|
||||
\item `what~~`...~
|
||||
\end{enumerate}
|
||||
|
||||
XPT description " begin{description} ... end{description}
|
||||
\begin{description}
|
||||
\item[`what~] `content~~`...~
|
||||
\item[`what~] `content~~`...~
|
||||
\end{description}
|
||||
|
||||
XPT sqrt " sqrt[..]{..}
|
||||
\sqrt`[`nth?`]~{`cursor~}
|
||||
|
||||
XPT sum " sum{..}~..{}
|
||||
\sum_{`init~}^`end~{`cursor~}
|
||||
|
||||
XPT documentclass " documentclass[..]{..}
|
||||
XSET kind=Choose(['article','book','report', 'letter','slides'])
|
||||
\documentclass[`11~pt]{`kind~}
|
||||
|
||||
XPT toc " \tableofcontents
|
||||
\tableofcontents
|
||||
|
||||
" backward compatible
|
||||
XPT beg alias=_begin
|
||||
|
||||
XPT columns " \begin{columns}...
|
||||
\begin{columns}
|
||||
\begin{column}[l]{`size~5cm~}
|
||||
\end{column}`...~
|
||||
|
||||
\begin{column}[l]{`size~5cm~}
|
||||
\end{column}`...~
|
||||
`cursor~
|
||||
\end{columns}
|
||||
|
||||
XPT enclose_ wraponly=wrapped " \begin{..} SEL \end{..}
|
||||
\begin{`something~}
|
||||
`wrapped~
|
||||
\end{`something~}
|
||||
|
||||
XPT as_ wraponly=wrapped " SEL{..}
|
||||
\\`wrapped~{`cursor~}
|
||||
|
||||
XPT with_ wraponly=wrapped " \\.. {SEL}
|
||||
\\`cursor~{`wrapped~}
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
30
plugins/bundle/xptemplate/ftplugin/vim/autoload.vim.xpt.vim
Normal file
30
plugins/bundle/xptemplate/ftplugin/vim/autoload.vim.xpt.vim
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
if expand( "%:p:h" ) . '/' !~# '\V\[\\/]autoload\[\\/]'
|
||||
finish
|
||||
endif
|
||||
|
||||
XPTemplate priority=lang-
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
fun! s:f.vim_autoload_pre()
|
||||
let path = expand( "%:p" )
|
||||
let path = substitute( path, '\V\\', '/', 'g' )
|
||||
let path = matchstr( path, '\V/autoload/\zs\.\+\ze.vim\$' )
|
||||
let path = substitute( path, '\V/', '#', 'g' )
|
||||
return path
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ vim/vim
|
||||
|
||||
" TODO fix it
|
||||
" XSET name|repl=vim_autoload_pre()#`name
|
||||
XPT fun alias=_fun " fun! vim_autoload_pre()#**
|
||||
XSET name=Build( '`' . vim_autoload_pre() . '#`n^' )
|
||||
|
||||
|
||||
XPT ## " vim_autoload_pre\()#
|
||||
`vim_autoload_pre()^#
|
||||
182
plugins/bundle/xptemplate/ftplugin/vim/vim.xpt.vim
Normal file
182
plugins/bundle/xptemplate/ftplugin/vim/vim.xpt.vim
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
|
||||
" int fun ** (
|
||||
" class name ** (
|
||||
XPTvar $SPfun ''
|
||||
|
||||
" int fun( ** arg ** )
|
||||
" if ( ** condition ** )
|
||||
" for ( ** statement ** )
|
||||
" [ ** a, b ** ]
|
||||
" { ** 'k' : 'v' ** }
|
||||
XPTvar $SParg ' '
|
||||
|
||||
" if ** (
|
||||
" while ** (
|
||||
" for ** (
|
||||
XPTvar $SPcmd ' '
|
||||
|
||||
" a ** = ** a ** + ** 1
|
||||
" (a, ** b, ** )
|
||||
XPTvar $SPop ' '
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _printf/c.like
|
||||
|
||||
XPTvar $CS "
|
||||
XPTinclude
|
||||
\ _comment/singleSign
|
||||
|
||||
fun! s:f.vim_call()
|
||||
" Note: do not use [ * - 2 ] which may be -1
|
||||
return getline( '.' )[ : self.ItemPos()[0][1] - 1 ] =~ '\v^\s*\w$' ? 'call ' : ''
|
||||
endfunction
|
||||
|
||||
call XPTdefineSnippet('vimformat', {}, [ '" vim:tw=78:ts=8:sw=4:sts=4:et:norl:fdm=marker:fmr={{{,}}}' ])
|
||||
|
||||
|
||||
|
||||
XPT lncol " [ line\( "." ), col\( "." ) ]
|
||||
[ line( '.' ), col( '.' ) ]
|
||||
|
||||
XPT printf " printf\(..)
|
||||
XSET elts|pre=Echo('')
|
||||
XSET elts=c_printf_elts( R( 'pattern' ), "," )
|
||||
printf(`$SParg^"`pattern^"`elts^`$SParg^)
|
||||
|
||||
XPT _args hidden " expandable arguments
|
||||
XSET arg*|post=ExpandInsideEdge( ',$SPop', '' )
|
||||
`$SParg`arg*`$SParg^
|
||||
|
||||
XPT self " self.
|
||||
self.
|
||||
|
||||
XPT once " if exists.. finish
|
||||
XSET i|pre=headerSymbol()
|
||||
if exists(`$SParg^"`g^:`i^"`$SParg^)
|
||||
finish
|
||||
endif
|
||||
let `g^:`i^`$SPop^=`$SPop^1
|
||||
`cursor^
|
||||
|
||||
XPT version " if exists && larger than
|
||||
XSET i|pre=headerSymbol()
|
||||
XSET ver=1
|
||||
if exists(`$SParg^"`g^:`i^"`$SParg^) && `g^:`i^`$SPop^>=`$SPop^`ver^
|
||||
finish
|
||||
endif
|
||||
let ``g^:``i^`$SPop^=`$SPop^``ver^
|
||||
`cursor^
|
||||
|
||||
XPT varconf " if !exists ".." let .. = .. endif
|
||||
if !exists(`$SParg^"`g^:`varname^"`$SParg^)
|
||||
let `g^:`varname^`$SPop^=`$SPop^`val^
|
||||
endif
|
||||
|
||||
XPT _fun hidden wrap " fun! ..(..) .. endfunction
|
||||
fun! `name^`$SPfun^(`:_args:^) "{{{
|
||||
`cursor^
|
||||
endfunction "}}}
|
||||
|
||||
XPT fun alias=_fun
|
||||
|
||||
XPT member wrap " tips
|
||||
fun! `name^`$SPfun^(`:_args:^) dict "{{{
|
||||
`cursor^
|
||||
endfunction "}}}
|
||||
|
||||
XPT while wrap " while .. .. endwhile
|
||||
while `cond^
|
||||
`cursor^
|
||||
endwhile
|
||||
|
||||
XPT while1 alias=while
|
||||
XSET cond=Embed( $TRUE )
|
||||
|
||||
XPT whilei wrap " while i | let i += 1
|
||||
let [`$SParg^`i^,`$SPop^`len^`$SParg^] = [`$SParg^`0^`$SPop^-`$SPop^1,`$SPop^`len_expr^`$SPop^-`$SPop^1`$SParg^]
|
||||
while `i^`$SPop^<`$SPop^`len^ | let `i^`$SPop^+=`$SPop^1
|
||||
`cursor^
|
||||
endwhile
|
||||
|
||||
XPT forin wrap " for .. in ..
|
||||
for `value^ in `list^
|
||||
`cursor^
|
||||
endfor
|
||||
|
||||
XPT try wrap=job " try .. catch ..
|
||||
try
|
||||
`job^
|
||||
`:catch:^
|
||||
endtry
|
||||
|
||||
XPT catch " catch / .. /
|
||||
XSET exception=.*
|
||||
catch /`exception^/
|
||||
`cursor^
|
||||
|
||||
XPT finally " finally ..
|
||||
finally
|
||||
`cursor^
|
||||
|
||||
XPT if wrap " if .. else ..
|
||||
if `cond^
|
||||
`cursor^
|
||||
endif
|
||||
|
||||
XPT else " else ..
|
||||
else
|
||||
`cursor^
|
||||
|
||||
XPT filehead " description of file
|
||||
" File Description {{{
|
||||
" =============================================================================
|
||||
" `cursor^
|
||||
" by `$author^
|
||||
" `$email^
|
||||
" Usage :
|
||||
"
|
||||
" =============================================================================
|
||||
" }}}
|
||||
..XPT
|
||||
|
||||
XPT savecpo " save &cpo
|
||||
let s:oldcpo = &cpo
|
||||
set cpo-=< cpo+=B
|
||||
`cursor^
|
||||
let &cpo = s:oldcpo
|
||||
|
||||
" The first placeholder wrapping 'com' keyword that causes ctags halt
|
||||
XPT sid " generate s:sid variable
|
||||
exe 'map <Plug>xsid <SID>|let s:sid=matchstr(maparg("<Plug>xsid"), "\\d\\+_")|unmap <Plug>xsid'
|
||||
|
||||
..XPT
|
||||
|
||||
XPT bench " while 1000.. doit..
|
||||
let n = `100000^
|
||||
let i = 0
|
||||
let `t^_0 = reltime()
|
||||
|
||||
while i < n
|
||||
let i += 1
|
||||
`cursor^
|
||||
endwhile
|
||||
|
||||
let `t^ = reltime( `t^_0 )
|
||||
let us = `t^[0] * 1000*1000 + `t^[1]
|
||||
echo 'spent:' reltimestr( `t^ )
|
||||
echo 'per-call(us):' us/n
|
||||
|
||||
XPT call wraponly=param " ..\( .. )
|
||||
`vim_call()`name^(`$SParg^`param^`$SParg^)
|
||||
|
||||
XPT _call hidden wrap=param? " $_xSnipName( .. )
|
||||
`$_xSnipName^(`$SParg`param?`$SParg^)
|
||||
|
||||
XPT string alias=_call
|
||||
6
plugins/bundle/xptemplate/ftplugin/xhtml/xhtml.xpt.vim
Normal file
6
plugins/bundle/xptemplate/ftplugin/xhtml/xhtml.xpt.vim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
XPTemplate priority=lang-
|
||||
|
||||
XPTinclude
|
||||
\ html/html
|
||||
|
||||
|
||||
155
plugins/bundle/xptemplate/ftplugin/xml/xml.xpt.vim
Normal file
155
plugins/bundle/xptemplate/ftplugin/xml/xml.xpt.vim
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
XPTemplate priority=spec
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $CURSOR_PH <!-- cursor -->
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
XPTvar $CL <!--
|
||||
XPTvar $CM
|
||||
XPTvar $CR -->
|
||||
XPTinclude
|
||||
\ _comment/doubleSign
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
fun! s:f.xml_att_val()
|
||||
if self.Phase()=='post'
|
||||
return ''
|
||||
endif
|
||||
|
||||
let name = self.ItemName()
|
||||
return self.Vmatch('\V' . name, '\V\^\s\*\$')
|
||||
\ ? ''
|
||||
\ : '="val" ' . name
|
||||
endfunction
|
||||
|
||||
fun! s:f.xml_tag_ontype()
|
||||
let v = self.V()
|
||||
if v =~ '\V\s\$'
|
||||
let v = substitute( v, '\V\s\*\$', '', 'g' )
|
||||
return self.Next( v )
|
||||
endif
|
||||
return v
|
||||
endfunction
|
||||
|
||||
fun! s:f.xml_attr_ontype()
|
||||
let v = self.V()
|
||||
if v =~ '\V=\$'
|
||||
return self.Next()
|
||||
elseif len( v ) > 2 && v =~ '\V""\$'
|
||||
return self.Next( v[ 0 : -2 ] )
|
||||
else
|
||||
return v
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
fun! s:f.xml_create_attr_ph()
|
||||
" let prev = self.PrevItem( -1 )
|
||||
if !self.HasStep( 'x' )
|
||||
return self.Embed('` `x^' . '`att*^')
|
||||
endif
|
||||
|
||||
let prev = self.Reference( 'x' )
|
||||
|
||||
if prev =~ '=$'
|
||||
return self.Embed('`"`x`"^' . '`att*^')
|
||||
elseif prev =~ '"$'
|
||||
return self.Embed('` `x^' . '`att*^')
|
||||
else
|
||||
return self.Next( '' )
|
||||
endif
|
||||
endfunction
|
||||
|
||||
fun! s:f.xml_close_tag()
|
||||
let v = self.V()
|
||||
if v[ 0 : 0 ] != '<' || v[ -1:-1 ] != '>'
|
||||
return ''
|
||||
endif
|
||||
|
||||
let v = v[ 1: -2 ]
|
||||
|
||||
if v =~ '\v/\s*$|^!'
|
||||
return ''
|
||||
else
|
||||
return '</' . matchstr( v, '\v^\S+' ) . '>'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
fun! s:f.xml_cont_helper()
|
||||
let v = self.V()
|
||||
if v =~ '\V\n'
|
||||
return self.ResetIndent( -s:nIndent, "\n" )
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let s:nIndent = 0
|
||||
fun! s:f.xml_cont_ontype()
|
||||
let v = self.V()
|
||||
if v =~ '\V\n'
|
||||
let v = matchstr( v, '\V\.\*\ze\n' )
|
||||
let s:nIndent = &indentexpr != ''
|
||||
\ ? eval( substitute( &indentexpr, '\Vv:lnum', 'line(".")', '' ) ) - indent( line( "." ) - 1 )
|
||||
\ : self.NIndent()
|
||||
|
||||
return self.Finish( v . "\n" . repeat( ' ', s:nIndent ) )
|
||||
else
|
||||
return v
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
" inoremap <silent> < <space><BS><C-r>=XPTtgr('__tag',{'syn':'','k':'<'})<cr>
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
XPT _tag hidden " <$_xSnipName>..</$_xSnipName>
|
||||
XSET content|def=Echo( R( 't' ) =~ '\v/\s*$' ? Finish() : '' )
|
||||
XSET content|ontype=xml_cont_ontype()
|
||||
<`t^$_xSnipName^>`content^`content^xml_cont_helper()^`t^xml_close_tag()^
|
||||
..XPT
|
||||
|
||||
XPT __tag hidden " <Tag>..</Tag>
|
||||
XSET content|def=Echo( R( 't' ) =~ '\v/\s*$' ? Finish() : '' )
|
||||
XSET content|ontype=xml_cont_ontype()
|
||||
`<`t`>^^`content^^`content^xml_cont_helper()^`t^xml_close_tag()^
|
||||
..XPT
|
||||
|
||||
" NOTE: use Embed in default value phase to prevent post filter ruin place
|
||||
" holder
|
||||
" XPT < " <Tag>..</Tag>
|
||||
" XSET tag|ontype=xml_tag_ontype()
|
||||
" XSET att*|pre=Echo('')
|
||||
" XSET att*|def=Embed( '` `^' )
|
||||
" <`tag^`att*^>`content^</`tag^>
|
||||
" ..XPT
|
||||
|
||||
|
||||
" " auto attributes completion
|
||||
" XPT < " <Tag>..</Tag>
|
||||
" XSET tag|ontype=xml_tag_ontype()
|
||||
" XSET att*|pre=Echo('')
|
||||
" XSET att*|def=xml_create_attr_ph()
|
||||
" XSET x|def=Echo( '' )
|
||||
" XSET x|ontype=xml_attr_ontype()
|
||||
" XSET x|post=SV( '\v^\s*$', '' )
|
||||
" <`tag^`att*^>`content^</`tag^>
|
||||
" ..XPT
|
||||
|
||||
|
||||
XPT ver " <?xml version=...
|
||||
<?xml version="`ver^1.0^" encoding="`enc^utf-8^" ?>
|
||||
|
||||
|
||||
XPT style " <?xml-stylesheet...
|
||||
<?xml-stylesheet type="`style^text/css^" href="`from^">
|
||||
|
||||
|
||||
XPT cdata wrap " <![CDATA[...
|
||||
<![CDATA[`cursor^]]>
|
||||
223
plugins/bundle/xptemplate/ftplugin/xpt/xpt.xpt.vim
Normal file
223
plugins/bundle/xptemplate/ftplugin/xpt/xpt.xpt.vim
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
XPTemplate priority=sub
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ vim/vim
|
||||
|
||||
|
||||
fun! s:f.xpt_vim_hint_escape()
|
||||
let v = substitute( self.V(), '\(\\*\)\([(]\)', '\1\1\\\2', 'g' )
|
||||
return v
|
||||
endfunction
|
||||
|
||||
|
||||
" TODO lazy load
|
||||
let s:xpt_snip = split( globpath( &rtp, "ftplugin/**/*.xpt.vim" ), "\n" )
|
||||
call map( s:xpt_snip, 'substitute(v:val, ''\V\'', ''/'', ''g'')' )
|
||||
call map( s:xpt_snip, 'matchstr(v:val, ''\Vftplugin/\zs\.\*\ze.xpt.vim'')' )
|
||||
|
||||
fun! s:f.xpt_ftp_pum()
|
||||
return self.Choose( s:xpt_snip )
|
||||
endfunction
|
||||
|
||||
let s:xpts = {}
|
||||
for v in s:xpt_snip
|
||||
if v == ''
|
||||
continue
|
||||
endif
|
||||
|
||||
let [ ft, snip ] = split( v, '/' )
|
||||
if !has_key( s:xpts, ft )
|
||||
let s:xpts[ ft ] = []
|
||||
endif
|
||||
|
||||
let s:xpts[ ft ] += [ snip ]
|
||||
endfor
|
||||
|
||||
|
||||
fun! s:f.xpt_vim_path()
|
||||
return keys( s:xpts )
|
||||
endfunction
|
||||
|
||||
fun! s:f.xpt_vim_name(path)
|
||||
let path = matchstr( a:path, '\w\+' )
|
||||
if has_key( s:xpts, path )
|
||||
return s:xpts[ path ]
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
|
||||
XPT ftpfile " xpt ftplugin snippet file
|
||||
XSET path=xpt_vim_path()
|
||||
XSET name=xpt_vim_name( R( 'path' ) )
|
||||
`path^/`name^
|
||||
|
||||
XPT incfile " XPTinclude ...
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ `:ftpfile:^
|
||||
|
||||
|
||||
XPT container " let s:f = ..
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
|
||||
XPT tmpl " XPT name ...
|
||||
XSET tips|post=xpt_vim_hint_escape()
|
||||
\XPT `name^` " `tips^
|
||||
`cursor^
|
||||
|
||||
|
||||
XPT snip alias=tmpl
|
||||
|
||||
|
||||
XPT var " XPTvar $*** ***
|
||||
XPTvar $`name^ `cursor^
|
||||
|
||||
|
||||
XPT varLang " variables to define language properties
|
||||
" variable prefix
|
||||
XPTvar $VAR_PRE
|
||||
|
||||
|
||||
XPT varFormat " variables to define format
|
||||
" if () ** {
|
||||
" else ** {
|
||||
XPTvar $BRif ' '
|
||||
|
||||
" } ** else {
|
||||
XPTvar $BRel \n
|
||||
|
||||
" for () ** {
|
||||
" while () ** {
|
||||
" do ** {
|
||||
XPTvar $BRloop ' '
|
||||
|
||||
" struct name ** {
|
||||
XPTvar $BRstc ' '
|
||||
|
||||
" int fun() ** {
|
||||
" class name ** {
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
|
||||
XPT varSpaces " variable to define spacing
|
||||
" int fun ** (
|
||||
" class name ** (
|
||||
XPTvar $SPfun ''
|
||||
|
||||
" int fun( ** arg ** )
|
||||
" if ( ** condition ** )
|
||||
" for ( ** statement ** )
|
||||
" [ ** a, b ** ]
|
||||
" { ** 'k' : 'v' ** }
|
||||
XPTvar $SParg ' '
|
||||
|
||||
" if ** (
|
||||
" while ** (
|
||||
" for ** (
|
||||
XPTvar $SPcmd ' '
|
||||
|
||||
" a ** = ** a ** + ** 1
|
||||
" (a, ** b, ** )
|
||||
XPTvar $SPop ' '
|
||||
|
||||
|
||||
XPT varConst " variables to define constants
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
|
||||
|
||||
XPT varHelper " variables to define helper place holders
|
||||
XPTvar $VOID_LINE
|
||||
XPTvar $CURSOR_PH
|
||||
|
||||
|
||||
XPT varComment1 " variables to define single sign comments
|
||||
XPTvar $CS `cursor^
|
||||
|
||||
|
||||
XPT varComment2 " variables to define double sign comments
|
||||
XPTvar $CL `left sign^
|
||||
XPTvar $CM `cursor^
|
||||
XPTvar $CR `right sign^
|
||||
|
||||
XPT spfun " `\$SPfun^
|
||||
\`$SPfun\^
|
||||
|
||||
XPT sparg " `\$SParg^
|
||||
\`$SParg\^
|
||||
|
||||
XPT spcmd " `\$SPcmd^
|
||||
\`$SPcmd\^
|
||||
|
||||
XPT spop " `\$SPop^
|
||||
\`$SPop\^
|
||||
|
||||
|
||||
XPT buildifeq " {{}}
|
||||
\``name^{{\^`cursor^\`}}\^
|
||||
|
||||
XPT inc " `::^
|
||||
\`:`name^:\^
|
||||
|
||||
XPT include " `Include:^
|
||||
\`Include:`name^\^
|
||||
|
||||
|
||||
XPT fun wrap " fun! s:f.**
|
||||
fun! `s:f.`name^(`$SParg`param?`$SParg^)
|
||||
`cursor^
|
||||
endfunction
|
||||
|
||||
|
||||
XPT skeleton " very simple snippet file skeleton
|
||||
" Save this file as ~/.vim/ftplugin/c/hello.xpt.vim(or
|
||||
" ~/vimfiles/ftplugin/c/hello.xpt.vim).
|
||||
" Then you can use it in C language file:
|
||||
" vim xpt.c
|
||||
" And type:
|
||||
" helloxpt<C-\>
|
||||
"
|
||||
XPTemplate priority=personal+
|
||||
|
||||
\XPT helloxpt " tips about what this snippet do
|
||||
Say hello to \`xpt^.
|
||||
\`xpt^ says hello.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
XPT xpt " start template to write template
|
||||
XPTemplate priority=`prio^
|
||||
XSET prio=ChooseStr( 'all', 'spec', 'like', 'lang', 'sub', 'personal' )
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
" use snippet 'varConst' to generate contant variables
|
||||
" use snippet 'varFormat' to generate formatting variables
|
||||
" use snippet 'varSpaces' to generate spacing variables
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
|
||||
\XPT helloxpt " tips about what this snippet does
|
||||
Say hello to \`xpt\^.
|
||||
\`xpt\^ says hello.
|
||||
|
||||
`cursor^
|
||||
|
||||
..XPT
|
||||
|
||||
|
||||
64
plugins/bundle/xptemplate/ftplugin/xptest/xptest.xpt.vim
Normal file
64
plugins/bundle/xptemplate/ftplugin/xptest/xptest.xpt.vim
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
|
||||
fun! s:f.fff()
|
||||
let v = self.V()
|
||||
if v == 'aa'
|
||||
return ''
|
||||
else
|
||||
return ', another'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
XPT aa syn=43w
|
||||
fjdkls
|
||||
\XPT
|
||||
fdskl
|
||||
..XPT
|
||||
|
||||
XPT table alias=_tag
|
||||
XPT tr alias=_tag
|
||||
|
||||
XPT e " tips
|
||||
#{ `^ }
|
||||
|
||||
XPT bb " tips
|
||||
XSET cursor=123
|
||||
what `a^ `cursor^
|
||||
\XPT
|
||||
..XPT
|
||||
|
||||
" XPT jkldsjfksl
|
||||
|
||||
XPT q " tips
|
||||
XSET $a=3
|
||||
`p`{$a}`p^-`p^
|
||||
|
||||
XPT x " tips
|
||||
XSET $a=3
|
||||
`p`p`p^-`$a^
|
||||
|
||||
XPT t " tips
|
||||
`:x:^fjkdls
|
||||
fjksl
|
||||
|
||||
|
||||
fd
|
||||
..XPT
|
||||
" XPT aa " paste at end test
|
||||
" `f^`aa...{{^pp`}}^`l^Echo( Context().history[-1].item.name )^
|
||||
|
||||
XPT pp " tips
|
||||
`...^
|
||||
- Let's repeat `this^
|
||||
`...^
|
||||
110
plugins/bundle/xptemplate/ftplugin/xslt/xslt.xpt.vim
Normal file
110
plugins/bundle/xptemplate/ftplugin/xslt/xslt.xpt.vim
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
XPTemplate priority=lang- keyword=<
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $CURSOR_PH cursor
|
||||
|
||||
XPTvar $BRif ' '
|
||||
XPTvar $BRel \n
|
||||
XPTvar $BRloop ' '
|
||||
XPTvar $BRstc ' '
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ html/html
|
||||
\ xml/xml
|
||||
|
||||
XPTvar $CL <!--
|
||||
XPTvar $CM
|
||||
XPTvar $CR -->
|
||||
XPTinclude
|
||||
\ _comment/doubleSign
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
|
||||
|
||||
XPT sort " <xsl:sort ...
|
||||
<xsl:sort select="`what^" />
|
||||
|
||||
|
||||
XPT valueof " <xsl:value-of ...
|
||||
<xsl:value-of select="`what^" />
|
||||
|
||||
|
||||
XPT apply " <xsl:apply-templates ...
|
||||
<xsl:apply-templates select="`what^" />
|
||||
|
||||
|
||||
XPT param " <xsl:param ...
|
||||
<xsl:param name="`name^" `select...{{^select="`expr^"`}}^ />
|
||||
|
||||
|
||||
XPT import " <xsl:import ...
|
||||
<xsl:import href="`URI^" />
|
||||
|
||||
|
||||
XPT include " <xsl:include ...
|
||||
<xsl:include href="`URI^" />
|
||||
|
||||
|
||||
XPT stylesheet " <xsl:stylesheet ...
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
|
||||
|
||||
<xsl:output method="xml" indent="yes"/>
|
||||
|
||||
<xsl:template match="/`cursor^">
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
|
||||
|
||||
XPT template " <xsl:template match= ...
|
||||
<xsl:template match="`match^">
|
||||
`cursor^
|
||||
</xsl:template>
|
||||
|
||||
|
||||
XPT foreach " <xsl:for-each select= ...
|
||||
<xsl:for-each select="`match^">
|
||||
`cursor^
|
||||
</xsl:for-each>
|
||||
|
||||
|
||||
XPT if " <xsl:if test= ...
|
||||
<xsl:if test="`test^">
|
||||
`cursor^
|
||||
</xsl:if>
|
||||
|
||||
|
||||
XPT choose " <xsl:choose ...
|
||||
XSET job=$CL void $CR
|
||||
<xsl:choose>
|
||||
<xsl:when test="`expr^">
|
||||
`job^
|
||||
</xsl:when>`...^
|
||||
<xsl:when test="`ex^">
|
||||
`job^
|
||||
</xsl:when>`...^
|
||||
`otherwise...{{^<xsl:otherwise>
|
||||
`cursor^
|
||||
</xsl:otherwise>`}}^
|
||||
</xsl:choose>
|
||||
|
||||
|
||||
XPT when " <xsl:when test= ...
|
||||
<xsl:when test="`ex^">
|
||||
`what^
|
||||
</xsl:when>
|
||||
|
||||
|
||||
55
plugins/bundle/xptemplate/ftplugin/yacc/yacc.xpt.vim
Normal file
55
plugins/bundle/xptemplate/ftplugin/yacc/yacc.xpt.vim
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
XPTemplate priority=lang-
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
XPTvar $UNDEFINED NULL
|
||||
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $CURSOR_PH /* cursor */
|
||||
|
||||
XPTvar $BRif ' '
|
||||
XPTvar $BRel \n
|
||||
XPTvar $BRloop ' '
|
||||
XPTvar $BRstc ' '
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ c/c
|
||||
|
||||
|
||||
" ========================= Function and Variables =============================
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
||||
|
||||
XPT yacc " Basic yacc file
|
||||
%{
|
||||
/* includes */
|
||||
%}
|
||||
/* options */
|
||||
%%
|
||||
/* grammar rules */
|
||||
%%
|
||||
/* C code */
|
||||
|
||||
XPT rule " ..: .. | .. | ...
|
||||
`ruleName^: `pattern^ { `action^ }
|
||||
` `...`
|
||||
{{^ | `pattern^ { `action^ }
|
||||
` `...`
|
||||
^`}}^ ;
|
||||
|
||||
XPT tok " %token ...
|
||||
%token
|
||||
|
||||
XPT prio " %left ... %right ...
|
||||
XSET op*|post=ExpandIfNotEmpty( "' '", 'op*', "" )
|
||||
%left '`op*^'` `...^
|
||||
%left '`op*^'` `...^
|
||||
|
||||
|
||||
8
plugins/bundle/xptemplate/ftplugin/zsh/zsh.xpt.vim
Normal file
8
plugins/bundle/xptemplate/ftplugin/zsh/zsh.xpt.vim
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
" got basic sh snippets for zsh files
|
||||
" (like ~/.zshrc)
|
||||
XPTemplate priority=lang
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ sh/sh
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue