2

I'm trying to add a set of keywords to my sqloracle.vim that only apply to external tables. There are various keywords like "big" and "csv" that only make sense for external tables, so I thought I might be able to define a region for it and only highlight them within that.

For example,

syn keyword sqlXTType     contained    big endian csv date_format little 
syn keyword sqlXTKeyword  contained    access are blanks data default delimited enclosed field[s] location missing newline reject parameters position terminated whitespace
syn region  sqlXTParams   transparent  matchgroup=sqlKeyword start=+\<organization\s\+external\>+ end=+)+ contains=sqlXTType,sqlXTKeyword,Comment

" Some highlighting rules (not my actual colour scheme!)
hi sqlKeyword    gui=BOLD guifg=DarkBlue guibg=NONE 
hi sqlType       gui=BOLD guifg=DarkCyan guibg=NONE 
hi sqlXTType     gui=BOLD guifg=DarkMagenta guibg=NONE 
hi sqlXTKeyword  gui=BOLD guifg=DarkRed guibg=NONE 

Here's an example of the kind of syntax I want it to work with. I've deliberately used table and column names like "parameters" and "position" which are SQL keywords only in the context of external tables. I'd like to have them highlighted only within an "organization external" clause.

create table parameters
( position     number(4)
, date_format  varchar2(20)
, terminated   char(1)
, start_date   date
, values       varchar2(200) )
organization external
( type oracle_loader
  default directory nfs_dir
  access parameters
  ( records delimited by newline
    missing field values are null
    fields terminated by "," optionally enclosed by '"' ldrtrim 
    all fields override
    reject rows with all null fields 
    ( pos, dt, xxx
    , start_dt char(21) date_format date mask "dd-mon-yyyy hh24:mi:ss"
    , zzz )
  )
  location ('dummy.dat')
)
parallel 1
reject limit unlimited;

However any opening bracket seems to trigger the start of an sqlXTParams region (in addition to the words "organization external"), and nothing terminates it. I suspect Vim's syntax region implementation is expecting things that are normally paired like brackets or quotes, and not just any old text like "organization external" up to a closing bracket, in which case this can't be done.

btw I'm using this tip to identify highlighting groups: http://vim.wikia.com/wiki/Identify_the_syntax_highlighting_group_used_at_the_cursor

2
  • Without seeing a sample of the text you're highlighting it is hard for me to envision this... but it sounds a little like this question to me, perhaps my answer there will be of help.
    – Dan Lowe
    Oct 20, 2015 at 0:14
  • Good point - I'll update the question. Oct 20, 2015 at 8:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.