PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Tools/Editors/Vim/objj.vim

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