blob: 74f5faf652b6880750e26b80852976aa09f351a3 [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
72syn keyword hapParam monitor-net skipwhite nextgroup=hapMonitorN
73syn 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
88syn keyword hapStats contained uri realm auth scope enable
89syn keyword hapLogFac contained kern user mail daemon auth syslog lpr news nextgroup=hapLogLvl skipwhite
90syn keyword hapLogFac contained uucp cron auth2 ftp ntp audit alert cron2 nextgroup=hapLogLvl skipwhite
91syn keyword hapLogFac contained local0 local1 local2 local3 local4 local5 local6 local7 nextgroup=hapLogLvl skipwhite
92syn keyword hapLogLvl contained emerg alert crit err warning notice info debug
93syn keyword hapCookieKey contained rewrite insert nocache postonly indirect prefix nextgroup=hapCookieKey skipwhite
94syn keyword hapCapture contained cookie nextgroup=hapNameLen skipwhite
95syn keyword hapCapture contained request response nextgroup=hapHeader skipwhite
96syn keyword hapHeader contained header nextgroup=hapNameLen skipwhite
97syn keyword hapSrvKey contained backup cookie check inter rise fall port source minconn maxconn weight usesrc
98syn match hapStatus contained /\d\{3}/
99syn match hapMonitorN contained /\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}\(\/\d\{1,2}\)\?/
100syn match hapLogIp contained /\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}/ nextgroup=hapLogFac skipwhite
101syn match hapIpPort contained /\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}:\d\{1,5}/
102syn match hapServerAd contained /\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}\(:[+-]\?\d\{1,5}\)\?/ nextgroup=hapSrvEOL skipwhite
103syn match hapNameLen contained /\S\+/ nextgroup=hapLen skipwhite
104syn match hapCookieNam contained /\S\+/ nextgroup=hapCookieKey skipwhite
105syn match hapServerN contained /\S\+/ nextgroup=hapServerAd skipwhite
106syn region hapSrvEOL contained start=/\S/ end=/$/ contains=hapSrvKey
107syn region hapRegexp contained start=/\S/ end=/\(\s\|$\)/ skip=/\\ / nextgroup=hapRegRepl skipwhite
108syn region hapRegRepl contained start=/\S/ end=/$/ contains=hapComment,hapEscape,hapBackRef
109syn region hapRegexp2 contained start=/\S/ end=/\(\s\|$\)/ skip=/\\ / nextgroup=hapSectLabel skipwhite
110syn match hapBackref contained /\\\d/
111
112
113" Transparent is a Vim keyword, so we need a regexp to match it
114syn match hapParam +transparent+
115syn match hapOption +transparent+ contained
116
117
118" Define the default highlighting.
119" For version 5.7 and earlier: only when not done already
120" For version 5.8 and later: only when an item doesn't have highlighting yet
121if version < 508
122 command -nargs=+ HiLink hi link <args>
123else
124 command -nargs=+ HiLink hi def link <args>
125endif
126
127HiLink hapEscape SpecialChar
128HiLink hapBackRef Special
129HiLink hapComment Comment
130HiLink hapTodo Todo
131HiLink hapSection Constant
132HiLink hapSectLabel Identifier
133HiLink hapParam Keyword
134
135HiLink hapRegexp String
136HiLink hapRegexp2 hapRegexp
137HiLink hapIp1 Number
138HiLink hapIp2 hapIp1
139HiLink hapLogIp hapIp1
140HiLink hapIpPort hapIp1
141HiLink hapMonitorN hapIp1
142HiLink hapServerAd hapIp1
143HiLink hapStatus Number
144
145HiLink hapOption Operator
146HiLink hapAppSess hapOption
147HiLink hapBalance hapOption
148HiLink hapCapture hapOption
149HiLink hapCookieKey hapOption
150HiLink hapHeader hapOption
151HiLink hapGLog hapOption
152HiLink hapLogFac hapOption
153HiLink hapLogLvl hapOption
154HiLink hapMode hapOption
155HiLink hapStats hapOption
156HiLink hapLen hapOption
157HiLink hapSrvKey hapOption
158
159
160delcommand HiLink
161
162let b:current_syntax = "haproxy"
163" vim: ts=8