Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: Windows Registry export with regedit (*.reg) |
Bram Moolenaar | 32efaf6 | 2014-11-05 17:02:17 +0100 | [diff] [blame] | 3 | " Maintainer: Dominique Stéphan (dominique@mggen.com) |
| 4 | " URL: http://www.mggen.com/vim/syntax/registry.zip (doesn't work) |
| 5 | " Last change: 2014 Oct 31 |
| 6 | " Included patch from Alexander A. Ulitin |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7 | |
| 8 | " clear any unwanted syntax defs |
| 9 | " For version 5.x: Clear all syntax items |
| 10 | " For version 6.x: Quit when a syntax file was already loaded |
| 11 | if version < 600 |
| 12 | syntax clear |
| 13 | elseif exists("b:current_syntax") |
| 14 | finish |
| 15 | endif |
| 16 | |
| 17 | " shut case off |
| 18 | syn case ignore |
| 19 | |
| 20 | " Head of regedit .reg files, it's REGEDIT4 on Win9#/NT |
Bram Moolenaar | 32efaf6 | 2014-11-05 17:02:17 +0100 | [diff] [blame] | 21 | syn match registryHead "^REGEDIT[0-9]*\s*$\|^Windows Registry Editor Version \d*\.\d*\s*$" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 22 | |
| 23 | " Comment |
| 24 | syn match registryComment "^;.*$" |
| 25 | |
| 26 | " Registry Key constant |
| 27 | syn keyword registryHKEY HKEY_LOCAL_MACHINE HKEY_CLASSES_ROOT HKEY_CURRENT_USER |
| 28 | syn keyword registryHKEY HKEY_USERS HKEY_CURRENT_CONFIG HKEY_DYN_DATA |
| 29 | " Registry Key shortcuts |
| 30 | syn keyword registryHKEY HKLM HKCR HKCU HKU HKCC HKDD |
| 31 | |
| 32 | " Some values often found in the registry |
| 33 | " GUID (Global Unique IDentifier) |
| 34 | syn match registryGUID "{[0-9A-Fa-f]\{8}\-[0-9A-Fa-f]\{4}\-[0-9A-Fa-f]\{4}\-[0-9A-Fa-f]\{4}\-[0-9A-Fa-f]\{12}}" contains=registrySpecial |
| 35 | |
| 36 | " Disk |
| 37 | " syn match registryDisk "[a-zA-Z]:\\\\" |
| 38 | |
| 39 | " Special and Separator characters |
| 40 | syn match registrySpecial "\\" |
| 41 | syn match registrySpecial "\\\\" |
| 42 | syn match registrySpecial "\\\"" |
| 43 | syn match registrySpecial "\." |
| 44 | syn match registrySpecial "," |
| 45 | syn match registrySpecial "\/" |
| 46 | syn match registrySpecial ":" |
| 47 | syn match registrySpecial "-" |
| 48 | |
| 49 | " String |
| 50 | syn match registryString "\".*\"" contains=registryGUID,registrySpecial |
| 51 | |
| 52 | " Path |
| 53 | syn region registryPath start="\[" end="\]" contains=registryHKEY,registryGUID,registrySpecial |
| 54 | |
| 55 | " Path to remove |
| 56 | " like preceding path but with a "-" at begin |
| 57 | syn region registryRemove start="\[\-" end="\]" contains=registryHKEY,registryGUID,registrySpecial |
| 58 | |
| 59 | " Subkey |
| 60 | syn match registrySubKey "^\".*\"=" |
| 61 | " Default value |
Bram Moolenaar | 32efaf6 | 2014-11-05 17:02:17 +0100 | [diff] [blame] | 62 | syn match registrySubKey "^@=" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 63 | |
| 64 | " Numbers |
| 65 | |
| 66 | " Hex or Binary |
| 67 | " The format can be precised between () : |
| 68 | " 0 REG_NONE |
| 69 | " 1 REG_SZ |
| 70 | " 2 REG_EXPAND_SZ |
| 71 | " 3 REG_BINARY |
| 72 | " 4 REG_DWORD, REG_DWORD_LITTLE_ENDIAN |
| 73 | " 5 REG_DWORD_BIG_ENDIAN |
| 74 | " 6 REG_LINK |
| 75 | " 7 REG_MULTI_SZ |
| 76 | " 8 REG_RESOURCE_LIST |
| 77 | " 9 REG_FULL_RESOURCE_DESCRIPTOR |
| 78 | " 10 REG_RESOURCE_REQUIREMENTS_LIST |
| 79 | " The value can take several lines, if \ ends the line |
| 80 | " The limit to 999 matches is arbitrary, it avoids Vim crashing on a very long |
| 81 | " line of hex values that ends in a comma. |
| 82 | "syn match registryHex "hex\(([0-9]\{0,2})\)\=:\([0-9a-fA-F]\{2},\)\{0,999}\([0-9a-fA-F]\{2}\|\\\)$" contains=registrySpecial |
| 83 | syn match registryHex "hex\(([0-9]\{0,2})\)\=:\([0-9a-fA-F]\{2},\)*\([0-9a-fA-F]\{2}\|\\\)$" contains=registrySpecial |
| 84 | syn match registryHex "^\s*\([0-9a-fA-F]\{2},\)\{0,999}\([0-9a-fA-F]\{2}\|\\\)$" contains=registrySpecial |
| 85 | " Dword (32 bits) |
| 86 | syn match registryDword "dword:[0-9a-fA-F]\{8}$" contains=registrySpecial |
| 87 | |
| 88 | if version >= 508 || !exists("did_registry_syntax_inits") |
| 89 | if version < 508 |
| 90 | let did_registry_syntax_inits = 1 |
| 91 | command -nargs=+ HiLink hi link <args> |
| 92 | else |
| 93 | command -nargs=+ HiLink hi def link <args> |
| 94 | endif |
| 95 | |
| 96 | " The default methods for highlighting. Can be overridden later |
| 97 | HiLink registryComment Comment |
| 98 | HiLink registryHead Constant |
| 99 | HiLink registryHKEY Constant |
| 100 | HiLink registryPath Special |
| 101 | HiLink registryRemove PreProc |
| 102 | HiLink registryGUID Identifier |
| 103 | HiLink registrySpecial Special |
| 104 | HiLink registrySubKey Type |
| 105 | HiLink registryString String |
| 106 | HiLink registryHex Number |
| 107 | HiLink registryDword Number |
| 108 | |
| 109 | delcommand HiLink |
| 110 | endif |
| 111 | |
| 112 | |
| 113 | let b:current_syntax = "registry" |
| 114 | |
| 115 | " vim:ts=8 |