[PATCH] Contrib: update vim syntax script

OOO othree at gmail.com
Mon Mar 7 09:31:09 UTC 2016


This new patch fixed the issues in previous patch.

Now the string and regexp are recognized well.
No keywords will highlight inside these two kind of sections.

Besides bug fixing, I also add lua, brotli, nginScript support.

Screenshots:
https://www.flickr.com/photos/othree/25212844679/
https://www.flickr.com/photos/othree/25580381505/
https://www.flickr.com/photos/othree/25461861942/



2016-03-07 17:30 GMT+08:00 OOO <othree at gmail.com>:

> # HG changeset patch
> # User Kao, Wei-Ko(othree) <othree at gmail.com>
> # Date 1457339778 -28800
> #      Mon Mar 07 16:36:18 2016 +0800
> # Node ID e0cfa435fe182f1533ae8c7a4eb5ee398dc83c4e
> # Parent  c5f81dcf97a79576138917501c9a6cc6f53ee930
> Update vim syntax file
>
> Updates including:
> * Fix regexp in string might breaks location ngxBlock
> * Add lua, brotli, nginScript modules
> * Update uwsgi, fast_cgi, mp4 directives to latest version
> * Highlight rewrite flags
>
> diff --git a/contrib/vim/syntax/nginx.vim b/contrib/vim/syntax/nginx.vim
> --- a/contrib/vim/syntax/nginx.vim
> +++ b/contrib/vim/syntax/nginx.vim
> @@ -5,57 +5,63 @@ if exists("b:current_syntax")
>    finish
>  end
>
>  setlocal iskeyword+=.
>  setlocal iskeyword+=/
>  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 match ngxComment ' *#.*$'
> +syn match ngxRewriteURI /\S\+/ contained contains=ngxVariableString
> nextgroup=ngxURI skipwhite
> +syn match ngxURI /\S\+/ contained contains=ngxVariableString skipwhite
> +syn match ngxLocationPath /[^ {]\+/ contained
>  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 match   ngxLocationOperator /\(=\|\~\*\|\^\~\|\~\)/ contained
> nextgroup=ngxLocationPath,ngxString skipwhite
> +syn match   ngxLocationNamedLoc /@\w\+/
> +syn keyword ngxDirectiveBlock location
> nextgroup=ngxLocationNamedLoc,ngxLocationOperator,ngxLocationPath,ngxString
> skipwhite
> +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
>  syn keyword ngxDirectiveImportant server
>  syn keyword ngxDirectiveImportant server_name
>  syn keyword ngxDirectiveImportant listen
>  syn keyword ngxDirectiveImportant internal
>  syn keyword ngxDirectiveImportant proxy_pass
>  syn keyword ngxDirectiveImportant memcached_pass
>  syn keyword ngxDirectiveImportant fastcgi_pass
>  syn keyword ngxDirectiveImportant scgi_pass
>  syn keyword ngxDirectiveImportant uwsgi_pass
>  syn keyword ngxDirectiveImportant try_files
>
>  syn keyword ngxDirectiveControl break
>  syn keyword ngxDirectiveControl return
> -syn keyword ngxDirectiveControl rewrite
> +syn keyword ngxDirectiveControl rewrite nextgroup=ngxRewriteURI skipwhite
>  syn keyword ngxDirectiveControl set
>
> +syn keyword ngxRewriteFlag last break redirect permanent
> +
>  syn keyword ngxDirectiveError error_page
>  syn keyword ngxDirectiveError post_action
>
>  syn keyword ngxDirectiveDeprecated connections
>  syn keyword ngxDirectiveDeprecated imap
>  syn keyword ngxDirectiveDeprecated limit_zone
>  syn keyword ngxDirectiveDeprecated open_file_cache_retest
>  syn keyword ngxDirectiveDeprecated optimize_server_names
> @@ -123,42 +129,46 @@ syn keyword ngxDirective fastcgi_bind
>  syn keyword ngxDirective fastcgi_buffer_size
>  syn keyword ngxDirective fastcgi_buffering
>  syn keyword ngxDirective fastcgi_buffers
>  syn keyword ngxDirective fastcgi_busy_buffers_size
>  syn keyword ngxDirective fastcgi_cache
>  syn keyword ngxDirective fastcgi_cache_bypass
>  syn keyword ngxDirective fastcgi_cache_key
>  syn keyword ngxDirective fastcgi_cache_lock
> +syn keyword ngxDirective fastcgi_cache_lock_age
>  syn keyword ngxDirective fastcgi_cache_lock_timeout
>  syn keyword ngxDirective fastcgi_cache_methods
>  syn keyword ngxDirective fastcgi_cache_min_uses
>  syn keyword ngxDirective fastcgi_cache_path
> +syn keyword ngxDirective fastcgi_cache_purge
>  syn keyword ngxDirective fastcgi_cache_revalidate
>  syn keyword ngxDirective fastcgi_cache_use_stale
>  syn keyword ngxDirective fastcgi_cache_valid
>  syn keyword ngxDirective fastcgi_catch_stderr
>  syn keyword ngxDirective fastcgi_connect_timeout
>  syn keyword ngxDirective fastcgi_force_ranges
>  syn keyword ngxDirective fastcgi_hide_header
>  syn keyword ngxDirective fastcgi_ignore_client_abort
>  syn keyword ngxDirective fastcgi_ignore_headers
>  syn keyword ngxDirective fastcgi_index
>  syn keyword ngxDirective fastcgi_intercept_errors
>  syn keyword ngxDirective fastcgi_keep_conn
> +syn keyword ngxDirective fastcgi_limit_rate
>  syn keyword ngxDirective fastcgi_max_temp_file_size
>  syn keyword ngxDirective fastcgi_next_upstream
>  syn keyword ngxDirective fastcgi_next_upstream_timeout
>  syn keyword ngxDirective fastcgi_next_upstream_tries
>  syn keyword ngxDirective fastcgi_no_cache
>  syn keyword ngxDirective fastcgi_param
>  syn keyword ngxDirective fastcgi_pass_header
>  syn keyword ngxDirective fastcgi_pass_request_body
>  syn keyword ngxDirective fastcgi_pass_request_headers
>  syn keyword ngxDirective fastcgi_read_timeout
> +syn keyword ngxDirective fastcgi_request_buffering
>  syn keyword ngxDirective fastcgi_send_lowat
>  syn keyword ngxDirective fastcgi_send_timeout
>  syn keyword ngxDirective fastcgi_split_path_info
>  syn keyword ngxDirective fastcgi_store
>  syn keyword ngxDirective fastcgi_store_access
>  syn keyword ngxDirective fastcgi_temp_file_write_size
>  syn keyword ngxDirective fastcgi_temp_path
>  syn keyword ngxDirective flv
> @@ -179,30 +189,33 @@ syn keyword ngxDirective gzip_http_versi
>  syn keyword ngxDirective gzip_min_length
>  syn keyword ngxDirective gzip_no_buffer
>  syn keyword ngxDirective gzip_proxied
>  syn keyword ngxDirective gzip_static
>  syn keyword ngxDirective gzip_types
>  syn keyword ngxDirective gzip_vary
>  syn keyword ngxDirective gzip_window
>  syn keyword ngxDirective hash
> +syn keyword ngxDirective http2 " Not a real directive
>  syn keyword ngxDirective if_modified_since
>  syn keyword ngxDirective ignore_invalid_headers
>  syn keyword ngxDirective image_filter
>  syn keyword ngxDirective image_filter_buffer
>  syn keyword ngxDirective image_filter_interlace
>  syn keyword ngxDirective image_filter_jpeg_quality
>  syn keyword ngxDirective image_filter_sharpen
>  syn keyword ngxDirective image_filter_transparency
>  syn keyword ngxDirective imap_auth
>  syn keyword ngxDirective imap_capabilities
>  syn keyword ngxDirective imap_client_buffer
>  syn keyword ngxDirective index
>  syn keyword ngxDirective iocp_threads
>  syn keyword ngxDirective ip_hash
> +syn keyword ngxDirective js_run
> +syn keyword ngxDirective js_set
>  syn keyword ngxDirective keepalive
>  syn keyword ngxDirective keepalive_disable
>  syn keyword ngxDirective keepalive_requests
>  syn keyword ngxDirective keepalive_timeout
>  syn keyword ngxDirective kqueue_changes
>  syn keyword ngxDirective kqueue_events
>  syn keyword ngxDirective large_client_header_buffers
>  syn keyword ngxDirective least_conn
> @@ -238,16 +251,18 @@ syn keyword ngxDirective memcached_read_
>  syn keyword ngxDirective memcached_send_timeout
>  syn keyword ngxDirective merge_slashes
>  syn keyword ngxDirective min_delete_depth
>  syn keyword ngxDirective modern_browser
>  syn keyword ngxDirective modern_browser_value
>  syn keyword ngxDirective mp4
>  syn keyword ngxDirective mp4_buffer_size
>  syn keyword ngxDirective mp4_max_buffer_size
> +syn keyword ngxDirective mp4_limit_rate
> +syn keyword ngxDirective mp4_limit_rate_after
>  syn keyword ngxDirective msie_padding
>  syn keyword ngxDirective msie_refresh
>  syn keyword ngxDirective multi_accept
>  syn keyword ngxDirective mysql_test
>  syn keyword ngxDirective open_file_cache
>  syn keyword ngxDirective open_file_cache_errors
>  syn keyword ngxDirective open_file_cache_events
>  syn keyword ngxDirective open_file_cache_min_uses
> @@ -262,17 +277,18 @@ syn keyword ngxDirective perl_require
>  syn keyword ngxDirective perl_set
>  syn keyword ngxDirective pid
>  syn keyword ngxDirective pop3_auth
>  syn keyword ngxDirective pop3_capabilities
>  syn keyword ngxDirective port_in_redirect
>  syn keyword ngxDirective post_acceptex
>  syn keyword ngxDirective postpone_gzipping
>  syn keyword ngxDirective postpone_output
> -syn keyword ngxDirective protocol
> +syn keyword ngxDirective protocol nextgroup=ngxMailProtocol skipwhite
> +syn keyword ngxMailProtocol imap pop3 smtp
>  syn keyword ngxDirective proxy
>  syn keyword ngxDirective proxy_bind
>  syn keyword ngxDirective proxy_buffer
>  syn keyword ngxDirective proxy_buffer_size
>  syn keyword ngxDirective proxy_buffering
>  syn keyword ngxDirective proxy_buffers
>  syn keyword ngxDirective proxy_busy_buffers_size
>  syn keyword ngxDirective proxy_cache
> @@ -466,16 +482,17 @@ syn keyword ngxDirective uwsgi_bind
>  syn keyword ngxDirective uwsgi_buffer_size
>  syn keyword ngxDirective uwsgi_buffering
>  syn keyword ngxDirective uwsgi_buffers
>  syn keyword ngxDirective uwsgi_busy_buffers_size
>  syn keyword ngxDirective uwsgi_cache
>  syn keyword ngxDirective uwsgi_cache_bypass
>  syn keyword ngxDirective uwsgi_cache_key
>  syn keyword ngxDirective uwsgi_cache_lock
> +syn keyword ngxDirective uwsgi_cache_lock_age
>  syn keyword ngxDirective uwsgi_cache_lock_timeout
>  syn keyword ngxDirective uwsgi_cache_methods
>  syn keyword ngxDirective uwsgi_cache_min_uses
>  syn keyword ngxDirective uwsgi_cache_path
>  syn keyword ngxDirective uwsgi_cache_revalidate
>  syn keyword ngxDirective uwsgi_cache_use_stale
>  syn keyword ngxDirective uwsgi_cache_valid
>  syn keyword ngxDirective uwsgi_connect_timeout
> @@ -487,24 +504,29 @@ syn keyword ngxDirective uwsgi_intercept
>  syn keyword ngxDirective uwsgi_max_temp_file_size
>  syn keyword ngxDirective uwsgi_modifier1
>  syn keyword ngxDirective uwsgi_modifier2
>  syn keyword ngxDirective uwsgi_next_upstream
>  syn keyword ngxDirective uwsgi_next_upstream_timeout
>  syn keyword ngxDirective uwsgi_next_upstream_tries
>  syn keyword ngxDirective uwsgi_no_cache
>  syn keyword ngxDirective uwsgi_param
> +syn keyword ngxDirective uwsgi_pass
>  syn keyword ngxDirective uwsgi_pass_header
>  syn keyword ngxDirective uwsgi_pass_request_body
>  syn keyword ngxDirective uwsgi_pass_request_headers
>  syn keyword ngxDirective uwsgi_read_timeout
> +syn keyword ngxDirective uwsgi_request_buffering
>  syn keyword ngxDirective uwsgi_send_timeout
> +syn keyword ngxDirective uwsgi_ssl_certificate
> +syn keyword ngxDirective uwsgi_ssl_certificate_key
>  syn keyword ngxDirective uwsgi_ssl_ciphers
>  syn keyword ngxDirective uwsgi_ssl_crl
>  syn keyword ngxDirective uwsgi_ssl_name
> +syn keyword ngxDirective uwsgi_ssl_password_file
>  syn keyword ngxDirective uwsgi_ssl_protocols
>  syn keyword ngxDirective uwsgi_ssl_server_name
>  syn keyword ngxDirective uwsgi_ssl_session_reuse
>  syn keyword ngxDirective uwsgi_ssl_trusted_certificate
>  syn keyword ngxDirective uwsgi_ssl_verify
>  syn keyword ngxDirective uwsgi_ssl_verify_depth
>  syn keyword ngxDirective uwsgi_store
>  syn keyword ngxDirective uwsgi_store_access
> @@ -546,16 +568,26 @@ syn keyword ngxDirectiveThirdParty acces
>  syn keyword ngxDirectiveThirdParty accesskey_hashmethod
>  syn keyword ngxDirectiveThirdParty accesskey_signature
>
>  " Auth PAM Module <http://web.iti.upv.es/~sto/nginx/>
>  " HTTP Basic Authentication using PAM.
>  syn keyword ngxDirectiveThirdParty auth_pam
>  syn keyword ngxDirectiveThirdParty auth_pam_service_name
>
> +" Brotli Module <https://github.com/google/ngx_brotli>
> +" Nginx module for Brotli compression
> +syn keyword ngxDirectiveThirdParty brotli_static
> +syn keyword ngxDirectiveThirdParty brotli
> +syn keyword ngxDirectiveThirdParty brotli_types
> +syn keyword ngxDirectiveThirdParty brotli_buffers
> +syn keyword ngxDirectiveThirdParty brotli_comp_level
> +syn keyword ngxDirectiveThirdParty brotli_window
> +syn keyword ngxDirectiveThirdParty brotli_min_length
> +
>  " Cache Purge Module <http://labs.frickle.com/nginx_ngx_cache_purge/>
>  " Module adding ability to purge content from FastCGI and proxy caches.
>  syn keyword ngxDirectiveThirdParty fastcgi_cache_purge
>  syn keyword ngxDirectiveThirdParty proxy_cache_purge
>
>  " Chunkin Module <http://wiki.nginx.org/NginxHttpChunkinModule>
>  " HTTP 1.1 chunked-encoding request body support for Nginx.
>  syn keyword ngxDirectiveThirdParty chunkin
> @@ -664,16 +696,80 @@ syn keyword ngxDirectiveThirdParty js_re
>  syn keyword ngxDirectiveThirdParty js_set
>  syn keyword ngxDirectiveThirdParty js_utf8
>
>  " Log Request Speed <http://wiki.nginx.org/NginxHttpLogRequestSpeed>
>  " Log the time it took to process each request.
>  syn keyword ngxDirectiveThirdParty log_request_speed_filter
>  syn keyword ngxDirectiveThirdParty log_request_speed_filter_timeout
>
> +
> +" Lua Module <https://github.com/openresty/lua-nginx-module>
> +" Embed the Power of Lua into NGINX HTTP servers
> +syn keyword ngxDirectiveThirdParty lua_use_default_type
> +syn keyword ngxDirectiveThirdParty lua_code_cache
> +syn keyword ngxDirectiveThirdParty lua_regex_cache_max_entries
> +syn keyword ngxDirectiveThirdParty lua_regex_match_limit
> +syn keyword ngxDirectiveThirdParty lua_package_path
> +syn keyword ngxDirectiveThirdParty lua_package_cpath
> +syn keyword ngxDirectiveThirdParty init_by_lua
> +syn keyword ngxDirectiveThirdParty init_by_lua_block
> +syn keyword ngxDirectiveThirdParty init_by_lua_file
> +syn keyword ngxDirectiveThirdParty init_worker_by_lua
> +syn keyword ngxDirectiveThirdParty init_worker_by_lua_block
> +syn keyword ngxDirectiveThirdParty init_worker_by_lua_file
> +syn keyword ngxDirectiveThirdParty set_by_lua
> +syn keyword ngxDirectiveThirdParty set_by_lua_block
> +syn keyword ngxDirectiveThirdParty set_by_lua_file
> +syn keyword ngxDirectiveThirdParty content_by_lua
> +syn keyword ngxDirectiveThirdParty content_by_lua_block
> +syn keyword ngxDirectiveThirdParty content_by_lua_file
> +syn keyword ngxDirectiveThirdParty rewrite_by_lua
> +syn keyword ngxDirectiveThirdParty rewrite_by_lua_block
> +syn keyword ngxDirectiveThirdParty rewrite_by_lua_file
> +syn keyword ngxDirectiveThirdParty access_by_lua
> +syn keyword ngxDirectiveThirdParty access_by_lua_block
> +syn keyword ngxDirectiveThirdParty access_by_lua_file
> +syn keyword ngxDirectiveThirdParty header_filter_by_lua
> +syn keyword ngxDirectiveThirdParty header_filter_by_lua_block
> +syn keyword ngxDirectiveThirdParty header_filter_by_lua_file
> +syn keyword ngxDirectiveThirdParty body_filter_by_lua
> +syn keyword ngxDirectiveThirdParty body_filter_by_lua_block
> +syn keyword ngxDirectiveThirdParty body_filter_by_lua_file
> +syn keyword ngxDirectiveThirdParty log_by_lua
> +syn keyword ngxDirectiveThirdParty log_by_lua_block
> +syn keyword ngxDirectiveThirdParty log_by_lua_file
> +syn keyword ngxDirectiveThirdParty balancer_by_lua_block
> +syn keyword ngxDirectiveThirdParty balancer_by_lua_file
> +syn keyword ngxDirectiveThirdParty lua_need_request_body
> +syn keyword ngxDirectiveThirdParty ssl_certificate_by_lua_block
> +syn keyword ngxDirectiveThirdParty ssl_certificate_by_lua_file
> +syn keyword ngxDirectiveThirdParty lua_shared_dict
> +syn keyword ngxDirectiveThirdParty lua_socket_connect_timeout
> +syn keyword ngxDirectiveThirdParty lua_socket_send_timeout
> +syn keyword ngxDirectiveThirdParty lua_socket_send_lowat
> +syn keyword ngxDirectiveThirdParty lua_socket_read_timeout
> +syn keyword ngxDirectiveThirdParty lua_socket_buffer_size
> +syn keyword ngxDirectiveThirdParty lua_socket_pool_size
> +syn keyword ngxDirectiveThirdParty lua_socket_keepalive_timeout
> +syn keyword ngxDirectiveThirdParty lua_socket_log_errors
> +syn keyword ngxDirectiveThirdParty lua_ssl_ciphers
> +syn keyword ngxDirectiveThirdParty lua_ssl_crl
> +syn keyword ngxDirectiveThirdParty lua_ssl_protocols
> +syn keyword ngxDirectiveThirdParty lua_ssl_trusted_certificate
> +syn keyword ngxDirectiveThirdParty lua_ssl_verify_depth
> +syn keyword ngxDirectiveThirdParty lua_http10_buffering
> +syn keyword ngxDirectiveThirdParty rewrite_by_lua_no_postpone
> +syn keyword ngxDirectiveThirdParty access_by_lua_no_postpone
> +syn keyword ngxDirectiveThirdParty
> lua_transform_underscores_in_response_headers
> +syn keyword ngxDirectiveThirdParty lua_check_client_abort
> +syn keyword ngxDirectiveThirdParty lua_max_pending_timers
> +syn keyword ngxDirectiveThirdParty lua_max_running_timers
> +
> +
>  " Memc Module <http://wiki.nginx.org/NginxHttpMemcModule>
>  " An extended version of the standard memcached module that supports set,
> add, delete, and many more memcached commands.
>  syn keyword ngxDirectiveThirdParty memc_buffer_size
>  syn keyword ngxDirectiveThirdParty memc_cmds_allowed
>  syn keyword ngxDirectiveThirdParty memc_connect_timeout
>  syn keyword ngxDirectiveThirdParty memc_flags_to_last_modified
>  syn keyword ngxDirectiveThirdParty memc_next_upstream
>  syn keyword ngxDirectiveThirdParty memc_pass
> @@ -814,22 +910,23 @@ syn keyword ngxDirectiveThirdParty xss_c
>  syn keyword ngxDirectiveThirdParty xss_get
>  syn keyword ngxDirectiveThirdParty xss_input_types
>  syn keyword ngxDirectiveThirdParty xss_output_type
>
>  " highlight
>
>  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 ngxLocationPath String
> +hi link ngxLocationNamedLoc Identifier
>
>  hi link ngxBoolean Boolean
> +hi link ngxRewriteFlag Boolean
>  hi link ngxDirectiveBlock Statement
>  hi link ngxDirectiveImportant Type
>  hi link ngxDirectiveControl Keyword
>  hi link ngxDirectiveError Constant
>  hi link ngxDirectiveDeprecated Error
>  hi link ngxDirective Identifier
>  hi link ngxDirectiveThirdParty Special
>
>
>


-- 
OOO
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20160307/6dd3f871/attachment.html>


More information about the nginx-devel mailing list