blob: 461ba855b979d18a7802f27e3a4d842d40584bef [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
Bram Moolenaar65e0d772020-06-14 17:29:55 +02002" 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 )
Bram Moolenaar9fbdbb82022-09-27 17:30:34 +01006" Last Change: 2022 Sep 22
Bram Moolenaar65e0d772020-06-14 17:29:55 +02007" 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 Moolenaar071d4272004-06-13 20:20:40 +000011
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020012" quit when a syntax file was already loaded
13if exists("b:current_syntax")
Bram Moolenaar65e0d772020-06-14 17:29:55 +020014 finish
Bram Moolenaar071d4272004-06-13 20:20:40 +000015endif
16
Bram Moolenaar65e0d772020-06-14 17:29:55 +020017let s:cpo_save = &cpo
18set cpo&vim
Bram Moolenaar071d4272004-06-13 20:20:40 +000019syn case match
20
Bram Moolenaar65e0d772020-06-14 17:29:55 +020021" 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
Bram Moolenaar071d4272004-06-13 20:20:40 +000036endif
37
Bram Moolenaar65e0d772020-06-14 17:29:55 +020038if 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
Bram Moolenaar071d4272004-06-13 20:20:40 +000043
Bram Moolenaar65e0d772020-06-14 17:29:55 +020044" Comment {{{1
45syn match dtComment /^#.*$/
Bram Moolenaar071d4272004-06-13 20:20:40 +000046
Bram Moolenaar65e0d772020-06-14 17:29:55 +020047" Error {{{1
48syn match dtError /\%(^\s.*\|\s\+$\)/
Bram Moolenaar071d4272004-06-13 20:20:40 +000049
Bram Moolenaar65e0d772020-06-14 17:29:55 +020050" Group Header {{{1
51" ASCII printable characters except for brackets [ (0x5B) and ] (0x5D)
52syn match dtGroup /^\[[\x20-\x5A\x5C\x5E-\x7E]\+\]$/
Bram Moolenaar071d4272004-06-13 20:20:40 +000053
Bram Moolenaar65e0d772020-06-14 17:29:55 +020054" 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
Bram Moolenaar071d4272004-06-13 20:20:40 +000060
Bram Moolenaar65e0d772020-06-14 17:29:55 +020061" Boolean Value {{{2
62syn match dtBoolean
Bram Moolenaar9fbdbb82022-09-27 17:30:34 +010063 \ /^\%(DBusActivatable\|Hidden\|NoDisplay\|PrefersNonDefaultGPU\|SingleMainWindow\|StartupNotify\|Terminal\)\s*=\s*\%(true\|false\)/
Bram Moolenaar65e0d772020-06-14 17:29:55 +020064 \ contains=dtBooleanKey,dtDelim,dtBooleanValue transparent
65syn keyword dtBooleanKey
Bram Moolenaar9fbdbb82022-09-27 17:30:34 +010066 \ DBusActivatable Hidden NoDisplay PrefersNonDefaultGPU SingleMainWindow StartupNotify Terminal
Bram Moolenaar65e0d772020-06-14 17:29:55 +020067 \ contained nextgroup=dtDelim
Bram Moolenaar071d4272004-06-13 20:20:40 +000068
Bram Moolenaar65e0d772020-06-14 17:29:55 +020069if 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
Bram Moolenaar071d4272004-06-13 20:20:40 +000078
Bram Moolenaar65e0d772020-06-14 17:29:55 +020079" 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
Bram Moolenaar071d4272004-06-13 20:20:40 +000085
Bram Moolenaar65e0d772020-06-14 17:29:55 +020086if 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
Bram Moolenaar071d4272004-06-13 20:20:40 +000092
Bram Moolenaar65e0d772020-06-14 17:29:55 +020093syn 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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000184
185
Bram Moolenaar65e0d772020-06-14 17:29:55 +0200186" 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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000192
Bram Moolenaar65e0d772020-06-14 17:29:55 +0200193" 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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000200
Bram Moolenaar65e0d772020-06-14 17:29:55 +0200201" 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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000208
Bram Moolenaar65e0d772020-06-14 17:29:55 +0200209if 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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000217
Bram Moolenaar65e0d772020-06-14 17:29:55 +0200218" 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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000222
Bram Moolenaar65e0d772020-06-14 17:29:55 +0200223" 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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000229
Bram Moolenaar65e0d772020-06-14 17:29:55 +0200230" Highlight {{{1
231hi def link dtComment Comment
232hi def link dtError Error
Bram Moolenaar071d4272004-06-13 20:20:40 +0000233
Bram Moolenaar65e0d772020-06-14 17:29:55 +0200234hi def link dtGroup Special
Bram Moolenaar071d4272004-06-13 20:20:40 +0000235
Bram Moolenaar65e0d772020-06-14 17:29:55 +0200236hi 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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000264let b:current_syntax = "desktop"
Bram Moolenaar65e0d772020-06-14 17:29:55 +0200265let &cpo = s:cpo_save
Bram Moolenaar071d4272004-06-13 20:20:40 +0000266
Bram Moolenaar65e0d772020-06-14 17:29:55 +0200267" vim:ts=8:sw=2:fdm=marker