brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: ACT c generation lang |
| 3 | " Maintainer: FRC Team 971 <spartanrobotics.org> |
| 4 | " Last Change: sometime |
| 5 | |
| 6 | " Quit when a (custom) syntax file was already loaded |
| 7 | if exists("b:current_syntax") |
| 8 | finish |
| 9 | endif |
| 10 | |
| 11 | syn keyword cTodo contained TODO FIXME XXX |
| 12 | |
| 13 | " It's easy to accidentally add a space after a backslash that was intended |
| 14 | " for line continuation. Some compilers allow it, which makes it |
| 15 | " unpredicatable and should be avoided. |
| 16 | syn match cBadContinuation contained "\\\s\+$" |
| 17 | |
| 18 | " cCommentGroup allows adding matches for special things in comments |
| 19 | syn cluster cCommentGroup contains=cTodo,cBadContinuation |
| 20 | |
| 21 | " This should be before cErrInParen to avoid problems with #define ({ xxx }) |
| 22 | if exists("c_curly_error") |
| 23 | syntax match cCurlyError "}" |
| 24 | syntax region cBlock start="{" end="}" contains=ALLBUT,cCurlyError,@cParenGroup,cErrInParen,cCppParen,cErrInBracket,cCppBracket,cCppString,@Spell fold |
| 25 | else |
| 26 | syntax region cBlock start="{" end="}" transparent fold |
| 27 | endif |
| 28 | |
| 29 | |
| 30 | |
| 31 | if exists("c_comment_strings") |
| 32 | " A comment can contain cString, cCharacter and cNumber. |
| 33 | " But a "*/" inside a cString in a cComment DOES end the comment! So we |
| 34 | " need to use a special type of cString: cCommentString, which also ends on |
| 35 | " "*/", and sees a "*" at the start of the line as comment again. |
| 36 | " Unfortunately this doesn't very well work for // type of comments :-( |
| 37 | syntax match cCommentSkip contained "^\s*\*\($\|\s\+\)" |
| 38 | syntax region cCommentString contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=cSpecial,cCommentSkip |
| 39 | syntax region cComment2String contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=cSpecial |
| 40 | syntax region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cComment2String,cCharacter,cNumbersCom,cSpaceError,@Spell |
| 41 | if exists("c_no_comment_fold") |
| 42 | " Use "extend" here to have preprocessor lines not terminate halfway a |
| 43 | " comment. |
| 44 | syntax region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,@Spell extend |
| 45 | else |
| 46 | syntax region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,@Spell fold extend |
| 47 | endif |
| 48 | else |
| 49 | syn region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cSpaceError,@Spell |
| 50 | if exists("c_no_comment_fold") |
| 51 | syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError,@Spell extend |
| 52 | else |
| 53 | syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError,@Spell fold extend |
| 54 | endif |
| 55 | endif |
| 56 | " keep a // comment separately, it terminates a preproc. conditional |
| 57 | syntax match cCommentError display "\*/" |
| 58 | syntax match cCommentStartError display "/\*"me=e-1 contained |
| 59 | |
| 60 | syn keyword cType int long short char void |
| 61 | syn keyword cType signed unsigned float double |
| 62 | if !exists("c_no_ansi") || exists("c_ansi_typedefs") |
| 63 | syn keyword cType size_t ssize_t off_t wchar_t ptrdiff_t sig_atomic_t fpos_t |
| 64 | syn keyword cType clock_t time_t va_list jmp_buf FILE DIR div_t ldiv_t |
| 65 | syn keyword cType mbstate_t wctrans_t wint_t wctype_t |
| 66 | endif |
| 67 | if !exists("c_no_c99") " ISO C99 |
| 68 | syn keyword cType bool complex |
| 69 | syn keyword cType int8_t int16_t int32_t int64_t |
| 70 | syn keyword cType uint8_t uint16_t uint32_t uint64_t |
| 71 | syn keyword cType int_least8_t int_least16_t int_least32_t int_least64_t |
| 72 | syn keyword cType uint_least8_t uint_least16_t uint_least32_t uint_least64_t |
| 73 | syn keyword cType int_fast8_t int_fast16_t int_fast32_t int_fast64_t |
| 74 | syn keyword cType uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t |
| 75 | syn keyword cType intptr_t uintptr_t |
| 76 | syn keyword cType intmax_t uintmax_t |
| 77 | endif |
| 78 | " syn keyword cStructure struct union enum typedef |
| 79 | |
| 80 | syn keyword cType args status action_name async_queue has priority |
| 81 | |
| 82 | |
| 83 | " Define the default highlighting. |
| 84 | " Only used when an item doesn't have highlighting yet |
| 85 | hi def link cFormat cSpecial |
| 86 | hi def link cCppString cString |
| 87 | hi def link cCommentL cComment |
| 88 | hi def link cCommentStart cComment |
| 89 | hi def link cLabel Label |
| 90 | hi def link cUserLabel Label |
| 91 | hi def link cConditional Conditional |
| 92 | hi def link cRepeat Repeat |
| 93 | hi def link cCharacter Character |
| 94 | hi def link cSpecialCharacter cSpecial |
| 95 | hi def link cNumber Number |
| 96 | hi def link cOctal Number |
| 97 | hi def link cOctalZero PreProc " link this to Error if you want |
| 98 | hi def link cFloat Float |
| 99 | hi def link cOctalError cError |
| 100 | hi def link cParenError cError |
| 101 | hi def link cErrInParen cError |
| 102 | hi def link cErrInBracket cError |
| 103 | hi def link cCommentError cError |
| 104 | hi def link cCommentStartError cError |
| 105 | hi def link cSpaceError cError |
| 106 | hi def link cSpecialError cError |
| 107 | hi def link cCurlyError cError |
| 108 | hi def link cOperator Operator |
| 109 | hi def link cStructure Structure |
| 110 | hi def link cStorageClass StorageClass |
| 111 | hi def link cInclude Include |
| 112 | hi def link cPreProc PreProc |
| 113 | hi def link cDefine Macro |
| 114 | hi def link cIncluded cString |
| 115 | hi def link cError Error |
| 116 | hi def link cStatement Statement |
| 117 | hi def link cPreCondit PreCondit |
| 118 | hi def link cType Type |
| 119 | hi def link cConstant Constant |
| 120 | hi def link cCommentString cString |
| 121 | hi def link cComment2String cString |
| 122 | hi def link cCommentSkip cComment |
| 123 | hi def link cString String |
| 124 | hi def link cComment Comment |
| 125 | hi def link cSpecial SpecialChar |
| 126 | hi def link cTodo Todo |
| 127 | hi def link cBadContinuation Error |
| 128 | hi def link cCppSkip cCppOut |
| 129 | hi def link cCppOut2 cCppOut |
| 130 | hi def link cCppOut Comment |
| 131 | |
| 132 | let b:current_syntax = "act" |
| 133 | |
| 134 | " vim: ts=8 |