blob: 3000b46bef44eec4a2183c4818b1499f27602607 [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: $
David Reisseaaf45c2009-03-30 22:52:46 +000011"
12" Licensed to the Apache Software Foundation (ASF) under one
13" or more contributor license agreements. See the NOTICE file
14" distributed with this work for additional information
15" regarding copyright ownership. The ASF licenses this file
16" to you under the Apache License, Version 2.0 (the
17" "License"); you may not use this file except in compliance
18" with the License. You may obtain a copy of the License at
19"
20" http://www.apache.org/licenses/LICENSE-2.0
21"
22" Unless required by applicable law or agreed to in writing,
23" software distributed under the License is distributed on an
24" "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
25" KIND, either express or implied. See the License for the
26" specific language governing permissions and limitations
27" under the License.
28"
Martin Kraemer8ca2d092007-05-15 23:24:30 +000029
30if version < 600
31 syntax clear
32elseif exists("b:current_syntax")
33 finish
34endif
35
36" Todo
37syn keyword thriftTodo TODO todo FIXME fixme XXX xxx contained
38
39" Comments
40syn match thriftComment "#.*" contains=thriftTodo
41syn region thriftComment start="/\*" end="\*/" contains=thriftTodo
42syn match thriftComment "//.\{-}\(?>\|$\)\@="
43
44" String
45syn region thriftStringDouble matchgroup=None start=+"+ end=+"+
46
47" Number
48syn match thriftNumber "-\=\<\d\+\>" contained
49
50" Keywords
David Reiss54b602b2008-03-27 21:41:06 +000051syn keyword thriftKeyword namespace
David Reiss92e10d82009-02-17 20:28:19 +000052syn keyword thriftKeyword xsd_all xsd_optional xsd_nillable xsd_attrs
David Reiss8320a922007-08-14 19:59:26 +000053syn keyword thriftKeyword include cpp_include cpp_type const optional required
54syn keyword thriftBasicTypes void bool byte i16 i32 i64 double string binary
Jens Geyer8203a142013-10-24 22:14:22 +020055syn keyword thriftStructure map list set struct typedef exception enum throws union
Martin Kraemer8ca2d092007-05-15 23:24:30 +000056
57" Special
58syn match thriftSpecial "\d\+:"
59
60" Structure
David Reisscecbed82009-03-24 20:02:22 +000061syn keyword thriftStructure service oneway extends
Martin Kraemer8ca2d092007-05-15 23:24:30 +000062"async" { return tok_async; }
63"exception" { return tok_xception; }
64"extends" { return tok_extends; }
65"throws" { return tok_throws; }
66"service" { return tok_service; }
67"enum" { return tok_enum; }
68"const" { return tok_const; }
69
70if version >= 508 || !exists("did_thrift_syn_inits")
71 if version < 508
72 let did_thrift_syn_inits = 1
73 command! -nargs=+ HiLink hi link <args>
74 else
75 command! -nargs=+ HiLink hi def link <args>
76 endif
77
78 HiLink thriftComment Comment
79 HiLink thriftKeyword Special
80 HiLink thriftBasicTypes Type
81 HiLink thriftStructure StorageClass
82 HiLink thriftTodo Todo
83 HiLink thriftString String
84 HiLink thriftNumber Number
85 HiLink thriftSpecial Special
86 HiLink thriftStructure Structure
David Reiss61481752007-08-06 20:56:30 +000087
88 delcommand HiLink
Martin Kraemer8ca2d092007-05-15 23:24:30 +000089endif
90
Mark Slee4b338132008-01-16 21:29:45 +000091let b:current_syntax = "thrift"