2011-02-17 08:07:27 -05:00
|
|
|
" Syntax highlighting for snippet files (used for UltiSnips.vim)
|
2011-03-27 02:07:44 -04:00
|
|
|
" Revision: 26/03/11 19:53:33
|
|
|
|
|
|
|
|
if exists("b:current_syntax")
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
2014-06-30 02:04:37 -04:00
|
|
|
" Embedded Syntaxes {{{1
|
|
|
|
|
2011-03-27 02:07:44 -04:00
|
|
|
syntax include @Python syntax/python.vim
|
2014-06-29 22:42:11 -04:00
|
|
|
unlet b:current_syntax
|
2012-02-05 07:15:25 -05:00
|
|
|
syntax include @Viml syntax/vim.vim
|
2014-06-29 22:42:11 -04:00
|
|
|
unlet b:current_syntax
|
2014-06-29 23:47:22 -04:00
|
|
|
syntax include @Shell syntax/sh.vim
|
|
|
|
unlet b:current_syntax
|
2011-02-17 08:07:27 -05:00
|
|
|
|
2014-06-30 02:04:37 -04:00
|
|
|
" Syntax definitions {{{1
|
|
|
|
|
|
|
|
" Comments {{{2
|
|
|
|
|
2014-06-30 02:22:53 -04:00
|
|
|
syn match snipComment "^#.*" contains=snipTODO display
|
|
|
|
syn keyword snipTODO contained display FIXME NOTE NOTES TODO XXX
|
2011-03-27 02:07:44 -04:00
|
|
|
|
2014-06-30 02:04:37 -04:00
|
|
|
" Miscellaneous {{{2
|
|
|
|
|
2013-03-21 06:32:17 -04:00
|
|
|
syn match snipDocString '"[^"]*"$'
|
2011-02-17 08:07:27 -05:00
|
|
|
syn match snipString '"[^"]*"'
|
|
|
|
syn match snipTabsOnly "^\t\+$"
|
2014-02-18 12:57:43 -05:00
|
|
|
syn match snipLeadingSpaces "^\t* \+"
|
2011-02-17 08:07:27 -05:00
|
|
|
|
2014-02-19 15:04:52 -05:00
|
|
|
syn match snipKeyword "\(\<\(end\)\?\(snippet\|global\)\>\)\|extends\|clearsnippets\|priority" contained
|
2011-02-19 14:00:24 -05:00
|
|
|
|
2014-06-30 02:04:37 -04:00
|
|
|
" Extends {{{2
|
|
|
|
|
2014-06-30 02:22:53 -04:00
|
|
|
syn match snipExtends "^extends\%(\s.*\|$\)" contains=snipExtendsKeyword display
|
|
|
|
syn match snipExtendsKeyword "^extends" contained display
|
2011-02-17 08:07:27 -05:00
|
|
|
|
2014-06-30 02:04:37 -04:00
|
|
|
" Definitions {{{2
|
|
|
|
|
|
|
|
" snippet {{{3
|
|
|
|
|
2014-06-30 02:33:36 -04:00
|
|
|
syn region snipSnippet start="^snippet\_s" end="^endsnippet\s*$" contains=snipSnippetHeader fold keepend
|
2014-06-30 03:00:20 -04:00
|
|
|
syn match snipSnippetHeader "^.*$" nextgroup=snipSnippetBody,snipSnippetFooter skipnl contained contains=snipSnippetHeaderKeyword
|
|
|
|
syn match snipSnippetHeaderKeyword "^snippet" contained nextgroup=snipSnippetTrigger skipwhite
|
2014-06-30 02:33:36 -04:00
|
|
|
syn region snipSnippetBody start="\_." end="^\zeendsnippet\s*$" contained contains=snipTabsOnly,snipLeadingSpaces,snipCommand,snipVarExpansion,snipVar,snipVisual nextgroup=snipSnippetFooter
|
|
|
|
syn match snipSnippetFooter "^endsnippet.*" contained contains=snipSnippetFooterKeyword
|
|
|
|
syn match snipSnippetFooterKeyword "^endsnippet" contained
|
2014-06-29 23:47:22 -04:00
|
|
|
|
2014-06-30 02:04:37 -04:00
|
|
|
" Command substitution {{{4
|
|
|
|
|
2014-06-29 23:47:22 -04:00
|
|
|
syn region snipCommand keepend matchgroup=snipCommandDelim start="`" skip="\\[{}\\$`]" end="`" contains=snipPythonCommand,snipVimLCommand,snipShellCommand
|
|
|
|
syn region snipShellCommand start="\ze\_." skip="\\[{}\\$`]" end="\ze`" contained contains=@Shell
|
|
|
|
syn region snipPythonCommand matchgroup=snipPythonCommandP start="`\@<=!p\_s" skip="\\[{}\\$`]" end="\ze`" contained contains=@Python
|
|
|
|
syn region snipVimLCommand matchgroup=snipVimLCommandV start="`\@<=!v\_s" skip="\\[{}\\$`]" end="\ze`" contained contains=@Viml
|
|
|
|
|
2014-06-30 02:04:37 -04:00
|
|
|
" Variables {{{4
|
|
|
|
|
2012-08-12 08:05:29 -04:00
|
|
|
syn match snipVar "\$\d*" contained
|
2012-02-05 07:15:25 -05:00
|
|
|
syn region snipVisual matchgroup=Define start="\${VISUAL" end="}" contained
|
2012-08-12 08:05:29 -04:00
|
|
|
syn region snipVarExpansion matchgroup=Define start="\${\d*" end="}" contained contains=snipVar,snipVarExpansion,snipCommand
|
2011-02-17 08:07:27 -05:00
|
|
|
|
2014-06-30 02:04:37 -04:00
|
|
|
" global {{{3
|
|
|
|
|
2014-06-30 02:44:22 -04:00
|
|
|
" Generic (non-Python) {{{4
|
2014-06-30 03:00:20 -04:00
|
|
|
|
2014-06-30 02:44:22 -04:00
|
|
|
syn region snipGlobal start="^global\_s" end="^endglobal\s*$" contains=snipGlobalHeader fold keepend
|
2014-06-30 03:00:20 -04:00
|
|
|
syn match snipGlobalHeader "^.*$" nextgroup=snipGlobalBody,snipGlobalFooter skipnl contained contains=snipGlobalHeaderKeyword
|
2014-06-30 02:44:22 -04:00
|
|
|
syn region snipGlobalBody start="\_." end="^\zeendglobal\s*$" contained contains=snipTabsOnly,snipLeadingSpaces nextgroup=snipGlobalFooter
|
|
|
|
|
|
|
|
" Python (!p) {{{4
|
|
|
|
|
|
|
|
syn region snipGlobal start="^global\s\+!p\_s\@=" end="^endglobal\s*$" contains=snipGlobalPHeader fold keepend
|
2014-06-30 03:00:20 -04:00
|
|
|
syn match snipGlobalPHeader "^.*$" nextgroup=snipGlobalPBody,snipGlobalFooter skipnl contained contains=snipGlobalHeaderKeyword
|
|
|
|
syn match snipGlobalHeaderKeyword "^global" contained nextgroup=snipSnippetTrigger skipwhite
|
2014-06-30 02:44:22 -04:00
|
|
|
syn region snipGlobalPBody start="\_." end="^\zeendglobal\s*$" contained contains=snipTabsOnly,snipLeadingSpaces,@Python nextgroup=snipGlobalFooter
|
2011-02-17 08:07:27 -05:00
|
|
|
|
2014-06-30 03:00:20 -04:00
|
|
|
" Common {{{4
|
|
|
|
|
|
|
|
syn match snipGlobalFooter "^endglobal.*" contained contains=snipGlobalFooterKeyword
|
|
|
|
syn match snipGlobalFooterKeyword "^endglobal" contained
|
|
|
|
|
2014-06-30 02:04:37 -04:00
|
|
|
" priority {{{3
|
|
|
|
|
2014-06-30 02:22:53 -04:00
|
|
|
syn match snipPriority "^priority\%(\s.*\|$\)" contains=snipPriorityKeyword display
|
|
|
|
syn match snipPriorityKeyword "^priority" contained nextgroup=snipPriorityValue skipwhite display
|
|
|
|
syn match snipPriorityValue "-\?\d\+" contained display
|
2012-11-24 04:12:36 -05:00
|
|
|
|
2014-06-30 02:04:37 -04:00
|
|
|
" Snippt Clearing {{{2
|
|
|
|
|
2014-06-30 02:22:53 -04:00
|
|
|
syn match snipClear "^clearsnippets\%(\s.*\|$\)" contains=snipClearKeyword display
|
|
|
|
syn match snipClearKeyword "^clearsnippets" contained display
|
2014-06-30 02:04:37 -04:00
|
|
|
|
|
|
|
" Highlight groups {{{1
|
2011-02-17 08:07:27 -05:00
|
|
|
|
2014-06-29 22:36:07 -04:00
|
|
|
hi def link snipComment Comment
|
|
|
|
hi def link snipLeadingSpaces Error
|
|
|
|
hi def link snipString String
|
|
|
|
hi def link snipDocString String
|
|
|
|
hi def link snipTabsOnly Error
|
2011-02-19 14:00:24 -05:00
|
|
|
|
2014-06-29 22:36:07 -04:00
|
|
|
hi def link snipKeyword Keyword
|
2011-02-17 08:07:27 -05:00
|
|
|
|
2014-06-30 02:44:22 -04:00
|
|
|
hi def link snipExtendsKeyword snipKeyword
|
2011-02-17 08:07:27 -05:00
|
|
|
|
2014-06-30 02:33:36 -04:00
|
|
|
hi def link snipSnippetHeaderKeyword snipKeyword
|
|
|
|
hi def link snipSnippetFooterKeyword snipKeyword
|
|
|
|
|
2014-06-30 02:44:22 -04:00
|
|
|
hi def link snipGlobalHeaderKeyword snipKeyword
|
|
|
|
hi def link snipGlobalFooterKeyword snipKeyword
|
2014-06-29 23:47:22 -04:00
|
|
|
|
2014-06-29 22:36:07 -04:00
|
|
|
hi def link snipCommand Special
|
2014-06-29 23:47:22 -04:00
|
|
|
hi def link snipCommandDelim snipCommand
|
|
|
|
hi def link snipShellCommand snipCommand
|
2014-06-29 22:36:07 -04:00
|
|
|
hi def link snipPythonCommand snipCommand
|
|
|
|
hi def link snipVimLCommand snipCommand
|
2014-06-29 23:47:22 -04:00
|
|
|
hi def link snipPythonCommandP PreProc
|
|
|
|
hi def link snipVimLCommandV PreProc
|
|
|
|
|
2014-06-29 22:36:07 -04:00
|
|
|
hi def link snipVar StorageClass
|
|
|
|
hi def link snipVarExpansion Normal
|
|
|
|
hi def link snipVisual Normal
|
2014-06-30 02:04:37 -04:00
|
|
|
hi def link snipSnippet Normal
|
2011-02-17 08:07:27 -05:00
|
|
|
|
2014-06-30 02:11:11 -04:00
|
|
|
hi def link snipPriorityKeyword Keyword
|
|
|
|
hi def link snipPriorityValue Number
|
|
|
|
|
|
|
|
hi def link snipClearKeyword Keyword
|
2012-11-24 04:12:36 -05:00
|
|
|
|
2014-06-30 02:04:37 -04:00
|
|
|
" }}}1
|
|
|
|
|
2014-06-29 22:42:57 -04:00
|
|
|
let b:current_syntax = "snippets"
|