Willy Tarreau | 5e47a72 | 2007-04-01 10:09:10 +0200 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: HAproxy |
| 3 | " Maintainer: Bruno Michel <brmichel@free.fr> |
| 4 | " Last Change: Mar 30, 2007 |
| 5 | " Version: 0.3 |
| 6 | " URL: http://haproxy.1wt.eu/ |
| 7 | " URL: http://vim.sourceforge.net/scripts/script.php?script_id=1845 |
| 8 | |
| 9 | " It is suggested to add the following line to $HOME/.vimrc : |
| 10 | " au BufRead,BufNewFile haproxy* set ft=haproxy |
| 11 | |
| 12 | " For version 5.x: Clear all syntax items |
| 13 | " For version 6.x: Quit when a syntax file was already loaded |
| 14 | if version < 600 |
| 15 | syntax clear |
| 16 | elseif exists("b:current_syntax") |
| 17 | finish |
| 18 | endif |
| 19 | |
| 20 | if version >= 600 |
| 21 | setlocal iskeyword=_,-,a-z,A-Z,48-57 |
| 22 | else |
| 23 | set iskeyword=_,-,a-z,A-Z,48-57 |
| 24 | endif |
| 25 | |
| 26 | |
| 27 | " Escaped chars |
| 28 | syn match hapEscape +\\\(\\\| \|n\|r\|t\|#\|x\x\x\)+ |
| 29 | |
| 30 | " Comments |
| 31 | syn match hapComment /#.*$/ contains=hapTodo |
| 32 | syn keyword hapTodo contained TODO FIXME XXX |
| 33 | syn case ignore |
| 34 | |
| 35 | " Sections |
| 36 | syn match hapSection /^\s*\(global\|defaults\)/ |
| 37 | syn match hapSection /^\s*\(listen\|frontend\|backend\|ruleset\)/ skipwhite nextgroup=hapSectLabel |
| 38 | syn match hapSectLabel /\S\+/ skipwhite nextgroup=hapIp1 contained |
| 39 | syn match hapIp1 /\(\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}\)\?:\d\{1,5}/ nextgroup=hapIp2 contained |
| 40 | syn match hapIp2 /,\(\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}\)\?:\d\{1,5}/hs=s+1 nextgroup=hapIp2 contained |
| 41 | |
| 42 | " Parameters |
Tim Duesterhus | 86e6b6e | 2019-05-14 20:57:59 +0200 | [diff] [blame] | 43 | syn keyword hapParam chroot cliexp |
Willy Tarreau | 5e47a72 | 2007-04-01 10:09:10 +0200 | [diff] [blame] | 44 | syn keyword hapParam daemon debug disabled |
| 45 | syn keyword hapParam enabled |
| 46 | syn keyword hapParam fullconn |
Willy Tarreau | 33a89a2 | 2007-09-17 11:30:23 +0200 | [diff] [blame] | 47 | syn keyword hapParam gid grace group |
Willy Tarreau | 5e47a72 | 2007-04-01 10:09:10 +0200 | [diff] [blame] | 48 | syn keyword hapParam maxconn monitor-uri |
| 49 | syn keyword hapParam nbproc noepoll nopoll |
| 50 | syn keyword hapParam pidfile |
| 51 | syn keyword hapParam quiet |
| 52 | syn keyword hapParam redispatch retries |
| 53 | syn keyword hapParam reqallow reqdel reqdeny reqpass reqtarpit skipwhite nextgroup=hapRegexp |
| 54 | syn keyword hapParam reqiallow reqidel reqideny reqipass reqitarpit skipwhite nextgroup=hapRegexp |
| 55 | syn keyword hapParam rspdel rspdeny skipwhite nextgroup=hapRegexp |
| 56 | syn keyword hapParam rspidel rspideny skipwhite nextgroup=hapRegexp |
| 57 | syn keyword hapParam reqsetbe reqisetbe skipwhite nextgroup=hapRegexp2 |
| 58 | syn keyword hapParam reqadd reqiadd rspadd rspiadd |
Tim Duesterhus | 86e6b6e | 2019-05-14 20:57:59 +0200 | [diff] [blame] | 59 | syn keyword hapParam server source srvexp |
Willy Tarreau | 33a89a2 | 2007-09-17 11:30:23 +0200 | [diff] [blame] | 60 | syn keyword hapParam uid ulimit-n user |
Willy Tarreau | 5e47a72 | 2007-04-01 10:09:10 +0200 | [diff] [blame] | 61 | syn keyword hapParam reqrep reqirep rsprep rspirep skipwhite nextgroup=hapRegexp |
| 62 | syn keyword hapParam errorloc errorloc302 errorloc303 skipwhite nextgroup=hapStatus |
| 63 | syn keyword hapParam default_backend skipwhite nextgroup=hapSectLabel |
| 64 | syn keyword hapParam appsession skipwhite nextgroup=hapAppSess |
| 65 | syn keyword hapParam bind skipwhite nextgroup=hapIp1 |
| 66 | syn keyword hapParam balance skipwhite nextgroup=hapBalance |
| 67 | syn keyword hapParam cookie skipwhite nextgroup=hapCookieNam |
| 68 | syn keyword hapParam capture skipwhite nextgroup=hapCapture |
| 69 | syn keyword hapParam dispatch skipwhite nextgroup=hapIpPort |
| 70 | syn keyword hapParam source skipwhite nextgroup=hapIpPort |
| 71 | syn keyword hapParam mode skipwhite nextgroup=hapMode |
Willy Tarreau | f401102 | 2007-04-01 11:05:06 +0200 | [diff] [blame] | 72 | syn keyword hapParam monitor-net skipwhite nextgroup=hapIPv4Mask |
Willy Tarreau | 5e47a72 | 2007-04-01 10:09:10 +0200 | [diff] [blame] | 73 | syn keyword hapParam option skipwhite nextgroup=hapOption |
| 74 | syn keyword hapParam stats skipwhite nextgroup=hapStats |
| 75 | syn keyword hapParam server skipwhite nextgroup=hapServerN |
| 76 | syn keyword hapParam source skipwhite nextgroup=hapServerEOL |
| 77 | syn keyword hapParam log skipwhite nextgroup=hapGLog,hapLogIp |
| 78 | |
| 79 | " Options and additional parameters |
| 80 | syn keyword hapAppSess contained len timeout |
| 81 | syn keyword hapBalance contained roundrobin source |
| 82 | syn keyword hapLen contained len |
| 83 | syn keyword hapGLog contained global |
| 84 | syn keyword hapMode contained http tcp health |
Tim Duesterhus | 10c6c16 | 2019-05-14 20:58:00 +0200 | [diff] [blame] | 85 | syn keyword hapOption contained abortonclose allbackups checkcache clitcpka dontlognull forwardfor |
Willy Tarreau | 5e47a72 | 2007-04-01 10:09:10 +0200 | [diff] [blame] | 86 | syn keyword hapOption contained httpchk httpclose httplog keepalive logasap persist srvtcpka ssl-hello-chk |
| 87 | syn keyword hapOption contained tcplog tcpka tcpsplice |
Willy Tarreau | f401102 | 2007-04-01 11:05:06 +0200 | [diff] [blame] | 88 | syn keyword hapOption contained except skipwhite nextgroup=hapIPv4Mask |
Willy Tarreau | 5e47a72 | 2007-04-01 10:09:10 +0200 | [diff] [blame] | 89 | syn keyword hapStats contained uri realm auth scope enable |
| 90 | syn keyword hapLogFac contained kern user mail daemon auth syslog lpr news nextgroup=hapLogLvl skipwhite |
| 91 | syn keyword hapLogFac contained uucp cron auth2 ftp ntp audit alert cron2 nextgroup=hapLogLvl skipwhite |
| 92 | syn keyword hapLogFac contained local0 local1 local2 local3 local4 local5 local6 local7 nextgroup=hapLogLvl skipwhite |
| 93 | syn keyword hapLogLvl contained emerg alert crit err warning notice info debug |
| 94 | syn keyword hapCookieKey contained rewrite insert nocache postonly indirect prefix nextgroup=hapCookieKey skipwhite |
| 95 | syn keyword hapCapture contained cookie nextgroup=hapNameLen skipwhite |
| 96 | syn keyword hapCapture contained request response nextgroup=hapHeader skipwhite |
| 97 | syn keyword hapHeader contained header nextgroup=hapNameLen skipwhite |
| 98 | syn keyword hapSrvKey contained backup cookie check inter rise fall port source minconn maxconn weight usesrc |
| 99 | syn match hapStatus contained /\d\{3}/ |
Willy Tarreau | f401102 | 2007-04-01 11:05:06 +0200 | [diff] [blame] | 100 | syn match hapIPv4Mask contained /\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}\(\/\d\{1,2}\)\?/ |
Willy Tarreau | 5e47a72 | 2007-04-01 10:09:10 +0200 | [diff] [blame] | 101 | syn match hapLogIp contained /\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}/ nextgroup=hapLogFac skipwhite |
| 102 | syn match hapIpPort contained /\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}:\d\{1,5}/ |
| 103 | syn match hapServerAd contained /\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}\(:[+-]\?\d\{1,5}\)\?/ nextgroup=hapSrvEOL skipwhite |
| 104 | syn match hapNameLen contained /\S\+/ nextgroup=hapLen skipwhite |
| 105 | syn match hapCookieNam contained /\S\+/ nextgroup=hapCookieKey skipwhite |
| 106 | syn match hapServerN contained /\S\+/ nextgroup=hapServerAd skipwhite |
| 107 | syn region hapSrvEOL contained start=/\S/ end=/$/ contains=hapSrvKey |
| 108 | syn region hapRegexp contained start=/\S/ end=/\(\s\|$\)/ skip=/\\ / nextgroup=hapRegRepl skipwhite |
| 109 | syn region hapRegRepl contained start=/\S/ end=/$/ contains=hapComment,hapEscape,hapBackRef |
| 110 | syn region hapRegexp2 contained start=/\S/ end=/\(\s\|$\)/ skip=/\\ / nextgroup=hapSectLabel skipwhite |
| 111 | syn match hapBackref contained /\\\d/ |
| 112 | |
| 113 | |
| 114 | " Transparent is a Vim keyword, so we need a regexp to match it |
| 115 | syn match hapParam +transparent+ |
| 116 | syn match hapOption +transparent+ contained |
| 117 | |
| 118 | |
| 119 | " Define the default highlighting. |
| 120 | " For version 5.7 and earlier: only when not done already |
| 121 | " For version 5.8 and later: only when an item doesn't have highlighting yet |
| 122 | if version < 508 |
| 123 | command -nargs=+ HiLink hi link <args> |
| 124 | else |
| 125 | command -nargs=+ HiLink hi def link <args> |
| 126 | endif |
| 127 | |
| 128 | HiLink hapEscape SpecialChar |
| 129 | HiLink hapBackRef Special |
| 130 | HiLink hapComment Comment |
| 131 | HiLink hapTodo Todo |
| 132 | HiLink hapSection Constant |
| 133 | HiLink hapSectLabel Identifier |
| 134 | HiLink hapParam Keyword |
| 135 | |
| 136 | HiLink hapRegexp String |
| 137 | HiLink hapRegexp2 hapRegexp |
| 138 | HiLink hapIp1 Number |
| 139 | HiLink hapIp2 hapIp1 |
| 140 | HiLink hapLogIp hapIp1 |
| 141 | HiLink hapIpPort hapIp1 |
Willy Tarreau | f401102 | 2007-04-01 11:05:06 +0200 | [diff] [blame] | 142 | HiLink hapIPv4Mask hapIp1 |
Willy Tarreau | 5e47a72 | 2007-04-01 10:09:10 +0200 | [diff] [blame] | 143 | HiLink hapServerAd hapIp1 |
| 144 | HiLink hapStatus Number |
| 145 | |
| 146 | HiLink hapOption Operator |
| 147 | HiLink hapAppSess hapOption |
| 148 | HiLink hapBalance hapOption |
| 149 | HiLink hapCapture hapOption |
| 150 | HiLink hapCookieKey hapOption |
| 151 | HiLink hapHeader hapOption |
| 152 | HiLink hapGLog hapOption |
| 153 | HiLink hapLogFac hapOption |
| 154 | HiLink hapLogLvl hapOption |
| 155 | HiLink hapMode hapOption |
| 156 | HiLink hapStats hapOption |
| 157 | HiLink hapLen hapOption |
| 158 | HiLink hapSrvKey hapOption |
| 159 | |
| 160 | |
| 161 | delcommand HiLink |
| 162 | |
| 163 | let b:current_syntax = "haproxy" |
| 164 | " vim: ts=8 |