cpp.vim 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. " Vim syntax file
  2. " Language: C++
  3. " Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp)
  4. " Previous Maintainer: Ken Shan <ccshan@post.harvard.edu>
  5. " Last Change: 2017 Jun 05
  6. " quit when a syntax file was already loaded
  7. if exists("b:current_syntax")
  8. finish
  9. endif
  10. " Read the C syntax to start with
  11. runtime! syntax/c.vim
  12. unlet b:current_syntax
  13. " C++ extensions
  14. syn keyword cppStatement new delete this friend using
  15. syn keyword cppAccess public protected private
  16. syn keyword cppModifier inline virtual explicit export
  17. syn keyword cppType bool wchar_t
  18. syn keyword cppExceptions throw try catch
  19. syn keyword cppOperator operator typeid
  20. syn keyword cppOperator and bitor or xor compl bitand and_eq or_eq xor_eq not not_eq
  21. syn match cppCast "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*<"me=e-1
  22. syn match cppCast "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*$"
  23. syn keyword cppStorageClass mutable
  24. syn keyword cppStructure class typename template namespace
  25. syn keyword cppBoolean true false
  26. syn keyword cppConstant __cplusplus
  27. " C++ 11 extensions
  28. if !exists("cpp_no_cpp11")
  29. syn keyword cppModifier override final
  30. syn keyword cppType nullptr_t auto
  31. syn keyword cppExceptions noexcept
  32. syn keyword cppStorageClass constexpr decltype thread_local
  33. syn keyword cppConstant nullptr
  34. syn keyword cppConstant ATOMIC_FLAG_INIT ATOMIC_VAR_INIT
  35. syn keyword cppConstant ATOMIC_BOOL_LOCK_FREE ATOMIC_CHAR_LOCK_FREE
  36. syn keyword cppConstant ATOMIC_CHAR16_T_LOCK_FREE ATOMIC_CHAR32_T_LOCK_FREE
  37. syn keyword cppConstant ATOMIC_WCHAR_T_LOCK_FREE ATOMIC_SHORT_LOCK_FREE
  38. syn keyword cppConstant ATOMIC_INT_LOCK_FREE ATOMIC_LONG_LOCK_FREE
  39. syn keyword cppConstant ATOMIC_LLONG_LOCK_FREE ATOMIC_POINTER_LOCK_FREE
  40. syn region cppRawString matchgroup=cppRawStringDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"+ contains=@Spell
  41. endif
  42. " C++ 14 extensions
  43. if !exists("cpp_no_cpp14")
  44. syn case ignore
  45. syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\(u\=l\{0,2}\|ll\=u\)\>"
  46. syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(u\=l\{0,2}\|ll\=u\)\>" contains=cFloat
  47. syn match cppNumber display "\<0x\x\('\=\x\+\)*\(u\=l\{0,2}\|ll\=u\)\>"
  48. syn case match
  49. endif
  50. " The minimum and maximum operators in GNU C++
  51. syn match cppMinMax "[<>]?"
  52. " Default highlighting
  53. hi def link cppAccess cppStatement
  54. hi def link cppCast cppStatement
  55. hi def link cppExceptions Exception
  56. hi def link cppOperator Operator
  57. hi def link cppStatement Statement
  58. hi def link cppModifier Type
  59. hi def link cppType Type
  60. hi def link cppStorageClass StorageClass
  61. hi def link cppStructure Structure
  62. hi def link cppBoolean Boolean
  63. hi def link cppConstant Constant
  64. hi def link cppRawStringDelimiter Delimiter
  65. hi def link cppRawString String
  66. hi def link cppNumber Number
  67. let b:current_syntax = "cpp"
  68. " vim: ts=8