/Tools/Editors/Vim/objj.vim

http://github.com/cacaodev/cappuccino · Vim Script · 145 lines · 76 code · 24 blank · 45 comment · 6 complexity · 0241de7784a58b81bb1100b3a377c360 MD5 · raw file

  1. " Vim syntax file
  2. " Language: Objective-J
  3. " Maintainer: Shawn MacIntyre <sdm@openradical.com>
  4. " First Author: Shawn MacIntyre <sdm@openradical.com>
  5. " Updaters: Kevin Xu <kevin.xu.1982.02.06@gmail.com>
  6. " Changes: (sm) merged JavaScript syntax by
  7. " Claudio Fleiner & Scott Shattuck and
  8. " Objective-C syntax by
  9. " Valentino Kyriakides, Anthony Hodsdon & Kazunobu Kuriyama
  10. " (sm) modified 'objc.vim' to our 'objj.vim'
  11. " which reads 'javascript.vim' in the beginning.
  12. " Last Change: 2014 Sep 29
  13. " For version 5.x: Clear all syntax items
  14. " For version 6.x: Quit when a syntax file was already loaded
  15. if version < 600
  16. syntax clear
  17. elseif exists("b:current_syntax")
  18. finish
  19. endif
  20. " Read the JavaScript syntax to start with
  21. if version < 600
  22. source <sfile>:p:h/javascript.vim
  23. else
  24. runtime! syntax/javascript.vim
  25. unlet b:current_syntax
  26. endif
  27. " Modify some syntax from 'javascript.vim'.
  28. syn clear javaScriptParens
  29. syn clear javaScriptBraces
  30. " TODO: The '{}' & '[]' representing the JavaScript 'object' & 'array'
  31. " should be highlighted.
  32. " Read the C syntax to start with
  33. if version < 600
  34. source <sfile>:p:h/c.vim
  35. else
  36. runtime! syntax/c.vim
  37. unlet b:current_syntax
  38. endif
  39. " FIXME: The highlighting the common special-notice 'TBD'
  40. " for comments in JavaScript
  41. " is broken by c.vim.
  42. " Objective-J extentions follow below
  43. "
  44. " NOTE: Objective-J is abbreviated to ObjJ/objj
  45. " and uses *.j as file extensions!
  46. " ObjJ keywords, types, type qualifiers etc.
  47. syn keyword objjStatement self super _cmd
  48. syn keyword objjStatement property getter setter readwrite readonly copy
  49. syn keyword objjType id Class SEL IMP BOOL
  50. syn keyword objjTypeModifier bycopy in out inout oneway
  51. syn keyword objjConstant nil Nil NULL NO YES
  52. " Match the ObjJ @import directive
  53. syn match objjDirective "@import"
  54. " Match the ObjJ #import directive (like C's #include)
  55. syn region objjImported display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
  56. syn match objjImported display contained "<[-_0-9a-zA-Z.\/]*>"
  57. syn match objjImport display "^\s*\(%:\|#\|@\)\s*import\>\s*["<]" contains=objjImported
  58. " Match the important ObjJ directives
  59. syn match objjDirective "@typedef"
  60. syn match objjDirective "@interface\|@implementation\|@protocol\|@end"
  61. syn match objjScopeDecl "@public\|@protected\|@private\|@package"
  62. syn match objjScopeDecl "@required\|@optional"
  63. syn match objjDirective "@property\|@synthesize\|@dynamic"
  64. syn match objjDirective "@outlet\|@accessors"
  65. syn match objjDirective "@action\|@selector"
  66. syn match objjDirective "@defs"
  67. syn match objjDirective "@global\|@class"
  68. syn match objjDirective "@encode"
  69. syn match objjDirective "@ref\|@deref"
  70. syn match objjDirective "@try\|@catch\|@finally\|@throw\|@synchronized"
  71. " Match the ObjJ method types
  72. "
  73. " NOTE: here I match only the indicators, this looks
  74. " much nicer and reduces cluttering color highlightings.
  75. " However, if you prefer full method declaration matching
  76. " append .* at the end of the next two patterns!
  77. "
  78. syn match objjInstMethod "^\s*-\s*"
  79. syn match objjFactMethod "^\s*+\s*"
  80. " To distinguish from a header inclusion from a protocol list.
  81. syn match objjProtocol display "<[_a-zA-Z][_a-zA-Z0-9]*>" contains=objjType,cType,Type
  82. " To distinguish labels from the keyword for a method's parameter.
  83. syn region objjKeyForMethodParam display
  84. \ start="^\s*[_a-zA-Z][_a-zA-Z0-9]*\s*:\s*("
  85. \ end=")\s*[_a-zA-Z][_a-zA-Z0-9]*"
  86. \ contains=objjType,objjTypeModifier,cType,cStructure,cStorageClass,Type
  87. " Objective-J Constant Strings
  88. syn match objjSpecial display "%@" contained
  89. syn region objjString start=+\(@"\|"\)+ skip=+\\\\\|\\"+ end=+"+ contains=cFormat,cSpecial,objjSpecial
  90. " Objective-J Message Expressions
  91. syn region objjMessage display start="\[" end="\]" contains=objjMessage,objjStatement,objjType,objjTypeModifier,objjString,objjConstant,objjDirective,cType,cStructure,cStorageClass,cString,cCharacter,cSpecialCharacter,cNumbers,cConstant,cOperator,cComment,cCommentL,Type
  92. syn cluster cParenGroup add=objjMessage
  93. syn cluster cPreProcGroup add=objjMessage
  94. " Define the default highlighting.
  95. " For version 5.7 and earlier: only when not done already
  96. " For version 5.8 and later: only when an item doesn't have highlighting yet
  97. if version >= 508 || !exists("did_objj_syntax_inits")
  98. if version < 508
  99. let did_objj_syntax_inits = 1
  100. command -nargs=+ HiLink hi link <args>
  101. else
  102. command -nargs=+ HiLink hi def link <args>
  103. endif
  104. HiLink objjImport Include
  105. HiLink objjImported cString
  106. HiLink objjTypeModifier objjType
  107. HiLink objjType Type
  108. HiLink objjScopeDecl Statement
  109. HiLink objjInstMethod Function
  110. HiLink objjFactMethod Function
  111. HiLink objjStatement Statement
  112. HiLink objjDirective Statement
  113. HiLink objjKeyForMethodParam None
  114. HiLink objjString cString
  115. HiLink objjSpecial Special
  116. HiLink objjProtocol None
  117. HiLink objjConstant cConstant
  118. delcommand HiLink
  119. endif
  120. let b:current_syntax = "objj"
  121. " vim: ts=8