|
| 1 | +" Vim syntax file |
| 2 | +" Language: FlashMQ configuration file |
| 3 | + |
| 4 | +" |
| 5 | +" Goals: |
| 6 | +" |
| 7 | +" Make incorrect / unknown options stand out. Special attention is given to |
| 8 | +" also have this work correctly for blocks, E.G., the toplevel directive |
| 9 | +" `log_file` is colored in a global scope but not when it's used inside a |
| 10 | +" `listen` block |
| 11 | +" |
| 12 | +" https://vimdoc.sourceforge.net/htmldoc/syntax.html |
| 13 | +" |
| 14 | +" TODO: |
| 15 | +" - Test number of arguments, specifically: most options take 1 argument, but |
| 16 | +" fe. bridge__subscribe takes an optional second argument |
| 17 | +" - Deal with quoted options? |
| 18 | +" |
| 19 | + |
| 20 | +if exists("b:current_syntax") |
| 21 | + finish |
| 22 | +endif |
| 23 | +let b:current_syntax = "flashmq" |
| 24 | + |
| 25 | +syn region fmqComment display oneline start='^\s*#' end='$' |
| 26 | + |
| 27 | +" We "render" fmqWrongBlock as Error (which makes it red), but then also use |
| 28 | +" transparent which makes it be the color of the parent, so it all becomes a |
| 29 | +" neutral color. |
| 30 | +" Without the transparent+Error trick you would see fmqTopLevelDirective |
| 31 | +" highlighted inside blocks which is undesirable: you can't specify `log_file` |
| 32 | +" inside a `listen` block, so it shouldn't get colorized. |
| 33 | +" |
| 34 | +" Real blocks (like `listen` and `bridge`) are defined later and thus get a |
| 35 | +" higher priority, and will replace this match. |
| 36 | +syn region fmqWrongBlock start=+^.*{+ end=+}+ transparent contains=NONE,fmqComment |
| 37 | + |
| 38 | +hi link fmqComment Comment |
| 39 | +hi link fmqWrongBlock Error |
| 40 | +hi link fmqTopLevelDirective Type |
| 41 | + |
| 42 | +" The rest of this file has been dynamically generated |
| 43 | +" |
| 44 | +" Local scopes |
| 45 | +" |
| 46 | + |
| 47 | +syn match fmqTopLevelDirective "^\s*allow_anonymous\s" |
| 48 | +syn match fmqTopLevelDirective "^\s*allow_unsafe_clientid_chars\s" |
| 49 | +syn match fmqTopLevelDirective "^\s*allow_unsafe_username_chars\s" |
| 50 | +syn match fmq_bridge_Directive "^\s*address\s" contained |
| 51 | +syn match fmq_bridge_Directive "^\s*bridge_protocol_bit\s" contained |
| 52 | +syn match fmq_bridge_Directive "^\s*ca_dir\s" contained |
| 53 | +syn match fmq_bridge_Directive "^\s*ca_file\s" contained |
| 54 | +syn match fmq_bridge_Directive "^\s*clientid_prefix\s" contained |
| 55 | +syn match fmq_bridge_Directive "^\s*inet_protocol\s" contained |
| 56 | +syn match fmq_bridge_Directive "^\s*keepalive\s" contained |
| 57 | +syn match fmq_bridge_Directive "^\s*local_clean_start\s" contained |
| 58 | +syn match fmq_bridge_Directive "^\s*local_session_expiry_interval\s" contained |
| 59 | +syn match fmq_bridge_Directive "^\s*local_username\s" contained |
| 60 | +syn match fmq_bridge_Directive "^\s*max_incoming_topic_aliases\s" contained |
| 61 | +syn match fmq_bridge_Directive "^\s*max_outgoing_topic_aliases\s" contained |
| 62 | +syn match fmq_bridge_Directive "^\s*port\s" contained |
| 63 | +syn match fmq_bridge_Directive "^\s*protocol_version\s" contained |
| 64 | +syn match fmq_bridge_Directive "^\s*publish\s" contained |
| 65 | +syn match fmq_bridge_Directive "^\s*remote_clean_start\s" contained |
| 66 | +syn match fmq_bridge_Directive "^\s*remote_password\s" contained |
| 67 | +syn match fmq_bridge_Directive "^\s*remote_retain_available\s" contained |
| 68 | +syn match fmq_bridge_Directive "^\s*remote_session_expiry_interval\s" contained |
| 69 | +syn match fmq_bridge_Directive "^\s*remote_username\s" contained |
| 70 | +syn match fmq_bridge_Directive "^\s*subscribe\s" contained |
| 71 | +syn match fmq_bridge_Directive "^\s*tls\s" contained |
| 72 | +syn match fmq_bridge_Directive "^\s*use_saved_clientid\s" contained |
| 73 | +syn match fmqTopLevelDirective "^\s*client_initial_buffer_size\s" |
| 74 | +syn match fmqTopLevelDirective "^\s*client_max_write_buffer_size\s" |
| 75 | +syn match fmqTopLevelDirective "^\s*expire_retained_messages_after_seconds\s" |
| 76 | +syn match fmqTopLevelDirective "^\s*expire_sessions_after_seconds\s" |
| 77 | +syn match fmqTopLevelDirective "^\s*include_dir\s" |
| 78 | +syn match fmq_listen_Directive "^\s*allow_anonymous\s" contained |
| 79 | +syn match fmq_listen_Directive "^\s*client_verification_ca_dir\s" contained |
| 80 | +syn match fmq_listen_Directive "^\s*client_verification_ca_file\s" contained |
| 81 | +syn match fmq_listen_Directive "^\s*client_verification_still_do_authn\s" contained |
| 82 | +syn match fmq_listen_Directive "^\s*fullchain\s" contained |
| 83 | +syn match fmq_listen_Directive "^\s*haproxy\s" contained |
| 84 | +syn match fmq_listen_Directive "^\s*inet4_bind_address\s" contained |
| 85 | +syn match fmq_listen_Directive "^\s*inet6_bind_address\s" contained |
| 86 | +syn match fmq_listen_Directive "^\s*inet_protocol\s" contained |
| 87 | +syn match fmq_listen_Directive "^\s*port\s" contained |
| 88 | +syn match fmq_listen_Directive "^\s*privkey\s" contained |
| 89 | +syn match fmq_listen_Directive "^\s*protocol\s" contained |
| 90 | +syn match fmqTopLevelDirective "^\s*log_debug\s" |
| 91 | +syn match fmqTopLevelDirective "^\s*log_file\s" |
| 92 | +syn match fmqTopLevelDirective "^\s*log_level\s" |
| 93 | +syn match fmqTopLevelDirective "^\s*log_subscriptions\s" |
| 94 | +syn match fmqTopLevelDirective "^\s*max_event_loop_drift\s" |
| 95 | +syn match fmqTopLevelDirective "^\s*max_incoming_topic_alias_value\s" |
| 96 | +syn match fmqTopLevelDirective "^\s*max_outgoing_topic_alias_value\s" |
| 97 | +syn match fmqTopLevelDirective "^\s*max_packet_size\s" |
| 98 | +syn match fmqTopLevelDirective "^\s*minimum_wildcard_subscription_depth\s" |
| 99 | +syn match fmqTopLevelDirective "^\s*mosquitto_acl_file\s" |
| 100 | +syn match fmqTopLevelDirective "^\s*mosquitto_password_file\s" |
| 101 | +syn match fmqTopLevelDirective "^\s*overload_mode\s" |
| 102 | +syn match fmqTopLevelDirective "^\s*plugin\s" |
| 103 | +syn match fmqTopLevelDirective "^\s*plugin_opt_\s" |
| 104 | +syn match fmqTopLevelDirective "^\s*plugin_serialize_auth_checks\s" |
| 105 | +syn match fmqTopLevelDirective "^\s*plugin_serialize_init\s" |
| 106 | +syn match fmqTopLevelDirective "^\s*plugin_timer_period\s" |
| 107 | +syn match fmqTopLevelDirective "^\s*quiet\s" |
| 108 | +syn match fmqTopLevelDirective "^\s*retained_messages_delivery_limit\s" |
| 109 | +syn match fmqTopLevelDirective "^\s*retained_messages_mode\s" |
| 110 | +syn match fmqTopLevelDirective "^\s*retained_messages_node_limit\s" |
| 111 | +syn match fmqTopLevelDirective "^\s*rlimit_nofile\s" |
| 112 | +syn match fmqTopLevelDirective "^\s*shared_subscription_targeting\s" |
| 113 | +syn match fmqTopLevelDirective "^\s*storage_dir\s" |
| 114 | +syn match fmqTopLevelDirective "^\s*thread_count\s" |
| 115 | +syn match fmqTopLevelDirective "^\s*websocket_set_real_ip_from\s" |
| 116 | +syn match fmqTopLevelDirective "^\s*wildcard_subscription_deny_mode\s" |
| 117 | +syn match fmqTopLevelDirective "^\s*wills_enabled\s" |
| 118 | +syn match fmqTopLevelDirective "^\s*zero_byte_username_is_anonymous\s" |
| 119 | + |
| 120 | +" |
| 121 | +" Global scopes |
| 122 | +" |
| 123 | + |
| 124 | +syn region fmq_bridge_InnerBlock start="{" end="}" contains=fmq_bridge_Directive,fmqComment |
| 125 | +syn region fmq_bridge_Block start="^bridge\s" end="$" contains=fmq_bridge_InnerBlock |
| 126 | +hi link fmq_bridge_Directive Type |
| 127 | +hi link fmq_bridge_Block Statement |
| 128 | + |
| 129 | +syn region fmq_listen_InnerBlock start="{" end="}" contains=fmq_listen_Directive,fmqComment |
| 130 | +syn region fmq_listen_Block start="^listen\s" end="$" contains=fmq_listen_InnerBlock |
| 131 | +hi link fmq_listen_Directive Type |
| 132 | +hi link fmq_listen_Block Statement |
| 133 | + |
0 commit comments