home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / runtime / dos / syntax / objc.vim < prev    next >
Encoding:
Text File  |  2012-05-31  |  3.9 KB  |  116 lines

  1. " Vim syntax file
  2. " Language:        Objective C
  3. " Maintainer:        Kazunobu Kuriyama <kazunobu.kuriyama@nifty.com>
  4. " Ex-maintainer:    Anthony Hodsdon <ahodsdon@fastmail.fm>
  5. " First Author:        Valentino Kyriakides <1kyriaki@informatik.uni-hamburg.de>
  6. " Last Change:        2012 Apr 30
  7.  
  8. " For version 5.x: Clear all syntax items
  9. " For version 6.x: Quit when a syntax file was already loaded
  10. if version < 600
  11.   syntax clear
  12. elseif exists("b:current_syntax")
  13.   finish
  14. endif
  15. let s:keepcpo= &cpo
  16. set cpo&vim
  17.  
  18. if &filetype != 'objcpp'
  19.   " Read the C syntax to start with
  20.   if version < 600
  21.     source <sfile>:p:h/c.vim
  22.   else
  23.     runtime! syntax/c.vim
  24.   endif
  25. endif
  26.  
  27. " Objective C extentions follow below
  28. "
  29. " NOTE: Objective C is abbreviated to ObjC/objc
  30. " and uses *.h, *.m as file extensions!
  31.  
  32.  
  33. " ObjC keywords, types, type qualifiers etc.
  34. syn keyword objcStatement    self super _cmd
  35. syn keyword objcType        id Class SEL IMP BOOL
  36. syn keyword objcTypeModifier    bycopy in out inout oneway
  37. syn keyword objcConstant    nil Nil
  38.  
  39. " Match the ObjC #import directive (like C's #include)
  40. syn region objcImported display contained start=+"+  skip=+\\\\\|\\"+  end=+"+
  41. syn match  objcImported display contained "<[-_0-9a-zA-Z.\/]*>"
  42. syn match  objcImport display "^\s*\(%:\|#\)\s*import\>\s*["<]" contains=objcImported
  43.  
  44. " Match the important ObjC directives
  45. syn match  objcScopeDecl    "@public\|@private\|@protected"
  46. syn match  objcDirective    "@interface\|@implementation"
  47. syn match  objcDirective    "@class\|@end\|@defs"
  48. syn match  objcDirective    "@encode\|@protocol\|@selector"
  49. syn match  objcDirective    "@try\|@catch\|@finally\|@throw\|@synchronized"
  50.  
  51. " Match the ObjC method types
  52. "
  53. " NOTE: here I match only the indicators, this looks
  54. " much nicer and reduces cluttering color highlightings.
  55. " However, if you prefer full method declaration matching
  56. " append .* at the end of the next two patterns!
  57. "
  58. syn match objcInstMethod    "^\s*-\s*"
  59. syn match objcFactMethod    "^\s*+\s*"
  60.  
  61. " To distinguish from a header inclusion from a protocol list.
  62. syn match objcProtocol display "<[_a-zA-Z][_a-zA-Z0-9]*>" contains=objcType,cType,Type
  63.  
  64.  
  65. " To distinguish labels from the keyword for a method's parameter.
  66. syn region objcKeyForMethodParam display
  67.     \ start="^\s*[_a-zA-Z][_a-zA-Z0-9]*\s*:\s*("
  68.     \ end=")\s*[_a-zA-Z][_a-zA-Z0-9]*"
  69.     \ contains=objcType,objcTypeModifier,cType,cStructure,cStorageClass,Type
  70.  
  71. " Objective-C Constant Strings
  72. syn match objcSpecial display "%@" contained
  73. syn region objcString start=+\(@"\|"\)+ skip=+\\\\\|\\"+ end=+"+ contains=cFormat,cSpecial,objcSpecial
  74.  
  75. " Objective-C Message Expressions
  76. syn region objcMessage display start="\[" end="\]" contains=objcMessage,objcStatement,objcType,objcTypeModifier,objcString,objcConstant,objcDirective,cType,cStructure,cStorageClass,cString,cCharacter,cSpecialCharacter,cNumbers,cConstant,cOperator,cComment,cCommentL,Type
  77.  
  78. syn cluster cParenGroup add=objcMessage
  79. syn cluster cPreProcGroup add=objcMessage
  80.  
  81. " Define the default highlighting.
  82. " For version 5.7 and earlier: only when not done already
  83. " For version 5.8 and later: only when an item doesn't have highlighting yet
  84. if version >= 508 || !exists("did_objc_syntax_inits")
  85.   if version < 508
  86.     let did_objc_syntax_inits = 1
  87.     command -nargs=+ HiLink hi link <args>
  88.   else
  89.     command -nargs=+ HiLink hi def link <args>
  90.   endif
  91.  
  92.   HiLink objcImport        Include
  93.   HiLink objcImported        cString
  94.   HiLink objcTypeModifier    objcType
  95.   HiLink objcType        Type
  96.   HiLink objcScopeDecl        Statement
  97.   HiLink objcInstMethod        Function
  98.   HiLink objcFactMethod        Function
  99.   HiLink objcStatement        Statement
  100.   HiLink objcDirective        Statement
  101.   HiLink objcKeyForMethodParam    None
  102.   HiLink objcString        cString
  103.   HiLink objcSpecial        Special
  104.   HiLink objcProtocol        None
  105.   HiLink objcConstant        cConstant
  106.  
  107.   delcommand HiLink
  108. endif
  109.  
  110. let b:current_syntax = "objc"
  111.  
  112. let &cpo = s:keepcpo
  113. unlet s:keepcpo
  114.  
  115. " vim: ts=8
  116.