开发者

vim syntax highlighting of ColdFusion hash marks

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,cfScriptParenE开发者_StackOverflow社区rror

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜