1" Vim syntax file 2" Language: XDG desktop entry 3" Filenames: *.desktop, *.directory 4" Maintainer: Eisuke Kawashima ( e.kawaschima+vim AT gmail.com ) 5" Previous Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl ) 6" Last Change: 2020-06-11 7" Version Info: desktop.vim 1.5 8" References: 9" - https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-1.5.html (2020-04-27) 10" - https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-0.11.html (2006-02-07) 11 12" quit when a syntax file was already loaded 13if exists("b:current_syntax") 14 finish 15endif 16 17let s:cpo_save = &cpo 18set cpo&vim 19syn case match 20 21" Variable {{{1 22" This syntax file can be used to all *nix configuration files similar to dos 23" ini format (eg. .xawtv, .radio, kde rc files) - this is default mode. 24" By default strict following of freedesktop.org standard is enforced. 25" To highlight nonstandard extensions that does not begin with X-, set 26" let g:desktop_enable_nonstd = v:true 27" Note that this may cause wrong highlight. 28" To highlight KDE-reserved features, set 29" let g:desktop_enable_kde = v:true 30" g:desktop_enable_kde follows g:desktop_enable_nonstd if not supplied 31 32if exists("g:desktop_enable_nonstd") && g:desktop_enable_nonstd 33 let s:desktop_enable_nonstd = v:true 34else 35 let s:desktop_enable_nonstd = v:false 36endif 37 38if exists("g:desktop_enable_kde") && g:desktop_enable_kde || s:desktop_enable_nonstd 39 let s:desktop_enable_kde = v:true 40else 41 let s:desktop_enable_kde = v:false 42endif 43 44" Comment {{{1 45syn match dtComment /^#.*$/ 46 47" Error {{{1 48syn match dtError /\%(^\s.*\|\s\+$\)/ 49 50" Group Header {{{1 51" ASCII printable characters except for brackets [ (0x5B) and ] (0x5D) 52syn match dtGroup /^\[[\x20-\x5A\x5C\x5E-\x7E]\+\]$/ 53 54" Entries {{{1 55syn match dtDelim /=/ contained 56" lang_territory.codeset@modifier 57syn match dtLocaleSuffix 58 \ /\[\%(C\|POSIX\|[a-z]\{2,4}\%(_[A-Z0-9]\{2,3}\)\?\)\%(\.[A-Za-z0-9_-]\+\)\?\%(@[A-Za-z]\+\)\?\]\ze\s*=/ 59 \ contained 60 61" Boolean Value {{{2 62syn match dtBoolean 63 \ /^\%(DBusActivatable\|Hidden\|NoDisplay\|PrefersNonDefaultGPU\|StartupNotify\|Terminal\)\s*=\s*\%(true\|false\)/ 64 \ contains=dtBooleanKey,dtDelim,dtBooleanValue transparent 65syn keyword dtBooleanKey 66 \ DBusActivatable Hidden NoDisplay PrefersNonDefaultGPU StartupNotify Terminal 67 \ contained nextgroup=dtDelim 68 69if s:desktop_enable_kde 70 syn match dtBoolean 71 \ /^ReadOnly\s*=\s*\%(true\|false\)/ 72 \ contains=dtBooleanKey,dtDelim,dtBooleanValue transparent 73 syn keyword dtBooleanKey 74 \ ReadOnly 75 \ contained nextgroup=dtDelim 76endif 77syn keyword dtBooleanValue true false contained 78 79" Numeric Value {{{2 80" icon theme 81syn match dtNumeric /^\%(MaxSize\|MinSize\|Size\|Threshold\)\s*=\s*\d\+/ contains=dtNumericKey,dtDelim,dtNumericDecimal 82syn keyword dtNumericKey 83 \ MaxSize MinSize Size Threshold 84 \ contained nextgroup=dtDelim 85 86if s:desktop_enable_kde 87 syn match dtNumeric /^InitialPreference\s*=\s*\d\+/ contains=dtNumericKey,dtDelim,dtNumericDecimal 88 syn keyword dtNumericKey 89 \ InitialPreference 90 \ contained nextgroup=dtDelim 91endif 92 93syn match dtNumericDecimal /\<\d\+$/ contained 94 95" String Value {{{2 96syn match dtString 97 \ /^\%(Actions\|Implements\|MimeType\|NotShowIn\|OnlyShowIn\|Path\|StartupWMClass\|URL\)\s*=.*\S/ 98 \ contains=dtStringKey,dtDelim transparent 99syn keyword dtStringKey 100 \ Actions Implements MimeType NotShowIn OnlyShowIn Path StartupWMClass URL Version 101 \ contained nextgroup=dtDelim 102 103" icon theme 104syn match dtString 105 \ /^\%(Context\|Directories\|Example\|Inherits\)\s*=.*\S/ 106 \ contains=dtStringKey,dtDelim transparent 107syn keyword dtStringKey 108 \ Context Directories Example Inherits 109 \ contained nextgroup=dtDelim 110 111if s:desktop_enable_kde 112 syn match dtString 113 \ /^\%(Dev\|DocPath\|FSType\|MountPoint\|ServiceTypes\)\s*=.*\S/ 114 \ contains=dtStringKey,dtDelim transparent 115 syn keyword dtStringKey 116 \ Dev DocPath FSType MountPoint ServiceTypes 117 \ contained nextgroup=dtDelim 118endif 119 120" Categories {{{3 121" https://specifications.freedesktop.org/menu-spec/menu-spec-1.0.html#category-registry 122syn match dtCategories /^Categories\s*=.\+\S/ contains=dtCategoriesKey,dtDelim,dtCategoriesValue transparent 123syn keyword dtCategoriesKey 124 \ Categories 125 \ contained nextgroup=dtDelim 126 127" Main Categories 128syn keyword dtCategoriesValue 129 \ Audio AudioVideo Development Education Game Graphics Network Office 130 \ Settings System Utility Video 131 \ contained 132 133" Additional Categories 134syn keyword dtCategoriesValue 135 \ BoardGame Chat Clock Geoscience Presentation 2DGraphics 3DGraphics 136 \ Accessibility ActionGame AdventureGame Amusement ArcadeGame Archiving 137 \ Art ArtificialIntelligence Astronomy AudioVideoEditing Biology 138 \ BlocksGame BoardGame Building Calculator Calendar CardGame Chart Chat 139 \ Chemistry Clock Compression ComputerScience ConsoleOnly Construction 140 \ ContactManagement Core DataVisualization Database Debugger 141 \ DesktopSettings Dialup Dictionary DiscBurning Documentation Economy 142 \ Electricity Electronics Email Emulator Engineering FileManager 143 \ FileTools FileTransfer Filesystem Finance FlowChart GNOME GTK 144 \ GUIDesigner Geography Geology Geoscience HamRadio HardwareSettings 145 \ History IDE IRCClient ImageProcessing InstantMessaging Java KDE 146 \ KidsGame Languages Literature LogicGame Math MedicalSoftware Midi 147 \ Mixer Monitor Motif Music News NumericalAnalysis OCR P2P PDA 148 \ PackageManager ParallelComputing Photography Physics Player 149 \ Presentation Printing Profiling ProjectManagement Publishing Qt 150 \ RasterGraphics Recorder RemoteAccess RevisionControl Robotics 151 \ RolePlaying Scanning Science Security Sequencer Simulation Sports 152 \ SportsGame Spreadsheet StrategyGame TV Telephony TelephonyTools 153 \ TerminalEmulator TextEditor TextTools Translation Tuner VectorGraphics 154 \ VideoConference Viewer WebBrowser WebDevelopment WordProcessor 155 \ contained 156 157" Reserved Category 158syn keyword dtCategoriesValue 159 \ Applet Screensaver Shell TrayIcon 160 \ contained 161 162" Exec/TryExec {{{3 163syn match dtExec /^\%(Exec\|TryExec\)\s*=.\+\S/ contains=dtExecKey,dtDelim,dtExecParam transparent 164syn keyword dtExecKey 165 \ Exec TryExec 166 \ contained nextgroup=dtDelim 167" code for file(s), URL(s), etc 168syn match dtExecParam /\s\zs%[fFuUick]\ze\%(\W\|$\)/ contained 169 170" Type {{{3 171syn match dtType /^Type\s*=\s*\S\+/ contains=dtTypeKey,dtDelim,dtTypeValue transparent 172syn keyword dtTypeKey 173 \ Type 174 \ contained nextgroup=dtDelim 175syn keyword dtTypeValue 176 \ Application Directory Link 177 \ contained 178 179if s:desktop_enable_kde 180 syn keyword dtTypeValue 181 \ FSDevice Service ServiceType 182 \ contained 183endif 184 185 186" Version {{{3 187syn match dtVersion /^Version\s*=\s*\S\+/ contains=dtVersionKey,dtDelim,dtVersionValue transparent 188syn keyword dtVersionKey 189 \ Version 190 \ contained nextgroup=dtDelim 191syn match dtVersionValue /[0-9]\+\%(\.[0-9]\+\)\{1,2}$/ contained 192 193" Localestring Value {{{2 194syn match dtLocalestring 195 \ /^\%(Comment\|GenericName\|Keywords\|Name\)\%(\[.\{-}\]\)\?\s*=.*\S/ 196 \ contains=dtLocalestringKey,dtLocaleSuffix,dtDelim transparent 197syn keyword dtLocalestringKey 198 \ Comment GenericName Keywords Name 199 \ contained nextgroup=dtLocaleSuffix,dtDelim skipwhite 200 201" Iconstring Value {{{2 202syn match dtIconstring 203 \ /^Icon\s*=.*\S/ 204 \ contains=dtIconstringKey,dtDelim transparent 205syn keyword dtIconstringKey 206 \ Icon 207 \ contained nextgroup=dtDelim skipwhite 208 209if s:desktop_enable_kde 210 syn match dtIconstring 211 \ /^UnmountIcon\>\%(\[.\{-}\]\)\?\s*=.*\S/ 212 \ contains=dtIconstringKey,dtLocaleSuffix,dtDelim transparent 213 syn keyword dtIconstringKey 214 \ UnmountIcon 215 \ contained nextgroup=dtLocaleSuffix,dtDelim skipwhite 216endif 217 218" X-Extension {{{2 219syn match dtXExtension /^X-[0-9A-Za-z-]*\%(\[.\{-}\]\)\?\s*=.*\S/ 220 \ contains=dtXExtensionKey,dtLocaleSuffix,dtDelim transparent 221syn match dtXExtensionKey /^X-[0-9A-Za-z-]*/ contained nextgroup=dtLocaleSuffix,dtDelim 222 223" non standard {{{2 224if s:desktop_enable_nonstd 225 syn match dtNonStdLabel /^[0-9A-Za-z-]\+\%(\[.\{-}\]\)\?\s*=.*\S/ 226 \ contains=dtNonStdLabelKey,dtLocaleSuffix,dtDelim transparent 227 syn match dtNonStdLabelKey /^[0-9A-Za-z-]\+/ contained nextgroup=dtLocaleSuffix,dtDelim 228endif 229 230" Highlight {{{1 231hi def link dtComment Comment 232hi def link dtError Error 233 234hi def link dtGroup Special 235 236hi def link dtDelim Delimiter 237hi def link dtLocaleSuffix Identifier 238 239hi def link dtBooleanKey Type 240hi def link dtBooleanValue Boolean 241 242hi def link dtNumericKey Type 243hi def link dtNumericDecimal Number 244 245hi def link dtStringKey Type 246hi def link dtCategoriesKey Type 247hi def link dtCategoriesValue Constant 248hi def link dtExecKey Type 249hi def link dtExecParam Special 250hi def link dtTypeKey Type 251hi def link dtTypeValue Constant 252hi def link dtVersionKey Type 253hi def link dtVersionValue Constant 254 255hi def link dtLocalestringKey Type 256 257hi def link dtIconStringKey Type 258 259hi def link dtXExtensionKey Type 260 261hi def link dtNonStdLabelKey Type 262 263" Clean Up {{{1 264let b:current_syntax = "desktop" 265let &cpo = s:cpo_save 266 267" vim:ts=8:sw=2:fdm=marker 268