Martin Kraemer | 8ca2d09 | 2007-05-15 23:24:30 +0000 | [diff] [blame] | 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 |
| 9 | " |
| 10 | " $Id: $ |
David Reiss | eaaf45c | 2009-03-30 22:52:46 +0000 | [diff] [blame] | 11 | " |
| 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 Kraemer | 8ca2d09 | 2007-05-15 23:24:30 +0000 | [diff] [blame] | 29 | |
| 30 | if version < 600 |
| 31 | syntax clear |
| 32 | elseif exists("b:current_syntax") |
| 33 | finish |
| 34 | endif |
| 35 | |
| 36 | " Todo |
| 37 | syn keyword thriftTodo TODO todo FIXME fixme XXX xxx contained |
| 38 | |
| 39 | " Comments |
| 40 | syn match thriftComment "#.*" contains=thriftTodo |
| 41 | syn region thriftComment start="/\*" end="\*/" contains=thriftTodo |
| 42 | syn match thriftComment "//.\{-}\(?>\|$\)\@=" |
| 43 | |
| 44 | " String |
| 45 | syn region thriftStringDouble matchgroup=None start=+"+ end=+"+ |
| 46 | |
| 47 | " Number |
| 48 | syn match thriftNumber "-\=\<\d\+\>" contained |
| 49 | |
| 50 | " Keywords |
David Reiss | 54b602b | 2008-03-27 21:41:06 +0000 | [diff] [blame] | 51 | syn keyword thriftKeyword namespace |
David Reiss | 92e10d8 | 2009-02-17 20:28:19 +0000 | [diff] [blame] | 52 | syn keyword thriftKeyword xsd_all xsd_optional xsd_nillable xsd_attrs |
David Reiss | 8320a92 | 2007-08-14 19:59:26 +0000 | [diff] [blame] | 53 | syn keyword thriftKeyword include cpp_include cpp_type const optional required |
| 54 | syn keyword thriftBasicTypes void bool byte i16 i32 i64 double string binary |
Martin Kraemer | 8ca2d09 | 2007-05-15 23:24:30 +0000 | [diff] [blame] | 55 | syn keyword thriftStructure map list set struct typedef exception enum throws |
| 56 | |
| 57 | " Special |
| 58 | syn match thriftSpecial "\d\+:" |
| 59 | |
| 60 | " Structure |
David Reiss | cecbed8 | 2009-03-24 20:02:22 +0000 | [diff] [blame] | 61 | syn keyword thriftStructure service oneway extends |
Martin Kraemer | 8ca2d09 | 2007-05-15 23:24:30 +0000 | [diff] [blame] | 62 | "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 | |
| 70 | if 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 Reiss | 6148175 | 2007-08-06 20:56:30 +0000 | [diff] [blame] | 87 | |
| 88 | delcommand HiLink |
Martin Kraemer | 8ca2d09 | 2007-05-15 23:24:30 +0000 | [diff] [blame] | 89 | endif |
| 90 | |
Mark Slee | 4b33813 | 2008-01-16 21:29:45 +0000 | [diff] [blame] | 91 | let b:current_syntax = "thrift" |