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