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