[PATCH] Contrib: vim syntax, support block region

Maxim Dounin mdounin at mdounin.ru
Wed Apr 19 15:10:53 UTC 2017


Hello!

On Wed, Apr 19, 2017 at 05:52:36PM +0800, OOO wrote:

> Hi Dounin
> 
> I have looked into your POC.
> I use this approach in yajs.vim too.
> The major problem of this approach is: It creates (sort of) redundant
> syntax group.
> For the listen directive:
> 
> > syn keyword ngxDirectiveImportantListen listen
> >     \ nextgroup=@ngxListenParams skipwhite skipempty
> > syn match ngxListenParam '\([^;{ \t\\]\|\\.\)\+'
> >     \ contained
> >     \ nextgroup=@ngxListenParams skipwhite skipempty
> > syn region ngxListenString start=+\z(["']\)+ end=+\z1+ skip=+\\\\\|\\\z1+
> >     \ contained
> >     \ nextgroup=@ngxListenParams skipwhite skipempty
> > syn match ngxListenComment '#.*$'
> >     \ contained
> >     \ nextgroup=@ngxListenParams skipwhite skipempty
> > syn keyword ngxListenOptions contained
> >     \ default_server ssl http2 spdy proxy_protocol
> >     \ setfib fastopen backlog rcvbuf sndbuf accept_filter deferred bind
> >     \ ipv6only reuseport so_keepalive keepidle
> >     \ nextgroup=@ngxListenParams skipwhite skipempty
> > syn cluster ngxListenParams
> >     \ contains=ngxListenParam,ngxListenString,ngxListenComment
> >     \ add=ngxListenOptions
> 
> The ngxListenParam, ngxListenString, ngxListenComment and
> ngxListenParams are the redundant groups.
> For every directive we want to highlight params.
> We will have to add four more syntax group like this one.

Yes, this is exactly what I mean when I wrote that "this
approach doesn't allow to extend things easily
with highlighting of directive-specific parameters" in the 
previous messages.  The most simple solution would be to avoid 
directive-specific parameters highlighting at all - nginx.vim 
never did this in the past, so probably this is a good enough 
solution.

-- 
Maxim Dounin
http://nginx.org/


More information about the nginx-devel mailing list