" Author:       Michael Sanders (msanders42 [at] gmail [dot] com)
"		Some modifications by Jonathan Schleifer <js@webkeks.org>
" Description:  Better syntax highlighting for Objective-C files (part of the
"               cocoa.vim plugin).
" Last Updated: May 6, 2011
"
" Put to ~/.vim/after/syntax/objc.vim

syn match objcDirective '@synthesize\|@property\|@optional\|@required\|@autoreleasepool' display
syn keyword objcType IBOutlet IBAction Method __block instancetype
syn keyword objcType __unsafe_unretained __bridge __bridge_retained __bridge_transfer __autoreleasing __strong __weak
syn keyword objcType of_unichar_t of_char16_t of_char32_t of_comparison_result_t
syn keyword objcType of_byte_order_t of_range_t of_point_t of_dimension_t
syn keyword objcType of_rectangle_t of_string_encoding_t of_time_interval_t
syn keyword objcType of_resolver_result_t of_udp_socket_address_t
syn keyword objcConstant YES NO TRUE FALSE

syn region objcImp start='@implementation' end='@end' transparent
syn region objcHeader start='@interface' end='@end' transparent

syn match objcSubclass '\(@implementation\|@interface\)\@<=\s*\k\+' display contained containedin=objcImp,objcHeader
syn match objcSuperclass '\(@\(implementation\|interface\)\s*\k\+\s*:\)\@<=\s*\k*' display contained containedin=objcImp,objcHeader

" Matches "bar" in "[NSObject bar]" or "bar" in "[[NSObject foo: baz] bar]",
" but NOT "bar" in "[NSObject foo: bar]".
syn match objcMessageName '\(\[\s*\k\+\s\+\|\]\s*\)\@<=\k*\s*\]'me=e-1 display contained containedin=objcMessage
" Matches "foo:" in "[NSObject foo: bar]" or "[[NSObject new] foo: bar]"
syn match objcMessageColon '\(\_\S\+\_\s\+\)\@<=\k\+\s*:' display contained containedin=objcMessage
" Matches "foo:" in above
syn match objcMessageArg ')\@<=\s*\k\+' contained containedin=objcMessage

" Don't match these in this strange group for edge cases...
syn cluster cMultiGroup add=objcMessageColon,objcMessageName

hi link objcMessageArg Identifier

hi link objcMessageName objcMessageArg
hi link objcMessageColon objcMessageName
hi link objcMessageReceiver Special

hi link objcSubclass objcMethodName
hi link objcSuperclass String

hi link objcError Error
