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: $ |
| 11 | |
| 12 | if version < 600 |
| 13 | syntax clear |
| 14 | elseif exists("b:current_syntax") |
| 15 | finish |
| 16 | endif |
| 17 | |
| 18 | " Todo |
| 19 | syn keyword thriftTodo TODO todo FIXME fixme XXX xxx contained |
| 20 | |
| 21 | " Comments |
| 22 | syn match thriftComment "#.*" contains=thriftTodo |
| 23 | syn region thriftComment start="/\*" end="\*/" contains=thriftTodo |
| 24 | syn match thriftComment "//.\{-}\(?>\|$\)\@=" |
| 25 | |
| 26 | " String |
| 27 | syn region thriftStringDouble matchgroup=None start=+"+ end=+"+ |
| 28 | |
| 29 | " Number |
| 30 | syn match thriftNumber "-\=\<\d\+\>" contained |
| 31 | |
| 32 | " Keywords |
David Reiss | ae8f1d3 | 2007-09-12 01:45:12 +0000 | [diff] [blame] | 33 | syn keyword thriftKeyword namespace cpp_namespace java_package cocoa_prefix |
David Reiss | 7f42bcf | 2008-01-11 20:59:12 +0000 | [diff] [blame] | 34 | syn keyword thriftKeyword csharp_namespace smalltalk_category smalltalk_prefix |
| 35 | syn keyword thriftKeyword php_namespace ruby_namespace py_module perl_package |
David Reiss | 8320a92 | 2007-08-14 19:59:26 +0000 | [diff] [blame] | 36 | syn keyword thriftKeyword xsd_all xsd_optional xsd_nillable xsd_namespace xsd_attrs |
| 37 | syn keyword thriftKeyword include cpp_include cpp_type const optional required |
| 38 | syn keyword thriftBasicTypes void bool byte i16 i32 i64 double string binary |
Martin Kraemer | 8ca2d09 | 2007-05-15 23:24:30 +0000 | [diff] [blame] | 39 | syn keyword thriftStructure map list set struct typedef exception enum throws |
| 40 | |
| 41 | " Special |
| 42 | syn match thriftSpecial "\d\+:" |
| 43 | |
| 44 | " Structure |
| 45 | syn keyword thriftStructure service async extends |
| 46 | "async" { return tok_async; } |
| 47 | "exception" { return tok_xception; } |
| 48 | "extends" { return tok_extends; } |
| 49 | "throws" { return tok_throws; } |
| 50 | "service" { return tok_service; } |
| 51 | "enum" { return tok_enum; } |
| 52 | "const" { return tok_const; } |
| 53 | |
| 54 | if version >= 508 || !exists("did_thrift_syn_inits") |
| 55 | if version < 508 |
| 56 | let did_thrift_syn_inits = 1 |
| 57 | command! -nargs=+ HiLink hi link <args> |
| 58 | else |
| 59 | command! -nargs=+ HiLink hi def link <args> |
| 60 | endif |
| 61 | |
| 62 | HiLink thriftComment Comment |
| 63 | HiLink thriftKeyword Special |
| 64 | HiLink thriftBasicTypes Type |
| 65 | HiLink thriftStructure StorageClass |
| 66 | HiLink thriftTodo Todo |
| 67 | HiLink thriftString String |
| 68 | HiLink thriftNumber Number |
| 69 | HiLink thriftSpecial Special |
| 70 | HiLink thriftStructure Structure |
David Reiss | 6148175 | 2007-08-06 20:56:30 +0000 | [diff] [blame] | 71 | |
| 72 | delcommand HiLink |
Martin Kraemer | 8ca2d09 | 2007-05-15 23:24:30 +0000 | [diff] [blame] | 73 | endif |
| 74 | |
Mark Slee | 4b33813 | 2008-01-16 21:29:45 +0000 | [diff] [blame] | 75 | let b:current_syntax = "thrift" |