blob: efab6d5f6fdfe5062017e191f36612e847d79ad3 [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
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020010" quit when a syntax file was already loaded
11if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000012 finish
13endif
14
15" This syntax file can be used to all *nix configuration files similar to dos
16" ini format (eg. .xawtv, .radio, kde rc files) - this is default mode. But
17" you can also enforce strict following of freedesktop.org standard for
18" .desktop and .directory files . Set (eg. in vimrc)
19" let enforce_freedesktop_standard = 1
20" and nonstandard extensions not following X- notation will not be highlighted.
21if exists("enforce_freedesktop_standard")
22 let b:enforce_freedesktop_standard = 1
23else
24 let b:enforce_freedesktop_standard = 0
25endif
26
27" case on
28syn case match
29
30" General
31if b:enforce_freedesktop_standard == 0
32 syn match dtNotStLabel "^.\{-}=\@=" nextgroup=dtDelim
33endif
34
35syn match dtGroup /^\s*\[.*\]/
36syn match dtComment /^\s*#.*$/
37syn match dtDelim /=/ contained
38
39" Locale
40syn match dtLocale /^\s*\<\(Name\|GenericName\|Comment\|SwallowTitle\|Icon\|UnmountIcon\)\>.*/ contains=dtLocaleKey,dtLocaleName,dtDelim transparent
41syn keyword dtLocaleKey Name GenericName Comment SwallowTitle Icon UnmountIcon nextgroup=dtLocaleName containedin=dtLocale
42syn match dtLocaleName /\(\[.\{-}\]\s*=\@=\|\)/ nextgroup=dtDelim containedin=dtLocale contained
43
44" Numeric
45syn match dtNumeric /^\s*\<Version\>/ contains=dtNumericKey,dtDelim
46syn keyword dtNumericKey Version nextgroup=dtDelim containedin=dtNumeric contained
47
48" Boolean
49syn match dtBoolean /^\s*\<\(StartupNotify\|ReadOnly\|Terminal\|Hidden\|NoDisplay\)\>.*/ contains=dtBooleanKey,dtDelim,dtBooleanValue transparent
50syn keyword dtBooleanKey StartupNotify ReadOnly Terminal Hidden NoDisplay nextgroup=dtDelim containedin=dtBoolean contained
51syn keyword dtBooleanValue true false containedin=dtBoolean contained
52
53" String
Bram Moolenaar939a1ab2016-04-10 01:31:25 +020054syn match dtString /^\s*\<\(Encoding\|Icon\|Path\|Actions\|FSType\|MountPoint\|UnmountIcon\|URL\|Keywords\|Categories\|OnlyShowIn\|NotShowIn\|StartupWMClass\|FilePattern\|MimeType\)\>.*/ contains=dtStringKey,dtDelim transparent
55syn 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 +000056
57" Exec
58syn match dtExec /^\s*\<\(Exec\|TryExec\|SwallowExec\)\>.*/ contains=dtExecKey,dtDelim,dtExecParam transparent
59syn keyword dtExecKey Exec TryExec SwallowExec nextgroup=dtDelim containedin=dtExec contained
60syn match dtExecParam /%[fFuUnNdDickv]/ containedin=dtExec contained
61
62" Type
63syn match dtType /^\s*\<Type\>.*/ contains=dtTypeKey,dtDelim,dtTypeValue transparent
64syn keyword dtTypeKey Type nextgroup=dtDelim containedin=dtType contained
65syn keyword dtTypeValue Application Link FSDevice Directory containedin=dtType contained
66
67" X-Addition
68syn match dtXAdd /^\s*X-.*/ contains=dtXAddKey,dtDelim transparent
69syn match dtXAddKey /^\s*X-.\{-}\s*=\@=/ nextgroup=dtDelim containedin=dtXAdd contains=dtXLocale contained
70
71" Locale for X-Addition
72syn match dtXLocale /\[.\{-}\]\s*=\@=/ containedin=dtXAddKey contained
73
74" Locale for all
75syn match dtALocale /\[.\{-}\]\s*=\@=/ containedin=ALL
76
77
78" Define the default highlighting.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020079" Only when an item doesn't have highlighting yet
80command -nargs=+ HiLink hi def link <args>
Bram Moolenaar071d4272004-06-13 20:20:40 +000081
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020082HiLink dtGroup Special
83HiLink dtComment Comment
84HiLink dtDelim String
Bram Moolenaar071d4272004-06-13 20:20:40 +000085
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020086HiLink dtLocaleKey Type
87HiLink dtLocaleName Identifier
88HiLink dtXLocale Identifier
89HiLink dtALocale Identifier
Bram Moolenaar071d4272004-06-13 20:20:40 +000090
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020091HiLink dtNumericKey Type
Bram Moolenaar071d4272004-06-13 20:20:40 +000092
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020093HiLink dtBooleanKey Type
94HiLink dtBooleanValue Constant
Bram Moolenaar071d4272004-06-13 20:20:40 +000095
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020096HiLink dtStringKey Type
Bram Moolenaar071d4272004-06-13 20:20:40 +000097
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020098HiLink dtExecKey Type
99HiLink dtExecParam Special
100HiLink dtTypeKey Type
101HiLink dtTypeValue Constant
102HiLink dtNotStLabel Type
103HiLink dtXAddKey Type
Bram Moolenaar071d4272004-06-13 20:20:40 +0000104
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200105delcommand HiLink
Bram Moolenaar071d4272004-06-13 20:20:40 +0000106
107let b:current_syntax = "desktop"
108
109" vim:ts=8