routeros.vim 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. " Vim syntax file
  2. " Language: MikroTik RouterOS Script
  3. " Maintainer: zainin <z@wintr.dev>
  4. " Original Author: ndbjorne @ MikroTik forums
  5. " Last Change: 2021 Nov 14
  6. " quit when a syntax file was already loaded
  7. if exists("b:current_syntax")
  8. finish
  9. endif
  10. syn case ignore
  11. syn iskeyword @,48-57,-
  12. " comments
  13. syn match routerosComment /^\s*\zs#.*/
  14. " options submenus: /interface ether1 etc
  15. syn match routerosSubMenu "\([a-z]\)\@<!/[a-zA-Z0-9-]*"
  16. " variables are matched by looking at strings ending with "=", e.g. var=
  17. syn match routerosVariable "[a-zA-Z0-9-/]*\(=\)\@="
  18. syn match routerosVariable "$[a-zA-Z0-9-]*"
  19. " colored for clarity
  20. syn match routerosDelimiter "[,=]"
  21. " match slash in CIDR notation (1.2.3.4/24, 2001:db8::/48, ::1/128)
  22. syn match routerosDelimiter "\(\x\|:\)\@<=\/\(\d\)\@="
  23. " dash in IP ranges
  24. syn match routerosDelimiter "\(\x\|:\)\@<=-\(\x\|:\)\@="
  25. " match service names after "set", like in original routeros syntax
  26. syn match routerosService "\(set\)\@<=\s\(api-ssl\|api\|dns\|ftp\|http\|https\|pim\|ntp\|smb\|ssh\|telnet\|winbox\|www\|www-ssl\)"
  27. " colors various interfaces
  28. syn match routerosInterface "bridge\d\+\|ether\d\+\|wlan\d\+\|pppoe-\(out\|in\)\d\+"
  29. syn keyword routerosBoolean yes no true false
  30. syn keyword routerosConditional if
  31. " operators
  32. syn match routerosOperator " \zs[-+*<>=!~^&.,]\ze "
  33. syn match routerosOperator "[<>!]="
  34. syn match routerosOperator "<<\|>>"
  35. syn match routerosOperator "[+-]\d\@="
  36. syn keyword routerosOperator and or in
  37. " commands
  38. syn keyword routerosCommands beep delay put len typeof pick log time set find environment
  39. syn keyword routerosCommands terminal error parse resolve toarray tobool toid toip toip6
  40. syn keyword routerosCommands tonum tostr totime add remove enable disable where get print
  41. syn keyword routerosCommands export edit find append as-value brief detail count-only file
  42. syn keyword routerosCommands follow follow-only from interval terse value-list without-paging
  43. syn keyword routerosCommands return
  44. " variable types
  45. syn keyword routerosType global local
  46. " loop keywords
  47. syn keyword routerosRepeat do while for foreach
  48. syn match routerosSpecial "[():[\]{|}]"
  49. syn match routerosLineContinuation "\\$"
  50. syn match routerosEscape "\\["\\nrt$?_abfv]" contained display
  51. syn match routerosEscape "\\\x\x" contained display
  52. syn region routerosString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=routerosEscape,routerosLineContinuation
  53. hi link routerosComment Comment
  54. hi link routerosSubMenu Function
  55. hi link routerosVariable Identifier
  56. hi link routerosDelimiter Operator
  57. hi link routerosEscape Special
  58. hi link routerosService Type
  59. hi link routerosInterface Type
  60. hi link routerosBoolean Boolean
  61. hi link routerosConditional Conditional
  62. hi link routerosOperator Operator
  63. hi link routerosCommands Operator
  64. hi link routerosType Type
  65. hi link routerosRepeat Repeat
  66. hi link routerosSpecial Delimiter
  67. hi link routerosString String
  68. hi link routerosLineContinuation Special
  69. let b:current_syntax = "routeros"