Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 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) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 11 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 12 | " quit when a syntax file was already loaded |
| 13 | if exists("b:current_syntax") |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 14 | finish |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 15 | endif |
| 16 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 17 | let s:cpo_save = &cpo |
| 18 | set cpo&vim |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 19 | syn case match |
| 20 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 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 | |
| 32 | if exists("g:desktop_enable_nonstd") && g:desktop_enable_nonstd |
| 33 | let s:desktop_enable_nonstd = v:true |
| 34 | else |
| 35 | let s:desktop_enable_nonstd = v:false |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 36 | endif |
| 37 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 38 | if exists("g:desktop_enable_kde") && g:desktop_enable_kde || s:desktop_enable_nonstd |
| 39 | let s:desktop_enable_kde = v:true |
| 40 | else |
| 41 | let s:desktop_enable_kde = v:false |
| 42 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 43 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 44 | " Comment {{{1 |
| 45 | syn match dtComment /^#.*$/ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 46 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 47 | " Error {{{1 |
| 48 | syn match dtError /\%(^\s.*\|\s\+$\)/ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 49 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 50 | " Group Header {{{1 |
| 51 | " ASCII printable characters except for brackets [ (0x5B) and ] (0x5D) |
| 52 | syn match dtGroup /^\[[\x20-\x5A\x5C\x5E-\x7E]\+\]$/ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 53 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 54 | " Entries {{{1 |
| 55 | syn match dtDelim /=/ contained |
| 56 | " lang_territory.codeset@modifier |
| 57 | syn 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 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 60 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 61 | " Boolean Value {{{2 |
| 62 | syn match dtBoolean |
| 63 | \ /^\%(DBusActivatable\|Hidden\|NoDisplay\|PrefersNonDefaultGPU\|StartupNotify\|Terminal\)\s*=\s*\%(true\|false\)/ |
| 64 | \ contains=dtBooleanKey,dtDelim,dtBooleanValue transparent |
| 65 | syn keyword dtBooleanKey |
| 66 | \ DBusActivatable Hidden NoDisplay PrefersNonDefaultGPU StartupNotify Terminal |
| 67 | \ contained nextgroup=dtDelim |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 68 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 69 | if 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 |
| 76 | endif |
| 77 | syn keyword dtBooleanValue true false contained |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 78 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 79 | " Numeric Value {{{2 |
| 80 | " icon theme |
| 81 | syn match dtNumeric /^\%(MaxSize\|MinSize\|Size\|Threshold\)\s*=\s*\d\+/ contains=dtNumericKey,dtDelim,dtNumericDecimal |
| 82 | syn keyword dtNumericKey |
| 83 | \ MaxSize MinSize Size Threshold |
| 84 | \ contained nextgroup=dtDelim |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 85 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 86 | if 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 |
| 91 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 92 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 93 | syn match dtNumericDecimal /\<\d\+$/ contained |
| 94 | |
| 95 | " String Value {{{2 |
| 96 | syn match dtString |
| 97 | \ /^\%(Actions\|Implements\|MimeType\|NotShowIn\|OnlyShowIn\|Path\|StartupWMClass\|URL\)\s*=.*\S/ |
| 98 | \ contains=dtStringKey,dtDelim transparent |
| 99 | syn keyword dtStringKey |
| 100 | \ Actions Implements MimeType NotShowIn OnlyShowIn Path StartupWMClass URL Version |
| 101 | \ contained nextgroup=dtDelim |
| 102 | |
| 103 | " icon theme |
| 104 | syn match dtString |
| 105 | \ /^\%(Context\|Directories\|Example\|Inherits\)\s*=.*\S/ |
| 106 | \ contains=dtStringKey,dtDelim transparent |
| 107 | syn keyword dtStringKey |
| 108 | \ Context Directories Example Inherits |
| 109 | \ contained nextgroup=dtDelim |
| 110 | |
| 111 | if 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 |
| 118 | endif |
| 119 | |
| 120 | " Categories {{{3 |
| 121 | " https://specifications.freedesktop.org/menu-spec/menu-spec-1.0.html#category-registry |
| 122 | syn match dtCategories /^Categories\s*=.\+\S/ contains=dtCategoriesKey,dtDelim,dtCategoriesValue transparent |
| 123 | syn keyword dtCategoriesKey |
| 124 | \ Categories |
| 125 | \ contained nextgroup=dtDelim |
| 126 | |
| 127 | " Main Categories |
| 128 | syn keyword dtCategoriesValue |
| 129 | \ Audio AudioVideo Development Education Game Graphics Network Office |
| 130 | \ Settings System Utility Video |
| 131 | \ contained |
| 132 | |
| 133 | " Additional Categories |
| 134 | syn 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 |
| 158 | syn keyword dtCategoriesValue |
| 159 | \ Applet Screensaver Shell TrayIcon |
| 160 | \ contained |
| 161 | |
| 162 | " Exec/TryExec {{{3 |
| 163 | syn match dtExec /^\%(Exec\|TryExec\)\s*=.\+\S/ contains=dtExecKey,dtDelim,dtExecParam transparent |
| 164 | syn keyword dtExecKey |
| 165 | \ Exec TryExec |
| 166 | \ contained nextgroup=dtDelim |
| 167 | " code for file(s), URL(s), etc |
| 168 | syn match dtExecParam /\s\zs%[fFuUick]\ze\%(\W\|$\)/ contained |
| 169 | |
| 170 | " Type {{{3 |
| 171 | syn match dtType /^Type\s*=\s*\S\+/ contains=dtTypeKey,dtDelim,dtTypeValue transparent |
| 172 | syn keyword dtTypeKey |
| 173 | \ Type |
| 174 | \ contained nextgroup=dtDelim |
| 175 | syn keyword dtTypeValue |
| 176 | \ Application Directory Link |
| 177 | \ contained |
| 178 | |
| 179 | if s:desktop_enable_kde |
| 180 | syn keyword dtTypeValue |
| 181 | \ FSDevice Service ServiceType |
| 182 | \ contained |
| 183 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 184 | |
| 185 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 186 | " Version {{{3 |
| 187 | syn match dtVersion /^Version\s*=\s*\S\+/ contains=dtVersionKey,dtDelim,dtVersionValue transparent |
| 188 | syn keyword dtVersionKey |
| 189 | \ Version |
| 190 | \ contained nextgroup=dtDelim |
| 191 | syn match dtVersionValue /[0-9]\+\%(\.[0-9]\+\)\{1,2}$/ contained |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 192 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 193 | " Localestring Value {{{2 |
| 194 | syn match dtLocalestring |
| 195 | \ /^\%(Comment\|GenericName\|Keywords\|Name\)\%(\[.\{-}\]\)\?\s*=.*\S/ |
| 196 | \ contains=dtLocalestringKey,dtLocaleSuffix,dtDelim transparent |
| 197 | syn keyword dtLocalestringKey |
| 198 | \ Comment GenericName Keywords Name |
| 199 | \ contained nextgroup=dtLocaleSuffix,dtDelim skipwhite |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 200 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 201 | " Iconstring Value {{{2 |
| 202 | syn match dtIconstring |
| 203 | \ /^Icon\s*=.*\S/ |
| 204 | \ contains=dtIconstringKey,dtDelim transparent |
| 205 | syn keyword dtIconstringKey |
| 206 | \ Icon |
| 207 | \ contained nextgroup=dtDelim skipwhite |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 208 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 209 | if 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 |
| 216 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 217 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 218 | " X-Extension {{{2 |
| 219 | syn match dtXExtension /^X-[0-9A-Za-z-]*\%(\[.\{-}\]\)\?\s*=.*\S/ |
| 220 | \ contains=dtXExtensionKey,dtLocaleSuffix,dtDelim transparent |
| 221 | syn match dtXExtensionKey /^X-[0-9A-Za-z-]*/ contained nextgroup=dtLocaleSuffix,dtDelim |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 222 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 223 | " non standard {{{2 |
| 224 | if 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 |
| 228 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 229 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 230 | " Highlight {{{1 |
| 231 | hi def link dtComment Comment |
| 232 | hi def link dtError Error |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 233 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 234 | hi def link dtGroup Special |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 235 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 236 | hi def link dtDelim Delimiter |
| 237 | hi def link dtLocaleSuffix Identifier |
| 238 | |
| 239 | hi def link dtBooleanKey Type |
| 240 | hi def link dtBooleanValue Boolean |
| 241 | |
| 242 | hi def link dtNumericKey Type |
| 243 | hi def link dtNumericDecimal Number |
| 244 | |
| 245 | hi def link dtStringKey Type |
| 246 | hi def link dtCategoriesKey Type |
| 247 | hi def link dtCategoriesValue Constant |
| 248 | hi def link dtExecKey Type |
| 249 | hi def link dtExecParam Special |
| 250 | hi def link dtTypeKey Type |
| 251 | hi def link dtTypeValue Constant |
| 252 | hi def link dtVersionKey Type |
| 253 | hi def link dtVersionValue Constant |
| 254 | |
| 255 | hi def link dtLocalestringKey Type |
| 256 | |
| 257 | hi def link dtIconStringKey Type |
| 258 | |
| 259 | hi def link dtXExtensionKey Type |
| 260 | |
| 261 | hi def link dtNonStdLabelKey Type |
| 262 | |
| 263 | " Clean Up {{{1 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 264 | let b:current_syntax = "desktop" |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 265 | let &cpo = s:cpo_save |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 266 | |
Bram Moolenaar | 65e0d77 | 2020-06-14 17:29:55 +0200 | [diff] [blame] | 267 | " vim:ts=8:sw=2:fdm=marker |