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