[PATCH] Contrib: update vim syntax script

Maxim Dounin mdounin at mdounin.ru
Fri Feb 17 15:24:29 UTC 2017


Hello!

On Thu, Feb 16, 2017 at 11:57:35PM +0800, OOO wrote:

> Hi
> 
> This patch improves vim syntax file for nginx conf.
> 
> Major changes:
> 
> * Fix regexp in string might breaks location ngxBlock
> * Use syntax iskeyword instead of modify real Vim iskeyword (new Vim
> feature, can avoid change user behavior)
> * Update keywords, based on document[1][2]
> * Add/Update all 3rd party module keywords based on wiki[3][4]
> 
> Full change history is on github[5].
> 
> [1]:https://nginx.org/en/docs/
> [2]:https://github.com/othree/nginx-contrib-vim/issues/4
> [3]:https://www.nginx.com/resources/wiki/modules/
> [4]:https://github.com/othree/nginx-contrib-vim/issues/1
> [5]:https://github.com/othree/nginx-contrib-vim
> 
> # HG changeset patch
> # User othree <othree at gmail.com>
> # Date 1487259832 -28800
> #      Thu Feb 16 23:43:52 2017 +0800
> # Node ID 3f74fe213e98697c932b20b86dfdaab505a8f89b
> # Parent  05fd0dc8f0dc808219f727dd18a5da2f078c4073
> Update contrib/vim/syntax
> 
> * Fix regexp in string might breaks location ngxBlock
> * Highlight rewrite flags
> * Update keywords based on latest document
> * Include all 3rd party modules listed on wiki
> * Use syntax iskeyword instead of modify iskeyword

Thank you for the patch.  Unfortunately, it fails to apply here, 
as it was word-wrapped by your mail client.  Please consider using "hg 
email" to make sure the patch won't be corrupted in transit, see 
http://nginx.org/en/docs/contributing_changes.html.

Note well that it would be much better to submit separate patches 
for different changes.

Some additional comments below.

> -setlocal iskeyword+=.
> -setlocal iskeyword+=/
> -setlocal iskeyword+=:
> +if has("patch-7.4-1142")
> +  if has("win32")
> +    syn iskeyword @,48-57,_,128-167,224-235,.,/,:
> +  else
> +    syn iskeyword @,48-57,_,192-255,.,/,:
> +  endif
> +else
> +  setlocal iskeyword+=.
> +  setlocal iskeyword+=/
> +  setlocal iskeyword+=:
> +endif

Is it at all needed?  As far as I see, syntax highliting doesn't 
directly depends on keyword chars, so it might be better idea to just 
remove iskeyword modifications.  It will have some negative 
effects by incorrectly matching directives in some file paths, 
for example:

     error_log /path/to/error_log;

will have "error_log" highlighted in the path, but this is 
something already happens on "-" in a configuration like:

    error_log /path/to/foo-error_log;

So probably this isn't something serious enough to worry about, 
and just removing iskeyword modifications may be a better option.

If you think it is really needed, it might be a better idea to use 
something like

if has("patch-7.4-1142")
  exe "syn iskeyword ".&iskeyword.",.,/,:"
else
  ...
endif

(Seen at https://github.com/vim/vim/blob/master/runtime/syntax/sh.vim#L91).

[...]

> +" Asynchronous FastCGI Module <https://github.com/rsms/afcgi>
> +" Primarily a modified version of the Nginx FastCGI module which
> implements multiplexing of connections, allowing a single FastCGI
> server to handle many concurrent requests.
> +" syn keyword ngxDirectiveThirdParty fastcgi_bind
> +" syn keyword ngxDirectiveThirdParty fastcgi_buffer_size
> +" syn keyword ngxDirectiveThirdParty fastcgi_buffers
> +" syn keyword ngxDirectiveThirdParty fastcgi_busy_buffers_size
> +" syn keyword ngxDirectiveThirdParty fastcgi_cache
> +" syn keyword ngxDirectiveThirdParty fastcgi_cache_key
> +" syn keyword ngxDirectiveThirdParty fastcgi_cache_methods
> +" syn keyword ngxDirectiveThirdParty fastcgi_cache_min_uses
> +" syn keyword ngxDirectiveThirdParty fastcgi_cache_path
> +" syn keyword ngxDirectiveThirdParty fastcgi_cache_use_stale
> +" syn keyword ngxDirectiveThirdParty fastcgi_cache_valid
> +" syn keyword ngxDirectiveThirdParty fastcgi_catch_stderr
> +" syn keyword ngxDirectiveThirdParty fastcgi_connect_timeout
> +" syn keyword ngxDirectiveThirdParty fastcgi_hide_header
> +" syn keyword ngxDirectiveThirdParty fastcgi_ignore_client_abort
> +" syn keyword ngxDirectiveThirdParty fastcgi_ignore_headers
> +" syn keyword ngxDirectiveThirdParty fastcgi_index
> +" syn keyword ngxDirectiveThirdParty fastcgi_intercept_errors
> +" syn keyword ngxDirectiveThirdParty fastcgi_max_temp_file_size
> +" syn keyword ngxDirectiveThirdParty fastcgi_next_upstream
> +" syn keyword ngxDirectiveThirdParty fastcgi_param
> +" syn keyword ngxDirectiveThirdParty fastcgi_pass
> +" syn keyword ngxDirectiveThirdParty fastcgi_pass_header
> +" syn keyword ngxDirectiveThirdParty fastcgi_pass_request_body
> +" syn keyword ngxDirectiveThirdParty fastcgi_pass_request_headers
> +" syn keyword ngxDirectiveThirdParty fastcgi_read_timeout
> +" syn keyword ngxDirectiveThirdParty fastcgi_send_lowat
> +" syn keyword ngxDirectiveThirdParty fastcgi_send_timeout
> +" syn keyword ngxDirectiveThirdParty fastcgi_split_path_info
> +" syn keyword ngxDirectiveThirdParty fastcgi_store
> +" syn keyword ngxDirectiveThirdParty fastcgi_store_access
> +" syn keyword ngxDirectiveThirdParty fastcgi_temp_file_write_size
> +" syn keyword ngxDirectiveThirdParty fastcgi_temp_path
> +syn keyword ngxDirectiveThirdParty fastcgi_upstream_fail_timeout
> +syn keyword ngxDirectiveThirdParty fastcgi_upstream_max_fails

This module seems to be a (likely non-working) copy of stock 
fastcgi module with no additional features.  It provides no 
additional directives.  The fastcgi_upstream_fail_timeout / 
fastcgi_upstream_max_fails directives you've listed here are long 
deprecated and will only print result in an error (including in 
this module).

[...]

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


More information about the nginx-devel mailing list