From d239402b7fabe7cdbf69d84a02dc23dafd63c863 Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Sun, 29 Jun 2014 23:44:22 -0700 Subject: [PATCH] Rewrite syntax matching for `global` The body of a global now only has Python syntax coloring if the trigger is !p. This matches the actual behavior of UltiSnips. AFAIK right now globals with other triggers are useless, but this opens the door to proper syntax coloring for those if they ever gain a use. --- syntax/snippets.vim | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/syntax/snippets.vim b/syntax/snippets.vim index 1d3cb16..649e841 100644 --- a/syntax/snippets.vim +++ b/syntax/snippets.vim @@ -61,9 +61,19 @@ syn region snipVarExpansion matchgroup=Define start="\${\d*" end="}" contained c " 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 +" Generic (non-Python) {{{4 +syn region snipGlobal start="^global\_s" end="^endglobal\s*$" contains=snipGlobalHeader fold keepend +syn match snipGlobalHeader "^.*$" nextgroup=snipGlobalBody skipnl contained contains=snipGlobalHeaderKeyword +syn match snipGlobalHeaderKeyword "^global" contained nextgroup=snipSnippetTrigger +syn region snipGlobalBody start="\_." end="^\zeendglobal\s*$" contained contains=snipTabsOnly,snipLeadingSpaces nextgroup=snipGlobalFooter +syn match snipGlobalFooter "^endglobal.*" contained contains=snipGlobalFooterKeyword +syn match snipGlobalFooterKeyword "^endglobal" contained + +" Python (!p) {{{4 + +syn region snipGlobal start="^global\s\+!p\_s\@=" end="^endglobal\s*$" contains=snipGlobalPHeader fold keepend +syn match snipGlobalPHeader "^.*$" nextgroup=snipGlobalPBody skipnl contained contains=snipGlobalHeaderKeyword +syn region snipGlobalPBody start="\_." end="^\zeendglobal\s*$" contained contains=snipTabsOnly,snipLeadingSpaces,@Python nextgroup=snipGlobalFooter " priority {{{3 @@ -86,13 +96,13 @@ hi def link snipTabsOnly Error hi def link snipKeyword Keyword -hi def link snipExtendsKeyword Keyword +hi def link snipExtendsKeyword snipKeyword hi def link snipSnippetHeaderKeyword snipKeyword hi def link snipSnippetFooterKeyword snipKeyword -hi def link snipStart Statement -hi def link snipEnd snipStart +hi def link snipGlobalHeaderKeyword snipKeyword +hi def link snipGlobalFooterKeyword snipKeyword hi def link snipCommand Special hi def link snipCommandDelim snipCommand @@ -107,10 +117,6 @@ hi def link snipVarExpansion Normal hi def link snipVisual Normal hi def link snipSnippet Normal -hi def link snipGlobalStart Statement -hi def link snipGlobalEnd Statement -hi def link snipGlobal Normal - hi def link snipPriorityKeyword Keyword hi def link snipPriorityValue Number