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