blob: e350a4eea3d345ab9143bba23264f3ae3ac5ccc2 [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 Reiss07ef3a92008-03-27 21:42:39 +000034syn keyword thriftKeyword php_namespace
David Reiss8320a922007-08-14 19:59:26 +000035syn keyword thriftKeyword xsd_all xsd_optional xsd_nillable xsd_namespace xsd_attrs
36syn keyword thriftKeyword include cpp_include cpp_type const optional required
37syn keyword thriftBasicTypes void bool byte i16 i32 i64 double string binary
Martin Kraemer8ca2d092007-05-15 23:24:30 +000038syn keyword thriftStructure map list set struct typedef exception enum throws
39
40" Special
41syn match thriftSpecial "\d\+:"
42
43" Structure
44syn keyword thriftStructure service async extends
45"async" { return tok_async; }
46"exception" { return tok_xception; }
47"extends" { return tok_extends; }
48"throws" { return tok_throws; }
49"service" { return tok_service; }
50"enum" { return tok_enum; }
51"const" { return tok_const; }
52
53if version >= 508 || !exists("did_thrift_syn_inits")
54 if version < 508
55 let did_thrift_syn_inits = 1
56 command! -nargs=+ HiLink hi link <args>
57 else
58 command! -nargs=+ HiLink hi def link <args>
59 endif
60
61 HiLink thriftComment Comment
62 HiLink thriftKeyword Special
63 HiLink thriftBasicTypes Type
64 HiLink thriftStructure StorageClass
65 HiLink thriftTodo Todo
66 HiLink thriftString String
67 HiLink thriftNumber Number
68 HiLink thriftSpecial Special
69 HiLink thriftStructure Structure
David Reiss61481752007-08-06 20:56:30 +000070
71 delcommand HiLink
Martin Kraemer8ca2d092007-05-15 23:24:30 +000072endif
73
Mark Slee4b338132008-01-16 21:29:45 +000074let b:current_syntax = "thrift"