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
|
|
5 " Last Change: 2019 Dec 12
|
|
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
|
|
17 syn keyword regoKeywords as default else false not null true with some
|
|
18
|
|
19 syn keyword regoFuncAggregates count sum product max min sort all any
|
|
20 syn match regoFuncArrays "\<array\.\(concat\|slice\)\>"
|
|
21 syn keyword regoFuncSets intersection union
|
|
22
|
|
23 syn keyword regoFuncStrings concat /\<contains\>/ endswith format_int indexof 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\>"
|
|
25 syn match regoFuncStrings3 "\<contains\>"
|
|
26
|
|
27 syn keyword regoFuncRegex re_match
|
|
28 syn match regoFuncRegex2 "\<regex\.\(split\|globs_match\|template_match\|find_n\|find_all_string_submatch_n\)\>"
|
|
29
|
|
30 syn match regoFuncGlob "\<glob\.\(match\|quote_meta\)\>"
|
|
31 syn match regoFuncUnits "\<units\.parse_bytes\>"
|
|
32 syn keyword regoFuncTypes is_number is_string is_boolean is_array is_set is_object is_null type_name
|
|
33 syn match regoFuncEncoding1 "\<\(base64\|base64url\)\.\(encode\|decode\)\>"
|
|
34 syn match regoFuncEncoding2 "\<urlquery\.\(encode\|decode\|encode_object\)\>"
|
|
35 syn match regoFuncEncoding3 "\<\(json\|yaml\)\.\(marshal\|unmarshal\)\>"
|
|
36 syn match regoFuncTokenSigning "\<io\.jwt\.\(encode_sign_raw\|encode_sign\)\>"
|
|
37 syn match regoFuncTokenVerification "\<io\.jwt\.\(verify_rs256\|verify_ps256\|verify_es256\|verify_hs256\|decode\|decode_verify\)\>"
|
|
38 syn match regoFuncTime "\<time\.\(now_ns\|parse_ns\|parse_rfc3339_ns\|parse_duration_ns\|date\|clock\|weekday\)\>"
|
|
39 syn match regoFuncCryptography "\<crypto\.x509\.parse_certificates\>"
|
|
40 syn keyword regoFuncGraphs walk
|
|
41 syn match regoFuncHttp "\<http\.send\>"
|
|
42 syn match regoFuncNet "\<net\.\(cidr_contains\|cidr_intersects\)\>"
|
|
43 syn match regoFuncRego "\<rego\.parse_module\>"
|
|
44 syn match regoFuncOpa "\<opa\.runtime\>"
|
|
45 syn keyword regoFuncDebugging trace
|
|
46
|
|
47 hi def link regoDirective Statement
|
|
48 hi def link regoKeywords Statement
|
|
49 hi def link regoFuncAggregates Statement
|
|
50 hi def link regoFuncArrays Statement
|
|
51 hi def link regoFuncSets Statement
|
|
52 hi def link regoFuncStrings Statement
|
|
53 hi def link regoFuncStrings2 Statement
|
|
54 hi def link regoFuncStrings3 Statement
|
|
55 hi def link regoFuncRegex Statement
|
|
56 hi def link regoFuncRegex2 Statement
|
|
57 hi def link regoFuncGlob Statement
|
|
58 hi def link regoFuncUnits Statement
|
|
59 hi def link regoFuncTypes Statement
|
|
60 hi def link regoFuncEncoding1 Statement
|
|
61 hi def link regoFuncEncoding2 Statement
|
|
62 hi def link regoFuncEncoding3 Statement
|
|
63 hi def link regoFuncTokenSigning Statement
|
|
64 hi def link regoFuncTokenVerification Statement
|
|
65 hi def link regoFuncTime Statement
|
|
66 hi def link regoFuncCryptography Statement
|
|
67 hi def link regoFuncGraphs Statement
|
|
68 hi def link regoFuncHttp Statement
|
|
69 hi def link regoFuncNet Statement
|
|
70 hi def link regoFuncRego Statement
|
|
71 hi def link regoFuncOpa Statement
|
|
72 hi def link regoFuncDebugging Statement
|
|
73
|
|
74 " https://www.openpolicyagent.org/docs/latest/policy-language/#strings
|
|
75 syn region regoString start=+"+ skip=+\\\\\|\\"+ end=+"+
|
|
76 syn region regoRawString start=+`+ end=+`+
|
|
77
|
|
78 hi def link regoString String
|
|
79 hi def link regoRawString String
|
|
80
|
|
81 " Comments; their contents
|
|
82 syn keyword regoTodo contained TODO FIXME XXX BUG
|
|
83 syn cluster regoCommentGroup contains=regoTodo
|
|
84 syn region regoComment start="#" end="$" contains=@regoCommentGroup,@Spell
|
|
85
|
|
86 hi def link regoComment Comment
|
|
87 hi def link regoTodo Todo
|
|
88
|
|
89 let b:current_syntax = 'rego'
|