Add svg plugin, closes #388
This commit is contained in:
parent
83bd298476
commit
eacf785f5a
@ -10,7 +10,7 @@ A collection of language packs for Vim.
|
|||||||
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
|
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
|
||||||
|
|
||||||
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
|
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
|
||||||
- It **installs and updates 120+ times faster** than the <!--Package Count-->133<!--/Package Count--> packages it consists of.
|
- It **installs and updates 120+ times faster** than the <!--Package Count-->135<!--/Package Count--> packages it consists of.
|
||||||
- Solid syntax and indentation support (other features skipped). Only the best language packs.
|
- Solid syntax and indentation support (other features skipped). Only the best language packs.
|
||||||
- All unnecessary files are ignored (like enormous documentation from php support).
|
- All unnecessary files are ignored (like enormous documentation from php support).
|
||||||
- No support for esoteric languages, only most popular ones (modern too, like `slim`).
|
- No support for esoteric languages, only most popular ones (modern too, like `slim`).
|
||||||
@ -156,6 +156,8 @@ If you need full functionality of any plugin, please use it directly with your p
|
|||||||
- [smt2](https://github.com/bohlender/vim-smt2) (syntax, autoload, ftplugin)
|
- [smt2](https://github.com/bohlender/vim-smt2) (syntax, autoload, ftplugin)
|
||||||
- [solidity](https://github.com/tomlion/vim-solidity) (syntax, indent, ftplugin)
|
- [solidity](https://github.com/tomlion/vim-solidity) (syntax, indent, ftplugin)
|
||||||
- [stylus](https://github.com/wavded/vim-stylus) (syntax, indent, ftplugin)
|
- [stylus](https://github.com/wavded/vim-stylus) (syntax, indent, ftplugin)
|
||||||
|
- [svg-indent](https://github.com/jasonshell/vim-svg-indent) (indent)
|
||||||
|
- [svg](https://github.com/vim-scripts/svg.vim) (syntax)
|
||||||
- [swift](https://github.com/keith/swift.vim) (syntax, indent, ftplugin)
|
- [swift](https://github.com/keith/swift.vim) (syntax, indent, ftplugin)
|
||||||
- [sxhkd](https://github.com/baskerville/vim-sxhkdrc) (syntax)
|
- [sxhkd](https://github.com/baskerville/vim-sxhkdrc) (syntax)
|
||||||
- [systemd](https://github.com/wgwoods/vim-systemd-syntax) (syntax)
|
- [systemd](https://github.com/wgwoods/vim-systemd-syntax) (syntax)
|
||||||
|
2
build
2
build
@ -264,6 +264,8 @@ PACKS="
|
|||||||
smt2:bohlender/vim-smt2
|
smt2:bohlender/vim-smt2
|
||||||
solidity:tomlion/vim-solidity
|
solidity:tomlion/vim-solidity
|
||||||
stylus:wavded/vim-stylus
|
stylus:wavded/vim-stylus
|
||||||
|
svg-indent:jasonshell/vim-svg-indent
|
||||||
|
svg:vim-scripts/svg.vim
|
||||||
swift:keith/swift.vim
|
swift:keith/swift.vim
|
||||||
sxhkd:baskerville/vim-sxhkdrc
|
sxhkd:baskerville/vim-sxhkdrc
|
||||||
systemd:wgwoods/vim-systemd-syntax
|
systemd:wgwoods/vim-systemd-syntax
|
||||||
|
109
indent/svg.vim
Normal file
109
indent/svg.vim
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'svg-indent') != -1
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Vim indent file
|
||||||
|
"
|
||||||
|
" Language: svg
|
||||||
|
" Maintainer: Jason Shell <jason.shell.mail@gmail.com>
|
||||||
|
" Last Change: 2015 Sep 23
|
||||||
|
" Notes: 1) will be confused by unbalanced tags in comments
|
||||||
|
|
||||||
|
" Only load this indent file when no other was loaded.
|
||||||
|
if exists('b:did_indent')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:did_indent = 1
|
||||||
|
let s:keepcpo= &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
" [-- local settings (must come before aborting the script) --]
|
||||||
|
setlocal indentexpr=SvgIndentGet(v:lnum,1)
|
||||||
|
setlocal indentkeys=o,O,*<Return>,<>>,<<>,/,{,}
|
||||||
|
|
||||||
|
if !exists('b:svg_indent_open')
|
||||||
|
let b:svg_indent_open = '.\{-}<\a'
|
||||||
|
" pre tag, e.g. <address>
|
||||||
|
" let b:svg_indent_open = '.\{-}<[/]\@!\(address\)\@!'
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !exists('b:svg_indent_close')
|
||||||
|
let b:svg_indent_close = '.\{-}</'
|
||||||
|
" end pre tag, e.g. </address>
|
||||||
|
" let b:svg_indent_close = '.\{-}</\(address\)\@!'
|
||||||
|
endif
|
||||||
|
|
||||||
|
let &cpo = s:keepcpo
|
||||||
|
unlet s:keepcpo
|
||||||
|
|
||||||
|
" [-- finish, if the function already exists --]
|
||||||
|
if exists('*SvgIndentGet')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:keepcpo= &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
fun! <SID>SvgIndentWithPattern(line, pat)
|
||||||
|
let s = substitute('x'.a:line, a:pat, "\1", 'g')
|
||||||
|
return strlen(substitute(s, "[^\1].*$", '', ''))
|
||||||
|
endfun
|
||||||
|
|
||||||
|
" [-- check if it's svg --]
|
||||||
|
fun! <SID>SvgIndentSynCheck(lnum)
|
||||||
|
if '' != &syntax
|
||||||
|
let syn1 = synIDattr(synID(a:lnum, 1, 1), 'name')
|
||||||
|
let syn2 = synIDattr(synID(a:lnum, strlen(getline(a:lnum)) - 1, 1), 'name')
|
||||||
|
if '' != syn1 && syn1 !~ 'svg' && '' != syn2 && syn2 !~ 'svg'
|
||||||
|
" don't indent pure non-xml code
|
||||||
|
return 0
|
||||||
|
|
||||||
|
" elseif syn1 =~ '^xmlComment' && syn2 =~ '^xmlComment'
|
||||||
|
elseif syn1 =~ '^svgComment' && syn2 =~ '^svgComment'
|
||||||
|
" indent comments specially
|
||||||
|
return -1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
return 1
|
||||||
|
endfun
|
||||||
|
|
||||||
|
" [-- return the sum of indents of a:lnum --]
|
||||||
|
fun! <SID>SvgIndentSum(lnum, style, add)
|
||||||
|
let line = getline(a:lnum)
|
||||||
|
if a:style == match(line, '^\s*</')
|
||||||
|
return (&sw *
|
||||||
|
\ (<SID>SvgIndentWithPattern(line, b:svg_indent_open)
|
||||||
|
\ - <SID>SvgIndentWithPattern(line, b:svg_indent_close)
|
||||||
|
\ - <SID>SvgIndentWithPattern(line, '.\{-}/>'))) + a:add
|
||||||
|
else
|
||||||
|
return a:add
|
||||||
|
endif
|
||||||
|
endfun
|
||||||
|
|
||||||
|
fun! SvgIndentGet(lnum, use_syntax_check)
|
||||||
|
" Find a non-empty line above the current line.
|
||||||
|
let lnum = prevnonblank(a:lnum - 1)
|
||||||
|
|
||||||
|
" Hit the start of the file, use zero indent.
|
||||||
|
if lnum == 0
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
if a:use_syntax_check
|
||||||
|
let check_lnum = <SID>SvgIndentSynCheck(lnum)
|
||||||
|
let check_alnum = <SID>SvgIndentSynCheck(a:lnum)
|
||||||
|
if 0 == check_lnum || 0 == check_alnum
|
||||||
|
return indent(a:lnum)
|
||||||
|
elseif -1 == check_lnum || -1 == check_alnum
|
||||||
|
return -1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
let ind = <SID>SvgIndentSum(lnum, -1, indent(lnum))
|
||||||
|
let ind = <SID>SvgIndentSum(a:lnum, 0, ind)
|
||||||
|
|
||||||
|
return ind
|
||||||
|
endfun
|
||||||
|
|
||||||
|
let &cpo = s:keepcpo
|
||||||
|
unlet s:keepcpo
|
149
syntax/svg.vim
Normal file
149
syntax/svg.vim
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'svg') != -1
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Vim syntax file
|
||||||
|
" Language: SVG
|
||||||
|
" Filenames: *.svg
|
||||||
|
" Maintainer: Michal Gorny <michal-gorny@wp.pl>
|
||||||
|
" Last_change: 2006-03-23
|
||||||
|
|
||||||
|
if !exists("main_syntax")
|
||||||
|
if exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let main_syntax = 'svg'
|
||||||
|
endif
|
||||||
|
|
||||||
|
if main_syntax == 'svg'
|
||||||
|
runtime! syntax/xml.vim
|
||||||
|
syn cluster xmlTagHook add=svgElement
|
||||||
|
syn cluster xmlAttribHook add=svgAttr
|
||||||
|
syn match xmlDecl /\<\(<?\)\@<=xml\(-stylesheet\)\?\>/ containedin=xmlProcessing contained
|
||||||
|
syn keyword xmlDeclAttr version encoding standalone containedin=xmlProcessing contained
|
||||||
|
syn keyword xmlDeclAttr alternate charset media href title type containedin=xmlProcessing contained
|
||||||
|
else
|
||||||
|
syn cluster xhtmlTagHook add=svgElement
|
||||||
|
syn cluster xhtmlAttribHook add=svgAttr
|
||||||
|
endif
|
||||||
|
|
||||||
|
syn case match
|
||||||
|
|
||||||
|
" SVG elements
|
||||||
|
syn match svgElement contained /\<svg\>[^:]/me=e-1
|
||||||
|
syn keyword svgElement contained altGlyph altGlyphDef altGlyphItem animate
|
||||||
|
syn keyword svgElement contained animateColor animateMotion animateTransform
|
||||||
|
syn keyword svgElement contained circle clipPath cursor defs desc ellipse
|
||||||
|
syn keyword svgElement contained feBlend feColorMatrix feComponentTransfer
|
||||||
|
syn keyword svgElement contained feComposite feConvolveMatrix feDiffuseLighting
|
||||||
|
syn keyword svgElement contained feDisplacementMap feDistantLight feFlood
|
||||||
|
syn keyword svgElement contained feFuncA feFuncB feFuncG feFuncR feGaussianBlur
|
||||||
|
syn keyword svgElement contained feImage feMerge feMergeNode feMorphology
|
||||||
|
syn keyword svgElement contained feOffset fePointLight feSpecularLighting
|
||||||
|
syn keyword svgElement contained feSpotLight feTile feTurbulence filter
|
||||||
|
syn keyword svgElement contained foreignObject glyph glyphRef hkern image line
|
||||||
|
syn keyword svgElement contained linearGradient marker mask metadata mpath path
|
||||||
|
syn keyword svgElement contained pattern polygon polyline radialGradient rect
|
||||||
|
syn keyword svgElement contained script set stop style switch symbol text
|
||||||
|
syn keyword svgElement contained textPath title tref tspan use view vkern
|
||||||
|
syn match svgElement contained /\<\(font\|font-face\)\>[^-]/me=e-1
|
||||||
|
syn match svgElement contained /\<font-face-\(format\|name\|src\|uri\)\>/
|
||||||
|
syn match svgElement contained /\<\(color-profile\|definition-src\)\>/
|
||||||
|
syn match svgElement contained /\<missing-glyph\>/
|
||||||
|
syn match svgElement contained /\<\(a\|g\)\>[^:]/me=e-1
|
||||||
|
|
||||||
|
" SVG 1.0 attributes
|
||||||
|
syn keyword svgAttr contained accumulate additive alphabetic amplitude ascent attributeName attributeType azimuth baseFrequency bbox begin bias by
|
||||||
|
syn keyword svgAttr contained calcMode class clipPathUnits contentScriptType contentStyleType cursor cx cy d descent diffuseConstant direction display
|
||||||
|
syn keyword svgAttr contained divisor dur dx dy edgeMode elevation end exponent externalResourcesRequired filter filterRes filterUnits format from fx fy
|
||||||
|
syn keyword svgAttr contained g1 g2 glyphRef gradientTransform gradientUnits hanging height id ideographic in in2 intercept k k1 k2 k3 k4 kernelMatrix
|
||||||
|
syn keyword svgAttr contained kernelUnitLength kerning keyPoints keySplines keyTimes lang lengthAdjust limitingConeAngle local markerHeight markerUnits
|
||||||
|
syn keyword svgAttr contained markerWidth mask maskContentUnits maskUnits mathematical max media method min mode name numOctaves offset opacity operator
|
||||||
|
syn keyword svgAttr contained order orient orientation origin overflow path pathLength patternContentUnits patternTransform patternUnits points pointsAtX
|
||||||
|
syn keyword svgAttr contained pointsAtY pointsAtZ preserveAlpha preserveAspectRatio primitiveUnits r radius refX refY repeatCount repeatDur
|
||||||
|
syn keyword svgAttr contained requiredExtensions requiredFeatures restart result rotate rx ry scale seed slope spacing specularConstant specularExponent
|
||||||
|
syn keyword svgAttr contained spreadMethod startOffset stdDeviation stemh stemv stitchTiles string style surfaceScale systemLanguage tableValues target
|
||||||
|
syn keyword svgAttr contained targetX targetY textLength title to transform type u1 u2 values version viewBox viewTarget visibility width widths x x1 x2
|
||||||
|
syn keyword svgAttr contained xChannelSelector y y1 y2 yChannelSelector z zoomAndPan
|
||||||
|
syn match svgAttr contained /\<xmlns\>[^:]/me=e-1
|
||||||
|
syn match svgAttr contained /\<\(clip\|color\|fill\)\>[^-]/me=e-1
|
||||||
|
syn match svgAttr contained /\<\(stroke\|unicode\)\>[^-]/me=e-1
|
||||||
|
syn match svgAttr contained /\<\(color-interpolation\|font-size\)\>[^-]/me=e-1
|
||||||
|
syn match svgAttr contained /\<\(\accent-height\|alignment-baseline\|arabic-form\|baseline-shift\|cap-height\|clip-\(path\|rule\)\|dominant-baseline\)\>/
|
||||||
|
syn match svgAttr contained /\<\(color-\(interpolation-filters\|profile\|rendering\)\|enable-background\|fill-\(opacity\|rule\)\)\>/
|
||||||
|
syn match svgAttr contained /\<\(flood-\(color\|opacity\)\|font-\(family\|size-adjust\|stretch\|style\|variant\|weight\)\|image-rendering\)\>/
|
||||||
|
syn match svgAttr contained /\<\(glyph-\(name\|orientation-\(horizontal\|vertical\)\)\|horiz-\(adv-x\|origin-\(x\|y\)\)\)\>/
|
||||||
|
syn match svgAttr contained /\<\(letter-spacing\|lighting-color\|marker-\(end\|mid\|start\)\|overline-\(position\|thickness\)\|panose-1\)\>/
|
||||||
|
syn match svgAttr contained /\<\(pointer-events\|rendering-intent\|shape-rendering\|stop-\(color\|opacity\)\|strikethrough-\(position\|thickness\)\)\>/
|
||||||
|
syn match svgAttr contained /\<\(text-\(anchor\|decoration\|rendering\)\|stroke-\(dasharray\|dashoffset\|linecap\|linejoin\|miterlimit\|opacity\|width\)\)\>/
|
||||||
|
syn match svgAttr contained /\<\(underline-\(position\|thickness\)\|unicode-\(bidi\|range\)\|units-per-em\|writing-mode\|x-height\)\>/
|
||||||
|
syn match svgAttr contained /\(vert-\(adv-y\|origin-\(x\|y\)\)\|v-\(alphabetic\|hanging\|ideographic\|mathematical\)\|word-spacing\)\>/
|
||||||
|
syn match svgAttr contained /\<\(xlink:\)\@<=\(actuate\|arcrole\|href\)\>/
|
||||||
|
syn match svgAttr contained /\<\(xlink:\)\@<=\(role\|show\|title\|type\)\>/
|
||||||
|
syn match svgAttr contained /\<\(xml:\)\@<=\(base\|lang\|space\)\>/
|
||||||
|
syn match svgAttr contained /\<\(xmlns:\)\@<=xlink\>/
|
||||||
|
" Events attributes
|
||||||
|
if exists("svg_no_events_rendering")
|
||||||
|
syn match svgEventAttr contained /\<on\(abort\|activate\|begin\|click\|end\|error\|focus\(in\|out\)\|\(un\)\?load\|mouse\(down\|move\|out\|over\|up\)\|repeat\|resize\|scroll\|zoom\)\>/
|
||||||
|
if main_syntax == 'svg'
|
||||||
|
syn cluster xmlAttribHook add=svgEventAttr
|
||||||
|
else
|
||||||
|
syn cluster xhtmlAttribHook add=svgEventAttr
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Attribute new in SVG 1.1
|
||||||
|
syn keyword svgAttr contained baseProfile
|
||||||
|
|
||||||
|
" Embedded ECMAScript (JavaScript)
|
||||||
|
if main_syntax == 'svg'
|
||||||
|
syn include @svgJavaScript syntax/javascript.vim
|
||||||
|
unlet b:current_syntax
|
||||||
|
syn region javaScript start=+<script[^>]*[^/]>+ keepend end=+</script>+me=s-1 contains=@svgJavaScript,svgScriptTag
|
||||||
|
syn region svgScriptTag contained start=+<script+ end=+>+ contains=xmlTagName,xmlString,xmlAttrib
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Events attributes rendering
|
||||||
|
if !exists("svg_no_events_rendering")
|
||||||
|
syn region svgEvent contained start=+\<on\(abort\|activate\|begin\|click\|end\|error\|focus\(in\|out\)\|\(un\)\?load\|mouse\(down\|move\|out\|over\|up\)\|repeat\|resize\|scroll\|zoom\)\s*=\s*'+ keepend end=+'+ contains=svgEventSQ
|
||||||
|
syn region svgEvent contained start=+\<on\(abort\|activate\|begin\|click\|end\|error\|focus\(in\|out\)\|\(un\)\?load\|mouse\(down\|move\|out\|over\|up\)\|repeat\|resize\|scroll\|zoom\)\s*=\s*"+ keepend end=+"+ contains=svgEventDQ
|
||||||
|
if main_syntax == 'svg'
|
||||||
|
syn cluster xmlAttribHook add=svgEvent
|
||||||
|
else
|
||||||
|
syn cluster xhtmlAttribHook add=svgEvent
|
||||||
|
endif
|
||||||
|
syn region svgEventSQ contained start=+'+ms=s+1 end=+'+me=s-1 contains=@svgJavaScript,@xhtmlJavaScript
|
||||||
|
syn region svgEventDQ contained start=+"+ms=s+1 end=+"+me=s-1 contains=@svgJavaScript,@xhtmlJavaScript
|
||||||
|
hi def link svgEventSQ svgEvent
|
||||||
|
hi def link svgEventDQ svgEvent
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Rendering
|
||||||
|
if !exists("svg_no_rendering")
|
||||||
|
syn region svgTitle start="<title\>" end="</title>"me=e-8 contains=xmlTag,xmlEndTag,xmlEntity,xmlComment
|
||||||
|
syn region svgDesc start="<desc\>" end="</desc>"me=e-8 contains=xmlTag,xmlEndTag,xmlEntity,xmlComment
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Highlighting
|
||||||
|
hi link xmlAttrib Function
|
||||||
|
hi def link xmlDecl Statement
|
||||||
|
hi def link xmlDeclAttr Type
|
||||||
|
hi link xmlEntity Special
|
||||||
|
hi link xmlEntityPunct Special
|
||||||
|
hi def link svgElement Statement
|
||||||
|
hi def link svgAttr Type
|
||||||
|
hi def link javaScript Special
|
||||||
|
hi def link svgEvent javaScript
|
||||||
|
hi def link svgEventAttr Type
|
||||||
|
if !exists("svg_no_rendering")
|
||||||
|
hi def link svgTitle Title
|
||||||
|
hi def link svgDesc Title
|
||||||
|
endif
|
||||||
|
|
||||||
|
let b:current_syntax = "svg"
|
||||||
|
|
||||||
|
if main_syntax == 'svg'
|
||||||
|
unlet main_syntax
|
||||||
|
endif
|
||||||
|
|
||||||
|
" vim: ts=8
|
Loading…
Reference in New Issue
Block a user