Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " 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 Moolenaar | 939a1ab | 2016-04-10 01:31:25 +0200 | [diff] [blame] | 6 | " Last Change: 2016 Apr 02 |
| 7 | " (added "Keywords") |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8 | " 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 |
| 12 | if version < 600 |
| 13 | syntax clear |
| 14 | elseif exists("b:current_syntax") |
| 15 | finish |
| 16 | endif |
| 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. |
| 24 | if exists("enforce_freedesktop_standard") |
| 25 | let b:enforce_freedesktop_standard = 1 |
| 26 | else |
| 27 | let b:enforce_freedesktop_standard = 0 |
| 28 | endif |
| 29 | |
| 30 | " case on |
| 31 | syn case match |
| 32 | |
| 33 | " General |
| 34 | if b:enforce_freedesktop_standard == 0 |
| 35 | syn match dtNotStLabel "^.\{-}=\@=" nextgroup=dtDelim |
| 36 | endif |
| 37 | |
| 38 | syn match dtGroup /^\s*\[.*\]/ |
| 39 | syn match dtComment /^\s*#.*$/ |
| 40 | syn match dtDelim /=/ contained |
| 41 | |
| 42 | " Locale |
| 43 | syn match dtLocale /^\s*\<\(Name\|GenericName\|Comment\|SwallowTitle\|Icon\|UnmountIcon\)\>.*/ contains=dtLocaleKey,dtLocaleName,dtDelim transparent |
| 44 | syn keyword dtLocaleKey Name GenericName Comment SwallowTitle Icon UnmountIcon nextgroup=dtLocaleName containedin=dtLocale |
| 45 | syn match dtLocaleName /\(\[.\{-}\]\s*=\@=\|\)/ nextgroup=dtDelim containedin=dtLocale contained |
| 46 | |
| 47 | " Numeric |
| 48 | syn match dtNumeric /^\s*\<Version\>/ contains=dtNumericKey,dtDelim |
| 49 | syn keyword dtNumericKey Version nextgroup=dtDelim containedin=dtNumeric contained |
| 50 | |
| 51 | " Boolean |
| 52 | syn match dtBoolean /^\s*\<\(StartupNotify\|ReadOnly\|Terminal\|Hidden\|NoDisplay\)\>.*/ contains=dtBooleanKey,dtDelim,dtBooleanValue transparent |
| 53 | syn keyword dtBooleanKey StartupNotify ReadOnly Terminal Hidden NoDisplay nextgroup=dtDelim containedin=dtBoolean contained |
| 54 | syn keyword dtBooleanValue true false containedin=dtBoolean contained |
| 55 | |
| 56 | " String |
Bram Moolenaar | 939a1ab | 2016-04-10 01:31:25 +0200 | [diff] [blame] | 57 | syn match dtString /^\s*\<\(Encoding\|Icon\|Path\|Actions\|FSType\|MountPoint\|UnmountIcon\|URL\|Keywords\|Categories\|OnlyShowIn\|NotShowIn\|StartupWMClass\|FilePattern\|MimeType\)\>.*/ contains=dtStringKey,dtDelim transparent |
| 58 | syn keyword dtStringKey Type Encoding TryExec Exec Path Actions FSType MountPoint URL Keywords Categories OnlyShowIn NotShowIn StartupWMClass FilePattern MimeType nextgroup=dtDelim containedin=dtString contained |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 59 | |
| 60 | " Exec |
| 61 | syn match dtExec /^\s*\<\(Exec\|TryExec\|SwallowExec\)\>.*/ contains=dtExecKey,dtDelim,dtExecParam transparent |
| 62 | syn keyword dtExecKey Exec TryExec SwallowExec nextgroup=dtDelim containedin=dtExec contained |
| 63 | syn match dtExecParam /%[fFuUnNdDickv]/ containedin=dtExec contained |
| 64 | |
| 65 | " Type |
| 66 | syn match dtType /^\s*\<Type\>.*/ contains=dtTypeKey,dtDelim,dtTypeValue transparent |
| 67 | syn keyword dtTypeKey Type nextgroup=dtDelim containedin=dtType contained |
| 68 | syn keyword dtTypeValue Application Link FSDevice Directory containedin=dtType contained |
| 69 | |
| 70 | " X-Addition |
| 71 | syn match dtXAdd /^\s*X-.*/ contains=dtXAddKey,dtDelim transparent |
| 72 | syn match dtXAddKey /^\s*X-.\{-}\s*=\@=/ nextgroup=dtDelim containedin=dtXAdd contains=dtXLocale contained |
| 73 | |
| 74 | " Locale for X-Addition |
| 75 | syn match dtXLocale /\[.\{-}\]\s*=\@=/ containedin=dtXAddKey contained |
| 76 | |
| 77 | " Locale for all |
| 78 | syn 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 |
| 84 | if 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 |
| 116 | endif |
| 117 | |
| 118 | let b:current_syntax = "desktop" |
| 119 | |
| 120 | " vim:ts=8 |