install_prereq: Download latest Jansson.
[asterisk/asterisk.git] / contrib / editors / asterisk.vim
1 " Vim syntax file
2 " Language:     Asterisk config file
3 " Maintainer:   tilghman
4 " Last Change:  2009 Mar 04 
5 " version 0.5
6 "
7 if version < 600
8   syntax clear
9 elseif exists("b:current_syntax")
10   finish
11 endif
12
13 syn sync clear
14 syn sync fromstart
15
16 syn keyword     asteriskTodo            TODO contained
17 syn match       asteriskComment         "\\\@<!;.*" contains=asteriskTodo
18 syn region      asteriskBlockComment    start=/\\\@<!;---\@!/ end=/--;/ contains=asteriskBlockComment,asteriskTodo
19 syn match       asteriskContext         "\[.\{-}\]"
20 syn match       asteriskExten           "^\s*exten\s*=>\?\s*[^,]\+" contains=asteriskPattern
21 syn match       asteriskExten           "^\s*\(register\|channel\|ignorepat\|include\|\(no\)\?load\)\s*=>\?"
22 syn match       asteriskPattern         "_\(\[[[:alnum:]#*\-]\+\]\|[[:alnum:]#*]\)*\.\?" contained
23 syn match       asteriskPattern         "[^A-Za-z0-9,]\zs[[:alnum:]#*]\+\ze" contained
24 syn match       asteriskApp             ",\zs[a-zA-Z]\+\ze$"
25 syn match       asteriskApp             ",\zs[a-zA-Z]\+\ze("
26 " Digits plus oldlabel (newlabel)
27 syn match       asteriskPriority        ",\zs[[:digit:]]\+\(+[[:alpha:]][[:alnum:]_]*\)\?\(([[:alpha:]][[:alnum:]_]*)\)\?\ze," contains=asteriskLabel
28 " oldlabel plus digits (newlabel)
29 syn match       asteriskPriority        ",\zs[[:alpha:]][[:alnum:]_]*+[[:digit:]]\+\(([[:alpha:]][[:alnum:]_]*)\)\?\ze," contains=asteriskLabel
30 " s or n plus digits (newlabel)
31 syn match       asteriskPriority        ",\zs[sn]\(+[[:digit:]]\+\)\?\(([[:alpha:]][[:alnum:]_]*)\)\?\ze," contains=asteriskLabel
32 syn match       asteriskLabel           "(\zs[[:alpha:]][[:alnum:]]*\ze)" contained
33 syn match       asteriskError           "^\s*#\s*[[:alnum:]]*"
34 syn match       asteriskInclude         "^\s*#\s*\(include\|exec\)\s.*"
35 syn region      asteriskVar             matchgroup=asteriskVarStart start="\${" end="}" contains=asteriskVar,asteriskFunction,asteriskExp
36 syn match       asteriskVar             "\zs[[:alpha:]][[:alnum:]_]*\ze=" contains=asteriskVar,asteriskFunction,asteriskExp
37 syn match       asteriskFunction        "\${_\{0,2}[[:alpha:]][[:alnum:]_]*(.*)}" contains=asteriskVar,asteriskFunction,asteriskExp
38 syn match       asteriskFunction        "(\zs[[:alpha:]][[:alnum:]_]*(.\{-})\ze=" contains=asteriskVar,asteriskFunction,asteriskExp
39 syn region      asteriskExp             matchgroup=asteriskExpStart start="\$\[" end="]" contains=asteriskVar,asteriskFunction,asteriskExp
40 syn match       asteriskCodecsPermit    "^\s*\(allow\|disallow\)\s*=\s*.*$" contains=asteriskCodecs
41 syn match       asteriskCodecs          "\(g723\|gsm\|ulaw\|alaw\|g726\|adpcm\|slin\|lpc10\|g729\|speex\|speex16\|ilbc\|all\s*$\)"
42 syn match       asteriskError           "^\(type\|auth\|permit\|deny\|bindaddr\|host\)\s*=.*$"
43 syn match       asteriskType            "^\zstype=\ze\<\(peer\|user\|friend\|phone\|line\|application\|network\)\>$" contains=asteriskTypeType
44 syn match       asteriskTypeType        "\<\(peer\|user\|friend\|phone\|line\|application\|network\)\>" contained
45 syn match       asteriskAuth            "^\zsauth\s*=\ze\s*\<\(md5\|rsa\|plaintext\)\>$" contains=asteriskAuthType
46 syn match       asteriskAuthType        "\<\(md5\|rsa\|plaintext\)\>" contained
47 syn match       asteriskAuth            "^\zs\(secret\|inkeys\|outkey\)\s*=\ze.*$"
48 syn match       asteriskAuth            "^\(permit\|deny\)\s*=\s*\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}/\d\{1,3}\(\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}\)\?\s*$" contains=asteriskIPRange
49 syn match       asteriskIPRange         "\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}/\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}" contained
50 syn match       asteriskIP              "\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}" contained
51 syn match       asteriskHostname        "\([[:alnum:]\-]*\.\)\+[[:alpha:]]\{2,10}" contained
52 syn match       asteriskPort            "\d\{1,5}" contained
53 syn match       asteriskSetting         "^\(tcp\|tls\)\?bindaddr\s*=\s*\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}$" contains=asteriskIP
54 syn match       asteriskError           "port\s*=.*$"
55 syn match       asteriskSetting         "^\(bind\)\?port\s*=\s*\d\{1,5}\s*$" contains=asteriskPort
56 syn match       asteriskSetting         "^host\s*=\s*\(dynamic\|\(\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}\)\|\([[:alnum:]\-]*\.\)\+[[:alpha:]]\{2,10}\)" contains=asteriskIP,asteriskHostname
57 syn match               asteriskError                   "[[:space:]]$"
58
59 " Define the default highlighting.
60 " For version 5.7 and earlier: only when not done already
61 " For version 5.8 and later: only when an item doesn't have highlighting yet
62 if version >= 508 || !exists("did_conf_syntax_inits")
63   if version < 508
64     let did_conf_syntax_inits = 1
65     command -nargs=+ HiLink hi link <args>
66   else
67     command -nargs=+ HiLink hi def link <args>
68   endif
69
70   HiLink        asteriskComment         Comment
71   HiLink        asteriskBlockComment    Comment
72   HiLink        asteriskExten           String
73   HiLink        asteriskContext         Preproc
74   HiLink        asteriskPattern         Type
75   HiLink        asteriskApp             Statement
76   HiLink        asteriskInclude         Preproc
77   HiLink        asteriskPriority        Preproc
78   HiLink        asteriskLabel           Type
79   HiLink        asteriskVar             String
80   HiLink        asteriskVarStart        String
81   HiLink        asteriskFunction        Function
82   HiLink        asteriskExp             Type
83   HiLink        asteriskExpStart        Type
84   HiLink        asteriskCodecsPermit    Preproc
85   HiLink        asteriskCodecs          String
86   HiLink        asteriskType            Statement
87   HiLink        asteriskTypeType        Type
88   HiLink        asteriskAuth            String
89   HiLink        asteriskAuthType        Type
90   HiLink        asteriskIPRange         Identifier
91   HiLink        asteriskIP              Identifier
92   HiLink        asteriskPort            Identifier
93   HiLink        asteriskHostname        Identifier
94   HiLink        asteriskSetting         Statement
95   HiLink        asteriskError           Error
96  delcommand HiLink
97 endif
98 let b:current_syntax = "asterisk" 
99 " vim: ts=8 sw=2
100