asterisk.vim 5.9 KB

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