Mercurial > vim
view runtime/syntax/rego.vim @ 34536:ad6cd802579d v9.1.0170
patch 9.1.0170: Re-allow curwin == prevwin, but document it instead
Commit: https://github.com/vim/vim/commit/d64801e913314d2e19dbb38f60e6d285238debff
Author: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Date: Tue Mar 12 20:46:12 2024 +0100
patch 9.1.0170: Re-allow curwin == prevwin, but document it instead
Problem: more places exist where curwin == prevwin, and it may even be
expected in some cases.
Solution: revert v9.1.0001, but document that it's possible instead.
(Sean Dewar)
I've had a change of heart for the following reasons:
- A quick 'n dirty [GitHub code
search](https://github.com/search?q=%2F%28winnr%5C%28%5C%29%5Cs*%3D%3D%5Cs*winnr%5C%28%5B%27%22%5D%23%5B%27%22%5D%5C%29%7Cwinnr%5C%28%5B%27%22%5D%23%5B%27%22%5D%5C%29%5Cs*%3D%3D%5Cs*winnr%5C%28%5C%29%29%2F&type=code)
reveals some cases where it's expected in the wild.
Particularly, it made me aware `winnr() == winnr('#')` is possible when curwin
is changed temporarily during the evaluation of a &statusline expression item
(`%{...}`), and is used to show something different on the statusline
belonging to the previous window; that behaviour wasn't changed in v9.1.0001,
but it means curwin == prevwin makes sense in some cases.
- The definition and call sites of back_to_prevwin imply some expectation that
prevwin == wp (== curwin) is possible, as it's used to skip entering the
prevwin in that case.
- Prior to v9.1.0001, `:wincmd p` would not beep in the case that was patched in
v9.1.0001, but now does. That resulted in #14047 being opened, as it affected
the CtrlP plugin.
I find it odd that `:wincmd p` had cases where it wouldn't beep despite doing
nothing, but it may be preferable to keep things that way (or instead also
beep if curwin == prevwin, if that's preferred).
- After more digging, I found cases in win_free_mem, enter_tabpage,
aucmd_restbuf and qf_open_new_cwindow where curwin == prevwin is possible
(many of them from autocommands). Others probably exist too, especially in
places where curwin is changed temporarily.
fixes: #14047
closes: #14186
Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 12 Mar 2024 21:00:11 +0100 |
parents | 15c80d8bc515 |
children |
line wrap: on
line source
" Vim syntax file " Language: rego policy language " Maintainer: Matt Dunford (zenmatic@gmail.com) " URL: https://github.com/zenmatic/vim-syntax-rego " Last Change: 2022 Dec 4 " https://www.openpolicyagent.org/docs/latest/policy-language/ " quit when a (custom) syntax file was already loaded if exists("b:current_syntax") finish endif syn case match syn keyword regoDirective package import allow deny syn keyword regoKeywords as default else every false if import package not null true with some in print syn keyword regoFuncAggregates count sum product max min sort all any syn match regoFuncArrays "\<array\.\(concat\|slice\|reverse\)\>" syn keyword regoFuncSets intersection union 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 syn match regoFuncStrings2 "\<strings\.\(replace_n\|reverse\|any_prefix_match\|any_suffix_match\)\>" syn match regoFuncStrings3 "\<contains\>" syn keyword regoFuncRegex re_match syn match regoFuncRegex2 "\<regex\.\(is_valid\|split\|globs_match\|template_match\|find_n\|find_all_string_submatch_n\|replace\)\>" syn match regoFuncUuid "\<uuid.rfc4122\>" syn match regoFuncBits "\<bits\.\(or\|and\|negate\|xor\|lsh\|rsh\)\>" syn match regoFuncObject "\<object\.\(get\|remove\|subset\|union\|union_n\|filter\)\>" syn match regoFuncGlob "\<glob\.\(match\|quote_meta\)\>" syn match regoFuncUnits "\<units\.parse\(_bytes\)\=\>" syn keyword regoFuncTypes is_number is_string is_boolean is_array is_set is_object is_null type_name syn match regoFuncEncoding1 "\<base64\.\(encode\|decode\|is_valid\)\>" syn match regoFuncEncoding2 "\<base64url\.\(encode\(_no_pad\)\=\|decode\)\>" syn match regoFuncEncoding3 "\<urlquery\.\(encode\|decode\|\(en\|de\)code_object\)\>" syn match regoFuncEncoding4 "\<\(json\|yaml\)\.\(is_valid\|marshal\|unmarshal\)\>" syn match regoFuncEncoding5 "\<json\.\(filter\|patch\|remove\)\>" syn match regoFuncTokenSigning "\<io\.jwt\.\(encode_sign_raw\|encode_sign\)\>" syn match regoFuncTokenVerification1 "\<io\.jwt\.\(decode\|decode_verify\)\>" syn match regoFuncTokenVerification2 "\<io\.jwt\.verify_\(rs\|ps\|es\|hs\)\(256\|384\|512\)\>" syn match regoFuncTime "\<time\.\(now_ns\|parse_ns\|parse_rfc3339_ns\|parse_duration_ns\|date\|clock\|weekday\|diff\|add_date\)\>" syn match regoFuncCryptography "\<crypto\.x509\.\(parse_certificates\|parse_certificate_request\|parse_and_verify_certificates\|parse_rsa_private_key\)\>" syn match regoFuncCryptography "\<crypto\.\(md5\|sha1\|sha256\)" syn match regoFuncCryptography "\<crypto\.hmac\.\(md5\|sha1\|sha256\|sha512\)" syn keyword regoFuncGraphs walk syn match regoFuncGraphs2 "\<graph\.reachable\(_paths\)\=\>" syn match regoFuncGraphQl "\<graphql\.\(\(schema_\)\=is_valid\|parse\(_\(and_verify\|query\|schema\)\)\=\)\>" syn match regoFuncHttp "\<http\.send\>" syn match regoFuncNet "\<net\.\(cidr_merge\|cidr_contains\|cidr_contains_matches\|cidr_intersects\|cidr_expand\|lookup_ip_addr\|cidr_is_valid\)\>" syn match regoFuncRego "\<rego\.\(parse_module\|metadata\.\(rule\|chain\)\)\>" syn match regoFuncOpa "\<opa\.runtime\>" syn keyword regoFuncDebugging trace syn match regoFuncRand "\<rand\.intn\>" syn match regoFuncNumbers "\<numbers\.\(range\|intn\)\>" syn keyword regoFuncNumbers round ceil floor abs syn match regoFuncSemver "\<semver\.\(is_valid\|compare\)\>" syn keyword regoFuncConversions to_number syn match regoFuncHex "\<hex\.\(encode\|decode\)\>" hi def link regoFuncUuid Statement hi def link regoFuncBits Statement hi def link regoDirective Statement hi def link regoKeywords Statement hi def link regoFuncAggregates Statement hi def link regoFuncArrays Statement hi def link regoFuncSets Statement hi def link regoFuncStrings Statement hi def link regoFuncStrings2 Statement hi def link regoFuncStrings3 Statement hi def link regoFuncRegex Statement hi def link regoFuncRegex2 Statement hi def link regoFuncGlob Statement hi def link regoFuncUnits Statement hi def link regoFuncTypes Statement hi def link regoFuncEncoding1 Statement hi def link regoFuncEncoding2 Statement hi def link regoFuncEncoding3 Statement hi def link regoFuncEncoding4 Statement hi def link regoFuncEncoding5 Statement hi def link regoFuncTokenSigning Statement hi def link regoFuncTokenVerification1 Statement hi def link regoFuncTokenVerification2 Statement hi def link regoFuncTime Statement hi def link regoFuncCryptography Statement hi def link regoFuncGraphs Statement hi def link regoFuncGraphQl Statement hi def link regoFuncGraphs2 Statement hi def link regoFuncHttp Statement hi def link regoFuncNet Statement hi def link regoFuncRego Statement hi def link regoFuncOpa Statement hi def link regoFuncDebugging Statement hi def link regoFuncObject Statement hi def link regoFuncNumbers Statement hi def link regoFuncSemver Statement hi def link regoFuncConversions Statement hi def link regoFuncHex Statement hi def link regoFuncRand Statement " https://www.openpolicyagent.org/docs/latest/policy-language/#strings syn region regoString start=+"+ skip=+\\\\\|\\"+ end=+"+ syn region regoRawString start=+`+ end=+`+ hi def link regoString String hi def link regoRawString String " Comments; their contents syn keyword regoTodo contained TODO FIXME XXX BUG syn cluster regoCommentGroup contains=regoTodo syn region regoComment start="#" end="$" contains=@regoCommentGroup,@Spell hi def link regoComment Comment hi def link regoTodo Todo let b:current_syntax = 'rego'