robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
946c2a8ee8
master
1" Vim syntax file 2" Language: host.conf(5) configuration file 3" Previous Maintainer: Nikolai Weibull <now@bitwi.se> 4" Latest Revision: 2007-06-25 5 6if exists ( "b:current_syntax" ) 7finish 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 ) 42if empty ( a: list ) 43return [] 44elseif len ( a: list ) == 1 45return a: list [ 0 ] 46else 47let i = 0 48let n = len ( a: list ) 49let sub_permutations = [] 50while i < n 51let list_copy = copy ( a: list ) 52let removed = list_copy [ i ] 53call remove ( list_copy , i ) 54call add ( sub_permutations , [ removed , s: permute_suffixes ( list_copy )]) 55let i += 1 56endwhile 57return sub_permutations 58endif 59endfunction 60 61function s: generate_suffix_groups ( list_of_order_of_orders , context , trailing_context ) 62for order_of_orders in a: list_of_order_of_orders 63let order = order_of_orders [ 0 ] 64let trailing_context = a: trailing_context . toupper ( order [ 0 ]) . order [ 1 :] 65let nextgroup = 'hostconfLookupOrder' . trailing_context 66let nextgroup_delimiter = nextgroup . 'Delimiter' 67let group = 'hostconfLookupOrder' . a: context 68execute 'syn keyword' group 'contained' order 'nextgroup=' . nextgroup_delimiter 'skipwhite' 69execute 'syn match' nextgroup_delimiter 'contained display "," nextgroup=' . nextgroup 'skipwhite' 70if a: context != "" 71execute 'hi def link' group 'hostconfLookupOrder' 72endif 73execute 'hi def link' nextgroup_delimiter 'hostconfLookupOrderDelimiter' 74let context = trailing_context 75if type ( order_of_orders [ 1 ]) == type ([]) 76call s: generate_suffix_groups ( order_of_orders [ 1 ], context , trailing_context ) 77else 78execute 'syn keyword hostconfLookupOrder' . context 'contained' order_of_orders [ -1 ] 79execute 'hi def link hostconfLookupOrder' . context 'hostconfLookupOrder' 80endif 81endfor 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