asterisk.vim 5.8 KB

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