chr4 / nginx.vim

Improved nginx vim plugin (incl. syntax highlighting)
450 stars 41 forks source link

Comment and TODO #12

Open egberts opened 4 years ago

egberts commented 4 years ago

I noticed that you haven't exactly supported comment (much less TODO/FIXME) yet.

I know for a fact that nginx.conf shares a very strong resemblance to ISC Bind9 named.conf configuration file's syntax.

I've been working on the vim-syntax-bind-named highlighter for this named.conf file. And it's pretty ALPHA at that point.

Maybe this snippet for your Vim syntax/nginx.vim will jumpstart you:

hi link namedError  Error
syn match namedError /[^;{#]$/

hi link namedToDo Todo
syn keyword namedToDo xxx contained XXX FIXME TODO TODO: FIXME:

syn region namedQuotedString start=/"/ skip=/\\"/ end=/"/ contained
syn region namedQuotedString start=/'/ skip=/\\'/ end=/'/ contained

" --- Other variants of strings
"  filespec = '_-.+~@$%^&*()=[]\\|:<>`?'  " no curly braces nor semicolon
"  filespec = can be unquoted but no space char allowed
hi link namedFilespec   String
syn match namedFilespec contained /[{}<>\|:;"'a-zA-Z0-9_\.\-\/\\]\+[^;]/ contains=namedQuotedString skipwhite skipempty skipnl 

hi link namedComment    Comment
syn match namedComment "//.*" contains=namedToDo
syn match namedComment "#.*" contains=namedToDo
syn region namedComment start="/\*" end="\*/" contains=namedToDo
syn match namedInclude /\_s*include/
\ nextgroup=namedFilespec,namedError
\ skipwhite