blob: 27dac5c8eea237564f3b857245c9e79261633bdd [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: .desktop, .directory files
3" according to freedesktop.org specification 0.9.4
4" http://pdx.freedesktop.org/Standards/desktop-entry-spec/desktop-entry-spec-0.9.4.html
5" Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl )
Bram Moolenaar939a1ab2016-04-10 01:31:25 +02006" Last Change: 2016 Apr 02
7" (added "Keywords")
Bram Moolenaar071d4272004-06-13 20:20:40 +00008" Version Info: desktop.vim 0.9.4-1.2
9
10" For version 5.x: Clear all syntax items
11" For version 6.x: Quit when a syntax file was already loaded
12if version < 600
13 syntax clear
14elseif exists("b:current_syntax")
15 finish
16endif
17
18" This syntax file can be used to all *nix configuration files similar to dos
19" ini format (eg. .xawtv, .radio, kde rc files) - this is default mode. But
20" you can also enforce strict following of freedesktop.org standard for
21" .desktop and .directory files . Set (eg. in vimrc)
22" let enforce_freedesktop_standard = 1
23" and nonstandard extensions not following X- notation will not be highlighted.
24if exists("enforce_freedesktop_standard")
25 let b:enforce_freedesktop_standard = 1
26else
27 let b:enforce_freedesktop_standard = 0
28endif
29
30" case on
31syn case match
32
33" General
34if b:enforce_freedesktop_standard == 0
35 syn match dtNotStLabel "^.\{-}=\@=" nextgroup=dtDelim
36endif
37
38syn match dtGroup /^\s*\[.*\]/
39syn match dtComment /^\s*#.*$/
40syn match dtDelim /=/ contained
41
42" Locale
43syn match dtLocale /^\s*\<\(Name\|GenericName\|Comment\|SwallowTitle\|Icon\|UnmountIcon\)\>.*/ contains=dtLocaleKey,dtLocaleName,dtDelim transparent
44syn keyword dtLocaleKey Name GenericName Comment SwallowTitle Icon UnmountIcon nextgroup=dtLocaleName containedin=dtLocale
45syn match dtLocaleName /\(\[.\{-}\]\s*=\@=\|\)/ nextgroup=dtDelim containedin=dtLocale contained
46
47" Numeric
48syn match dtNumeric /^\s*\<Version\>/ contains=dtNumericKey,dtDelim
49syn keyword dtNumericKey Version nextgroup=dtDelim containedin=dtNumeric contained
50
51" Boolean
52syn match dtBoolean /^\s*\<\(StartupNotify\|ReadOnly\|Terminal\|Hidden\|NoDisplay\)\>.*/ contains=dtBooleanKey,dtDelim,dtBooleanValue transparent
53syn keyword dtBooleanKey StartupNotify ReadOnly Terminal Hidden NoDisplay nextgroup=dtDelim containedin=dtBoolean contained
54syn keyword dtBooleanValue true false containedin=dtBoolean contained
55
56" String
Bram Moolenaar939a1ab2016-04-10 01:31:25 +020057syn match dtString /^\s*\<\(Encoding\|Icon\|Path\|Actions\|FSType\|MountPoint\|UnmountIcon\|URL\|Keywords\|Categories\|OnlyShowIn\|NotShowIn\|StartupWMClass\|FilePattern\|MimeType\)\>.*/ contains=dtStringKey,dtDelim transparent
58syn keyword dtStringKey Type Encoding TryExec Exec Path Actions FSType MountPoint URL Keywords Categories OnlyShowIn NotShowIn StartupWMClass FilePattern MimeType nextgroup=dtDelim containedin=dtString contained
Bram Moolenaar071d4272004-06-13 20:20:40 +000059
60" Exec
61syn match dtExec /^\s*\<\(Exec\|TryExec\|SwallowExec\)\>.*/ contains=dtExecKey,dtDelim,dtExecParam transparent
62syn keyword dtExecKey Exec TryExec SwallowExec nextgroup=dtDelim containedin=dtExec contained
63syn match dtExecParam /%[fFuUnNdDickv]/ containedin=dtExec contained
64
65" Type
66syn match dtType /^\s*\<Type\>.*/ contains=dtTypeKey,dtDelim,dtTypeValue transparent
67syn keyword dtTypeKey Type nextgroup=dtDelim containedin=dtType contained
68syn keyword dtTypeValue Application Link FSDevice Directory containedin=dtType contained
69
70" X-Addition
71syn match dtXAdd /^\s*X-.*/ contains=dtXAddKey,dtDelim transparent
72syn match dtXAddKey /^\s*X-.\{-}\s*=\@=/ nextgroup=dtDelim containedin=dtXAdd contains=dtXLocale contained
73
74" Locale for X-Addition
75syn match dtXLocale /\[.\{-}\]\s*=\@=/ containedin=dtXAddKey contained
76
77" Locale for all
78syn match dtALocale /\[.\{-}\]\s*=\@=/ containedin=ALL
79
80
81" Define the default highlighting.
82" For version 5.7 and earlier: only when not done already
83" For version 5.8 and later: only when an item doesn't have highlighting yet
84if version >= 508 || !exists("did_desktop_syntax_inits")
85 if version < 508
86 let did_dosini_syntax_inits = 1
87 command -nargs=+ HiLink hi link <args>
88 else
89 command -nargs=+ HiLink hi def link <args>
90 endif
91
92 HiLink dtGroup Special
93 HiLink dtComment Comment
94 HiLink dtDelim String
95
96 HiLink dtLocaleKey Type
97 HiLink dtLocaleName Identifier
98 HiLink dtXLocale Identifier
99 HiLink dtALocale Identifier
100
101 HiLink dtNumericKey Type
102
103 HiLink dtBooleanKey Type
104 HiLink dtBooleanValue Constant
105
106 HiLink dtStringKey Type
107
108 HiLink dtExecKey Type
109 HiLink dtExecParam Special
110 HiLink dtTypeKey Type
111 HiLink dtTypeValue Constant
112 HiLink dtNotStLabel Type
113 HiLink dtXAddKey Type
114
115 delcommand HiLink
116endif
117
118let b:current_syntax = "desktop"
119
120" vim:ts=8