msmessages.vim 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. " Vim syntax file
  2. " Language: MS Message Text files (*.mc)
  3. " Maintainer: Kevin Locke <kwl7@cornell.edu>
  4. " Last Change: 2008 April 09
  5. " Location: http://kevinlocke.name/programs/vim/syntax/msmessages.vim
  6. " See format description at <http://msdn2.microsoft.com/en-us/library/aa385646.aspx>
  7. " This file is based on the rc.vim and c.vim
  8. " quit when a syntax file was already loaded
  9. if exists("b:current_syntax")
  10. finish
  11. endif
  12. " Common MS Messages keywords
  13. syn case ignore
  14. syn keyword msmessagesIdentifier MessageIdTypedef
  15. syn keyword msmessagesIdentifier SeverityNames
  16. syn keyword msmessagesIdentifier FacilityNames
  17. syn keyword msmessagesIdentifier LanguageNames
  18. syn keyword msmessagesIdentifier OutputBase
  19. syn keyword msmessagesIdentifier MessageId
  20. syn keyword msmessagesIdentifier Severity
  21. syn keyword msmessagesIdentifier Facility
  22. syn keyword msmessagesIdentifier OutputBase
  23. syn match msmessagesIdentifier /\<SymbolicName\>/ nextgroup=msmessagesIdentEq skipwhite
  24. syn match msmessagesIdentEq transparent /=/ nextgroup=msmessagesIdentDef skipwhite contained
  25. syn match msmessagesIdentDef display /\w\+/ contained
  26. " Note: The Language keyword is highlighted as part of an msmessagesLangEntry
  27. " Set value
  28. syn case match
  29. syn region msmessagesSet start="(" end=")" transparent fold contains=msmessagesName keepend
  30. syn match msmessagesName /\w\+/ nextgroup=msmessagesSetEquals skipwhite contained
  31. syn match msmessagesSetEquals /=/ display transparent nextgroup=msmessagesNumVal skipwhite contained
  32. syn match msmessagesNumVal display transparent "\<\d\|\.\d" contains=msmessagesNumber,msmessagesFloat,msmessagesOctalError,msmessagesOctal nextgroup=msmessagesValSep
  33. syn match msmessagesValSep /:/ display nextgroup=msmessagesNameDef contained
  34. syn match msmessagesNameDef /\w\+/ display contained
  35. " Comments are converted to C source (by removing leading ;)
  36. " So we highlight the comments as C
  37. syn include @msmessagesC syntax/c.vim
  38. unlet b:current_syntax
  39. syn region msmessagesCComment matchgroup=msmessagesComment start=/;/ end=/$/ contains=@msmessagesC keepend
  40. " String and Character constants
  41. " Highlight special characters (those which have a escape) differently
  42. syn case ignore
  43. syn region msmessagesLangEntry start=/\<Language\>\s*=\s*\S\+\s*$/hs=e+1 end=/^\./ contains=msmessagesFormat,msmessagesLangEntryEnd,msmessagesLanguage keepend
  44. syn match msmessagesLanguage /\<Language\(\s*=\)\@=/ contained
  45. syn match msmessagesLangEntryEnd display /^\./ contained
  46. syn case match
  47. syn match msmessagesFormat display /%[1-9]\d\?\(![-+0 #]*\d*\(\.\d\+\)\?\(h\|l\|ll\|I\|I32\|I64\)\?[aAcCdeEfgGinopsSuxX]!\)\?/ contained
  48. syn match msmessagesFormat display /%[0.%\\br]/ contained
  49. syn match msmessagesFormat display /%!\(\s\)\@=/ contained
  50. " Integer number, or floating point number without a dot and with "f".
  51. " Copied from c.vim
  52. syn case ignore
  53. "(long) integer
  54. syn match msmessagesNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>"
  55. "hex number
  56. syn match msmessagesNumber display contained "\<0x\x\+\(u\=l\{0,2}\|ll\=u\)\>"
  57. " Flag the first zero of an octal number as something special
  58. syn match msmessagesOctal display contained "\<0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=msmessagesOctalZero
  59. syn match msmessagesOctalZero display contained "\<0"
  60. " flag an octal number with wrong digits
  61. syn match msmessagesOctalError display contained "\<0\o*[89]\d*"
  62. syn match msmessagesFloat display contained "\d\+f"
  63. "floating point number, with dot, optional exponent
  64. syn match msmessagesFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
  65. "floating point number, starting with a dot, optional exponent
  66. syn match msmessagesFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
  67. "floating point number, without dot, with exponent
  68. syn match msmessagesFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>"
  69. "hexadecimal floating point number, optional leading digits, with dot, with exponent
  70. syn match msmessagesFloat display contained "0x\x*\.\x\+p[-+]\=\d\+[fl]\=\>"
  71. "hexadecimal floating point number, with leading digits, optional dot, with exponent
  72. syn match msmessagesFloat display contained "0x\x\+\.\=p[-+]\=\d\+[fl]\=\>"
  73. " Types (used in MessageIdTypedef statement)
  74. syn case match
  75. syn keyword msmessagesType int long short char
  76. syn keyword msmessagesType signed unsigned
  77. syn keyword msmessagesType size_t ssize_t sig_atomic_t
  78. syn keyword msmessagesType int8_t int16_t int32_t int64_t
  79. syn keyword msmessagesType uint8_t uint16_t uint32_t uint64_t
  80. syn keyword msmessagesType int_least8_t int_least16_t int_least32_t int_least64_t
  81. syn keyword msmessagesType uint_least8_t uint_least16_t uint_least32_t uint_least64_t
  82. syn keyword msmessagesType int_fast8_t int_fast16_t int_fast32_t int_fast64_t
  83. syn keyword msmessagesType uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t
  84. syn keyword msmessagesType intptr_t uintptr_t
  85. syn keyword msmessagesType intmax_t uintmax_t
  86. " Add some Windows datatypes that will be common in msmessages files
  87. syn keyword msmessagesType BYTE CHAR SHORT SIZE_T SSIZE_T TBYTE TCHAR UCHAR USHORT
  88. syn keyword msmessagesType DWORD DWORDLONG DWORD32 DWORD64
  89. syn keyword msmessagesType INT INT32 INT64 UINT UINT32 UINT64
  90. syn keyword msmessagesType LONG LONGLONG LONG32 LONG64
  91. syn keyword msmessagesType ULONG ULONGLONG ULONG32 ULONG64
  92. " Sync to language entries, since they should be most common
  93. syn sync match msmessagesLangSync grouphere msmessagesLangEntry "\<Language\s*="
  94. syn sync match msmessagesLangEndSync grouphere NONE "^\."
  95. " Define the default highlighting.
  96. hi def link msmessagesNumber Number
  97. hi def link msmessagesOctal Number
  98. hi def link msmessagesFloat Float
  99. hi def link msmessagesOctalError msmessagesError
  100. hi def link msmessagesSetError msmessagesError
  101. hi def link msmessagesError Error
  102. hi def link msmessagesLangEntry String
  103. hi def link msmessagesLangEntryEnd Special
  104. hi def link msmessagesComment Comment
  105. hi def link msmessagesFormat msmessagesSpecial
  106. hi def link msmessagesSpecial SpecialChar
  107. hi def link msmessagesType Type
  108. hi def link msmessagesIdentifier Identifier
  109. hi def link msmessagesLanguage msmessagesIdentifier
  110. hi def link msmessagesName msmessagesIdentifier
  111. hi def link msmessagesNameDef Macro
  112. hi def link msmessagesIdentDef Macro
  113. hi def link msmessagesValSep Special
  114. hi def link msmessagesNameErr Error
  115. let b:current_syntax = "msmessages"
  116. " vim: ts=8