[PATCH 3 of 4] Contrib: vim syntax, highlight HTTP status code

othree othree at gmail.com
Fri Mar 3 10:56:58 UTC 2017


# HG changeset patch
# User othree <othree at gmail.com>
# Date 1488526564 -28800
#      Fri Mar 03 15:36:04 2017 +0800
# Node ID b88ed85b7b4f3ea5a586f4f58251481348c502f1
# Parent  47796d6e4c8af080e515fa45699cf23cd10cf7ad
Contrib: vim syntax, highlight HTTP status code.

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
@@ -61,31 +61,37 @@ syn keyword ngxListenOptions accept_filt
 syn keyword ngxListenOptions deferred       contained
 syn keyword ngxListenOptions bind           contained
 syn keyword ngxListenOptions ipv6only       contained
 syn keyword ngxListenOptions reuseport      contained
 syn keyword ngxListenOptions so_keepalive   contained
 syn keyword ngxListenOptions keepidle       contained
 
 syn keyword ngxDirectiveControl break
-syn keyword ngxDirectiveControl return
+syn keyword ngxDirectiveControl return nextgroup=ngxStatusCode skipwhite skipempty
 syn keyword ngxDirectiveControl rewrite nextgroup=ngxRewriteURI skipwhite skipempty
 syn keyword ngxDirectiveControl set
 
+syn match ngxStatusCode  /\d\d\d/ contained
+syn match ngxStatusCodes /\d\d\d/ contained contains=ngxStatusCode nextgroup=ngxStatusCode skipwhite skipempty
+
 syn match ngxRewriteURI  /\S\+/ contained contains=ngxVariableString nextgroup=ngxRewritedURI skipwhite skipempty
 syn match ngxRewritedURI /\S\+/ contained contains=ngxVariableString nextgroup=ngxRewriteFlag skipwhite skipempty
 
 syn keyword ngxRewriteFlag last      contained
 syn keyword ngxRewriteFlag break     contained
 syn keyword ngxRewriteFlag redirect  contained
 syn keyword ngxRewriteFlag permanent contained
 
-syn keyword ngxDirectiveError error_page
+syn keyword ngxDirectiveError error_page nextgroup=ngxErrorStatusCode skipwhite skipempty
 syn keyword ngxDirectiveError post_action
 
+syn match ngxErrorStatusCode   /\d\d\d/  contained contains=ngxStatusCode nextgroup=ngxErrorResponseCode skipwhite skipempty
+syn match ngxErrorResponseCode /=\d\d\d/ contained contains=ngxStatusCode
+
 syn keyword ngxDirectiveDeprecated connections
 syn keyword ngxDirectiveDeprecated imap
 syn keyword ngxDirectiveDeprecated limit_zone
 syn keyword ngxDirectiveDeprecated mysql_test
 syn keyword ngxDirectiveDeprecated open_file_cache_retest
 syn keyword ngxDirectiveDeprecated optimize_server_names
 syn keyword ngxDirectiveDeprecated satisfy_any
 syn keyword ngxDirectiveDeprecated so_keepalive
@@ -270,23 +276,23 @@ syn keyword ngxDirective keepalive_reque
 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
 syn keyword ngxDirective least_time
 syn keyword ngxDirective limit_conn
 syn keyword ngxDirective limit_conn_log_level
-syn keyword ngxDirective limit_conn_status
+syn keyword ngxDirective limit_conn_status nextgroup=ngxStatusCode skipwhite skipempty
 syn keyword ngxDirective limit_conn_zone
 syn keyword ngxDirective limit_rate
 syn keyword ngxDirective limit_rate_after
 syn keyword ngxDirective limit_req
 syn keyword ngxDirective limit_req_log_level
-syn keyword ngxDirective limit_req_status
+syn keyword ngxDirective limit_req_status nextgroup=ngxStatusCode skipwhite skipempty
 syn keyword ngxDirective limit_req_zone
 syn keyword ngxDirective lingering_close
 syn keyword ngxDirective lingering_time
 syn keyword ngxDirective lingering_timeout
 syn keyword ngxDirective load_module
 syn keyword ngxDirective lock_file
 syn keyword ngxDirective log_format
 syn keyword ngxDirective log_not_found
@@ -359,17 +365,17 @@ syn keyword ngxDirective proxy_cache_loc
 syn keyword ngxDirective proxy_cache_lock_timeout
 syn keyword ngxDirective proxy_cache_max_range_offset
 syn keyword ngxDirective proxy_cache_methods
 syn keyword ngxDirective proxy_cache_min_uses
 syn keyword ngxDirective proxy_cache_path
 syn keyword ngxDirective proxy_cache_purge
 syn keyword ngxDirective proxy_cache_revalidate
 syn keyword ngxDirective proxy_cache_use_stale
-syn keyword ngxDirective proxy_cache_valid
+syn keyword ngxDirective proxy_cache_valid nextgroup=ngxStatusCodes skipwhite skipempty
 syn keyword ngxDirective proxy_connect_timeout
 syn keyword ngxDirective proxy_cookie_domain
 syn keyword ngxDirective proxy_cookie_path
 syn keyword ngxDirective proxy_download_rate
 syn keyword ngxDirective proxy_force_ranges
 syn keyword ngxDirective proxy_headers_hash_bucket_size
 syn keyword ngxDirective proxy_headers_hash_max_size
 syn keyword ngxDirective proxy_hide_header
@@ -2132,16 +2138,17 @@ syn keyword ngxDirectiveThirdParty xss_i
 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
+hi link ngxStatusCode Number
 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


More information about the nginx-devel mailing list