blob: 8bdd71125beb9e0927ab91f008139aa23dd7120e [file] [log] [blame]
Willy Tarreau5e47a722007-04-01 10:09:10 +02001" 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
14if version < 600
15 syntax clear
16elseif exists("b:current_syntax")
17 finish
18endif
19
20if version >= 600
21 setlocal iskeyword=_,-,a-z,A-Z,48-57
22else
23 set iskeyword=_,-,a-z,A-Z,48-57
24endif
25
26
27" Escaped chars
28syn match hapEscape +\\\(\\\| \|n\|r\|t\|#\|x\x\x\)+
29
30" Comments
31syn match hapComment /#.*$/ contains=hapTodo
32syn keyword hapTodo contained TODO FIXME XXX
33syn case ignore
34
35" Sections
36syn match hapSection /^\s*\(global\|defaults\)/
37syn match hapSection /^\s*\(listen\|frontend\|backend\|ruleset\)/ skipwhite nextgroup=hapSectLabel
38syn match hapSectLabel /\S\+/ skipwhite nextgroup=hapIp1 contained
39syn match hapIp1 /\(\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}\)\?:\d\{1,5}/ nextgroup=hapIp2 contained
40syn 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
43syn keyword hapParam chroot cliexp clitimeout contimeout
44syn keyword hapParam daemon debug disabled
45syn keyword hapParam enabled
46syn keyword hapParam fullconn
47syn keyword hapParam gid grace
48syn keyword hapParam maxconn monitor-uri
49syn keyword hapParam nbproc noepoll nopoll
50syn keyword hapParam pidfile
51syn keyword hapParam quiet
52syn keyword hapParam redispatch retries
53syn keyword hapParam reqallow reqdel reqdeny reqpass reqtarpit skipwhite nextgroup=hapRegexp
54syn keyword hapParam reqiallow reqidel reqideny reqipass reqitarpit skipwhite nextgroup=hapRegexp
55syn keyword hapParam rspdel rspdeny skipwhite nextgroup=hapRegexp
56syn keyword hapParam rspidel rspideny skipwhite nextgroup=hapRegexp
57syn keyword hapParam reqsetbe reqisetbe skipwhite nextgroup=hapRegexp2
58syn keyword hapParam reqadd reqiadd rspadd rspiadd
59syn keyword hapParam server source srvexp srvtimeout
60syn keyword hapParam uid ulimit-n
61syn keyword hapParam reqrep reqirep rsprep rspirep skipwhite nextgroup=hapRegexp
62syn keyword hapParam errorloc errorloc302 errorloc303 skipwhite nextgroup=hapStatus
63syn keyword hapParam default_backend skipwhite nextgroup=hapSectLabel
64syn keyword hapParam appsession skipwhite nextgroup=hapAppSess
65syn keyword hapParam bind skipwhite nextgroup=hapIp1
66syn keyword hapParam balance skipwhite nextgroup=hapBalance
67syn keyword hapParam cookie skipwhite nextgroup=hapCookieNam
68syn keyword hapParam capture skipwhite nextgroup=hapCapture
69syn keyword hapParam dispatch skipwhite nextgroup=hapIpPort
70syn keyword hapParam source skipwhite nextgroup=hapIpPort
71syn keyword hapParam mode skipwhite nextgroup=hapMode
Willy Tarreauf4011022007-04-01 11:05:06 +020072syn keyword hapParam monitor-net skipwhite nextgroup=hapIPv4Mask
Willy Tarreau5e47a722007-04-01 10:09:10 +020073syn keyword hapParam option skipwhite nextgroup=hapOption
74syn keyword hapParam stats skipwhite nextgroup=hapStats
75syn keyword hapParam server skipwhite nextgroup=hapServerN
76syn keyword hapParam source skipwhite nextgroup=hapServerEOL
77syn keyword hapParam log skipwhite nextgroup=hapGLog,hapLogIp
78
79" Options and additional parameters
80syn keyword hapAppSess contained len timeout
81syn keyword hapBalance contained roundrobin source
82syn keyword hapLen contained len
83syn keyword hapGLog contained global
84syn keyword hapMode contained http tcp health
85syn keyword hapOption contained abortonclose allbackups checkcache clitcpka dontlognull forceclose forwardfor
86syn keyword hapOption contained httpchk httpclose httplog keepalive logasap persist srvtcpka ssl-hello-chk
87syn keyword hapOption contained tcplog tcpka tcpsplice
Willy Tarreauf4011022007-04-01 11:05:06 +020088syn keyword hapOption contained except skipwhite nextgroup=hapIPv4Mask
Willy Tarreau5e47a722007-04-01 10:09:10 +020089syn keyword hapStats contained uri realm auth scope enable
90syn keyword hapLogFac contained kern user mail daemon auth syslog lpr news nextgroup=hapLogLvl skipwhite
91syn keyword hapLogFac contained uucp cron auth2 ftp ntp audit alert cron2 nextgroup=hapLogLvl skipwhite
92syn keyword hapLogFac contained local0 local1 local2 local3 local4 local5 local6 local7 nextgroup=hapLogLvl skipwhite
93syn keyword hapLogLvl contained emerg alert crit err warning notice info debug
94syn keyword hapCookieKey contained rewrite insert nocache postonly indirect prefix nextgroup=hapCookieKey skipwhite
95syn keyword hapCapture contained cookie nextgroup=hapNameLen skipwhite
96syn keyword hapCapture contained request response nextgroup=hapHeader skipwhite
97syn keyword hapHeader contained header nextgroup=hapNameLen skipwhite
98syn keyword hapSrvKey contained backup cookie check inter rise fall port source minconn maxconn weight usesrc
99syn match hapStatus contained /\d\{3}/
Willy Tarreauf4011022007-04-01 11:05:06 +0200100syn match hapIPv4Mask contained /\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}\(\/\d\{1,2}\)\?/
Willy Tarreau5e47a722007-04-01 10:09:10 +0200101syn match hapLogIp contained /\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}/ nextgroup=hapLogFac skipwhite
102syn match hapIpPort contained /\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}:\d\{1,5}/
103syn match hapServerAd contained /\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}\(:[+-]\?\d\{1,5}\)\?/ nextgroup=hapSrvEOL skipwhite
104syn match hapNameLen contained /\S\+/ nextgroup=hapLen skipwhite
105syn match hapCookieNam contained /\S\+/ nextgroup=hapCookieKey skipwhite
106syn match hapServerN contained /\S\+/ nextgroup=hapServerAd skipwhite
107syn region hapSrvEOL contained start=/\S/ end=/$/ contains=hapSrvKey
108syn region hapRegexp contained start=/\S/ end=/\(\s\|$\)/ skip=/\\ / nextgroup=hapRegRepl skipwhite
109syn region hapRegRepl contained start=/\S/ end=/$/ contains=hapComment,hapEscape,hapBackRef
110syn region hapRegexp2 contained start=/\S/ end=/\(\s\|$\)/ skip=/\\ / nextgroup=hapSectLabel skipwhite
111syn match hapBackref contained /\\\d/
112
113
114" Transparent is a Vim keyword, so we need a regexp to match it
115syn match hapParam +transparent+
116syn 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
122if version < 508
123 command -nargs=+ HiLink hi link <args>
124else
125 command -nargs=+ HiLink hi def link <args>
126endif
127
128HiLink hapEscape SpecialChar
129HiLink hapBackRef Special
130HiLink hapComment Comment
131HiLink hapTodo Todo
132HiLink hapSection Constant
133HiLink hapSectLabel Identifier
134HiLink hapParam Keyword
135
136HiLink hapRegexp String
137HiLink hapRegexp2 hapRegexp
138HiLink hapIp1 Number
139HiLink hapIp2 hapIp1
140HiLink hapLogIp hapIp1
141HiLink hapIpPort hapIp1
Willy Tarreauf4011022007-04-01 11:05:06 +0200142HiLink hapIPv4Mask hapIp1
Willy Tarreau5e47a722007-04-01 10:09:10 +0200143HiLink hapServerAd hapIp1
144HiLink hapStatus Number
145
146HiLink hapOption Operator
147HiLink hapAppSess hapOption
148HiLink hapBalance hapOption
149HiLink hapCapture hapOption
150HiLink hapCookieKey hapOption
151HiLink hapHeader hapOption
152HiLink hapGLog hapOption
153HiLink hapLogFac hapOption
154HiLink hapLogLvl hapOption
155HiLink hapMode hapOption
156HiLink hapStats hapOption
157HiLink hapLen hapOption
158HiLink hapSrvKey hapOption
159
160
161delcommand HiLink
162
163let b:current_syntax = "haproxy"
164" vim: ts=8