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