views:

105

answers:

1

I'm trying to create a patch for cf.vim to resolve an issue with hashes. In ColdFusion, # signs are used to enclose an expression inside a cfoutput block.

<cfset x = 1 />
<cfoutput> x is now #x# </cfoutput>
<!--- outputs "x is now 1" --->

The problem comes into play when there is a lone #, not inside a cfoutput block:

<a href="#x">an anchored link</a>

This will cause vim to highlight everything after the # as if it were in a cfHashRegion.

syn region cfHashRegion start=+#+ skip=+"[^"]*"\|'[^']*'+ end=+#+ contained containedin=cfOutputRegion contains=@cfExpressionCluster,cfScriptParenError

syn region cfOutputRegion matchgroup=NONE transparent start=+<cfoutput>+ end=+</cfoutput>+ contains=TOP

Is there something I can add to cfHashRegion to tell vim "Don't enter a cfHashRegion unless the start and end properties are both found?

Super-bonus: cfoutput is only the most common way to be in a "cfOutputRegion". Any cffunction with output="true" will behave as if everything inside its block were wrapped in cfoutput tags.

+1  A: 

Have you tried using syn match instead of syn region? I don't know the ColdFusion syntax, so I won't know if this is possible/correct.

Something like:

syn region cfHashRegion "L\=#[^#]+#" containedin=cfOutputRegion  contains=@cfExpressionCluster,cfScriptParenError

You may also want to look into the use of the contains=ALLBUT,{group-name},.. argument list for some cases.

Marius
I had to escape the +, but it worked. It isn't perfect, because a `cfHashRegion` can actually be split over multiple lines. In practice though, they are almost always on a single line. Thanks!
mwc