1" Vim syntax file 2" Language: host.conf(5) configuration file 3" Maintainer: Nikolai Weibull <now@bitwi.se> 4" Latest Revision: 2007-06-25 5 6if exists("b:current_syntax") 7 finish 8endif 9 10let s:cpo_save = &cpo 11set cpo&vim 12 13syn keyword hostconfTodo 14 \ contained 15 \ TODO 16 \ FIXME 17 \ XXX 18 \ NOTE 19 20syn match hostconfComment 21 \ display 22 \ contained 23 \ '\s*#.*' 24 \ contains=hostconfTodo, 25 \ @Spell 26 27syn match hostconfBegin 28 \ display 29 \ '^' 30 \ nextgroup=hostconfComment,hostconfKeyword 31 \ skipwhite 32 33syn keyword hostconfKeyword 34 \ contained 35 \ order 36 \ nextgroup=hostconfLookupOrder 37 \ skipwhite 38 39let s:orders = ['bind', 'hosts', 'nis'] 40 41function 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 59endfunction 60 61function 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 82endfunction 83 84call s:generate_suffix_groups(s:permute_suffixes(s:orders), "", "") 85 86delfunction s:generate_suffix_groups 87delfunction s:permute_suffixes 88 89syn keyword hostconfKeyword 90 \ contained 91 \ trim 92 \ nextgroup=hostconfDomain 93 \ skipwhite 94 95syn match hostconfDomain 96 \ contained 97 \ '\.[^:;,[:space:]]\+' 98 \ nextgroup=hostconfDomainDelimiter 99 \ skipwhite 100 101syn match hostconfDomainDelimiter 102 \ contained 103 \ display 104 \ '[:;,]' 105 \ nextgroup=hostconfDomain 106 \ skipwhite 107 108syn keyword hostconfKeyword 109 \ contained 110 \ multi 111 \ nospoof 112 \ spoofalert 113 \ reorder 114 \ nextgroup=hostconfBoolean 115 \ skipwhite 116 117syn keyword hostconfBoolean 118 \ contained 119 \ on 120 \ off 121 122syn keyword hostconfKeyword 123 \ contained 124 \ spoof 125 \ nextgroup=hostconfSpoofValue 126 \ skipwhite 127 128syn keyword hostconfSpoofValue 129 \ contained 130 \ off 131 \ nowarn 132 \ warn 133 134hi def link hostconfTodo Todo 135hi def link hostconfComment Comment 136hi def link hostconfKeyword Keyword 137hi def link hostconfLookupOrder Identifier 138hi def link hostconfLookupOrderDelimiter Delimiter 139hi def link hostconfDomain String 140hi def link hostconfDomainDelimiter Delimiter 141hi def link hostconfBoolean Boolean 142hi def link hostconfSpoofValue hostconfBoolean 143 144let b:current_syntax = "hostconf" 145 146let &cpo = s:cpo_save 147unlet s:cpo_save 148