[PATCH] Contrib: removed ngxBlock syntax group

OOO othree at gmail.com
Thu Mar 3 15:21:51 UTC 2016


More info about this patch.

Before the patch
https://www.flickr.com/photos/othree/24844596133/

After the patch
https://www.flickr.com/photos/othree/25471327825/

The major difference is the `rewrite ` directives are correct now.
Old syntax had wrong syntax on rewrite if following regexp have character
`{`.
Which have special function in regexp.

The easiest way to solve this issue is to remove the `ngxBlock` definition.

Cons of this patch:

Old syntax have some debug feature. (incorrect directive follow by `{}`
block will not highlight)
New syntax don't have this feature.

If want to have both correct syntax and debug feature.
Will lead to more complete syntax definition.
And will be slower.


2016-03-03 23:11 GMT+08:00 OOO <othree at gmail.com>:

> # HG changeset patch
> # User Kao, Wei-Ko(othree) <othree at gmail.com>
> # Date 1457016287 -28800
> #      Thu Mar 03 22:44:47 2016 +0800
> # Node ID 078464d1da32d30b0edef6f441d750765c1a4110
> # Parent  3b9fe734a76ca0863ec87596369690831e9f4086
> Contrib: removed ngxBlock syntax group
>
> ngxBlock syntax group is not design well. If any directive's parameter
> have `{`, then the syntax highlight of that directive will incorrect.
>
> diff -r 3b9fe734a76c -r 078464d1da32 contrib/vim/syntax/nginx.vim
> --- a/contrib/vim/syntax/nginx.vim    Tue Mar 01 15:18:07 2016 +0300
> +++ b/contrib/vim/syntax/nginx.vim    Thu Mar 03 22:44:47 2016 +0800
> @@ -10,28 +10,26 @@
>  setlocal iskeyword+=:
>
>  syn match ngxVariable '\$\(\w\+\|{\w\+}\)'
> -syn match ngxVariableBlock '\$\(\w\+\|{\w\+}\)' contained
>  syn match ngxVariableString '\$\(\w\+\|{\w\+}\)' contained
> -syn region ngxBlock start=+^+ end=+{+ skip=+\${+
> contains=ngxComment,ngxDirectiveBlock,ngxVariableBlock,ngxString oneline
>  syn region ngxString start=+\z(["']\)+ end=+\z1+ skip=+\\\\\|\\\z1+
> contains=ngxVariableString
>  syn match ngxComment ' *#.*$'
>
>  syn keyword ngxBoolean on
>  syn keyword ngxBoolean off
>
> -syn keyword ngxDirectiveBlock http         contained
> -syn keyword ngxDirectiveBlock mail         contained
> -syn keyword ngxDirectiveBlock events       contained
> -syn keyword ngxDirectiveBlock server       contained
> -syn keyword ngxDirectiveBlock types        contained
> -syn keyword ngxDirectiveBlock location     contained
> -syn keyword ngxDirectiveBlock upstream     contained
> -syn keyword ngxDirectiveBlock charset_map  contained
> -syn keyword ngxDirectiveBlock limit_except contained
> -syn keyword ngxDirectiveBlock if           contained
> -syn keyword ngxDirectiveBlock geo          contained
> -syn keyword ngxDirectiveBlock map          contained
> -syn keyword ngxDirectiveBlock split_clients contained
> +syn keyword ngxDirectiveBlock http
> +syn keyword ngxDirectiveBlock mail
> +syn keyword ngxDirectiveBlock events
> +syn keyword ngxDirectiveBlock server
> +syn keyword ngxDirectiveBlock types
> +syn keyword ngxDirectiveBlock location
> +syn keyword ngxDirectiveBlock upstream
> +syn keyword ngxDirectiveBlock charset_map
> +syn keyword ngxDirectiveBlock limit_except
> +syn keyword ngxDirectiveBlock if
> +syn keyword ngxDirectiveBlock geo
> +syn keyword ngxDirectiveBlock map
> +syn keyword ngxDirectiveBlock split_clients
>
>  syn keyword ngxDirectiveImportant include
>  syn keyword ngxDirectiveImportant root
> @@ -819,9 +817,7 @@
>
>  hi link ngxComment Comment
>  hi link ngxVariable Identifier
> -hi link ngxVariableBlock Identifier
>  hi link ngxVariableString PreProc
> -hi link ngxBlock Normal
>  hi link ngxString String
>
>  hi link ngxBoolean Boolean
>
>
> --
> OOO
>



-- 
OOO
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20160303/4a36a11f/attachment.html>


More information about the nginx-devel mailing list