%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: nginx
file_extensions:
- conf.erb
- conf
- nginx.conf
- mime.types
- fastcgi_params
- scgi_params
- uwsgi_params
scope: source.nginx
contexts:
main:
- match: \#.*
scope: comment.line.number-sign
- match: '\b(events) +\{'
captures:
1: storage.type.context.nginx
push:
- meta_scope: meta.context.events.nginx
- match: '\}'
pop: true
- include: main
- match: '\b(http) +\{'
captures:
1: storage.type.context.nginx
push:
- meta_scope: meta.context.http.nginx
- match: '\}'
pop: true
- include: main
- match: '\b(types) +\{'
captures:
1: storage.type.context.nginx
push:
- meta_scope: meta.context.types.nginx
- match: '\}'
pop: true
- include: main
- match: '\b(server) +\{'
captures:
1: storage.type.context.nginx
push:
- meta_scope: meta.context.server.nginx
- match: '\}'
pop: true
- include: main
- match: '\b(location) +[\^]?~[\*]? +(.*?)\{'
captures:
1: storage.type.context.location.nginx
2: string.regexp.nginx
push:
- meta_scope: meta.context.location.nginx
- match: '\}'
pop: true
- include: main
- match: '\b(location) +(.*?)\{'
captures:
1: storage.type.context.location.nginx
2: entity.name.context.location.nginx
push:
- meta_scope: meta.context.location.nginx
- match: '\}'
pop: true
- include: main
- match: '\b(upstream) +(.*?)\{'
captures:
1: storage.type.context.nginx
2: entity.name.context.location.nginx
push:
- meta_scope: meta.context.upstream.nginx
- match: '\}'
pop: true
- include: main
- match: \b(if) +\(
captures:
1: keyword.control.nginx
push:
- match: \)
pop: true
- include: values
- match: '\{'
push:
- meta_scope: meta.block.nginx
- match: '\}'
pop: true
- include: main
- match: \b(daemon|env|debug_points|error_log|include|lock_file|master_process|pid|ssl_engine|timer_resolution|user|worker_cpu_affinity|worker_priority|worker_processes|worker_rlimit_core|worker_rlimit_nofile|worker_rlimit_sigpending|working_directory)\b
captures:
1: keyword.directive.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(accept_mutex|accept_mutex_delay|debug_connection|devpoll_changes|devpoll_events|epoll_events|kqueue_changes|kqueue_events|multi_accept|rtsig_signo|rtsig_overflow_events|rtsig_overflow_test|rtsig_overflow_threshold|use|worker_connections)\b
captures:
1: keyword.directive.module.events.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(aio|alias|chunked_transfer_encoding|client_body_in_file_only|client_body_in_single_buffer|client_body_buffer_size|client_body_temp_path|client_body_timeout|client_header_buffer_size|client_header_timeout|client_max_body_size|connection_pool_size|default_type|directio|error_page|if_modified_since|internal|keepalive_disable|keepalive_timeout|keepalive_requests|large_client_header_buffers|limit_except|limit_rate|limit_rate_after|lingering_close|lingering_time|lingering_timeout|listen|log_not_found|log_subrequest|msie_padding|msie_refresh|open_file_cache|open_file_cache_errors|open_file_cache_min_uses|open_file_cache_valid|optimize_server_names|port_in_redirect|post_action|recursive_error_pages|request_pool_size|reset_timedout_connection|resolver|resolver_timeout|root|satisfy|satisfy_any|send_timeout|sendfile|server_name|server_name_in_redirect|server_names_hash_max_size|server_names_hash_bucket_size|server_tokens|tcp_nodelay|tcp_nopush|try_files|types\ |underscores_in_hashes|variables_hash_bucket_size|variables_hash_max_size|types_hash_max_size)\b
captures:
1: keyword.directive.module.http.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(set_real_ip_from|real_ip_recursive|real_ip_header)\b
captures:
1: keyword.directive.module.http.realip.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(allow|deny)\b
captures:
1: keyword.directive.module.http.access.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(auth_basic|auth_basic_user_file)\b
captures:
1: keyword.directive.module.http.auth_basic.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(autoindex|autoindex_exact_size|autoindex_localtime)\b
captures:
1: keyword.directive.module.http.autoindex.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(ancient_browser|ancient_browser_value|modern_browser|modern_browser_value)\b
captures:
1: keyword.directive.module.http.browser.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(charset|charset_map|override_charset|source_charset)\b
captures:
1: keyword.directive.module.http.charset.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(empty_gif)\b
captures:
1: keyword.directive.module.http.empty_gif.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(fastcgi_bind|fastcgi_buffer_size|fastcgi_buffers|fastcgi_cache|fastcgi_cache_key|fastcgi_cache_path|fastcgi_cache_methods|fastcgi_cache_min_uses|fastcgi_cache_use_stale|fastcgi_cache_valid|fastcgi_connect_timeout|fastcgi_index|fastcgi_hide_header|fastcgi_ignore_client_abort|fastcgi_ignore_headers|fastcgi_intercept_errors|fastcgi_max_temp_file_size|fastcgi_no_cache|fastcgi_next_upstream|fastcgi_param|fastcgi_pass|fastcgi_pass_header|fastcgi_pass_request_body|fastcgi_pass_request_headers|fastcgi_read_timeout|fastcgi_redirect_errors|fastcgi_send_timeout|fastcgi_split_path_info|fastcgi_store|fastcgi_store_access|fastcgi_temp_path)\b
captures:
1: keyword.directive.module.http.fastcgi.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(geo)\b
captures:
1: keyword.directive.module.http.geo.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(gzip|gzip_buffers|gzip_comp_level|gzip_disable|gzip_http_version|gzip_min_length|gzip_proxied|gzip_types|gzip_vary)\b
captures:
1: keyword.directive.module.http.gzip.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(gzip_static|gzip_disable|gzip_http_version|gzip_proxied|gzip_vary)\b
captures:
1: keyword.directive.module.http.gzip_static.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(add_header|expires)\b
captures:
1: keyword.directive.module.http.headers.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(index)\b
captures:
1: keyword.directive.module.http.index.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(limit_req_log_level|limit_req_zone|limit_req)\b
scope: punctuation.definition.variable
captures:
1: keyword.directive.module.http.limit_req.nginx
- match: \b(limit_zone|limit_conn|limit_conn_log_level)\b
captures:
1: keyword.directive.module.http.limit_zone.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(limit_conn_zone|limit_conn|limit_conn_log_level)\b
captures:
1: keyword.directive.module.http.limit_conn.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(access_log|log_format|open_log_file_cache)\b
captures:
1: keyword.directive.module.http.log.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: '\b(map) +(\$[A-Za-z0-9\_]+) +(\$[A-Za-z0-9\_]+) *\{'
captures:
1: storage.type.context.nginx
2: variable.other.nginx
3: variable.other.nginx
push:
- meta_scope: meta.context.map.nginx
- match: '\}'
pop: true
- include: values
- match: ;
scope: punctuation.definition.map.nginx
- match: \#.*
scope: comment.line.number-sign
- match: \b(map_hash_max_size|map_hash_bucket_size)\b
captures:
1: keyword.directive.module.http.map.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(memcached_pass|memcached_connect_timeout|memcached_read_timeout|memcached_send_timeout|memcached_buffer_size|memcached_next_upstream)\b
captures:
1: keyword.directive.module.http.memcached.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(proxy_bind|proxy_buffer_size|proxy_buffering|proxy_buffers|proxy_busy_buffers_size|proxy_cache|proxy_cache_bypass|proxy_cache_key|proxy_cache_methods|proxy_cache_min_uses|proxy_cache_path|proxy_cache_use_stale|proxy_cache_valid|proxy_connect_timeout|proxy_headers_hash_bucket_size|proxy_headers_hash_max_size|proxy_hide_header|proxy_ignore_client_abort|proxy_ignore_headers|proxy_intercept_errors|proxy_max_temp_file_size|proxy_method|proxy_next_upstream|proxy_no_cache|proxy_pass|proxy_http_version|proxy_pass_header|proxy_pass_request_body|proxy_pass_request_headers|proxy_redirect|proxy_read_timeout|proxy_redirect_errors|proxy_send_lowat|proxy_send_timeout|proxy_set_body|proxy_set_header|proxy_ssl_session_reuse|proxy_store|proxy_store_access|proxy_temp_file_write_size|proxy_temp_path|proxy_upstream_fail_timeout|proxy_upstream_max_fails)\b
captures:
1: keyword.directive.module.http.proxy.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(valid_referers)\b
captures:
1: keyword.directive.module.http.referer.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(rewrite_log|set|uninitialized_variable_warn)\b
captures:
1: keyword.directive.module.http.rewrite.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(break|return)\b
captures:
1: support.function.module.http.rewrite.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(rewrite)\b *(".+?(?<!\\)"|'.+?(?<!\\)'|((.+?)(?<!\\)\s))
captures:
1: keyword.directive.module.http.rewrite.nginx
2: string.regexp.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(scgi_bind|scgi_buffer_size|scgi_buffering|scgi_buffers|scgi_busy_buffers_size|scgi_cache|scgi_cache_bypass|scgi_cache_key|scgi_cache_methods|scgi_cache_min_uses|scgi_cache_path|scgi_cache_use_stale|scgi_cache_valid|scgi_connect_timeout|scgi_hide_header|scgi_ignore_client_abort|scgi_ignore_headers|scgi_intercept_errors|scgi_max_temp_file_size|scgi_next_upstream|scgi_no_cache|scgi_param|scgi_pass|scgi_pass_header|scgi_pass_request_body|scgi_pass_request_headers|scgi_read_timeout|scgi_send_timeout|scgi_store|scgi_store_access|scgi_temp_file_write_size|scgi_temp_path)\b
captures:
1: keyword.directive.module.http.scgi.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(split_clients)\b
captures:
1: keyword.directive.module.http.split_clients.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(ssi|ssi_silent_errors|ssi_types|ssi_value_length)\b
captures:
1: keyword.directive.module.http.ssi.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(ssl|ssl_certificate|ssl_certificate_key|ssl_client_certificate|ssl_dhparam|ssl_ciphers|ssl_crl|ssl_prefer_server_ciphers|ssl_protocols|ssl_verify_client|ssl_verify_depth|ssl_session_cache|ssl_session_timeout|ssl_engine)\b
captures:
1: keyword.directive.module.http.ssl.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(ip_hash|server)\b
captures:
1: keyword.directive.module.http.upstream.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(userid|userid_domain|userid_expires|userid_name|userid_p3p|userid_path|userid_service)\b
captures:
1: keyword.directive.module.http.userid.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: \b(uwsgi_bind|uwsgi_buffer_size|uwsgi_buffering|uwsgi_buffers|uwsgi_busy_buffers_size|uwsgi_cache|uwsgi_cache_bypass|uwsgi_cache_key|uwsgi_cache_methods|uwsgi_cache_min_uses|uwsgi_cache_path|uwsgi_cache_use_stale|uwsgi_cache_valid|uwsgi_connect_timeout|uwsgi_hide_header|uwsgi_ignore_client_abort|uwsgi_ignore_headers|uwsgi_intercept_errors|uwsgi_max_temp_file_size|uwsgi_modifier1|uwsgi_modifier2|uwsgi_next_upstream|uwsgi_no_cache|uwsgi_param|uwsgi_pass|uwsgi_pass_header|uwsgi_pass_request_body|uwsgi_pass_request_headers|uwsgi_read_timeout|uwsgi_send_timeout|uwsgi_store|uwsgi_store_access|uwsgi_string|uwsgi_temp_file_write_size|uwsgi_temp_path)\b
captures:
1: keyword.directive.module.http.uwsgi.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: '\b.*_by_lua_block\s+\{'
push: Packages/Lua/Lua.sublime-syntax
with_prototype:
- match: '^\s*\}'
pop: 3
- match: '\b([a-zA-Z0-9\_]+)\s+'
captures:
1: keyword.directive.module.unsupported.nginx
push:
- meta_scope: punctuation.definition.variable
- match: (;|$)
pop: true
- include: values
- match: \b(stub_status)\b
captures:
1: keyword.directive.module.http.stub_status.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
- match: '\b([a-z]+\/[a-z0-9\-\.\+]+)\b'
captures:
1: keyword.directive.module.http.nginx
push:
- meta_scope: punctuation.definition.variable
- match: ;
pop: true
- include: values
values:
- include: variables
- match: '[\t ]([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|[0-9a-f:]+)(\/[0-9]{2})?(?=[\t ;])'
captures:
1: string.ipaddress.nginx
2: constant.numeric.cidr.nginx
- match: '[\t ](=?[0-9][0-9\.]*[bBkKmMgGtTsShHdD]?)(?=[\t ;])'
captures:
1: constant.numeric.nginx
- match: '[\t ](on|off|true|false)(?=[\t ;])'
scope: constant.language.nginx
- match: '[\t ](kqueue|rtsig|epoll|\/dev\/poll|select|poll|eventport|max|all|default_server|default|main|crit|error|debug|warn|notice|last)(?=[\t ;])'
scope: constant.language.nginx
- match: \\.*\ |\~\*|\~|\!\~\*|\!\~
scope: string.regexp.nginx
- match: \^.*?\$
scope: string.regexp.nginx
- match: '"'
push:
- meta_scope: string.quoted.double.nginx
- match: '"'
pop: true
- match: \\"
scope: constant.character.escape.nginx
- include: variables
- match: "'"
push:
- meta_scope: string.quoted.single.nginx
- match: "'"
pop: true
- match: \\'
scope: constant.character.escape.nginx
- include: variables
variables:
- match: '(\$[A-Za-z0-9\_]+)\b'
scope: variable.other.nginx