From 672117c478a66a38384be374b7a1fbee4b1e6184 Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Sun, 29 Jun 2014 23:04:37 -0700 Subject: [PATCH] Add hierarchy to syntax file Redo comments with fold markers to provide an appropriate hierarchy to the syntax file itself. --- syntax/snippets.vim | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/syntax/snippets.vim b/syntax/snippets.vim index 96e24a1..4ce3d23 100644 --- a/syntax/snippets.vim +++ b/syntax/snippets.vim @@ -5,6 +5,8 @@ if exists("b:current_syntax") finish endif +" Embedded Syntaxes {{{1 + syntax include @Python syntax/python.vim unlet b:current_syntax syntax include @Viml syntax/vim.vim @@ -12,10 +14,15 @@ unlet b:current_syntax syntax include @Shell syntax/sh.vim unlet b:current_syntax -" global matches +" Syntax definitions {{{1 + +" Comments {{{2 + syn match snipComment "^#.*" contains=snipTODO syn keyword snipTODO FIXME NOTE NOTES TODO XXX contained +" Miscellaneous {{{2 + syn match snipDocString '"[^"]*"$' syn match snipString '"[^"]*"' syn match snipTabsOnly "^\t\+$" @@ -23,33 +30,47 @@ syn match snipLeadingSpaces "^\t* \+" syn match snipKeyword "\(\<\(end\)\?\(snippet\|global\)\>\)\|extends\|clearsnippets\|priority" contained -" extends definitions +" Extends {{{2 + syn match snipExtends "^extends.*" contains=snipKeyword -" snippet definitions +" Definitions {{{2 + +" snippet {{{3 + +syn region snipSnippet fold keepend start="^snippet" end="^endsnippet" contains=snipStart,snipEnd,snipTabsOnly,snipLeadingSpaces,snipCommand,snipVarExpansion,snipVar,snipVisual + syn match snipStart "^snippet.*" contained contains=snipKeyword,snipDocString syn match snipEnd "^endsnippet" contained contains=snipKeyword +" Command substitution {{{4 + 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 +" Variables {{{4 + syn match snipVar "\$\d*" contained syn region snipVisual matchgroup=Define start="\${VISUAL" end="}" contained syn region snipVarExpansion matchgroup=Define start="\${\d*" end="}" contained contains=snipVar,snipVarExpansion,snipCommand -syn region snippet fold keepend start="^snippet" end="^endsnippet" contains=snipStart,snipEnd,snipTabsOnly,snipLeadingSpaces,snipCommand,snipVarExpansion,snipVar,snipVisual -" global definitions +" global {{{3 + syn match snipGlobalStart "^global.*" contained contains=snipKeyword,snipString syn match snipGlobalEnd "^endglobal" contained contains=snipKeyword syn region snipGlobal fold keepend start="^global" end="^endglobal" contains=snipGlobalStart,snipGlobalEnd,snipLeadingSpaces,snipTabsOnly,snipCommand,snipVarExpansion,snipVar,@Python -" snippet clearing -syn match snipClear "^clearsnippets" +" priority {{{3 + syn match snipPriority "^priority" -" highlighting rules +" Snippt Clearing {{{2 + +syn match snipClear "^clearsnippets" + +" Highlight groups {{{1 hi def link snipComment Comment hi def link snipLeadingSpaces Error @@ -75,7 +96,7 @@ hi def link snipVimLCommandV PreProc hi def link snipVar StorageClass hi def link snipVarExpansion Normal hi def link snipVisual Normal -hi def link snippet Normal +hi def link snipSnippet Normal hi def link snipGlobalStart Statement hi def link snipGlobalEnd Statement @@ -84,4 +105,6 @@ hi def link snipGlobal Normal hi def link snipClear Statement hi def link snipPriority Statement +" }}}1 + let b:current_syntax = "snippets"