r1363@opsdev009 (orig r71627): mcslee | 2007-11-27 18:39:59 -0800
[amiethrift.git] / thrift.vim
blobd6727fb0cc19dfd47bfbfa1da4bac5b6136bdf61
1 " 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
10 " $Id: $
12 if version < 600
13   syntax clear
14 elseif exists("b:current_syntax")
15   finish
16 endif
18 " Todo
19 syn keyword thriftTodo TODO todo FIXME fixme XXX xxx contained
21 " Comments
22 syn match thriftComment "#.*" contains=thriftTodo
23 syn region thriftComment start="/\*" end="\*/" contains=thriftTodo
24 syn match thriftComment "//.\{-}\(?>\|$\)\@="
26 " String
27 syn region thriftStringDouble matchgroup=None start=+"+  end=+"+
29 " Number
30 syn match thriftNumber "-\=\<\d\+\>" contained
32 " Keywords
33 syn keyword thriftKeyword namespace cpp_namespace java_package cocoa_prefix
34 syn keyword php_namespace ruby_namespace py_module perl_package
35 syn keyword thriftKeyword xsd_all xsd_optional xsd_nillable xsd_namespace xsd_attrs
36 syn keyword thriftKeyword include cpp_include cpp_type const optional required
37 syn keyword thriftBasicTypes void bool byte i16 i32 i64 double string binary
38 syn keyword thriftStructure map list set struct typedef exception enum throws
40 " Special
41 syn match thriftSpecial "\d\+:"
43 " Structure
44 syn 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;         }
53 if 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
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
71   delcommand HiLink
72 endif
74 let b:currenct_syntax = "thrift"