runtime(mbsync): Properly handle values for the "Sync" keyword

Commit: 
https://github.com/vim/vim/commit/85eb099bf2210a3882005c0bf5d47306902c999e
Author: Cyril Roelandt <[email protected]>
Date:   Wed May 20 21:15:33 2026 +0000

    runtime(mbsync): Properly handle values for the "Sync" keyword
    
    This has been manually tested with my personal mbsync configuration and
    with the following test file:
    
        $ cat test.mbsyncrc
        Channel Foo
        # None may not be combined with other operations
        Sync None
        Sync None New
        # First form
        Sync Pull
        Sync Push
        Sync New
        Sync Old
        Sync Upgrade
        Sync ReNew
        Sync Gone
        Sync Delete
        Sync Flags
        Sync Invalid
        # Second form
        Sync PullNew
        Sync PullOld
        Sync PullUpgrade
        Sync PullReNew
        Sync PullGone
        Sync PullDelete
        Sync PullFlags
        Sync PullFull
        Sync PullAll
        Sync PullInvalid
        Sync PushNew
        Sync PushOld
        Sync PushUpgrade
        Sync PushReNew
        Sync PushGone
        Sync PushDelete
        Sync PushFlags
        Sync PushFull
        Sync PushAll
        Sync PushInvalid
        Sync NewInvalid
        # Multiple operations
        Sync New Upgrade Gone Flags
        # Mix of the two styles (an example from the mbsync manpage)
        Sync PullNew PullGone Push
        # Syntaxically correct, though they will raise a warning in mbsync:
        Sync PullNew Pull
        Sync PullNew Gone Push
    
    closes: #20243
    
    Signed-off-by: Pierrick Guillaume <[email protected]>
    Signed-off-by: Cyril Roelandt <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/runtime/syntax/mbsync.vim b/runtime/syntax/mbsync.vim
index daef41ddd..eacd46ddb 100644
--- a/runtime/syntax/mbsync.vim
+++ b/runtime/syntax/mbsync.vim
@@ -4,6 +4,7 @@
 " Last Change: 2025 Apr 13
 " 2025 Jun 04 by Vim project: match TLSType configuration variable
 " 2026 Jan 15 by Vim project: support TLSVersions keyword
+" 2026 May 20 by Vim project: handle sync keyword #20243
 "
 " Syntax support for mbsync config file
 
@@ -132,7 +133,28 @@ syn match mbsCConfStPattern       '^Patterns\?\s\+\ze.*$'  
   contains=mbsCConfI
 syn match mbsCConfStMaxSize       '^MaxSize\s\+\ze.*$'        
contains=mbsCConfItemK contained nextgroup=mbsSize transparent
 syn match mbsCConfStMaxMessages   '^MaxMessages\s\+\ze.*$'    
contains=mbsCConfItemK contained nextgroup=mbsNumber transparent
 syn match mbsCConfStExpireUnread  '^ExpireUnread\s\+\ze.*$'   
contains=mbsCConfItemK contained nextgroup=mbsBool transparent
-syn match mbsCConfSyncOpt 
'None\|All\|\%(\s\+\%(Pull\|Push\|New\|ReNew\|Delete\|Flags\)\)\+' display 
contained
+" Properly matching mbsCConfSyncOpt:
+"
+" None is a special case. From mbsync's man page:
+"   "None may not be combined with any other operation."
+" Once "None" is out of the way, first try to match operations, including:
+"   - New, Old, Upgrade, Gone, Flags
+"   - ReNew (deprecated synonym for Upgrade)
+"   - Delete (deprecated synonym for Gone)
+"   - All and Full, since they can be combined with other flags
+" Then try to match the "second style" (as defined by mbsync's man page),
+" which is a concatenation of direction Flags (Pull/Push) and of the
+" operations seen above (New, Old, Upgrade/Renew, Gone/Delete, Flags, Full).
+" Note that while "PullFull" exists, "PullAll" is not handled by mbsync's
+" parser.
+" Last but not least, match "\s+%(All of the above, except None) as multiple
+" operations may be given to Sync.
+syn match mbsCConfSyncOpt / (
+  \None
+  \|%(Pull|Push|New|Old|Upgrade|ReNew|Gone|Delete|Flags|Full|All
+    \|%(Pull|Push)%(New|Old|Upgrade|ReNew|Gone|Delete|Flags|Full))
+  \%(\s+%(Pull|Push|New|Old|Upgrade|ReNew|Gone|Delete|Flags|Full|All
+        \|%(Pull|Push)%(New|Old|Upgrade|ReNew|Gone|Delete|Flags|Full)))*)$/ 
display contained
 syn match mbsCConfStSync          '^Sync\s\+\ze.*$'           
contains=mbsCConfItemK contained nextgroup=mbsCConfSyncOpt transparent
 syn keyword mbsCConfManipOpt  None Far Near Both contained
 syn match mbsCConfStCreate        '^Create\s\+\ze.*$'         
contains=mbsCConfItemK contained nextgroup=mbsCConfManipOpt transparent

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1wPoUO-00FKIh-Ew%40256bit.org.

Raspunde prin e-mail lui