Friday, October 2, 2015

How to define highlighting groups that are only valid within a syntax region

I'm trying to add a set of keywords to my sqloracle.vim that only apply to external tables. I'm trying to avoid the case where some table/column/variable name is highlighted as a keyword in some context where it isn't one.

My idea was to define a keyword group as "contained" and a region that contains it, so that the contained keywords would only be treated as keywords when they occur within the region.

For example,

syn match sqlXTType contained big endian csv date_format little

syn region sqlXTParams transparent matchgroup=sqlKeyword start=+\<organization\s\+external\>+ end=+)+ contains=sqlXTTYPE

hi sqlXTType gui=BOLD guifg=DarkMagenta guibg=NONE

(sqlKeyword is already defined.)

However any opening bracket seems to trigger the start of an sqlXTParams region (in addition to the words "organization external", and nothing terminates it.

Is this even doable?

I'm on Vim 7.2 at my work thanks to corporate desktop policy, but I'll try on MacVim 7.4 at home when I get a chance.

btw I'm using the tip here to identify highlighting groups, when bold purple isn't enough :)
http://vim.wikia.com/wiki/Identify_the_syntax_highlighting_group_used_at_the_cursor

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment