18928
|
1 " Vim syntax file
|
|
2 " Language: rego policy language
|
|
3 " Maintainer: Matt Dunford (zenmatic@gmail.com)
|
|
4 " URL: https://github.com/zenmatic/vim-syntax-rego
|
31383
|
5 " Last Change: 2022 Dec 4
|
18928
|
6
|
|
7 " https://www.openpolicyagent.org/docs/latest/policy-language/
|
|
8
|
|
9 " quit when a (custom) syntax file was already loaded
|
|
10 if exists("b:current_syntax")
|
|
11 finish
|
|
12 endif
|
|
13
|
|
14 syn case match
|
|
15
|
|
16 syn keyword regoDirective package import allow deny
|
31383
|
17 syn keyword regoKeywords as default else every false if import package not null true with some in print
|
18928
|
18
|
|
19 syn keyword regoFuncAggregates count sum product max min sort all any
|
31383
|
20 syn match regoFuncArrays "\<array\.\(concat\|slice\|reverse\)\>"
|
18928
|
21 syn keyword regoFuncSets intersection union
|
|
22
|
31383
|
23 syn keyword regoFuncStrings concat /\<contains\>/ endswith format_int indexof indexof_n lower replace split sprintf startswith substring trim trim_left trim_prefix trim_right trim_suffix trim_space upper
|
|
24 syn match regoFuncStrings2 "\<strings\.\(replace_n\|reverse\|any_prefix_match\|any_suffix_match\)\>"
|
18928
|
25 syn match regoFuncStrings3 "\<contains\>"
|
|
26
|
|
27 syn keyword regoFuncRegex re_match
|
31383
|
28 syn match regoFuncRegex2 "\<regex\.\(is_valid\|split\|globs_match\|template_match\|find_n\|find_all_string_submatch_n\|replace\)\>"
|
18928
|
29
|
31383
|
30 syn match regoFuncUuid "\<uuid.rfc4122\>"
|
|
31 syn match regoFuncBits "\<bits\.\(or\|and\|negate\|xor\|lsh\|rsh\)\>"
|
|
32 syn match regoFuncObject "\<object\.\(get\|remove\|subset\|union\|union_n\|filter\)\>"
|
18928
|
33 syn match regoFuncGlob "\<glob\.\(match\|quote_meta\)\>"
|
31383
|
34 syn match regoFuncUnits "\<units\.parse\(_bytes\)\=\>"
|
18928
|
35 syn keyword regoFuncTypes is_number is_string is_boolean is_array is_set is_object is_null type_name
|
31383
|
36 syn match regoFuncEncoding1 "\<base64\.\(encode\|decode\|is_valid\)\>"
|
|
37 syn match regoFuncEncoding2 "\<base64url\.\(encode\(_no_pad\)\=\|decode\)\>"
|
|
38 syn match regoFuncEncoding3 "\<urlquery\.\(encode\|decode\|\(en\|de\)code_object\)\>"
|
|
39 syn match regoFuncEncoding4 "\<\(json\|yaml\)\.\(is_valid\|marshal\|unmarshal\)\>"
|
|
40 syn match regoFuncEncoding5 "\<json\.\(filter\|patch\|remove\)\>"
|
18928
|
41 syn match regoFuncTokenSigning "\<io\.jwt\.\(encode_sign_raw\|encode_sign\)\>"
|
31383
|
42 syn match regoFuncTokenVerification1 "\<io\.jwt\.\(decode\|decode_verify\)\>"
|
|
43 syn match regoFuncTokenVerification2 "\<io\.jwt\.verify_\(rs\|ps\|es\|hs\)\(256\|384\|512\)\>"
|
|
44 syn match regoFuncTime "\<time\.\(now_ns\|parse_ns\|parse_rfc3339_ns\|parse_duration_ns\|date\|clock\|weekday\|diff\|add_date\)\>"
|
|
45 syn match regoFuncCryptography "\<crypto\.x509\.\(parse_certificates\|parse_certificate_request\|parse_and_verify_certificates\|parse_rsa_private_key\)\>"
|
|
46 syn match regoFuncCryptography "\<crypto\.\(md5\|sha1\|sha256\)"
|
|
47 syn match regoFuncCryptography "\<crypto\.hmac\.\(md5\|sha1\|sha256\|sha512\)"
|
18928
|
48 syn keyword regoFuncGraphs walk
|
31383
|
49 syn match regoFuncGraphs2 "\<graph\.reachable\(_paths\)\=\>"
|
|
50 syn match regoFuncGraphQl "\<graphql\.\(\(schema_\)\=is_valid\|parse\(_\(and_verify\|query\|schema\)\)\=\)\>"
|
18928
|
51 syn match regoFuncHttp "\<http\.send\>"
|
31383
|
52 syn match regoFuncNet "\<net\.\(cidr_merge\|cidr_contains\|cidr_contains_matches\|cidr_intersects\|cidr_expand\|lookup_ip_addr\|cidr_is_valid\)\>"
|
|
53 syn match regoFuncRego "\<rego\.\(parse_module\|metadata\.\(rule\|chain\)\)\>"
|
18928
|
54 syn match regoFuncOpa "\<opa\.runtime\>"
|
|
55 syn keyword regoFuncDebugging trace
|
31383
|
56 syn match regoFuncRand "\<rand\.intn\>"
|
18928
|
57
|
31383
|
58 syn match regoFuncNumbers "\<numbers\.\(range\|intn\)\>"
|
|
59 syn keyword regoFuncNumbers round ceil floor abs
|
|
60
|
|
61 syn match regoFuncSemver "\<semver\.\(is_valid\|compare\)\>"
|
|
62 syn keyword regoFuncConversions to_number
|
|
63 syn match regoFuncHex "\<hex\.\(encode\|decode\)\>"
|
|
64
|
|
65 hi def link regoFuncUuid Statement
|
|
66 hi def link regoFuncBits Statement
|
18928
|
67 hi def link regoDirective Statement
|
|
68 hi def link regoKeywords Statement
|
|
69 hi def link regoFuncAggregates Statement
|
|
70 hi def link regoFuncArrays Statement
|
|
71 hi def link regoFuncSets Statement
|
|
72 hi def link regoFuncStrings Statement
|
|
73 hi def link regoFuncStrings2 Statement
|
|
74 hi def link regoFuncStrings3 Statement
|
|
75 hi def link regoFuncRegex Statement
|
|
76 hi def link regoFuncRegex2 Statement
|
|
77 hi def link regoFuncGlob Statement
|
|
78 hi def link regoFuncUnits Statement
|
|
79 hi def link regoFuncTypes Statement
|
|
80 hi def link regoFuncEncoding1 Statement
|
|
81 hi def link regoFuncEncoding2 Statement
|
|
82 hi def link regoFuncEncoding3 Statement
|
31383
|
83 hi def link regoFuncEncoding4 Statement
|
|
84 hi def link regoFuncEncoding5 Statement
|
18928
|
85 hi def link regoFuncTokenSigning Statement
|
31383
|
86 hi def link regoFuncTokenVerification1 Statement
|
|
87 hi def link regoFuncTokenVerification2 Statement
|
18928
|
88 hi def link regoFuncTime Statement
|
|
89 hi def link regoFuncCryptography Statement
|
|
90 hi def link regoFuncGraphs Statement
|
31383
|
91 hi def link regoFuncGraphQl Statement
|
|
92 hi def link regoFuncGraphs2 Statement
|
18928
|
93 hi def link regoFuncHttp Statement
|
|
94 hi def link regoFuncNet Statement
|
|
95 hi def link regoFuncRego Statement
|
|
96 hi def link regoFuncOpa Statement
|
|
97 hi def link regoFuncDebugging Statement
|
31383
|
98 hi def link regoFuncObject Statement
|
|
99 hi def link regoFuncNumbers Statement
|
|
100 hi def link regoFuncSemver Statement
|
|
101 hi def link regoFuncConversions Statement
|
|
102 hi def link regoFuncHex Statement
|
|
103 hi def link regoFuncRand Statement
|
18928
|
104
|
|
105 " https://www.openpolicyagent.org/docs/latest/policy-language/#strings
|
|
106 syn region regoString start=+"+ skip=+\\\\\|\\"+ end=+"+
|
|
107 syn region regoRawString start=+`+ end=+`+
|
|
108
|
|
109 hi def link regoString String
|
|
110 hi def link regoRawString String
|
|
111
|
|
112 " Comments; their contents
|
|
113 syn keyword regoTodo contained TODO FIXME XXX BUG
|
|
114 syn cluster regoCommentGroup contains=regoTodo
|
|
115 syn region regoComment start="#" end="$" contains=@regoCommentGroup,@Spell
|
|
116
|
|
117 hi def link regoComment Comment
|
|
118 hi def link regoTodo Todo
|
|
119
|
|
120 let b:current_syntax = 'rego'
|