robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
74cc0364f1
master
1" Vim syntax file 2" Language: mbsyncrc 3" Maintainer: Pierrick Guillaume <pguillaume@fymyte.com> 4" Last Change: 2025 Apr 13 5" 2025 Jun 04 by Vim project: match TLSType configuration variable 6" 2026 Jan 15 by Vim project: support TLSVersions keyword 7" 2026 May 20 by Vim project: handle sync keyword #20243 8" 9" Syntax support for mbsync config file 10 11" This file is based on the mbsync manual (isync v1.4.4) 12" https://isync.sourceforge.io/mbsync.html 13 14if exists ( 'b:current_syntax' ) 15finish 16endif 17 18let b: current_syntax = 'mbsync' 19 20let s: cpo_save = & cpo 21set cpo & vim 22 23syn match mbsError '. * ' 24 25syn match mbsCommentL '^#. * $ ' 26 27" Properties {{{ 28 29syn match mbsNumber '[ 0-9 ] \+ 'display contained 30syn match mbsPath '\%( [ A-Za-z0-9/._+#$%~=\\{}\[\]:@!- ] \|\\.\)\+ 'display contained 31syn match mbsPath '"\%( [ A-Za-z0-9/._+#$%~=\\{}\[\]:@! - ] \|\\.\)\+" 'display contained 32syn match mbsName '\%( [ A-Za-z0-9/._+#$%~=\\{}\[\]:@!- ] \|\\.\)\+ 'display contained 33syn match mbsName '"\%( [ A-Za-z0-9/._+#$%~=\\{}\[\]:@! - ] \|\\.\)\+" 'display contained 34syn match mbsCommand '+\?. * $ 'display contained contains = mbsCommandPrompt 35syn match mbsCommandPrompt '+ 'display contained 36syn region mbsString start = +" +skip = +\\" +end = +" +display contained 37syn match mbsSizeUnit '[ kKmMbB ] 'display contained 38syn match mbsSize '[ 0-9 ] \+ 'display contained contains = mbsNumber nextgroup = mbsSizeUnit 39syn keyword mbsBool yes no contained 40 41" }}} 42 43 44" Stores {{{ 45" Global Store Config Items 46syn match mbsGlobConfPath '^Path\s\+\ze. * $ 'contains = mbsGlobConfItemK contained nextgroup = mbsPath transparent 47syn match mbsGlobConfMaxSize '^MaxSize\s\+\ze. * $ 'contains = mbsGlobConfItemK contained nextgroup = mbsSize transparent 48syn match mbsGlobConfMapInbox '^MapInbox\s\+\ze. * $ 'contains = mbsGlobConfItemK contained nextgroup = mbsPath transparent 49syn match mbsGlobConfFlatten '^Flatten\s\+\ze. * $ 'contains = mbsGlobConfItemK contained nextgroup = mbsPath transparent 50syn match mbsGlobConfTrash '^Trash\s\+\ze. * $ 'contains = mbsGlobConfItemK contained nextgroup = mbsPath transparent 51syn match mbsGlobConfTrashNO '^TrashNewOnly\s\+\ze. * $ 'contains = mbsGlobConfItemK contained nextgroup = mbsBool transparent 52syn match mbsGlobConfTrashRN '^TrashRemoteNew\s\+\ze. * $ 'contains = mbsGlobConfItemK contained nextgroup = mbsBool transparent 53syn keyword mbsGlobConfItemK Path MaxSize MapInbox Flatten Trash TrashNewOnly TrashRemoteNew contained 54 55syn cluster mbsGlobConfItem contains = mbsGlobConfPath , mbsGlobConfMaxSize , mbsGlobConfMapInbox , mbsGlobConfFlatten , mbsCommentL , mbsGlobConfTrash. * 56 57 58" MaildirStore 59syn match mbsMdSConfStMaildirStore '^MaildirStore\s\+\ze. * $ 'contains = mbsMdSConfItemK contained nextgroup = mbsName transparent 60syn match mbsMdSConfStAltMap '^AltMap\s\+\ze. * $ 'contains = mbsMdSConfItemK contained nextgroup = mbsBool transparent 61syn match mbsMdsConfStInbox '^Inbox\s\+\ze. * $ 'contains = mbsMdSConfItemK contained nextgroup = mbsPath transparent 62syn match mbsMdsConfStInfoDelimiter '^InfoDelimiter\s\+\ze. * $ 'contains = mbsMdSConfItemK contained nextgroup = mbsPath transparent 63syn keyword mbsMdSConfSubFoldersOpt Verbatim Legacy contained 64syn match mbsMdSConfSubFoldersOpt 'Maildir++ 'display contained 65syn match mbsMdsConfStSubFolders '^SubFolders\s\+\ze. * $ 'contains = mbsMdSConfItemK contained nextgroup = mbsMdSConfSubFoldersOpt transparent 66 67syn cluster mbsMdSConfItem contains = mbsMdSConfSt. * 68 69syn keyword mbsMdSConfItemK MaildirStore AltMap Inbox InfoDelimiter SubFolders contained 70 71syn region mbsMaildirStore start = "^MaildirStore "end = "^$ "end = '\%$ 'contains = @mbsGlobConfItem , mbsCommentL , @mbsMdSConfItem , mbsError transparent 72 73 74" IMAP4Accounts 75syn match mbsIAConfStIMAPAccount '^IMAPAccount\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsName transparent 76syn match mbsIAConfStHost '^Host\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsPath transparent 77syn match mbsIAConfStPort '^Port\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsNumber transparent 78syn match mbsIAConfStTimeout '^Timeout\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsNumber transparent 79syn match mbsIAConfStUser '^User\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsPath transparent 80syn match mbsIAConfStUserCmd '^UserCmd\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsCommand transparent 81syn match mbsIAConfStPass '^Pass\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsPath transparent 82syn match mbsIAConfStPassCmd '^PassCmd\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsCommand transparent 83syn match mbsIAConfStUseKeychain '^UseKeychain\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsBool transparent 84syn match mbsIAConfStTunnel '^Tunnel\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsCommand transparent 85syn match mbsIAConfStAuthMechs '^AuthMechs\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsPath transparent 86syn keyword mbsIAConfTLSTypeOpt None STARTTLS IMAPS contained 87syn match mbsIAConfStSSLType '^SSLType\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsIAConfTLSTypeOpt transparent 88syn match mbsIAConfStTLSType '^TLSType\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsIAConfTLSTypeOpt transparent 89syn match mbsIAConfSSLVersionsOpt '\%(SSLv3\|TLSv1\%(. [ 123 ] \)\?\)\%(\s\+\%(SSLv3\|TLSv1\%(. [ 123 ] \)\?\)\) * 'contained 90syn match mbsIAConfTLSVersionsOpt '[ +- ] \d\.\d\(\s\+ [ +- ] \d\.\d\) * 'contained 91syn match mbsIAConfStSSLVersions '^SSLVersions\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsIAConfSSLVersionsOpt transparent 92syn match mbsIAConfStTLSVersions '^TLSVersions\s\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsIAConfTLSVersionsOpt transparent 93syn match mbsIAConfStSystemCertificates '^SystemCertificates\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsBool transparent 94syn match mbsIAConfStCertificateFile '^CertificateFile\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsPath transparent 95syn match mbsIAConfStClientCertificate '^ClientCertificate\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsPath transparent 96syn match mbsIAConfStClientKey '^ClientKey\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsPath transparent 97syn match mbsIAConfStCipherString '^CipherString\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsString transparent 98syn match mbsIAConfStPipelineDepth '^PipelineDepth\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsNumber transparent 99syn match mbsIAConfStDisableExtensions '^DisableExtensions\?\s\+\ze. * $ 'contains = mbsIAConfItemK contained nextgroup = mbsPath transparent 100 101syn cluster mbsIAConfItem contains = mbsIAConfSt. * 102syn keyword mbsIAConfItemK 103 \IMAPAccount Host Port Timeout User UserCmd Pass PassCmd UseKeychain Tunnel TLSVersions 104 \AuthMechs SSLType TLSType SSLVersions SystemCertificates CertificateFile ClientCertificate 105 \ClientKey CipherString PipelineDepth DisableExtension[s] contained 106 107syn region mbsIMAP4AccontsStore start = "^IMAPAccount "end = "^$ "end = "\%$ "contains = @mbsGlobConfItem , mbsCommentL , @mbsIAConfItem , mbsError transparent 108 109 110" IMAPStores 111syn match mbsISConfStIMAPStore '^IMAPStore\s\+\ze. * $ 'contains = mbsISConfItemK contained nextgroup = mbsName transparent 112syn match mbsISConfStAccount '^Account\s\+\ze. * $ 'contains = mbsISConfItemK contained nextgroup = mbsName transparent 113syn match mbsISConfStUseNamespace '^UseNamespace\s\+\ze. * $ 'contains = mbsISConfItemK contained nextgroup = mbsBool transparent 114syn match mbsISConfStPathDelimiter '^PathDelimiter\s\+\ze. * $ 'contains = mbsISConfItemK contained nextgroup = mbsPath transparent 115syn match mbsISConfStSubscribedOnly '^SubscribedOnly\s\+\ze. * $ 'contains = mbsISConfItemK contained nextgroup = mbsBool transparent 116 117syn cluster mbsISConfItem contains = mbsISConfSt. * 118syn keyword mbsISConfItemK IMAPStore Account UseNamespace PathDelimiter SubscribedOnly contained 119 120syn region mbsIMAPStore start = "^IMAPStore "end = "^$ "end = "\%$ "contains = @mbsGlobConfItem , mbsCommentL , @mbsISConfItem , mbsError transparent 121 122" }}} 123 124" Channels {{{ 125 126syn match mbsCConfStChannel '^Channel\s\+\ze. * $ 'contains = mbsCConfItemK contained nextgroup = mbsName transparent 127syn region mbsCConfProxOpt matchgroup = mbsCConfProxOptOp start = ': 'matchgroup = mbsCConfProxOptOp end = ': 'contained contains = mbsName nextgroup = mbsPath keepend 128syn match mbsCConfStFar '^Far\s\+\ze. * $ 'contains = mbsCConfItemK contained nextgroup = mbsCConfProxOpt transparent 129syn match mbsCConfStNear '^Near\s\+\ze. * $ 'contains = mbsCConfItemK contained nextgroup = mbsCConfProxOpt transparent 130syn match mbsCConfPatternOptOp '[ *%! ] 'display contained 131syn match mbsCConfPatternOpt '. * $ 'display contained contains = mbsCConfPatternOptOp 132syn match mbsCConfStPattern '^Patterns\?\s\+\ze. * $ 'contains = mbsCConfItemK contained nextgroup = mbsCConfPatternOpt transparent 133syn match mbsCConfStMaxSize '^MaxSize\s\+\ze. * $ 'contains = mbsCConfItemK contained nextgroup = mbsSize transparent 134syn match mbsCConfStMaxMessages '^MaxMessages\s\+\ze. * $ 'contains = mbsCConfItemK contained nextgroup = mbsNumber transparent 135syn match mbsCConfStExpireUnread '^ExpireUnread\s\+\ze. * $ 'contains = mbsCConfItemK contained nextgroup = mbsBool transparent 136" Properly matching mbsCConfSyncOpt: 137" 138" None is a special case. From mbsync's man page: 139" "None may not be combined with any other operation." 140" Once "None" is out of the way, first try to match operations, including: 141" - New, Old, Upgrade, Gone, Flags 142" - ReNew (deprecated synonym for Upgrade) 143" - Delete (deprecated synonym for Gone) 144" - All and Full, since they can be combined with other flags 145" Then try to match the "second style" (as defined by mbsync's man page), 146" which is a concatenation of direction Flags (Pull/Push) and of the 147" operations seen above (New, Old, Upgrade/Renew, Gone/Delete, Flags, Full). 148" Note that while "PullFull" exists, "PullAll" is not handled by mbsync's 149" parser. 150" Last but not least, match "\s+%(All of the above, except None) as multiple 151" operations may be given to Sync. 152syn match mbsCConfSyncOpt /\v( 153\None 154\|%(Pull|Push|New|Old|Upgrade|ReNew|Gone|Delete|Flags|Full|All 155\|%(Pull|Push)%(New|Old|Upgrade|ReNew|Gone|Delete|Flags|Full)) 156\%(\s+%(Pull|Push|New|Old|Upgrade|ReNew|Gone|Delete|Flags|Full|All 157\|%(Pull|Push)%(New|Old|Upgrade|ReNew|Gone|Delete|Flags|Full))) * )$ /display contained 158syn match mbsCConfStSync '^Sync\s\+\ze. * $ 'contains = mbsCConfItemK contained nextgroup = mbsCConfSyncOpt transparent 159syn keyword mbsCConfManipOpt None Far Near Both contained 160syn match mbsCConfStCreate '^Create\s\+\ze. * $ 'contains = mbsCConfItemK contained nextgroup = mbsCConfManipOpt transparent 161syn match mbsCConfStRemove '^Remove\s\+\ze. * $ 'contains = mbsCConfItemK contained nextgroup = mbsCConfManipOpt transparent 162syn match mbsCConfStExpunge '^Expunge\s\+\ze. * $ 'contains = mbsCConfItemK contained nextgroup = mbsCConfManipOpt transparent 163syn match mbsCConfStCopyArrivalDate '^CopyArrivalDate\s\+\ze. * $ 'contains = mbsCConfItemK contained nextgroup = mbsBool transparent 164syn match mbsCConfSyncStateOpt '\*\|. * $ 'display contained contains = mbsCConfSyncStateOptOp , mbsPath transparent 165syn match mbsCConfSyncStateOptOp '\* 'display contained 166syn match mbsCConfStSyncState '^SyncState\s\+\ze. * $ 'contains = mbsCConfItemK contained nextgroup = mbsCConfSyncStateOpt transparent 167 168syn cluster mbsCConfItem contains = mbsCConfSt. * 169 170syn keyword mbsCConfItemK 171 \Channel Far Near Pattern[s] MaxSize MaxMessages ExpireUnread Sync Create 172 \Remove Expunge CopyArrivalDate SyncState contained 173 174syn region mbsChannel start = "^Channel "end = "^$ "end = "\%$ "contains = @mbsCConfItem , mbsCommentL , mbsError transparent 175 176" }}} 177 178" Groups {{{ 179 180syn match mbsGConfGroupOpt '\%( [ A-Za-z0-9/._+#$%~=\\{}\[\]:@!- ] \|\\.\)\+ 'display contained contains = mbsName nextgroup = mbsGConfChannelOpt 181syn match mbsGConfStGroup '^Group\s\+\ze. * $ 'contains = mbsGConfItemK contained nextgroup = mbsGConfGroupOpt transparent 182syn match mbsGConfChannelOpt '. * $ 'display contained 183syn match mbsGConfStChannel '^Channels\?\s\+\ze. * $ 'contains = mbsGConfItemK contained nextgroup = mbsGConfChannelOpt transparent 184 185syn cluster mbsGConfItem contains = mbsGConfSt. * 186 187syn keyword mbsGConfItemK Group Channel[s] contained 188 189syn region mbsGroup start = "^Group "end = "^$ "end = "\%$ "contains = @mbsGConfItem , mbsError transparent 190 191" }}} 192 193" Global Options {{{ 194 195syn match mbsFSync '^FSync\s\+\ze. * $ 'contains = mbsGlobOptItemK nextgroup = mbsBool transparent 196syn match mbsFieldDelimiter '^FieldDelimiter\s\+\ze. * $ 'contains = mbsGlobOptItemK nextgroup = mbsPath transparent 197syn match mbsBufferLimit '^BufferLimit\s\+\ze. * $ 'contains = mbsGlobOptItemK nextgroup = mbsSize transparent 198 199syn keyword mbsGlobOptItemK FSync FieldDelimiter BufferLimit contained 200" }}} 201 202" Highlights {{{ 203 204hi def link mbsError Error 205 206hi def link mbsCommentL Comment 207 208hi def link mbsNumber Number 209hi def link mbsSizeUnit Type 210hi def link mbsPath String 211hi def link mbsString String 212hi def link mbsCommand String 213hi def link mbsCommandPrompt Operator 214hi def link mbsName Constant 215hi def link mbsBool Boolean 216 217hi def link mbsGlobConfItemK Statement 218 219hi def link mbsMdSConfItemK Statement 220hi def link mbsMdSConfSubFoldersOpt Keyword 221 222hi def link mbsIAConfItemK Statement 223hi def link mbsIAConfTLSTypeOpt Keyword 224hi def link mbsIAConfSSLVersionsOpt Keyword 225hi def link mbsIAConfTLSVersionsOpt Keyword 226 227hi def link mbsISConfItemK Statement 228 229hi def link mbsCConfItemK Statement 230hi def link mbsCConfProxOptOp Operator 231hi def link mbsCConfPatternOpt String 232hi def link mbsCConfPatternOptOp Operator 233hi def link mbsCConfSyncOpt Keyword 234hi def link mbsCConfManipOpt Keyword 235hi def link mbsCConfSyncStateOptOp Operator 236 237hi def link mbsGConfItemK Statement 238hi def link mbsGConfChannelOpt String 239 240hi def link mbsGlobOptItemK Statement 241" }}} 242 243let & cpo = s: cpo_save 244unlet s: cpo_save