Add "show hidden files" checkbox to save dialog
[MacVim.git] / runtime / syntax / hostconf.vim
blob4fc8af0ba3a2770706a534e0c357d6eeff34003d
1 " Vim syntax file
2 " Language:         host.conf(5) configuration file
3 " Maintainer:       Nikolai Weibull <now@bitwi.se>
4 " Latest Revision:  2007-06-25
6 if exists("b:current_syntax")
7   finish
8 endif
10 let s:cpo_save = &cpo
11 set cpo&vim
13 syn keyword hostconfTodo
14       \ contained
15       \ TODO
16       \ FIXME
17       \ XXX
18       \ NOTE
20 syn match   hostconfComment
21       \ display
22       \ contained
23       \ '\s*#.*'
24       \ contains=hostconfTodo,
25       \          @Spell
27 syn match   hostconfBegin
28       \ display
29       \ '^'
30       \ nextgroup=hostconfComment,hostconfKeyword
31       \ skipwhite
33 syn keyword hostconfKeyword
34       \ contained
35       \ order
36       \ nextgroup=hostconfLookupOrder
37       \ skipwhite
39 let s:orders = ['bind', 'hosts', 'nis']
41 function s:permute_suffixes(list)
42   if empty(a:list)
43     return []
44   elseif len(a:list) == 1
45     return a:list[0]
46   else
47     let i = 0
48     let n = len(a:list)
49     let sub_permutations = []
50     while i < n
51       let list_copy = copy(a:list)
52       let removed = list_copy[i]
53       call remove(list_copy, i)
54       call add(sub_permutations, [removed, s:permute_suffixes(list_copy)])
55       let i += 1
56     endwhile
57     return sub_permutations
58   endif
59 endfunction
61 function s:generate_suffix_groups(list_of_order_of_orders, context, trailing_context)
62   for order_of_orders in a:list_of_order_of_orders
63     let order = order_of_orders[0]
64     let trailing_context = a:trailing_context . toupper(order[0]) . order[1:]
65     let nextgroup = 'hostconfLookupOrder' . trailing_context
66     let nextgroup_delimiter = nextgroup . 'Delimiter'
67     let group = 'hostconfLookupOrder' . a:context
68     execute 'syn keyword' group 'contained' order 'nextgroup=' . nextgroup_delimiter 'skipwhite'
69     execute 'syn match' nextgroup_delimiter 'contained display "," nextgroup=' . nextgroup 'skipwhite'
70     if a:context != ""
71       execute 'hi def link' group 'hostconfLookupOrder'
72     endif
73     execute 'hi def link' nextgroup_delimiter 'hostconfLookupOrderDelimiter'
74     let context = trailing_context
75     if type(order_of_orders[1]) == type([])
76       call s:generate_suffix_groups(order_of_orders[1], context, trailing_context)
77     else
78       execute 'syn keyword hostconfLookupOrder' . context 'contained' order_of_orders[-1]
79       execute 'hi def link hostconfLookupOrder' . context 'hostconfLookupOrder'
80     endif
81   endfor
82 endfunction
84 call s:generate_suffix_groups(s:permute_suffixes(s:orders), "", "")
86 delfunction s:generate_suffix_groups
87 delfunction s:permute_suffixes
89 syn keyword hostconfKeyword
90       \ contained
91       \ trim
92       \ nextgroup=hostconfDomain
93       \ skipwhite
95 syn match   hostconfDomain
96       \ contained
97       \ '\.[^:;,[:space:]]\+'
98       \ nextgroup=hostconfDomainDelimiter
99       \ skipwhite
101 syn match   hostconfDomainDelimiter
102       \ contained
103       \ display
104       \ '[:;,]'
105       \ nextgroup=hostconfDomain
106       \ skipwhite
108 syn keyword hostconfKeyword
109       \ contained
110       \ multi
111       \ nospoof
112       \ spoofalert
113       \ reorder
114       \ nextgroup=hostconfBoolean
115       \ skipwhite
117 syn keyword hostconfBoolean
118       \ contained
119       \ on
120       \ off
122 syn keyword hostconfKeyword
123       \ contained
124       \ spoof
125       \ nextgroup=hostconfSpoofValue
126       \ skipwhite
128 syn keyword hostconfSpoofValue
129       \ contained
130       \ off
131       \ nowarn
132       \ warn
134 hi def link hostconfTodo                  Todo
135 hi def link hostconfComment               Comment
136 hi def link hostconfKeyword               Keyword
137 hi def link hostconfLookupOrder           Identifier
138 hi def link hostconfLookupOrderDelimiter  Delimiter
139 hi def link hostconfDomain                String
140 hi def link hostconfDomainDelimiter       Delimiter
141 hi def link hostconfBoolean               Boolean
142 hi def link hostconfSpoofValue            hostconfBoolean
144 let b:current_syntax = "hostconf"
146 let &cpo = s:cpo_save
147 unlet s:cpo_save