PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/vimfiles/after/syntax/c.vim

https://github.com/dumuzid/exVim
Vim Script | 124 lines | 60 code | 23 blank | 41 comment | 2 complexity | 002066ef52bd8d027e6522ca204cfc8a MD5 | raw file
  1. " ======================================================================================
  2. " File : c.vim
  3. " Author : Wu Jie
  4. " Last Change : 10/21/2008 | 22:50:46 PM | Tuesday,October
  5. " Description :
  6. " ======================================================================================
  7. "/////////////////////////////////////////////////////////////////////////////
  8. " the extertion syntax define
  9. "/////////////////////////////////////////////////////////////////////////////
  10. " ========================================================
  11. " EX_ENGINE extentions
  12. " ========================================================
  13. syn keyword cType UINT INT UINT8 INT8 UINT16 INT16 UINT32 INT32 UINT64 INT64 CHAR WCHAR TCHAR
  14. syn keyword cType uint uint8 int8 uint16 int16 uint32 int32 uint64 int64 wchar tchar f32 f64 vec_f32_t
  15. syn keyword cType TEXT INLINE NOINLINE
  16. syn keyword cConstant TRUE FALSE
  17. syn keyword cStatement ex_malloc ex_malloc_use ex_malloc_nomanage ex_malloc_tag ex_malloc_tag_use
  18. syn keyword cStatement ex_realloc ex_realloc_use ex_realloc_nomanage ex_realloc_tag ex_realloc_tag_use
  19. syn keyword cStatement ex_free ex_free_use ex_free_nomanage
  20. syn keyword cStatement ex_safe_free ex_safe_free_use ex_safe_free_nomanage
  21. syn keyword cStatement ex_stack_malloc
  22. syn keyword cStatement ex_log ex_error ex_warning ex_log_func ex_assert ex_assert_slow ex_assert_return ex_assert_exec ex_check ex_check_return ex_check_exec ex_static_assert ex_compile_time_assert
  23. if !exists('g:ex_todo_keyword')
  24. let g:ex_todo_keyword = 'NOTE REF EXAMPLE'
  25. endif
  26. if !exists('g:ex_comment_lable_keyword')
  27. let g:ex_comment_lable_keyword = 'TEMP CRASH MODIFY DEBUG DUMMY DELME TESTME OPTME REFACTORING DUPLICATE REDUNDANCY'
  28. endif
  29. silent exec ':syn keyword cTodo contained ' . g:ex_todo_keyword
  30. silent exec ':syn keyword exCommentLable contained ' . g:ex_comment_lable_keyword
  31. syn cluster cCommentGroup contains=cTodo,exCommentLable
  32. " ========================================================
  33. " exMacroHighlight Predeined Syntax
  34. " ========================================================
  35. " the cPreCondit conflict with exMacroInside, use exPreCondit instead
  36. syn region exMacroInside contained matchgroup=cPreProc start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\).*\/\/"rs=e-2 start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\).*" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" extend contains=@exEnableContainedGroup
  37. syn match exPreCondit display "^\s*\(%:\|#\)\s*\(else\|elif\)\>.*" contains=cComment,cCommentL
  38. " the bug is the exElseDisable and exIfxEnable share the same end.
  39. syn region exElseDisable contained start="^\s*\(%:\|#\)\s*else\>" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" keepend contains=exCppSkip
  40. syn region exElseEnable contained matchgroup=cPreProc start="^\s*\(%:\|#\)\s*else\>" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" keepend contains=@exEnableContainedGroup
  41. syn region exCppSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" extend contains=cSpaceError,exCppSkip
  42. " add c enable group
  43. syn cluster exEnableContainedGroup contains=cStatement,cLabel,cConditional,cRepeat,cString,cCppString,cCharacter,cSpecialError,cSpecialCharacter,cSpaceError,cBlock,cParen,cParenError,cBracket,cNumbers,cComment,cCommentL,cCommentError,cOperator,cType,cStructure,cStorageClass,cConstant,cCppOut,cInclude,cDefine,cPreProc,cMulti,cUserCont,cBitField
  44. " add exMacroHighlight enable group
  45. syn cluster exEnableContainedGroup add=exPreCondit,exMacroInside
  46. syn cluster exEnableContainedGroup add=exIfDisableStart,exIfnDisableStart,exIfEnableStart,exIfnEnableStart
  47. syn cluster exEnableContainedGroup add=exElifEnableStart,exElifnEnableStart,exElifDisableStart,exElifnDisableStart
  48. " add to original c_syntax groups
  49. " don't add exXXXStart in, or we will lose effect in Paren --> ( ... )
  50. syn cluster cParenGroup add=exCppSkip,exMacroInside,exIfEnable,exIfDisable,exIfnEnable,exIfnDisable,exElifEnable,exElifnEnable,exElifDisable,exElifnDisable,exElseDisable,exElseEnable,exAndEnable,exAndnotEnable,exOrDisable,exOrnotDisable
  51. syn cluster cPreProcGroup add=exCppSkip,exMacroInside,exIfEnable,exIfDisable,exIfnEnable,exIfnDisable,exElifEnable,exElifnEnable,exElifDisable,exElifnDisable,exElseDisable,exElseEnable,exAndEnable,exAndnotEnable,exOrDisable,exOrnotDisable
  52. syn cluster cMultiGroup add=exCppSkip,exMacroInside,exIfEnable,exIfDisable,exIfnEnable,exIfnDisable,exElifEnable,exElifnEnable,exElifDisable,exElifnDisable,exElseDisable,exElseEnable,exAndEnable,exAndnotEnable,exOrDisable,exOrnotDisable
  53. "/////////////////////////////////////////////////////////////////////////////
  54. " Default highlighting
  55. "/////////////////////////////////////////////////////////////////////////////
  56. " ========================================================
  57. " EX_ENGINE hilight defines
  58. " ========================================================
  59. hi def link cType Type
  60. hi def link cStatement Statement
  61. hi def link cConstant Boolean
  62. " ========================================================
  63. " exMacroHilight hilight defines
  64. " ========================================================
  65. " inside pattern
  66. hi def link exCppSkip exMacroDisable
  67. hi def link exMacroInside Normal
  68. hi def link exPreCondit cPreProc
  69. " else disable/enable
  70. hi def link exElseDisable exMacroDisable
  71. hi def link exElseEnable Normal
  72. " logic
  73. hi def link exAndEnable Normal
  74. hi def link exAndnotEnable Normal
  75. hi def link exOrDisable exMacroDisable
  76. hi def link exOrnotDisable exMacroDisable
  77. " if/ifn eanble
  78. hi def link exIfEnableStart cPreProc
  79. hi def link exIfEnable Normal
  80. hi def link exIfnEnableStart cPreProc
  81. hi def link exIfnEnable Normal
  82. " if/ifn disable
  83. hi def link exIfDisable exMacroDisable
  84. hi def link exIfDisableStart exMacroDisable
  85. hi def link exIfnDisable exMacroDisable
  86. hi def link exIfnDisableStart exMacroDisable
  87. " elif/elifn enable
  88. hi def link exElifEnableStart cPreProc
  89. hi def link exElifEnable Normal
  90. hi def link exElifnEnableStart cPreProc
  91. hi def link exElifnEnable Normal
  92. " elif/elifn disable
  93. hi def link exElifDisableStart exMacroDisable
  94. hi def link exElifDisable exMacroDisable
  95. hi def link exElifnDisableStart exMacroDisable
  96. hi def link exElifnDisable exMacroDisable
  97. "/////////////////////////////////////////////////////////////////////////////
  98. " finish
  99. "/////////////////////////////////////////////////////////////////////////////
  100. let b:current_syntax = "c"
  101. " vim: ts=8