blob: dd87eb3a56a700705068c5320382197c7c4b7cc8 [file] [log] [blame]
Martin Kraemer8ca2d092007-05-15 23:24:30 +00001" Vim syntax file
2" Language: Thrift
3" Maintainer: Martin Smith <martin@facebook.com>
4" Last Change: $Date: $
5" Copy to ~/.vim/
6" Add to ~/.vimrc
7" au BufRead,BufNewFile *.thrift set filetype=thrift
8" au! Syntax thrift source ~/.vim/thrift.vim
9"
10" $Id: $
11
12if version < 600
13 syntax clear
14elseif exists("b:current_syntax")
15 finish
16endif
17
18" Todo
19syn keyword thriftTodo TODO todo FIXME fixme XXX xxx contained
20
21" Comments
22syn match thriftComment "#.*" contains=thriftTodo
23syn region thriftComment start="/\*" end="\*/" contains=thriftTodo
24syn match thriftComment "//.\{-}\(?>\|$\)\@="
25
26" String
27syn region thriftStringDouble matchgroup=None start=+"+ end=+"+
28
29" Number
30syn match thriftNumber "-\=\<\d\+\>" contained
31
32" Keywords
David Reiss54b602b2008-03-27 21:41:06 +000033syn keyword thriftKeyword namespace
David Reiss92e10d82009-02-17 20:28:19 +000034syn keyword thriftKeyword xsd_all xsd_optional xsd_nillable xsd_attrs
David Reiss8320a922007-08-14 19:59:26 +000035syn keyword thriftKeyword include cpp_include cpp_type const optional required
36syn keyword thriftBasicTypes void bool byte i16 i32 i64 double string binary
Martin Kraemer8ca2d092007-05-15 23:24:30 +000037syn keyword thriftStructure map list set struct typedef exception enum throws
38
39" Special
40syn match thriftSpecial "\d\+:"
41
42" Structure
David Reisscecbed82009-03-24 20:02:22 +000043syn keyword thriftStructure service oneway extends
Martin Kraemer8ca2d092007-05-15 23:24:30 +000044"async" { return tok_async; }
45"exception" { return tok_xception; }
46"extends" { return tok_extends; }
47"throws" { return tok_throws; }
48"service" { return tok_service; }
49"enum" { return tok_enum; }
50"const" { return tok_const; }
51
52if version >= 508 || !exists("did_thrift_syn_inits")
53 if version < 508
54 let did_thrift_syn_inits = 1
55 command! -nargs=+ HiLink hi link <args>
56 else
57 command! -nargs=+ HiLink hi def link <args>
58 endif
59
60 HiLink thriftComment Comment
61 HiLink thriftKeyword Special
62 HiLink thriftBasicTypes Type
63 HiLink thriftStructure StorageClass
64 HiLink thriftTodo Todo
65 HiLink thriftString String
66 HiLink thriftNumber Number
67 HiLink thriftSpecial Special
68 HiLink thriftStructure Structure
David Reiss61481752007-08-06 20:56:30 +000069
70 delcommand HiLink
Martin Kraemer8ca2d092007-05-15 23:24:30 +000071endif
72
Mark Slee4b338132008-01-16 21:29:45 +000073let b:current_syntax = "thrift"