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