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 |
| 33 | syn keyword thriftKeyword namespace cpp_namespace cpp_include |
| 34 | syn keyword thriftKeyword cpp_type java_package include const |
| 35 | syn keyword thriftBasicTypes void bool byte i16 i32 i64 double string |
| 36 | |
| 37 | syn keyword thriftStructure map list set struct typedef exception enum throws |
| 38 | |
| 39 | " Special |
| 40 | syn match thriftSpecial "\d\+:" |
| 41 | |
| 42 | " Structure |
| 43 | syn keyword thriftStructure service async extends |
| 44 | "async" { return tok_async; } |
| 45 | "exception" { return tok_xception; } |
| 46 | "extends" { return tok_extends; } |
| 47 | "throws" { return tok_throws; } |
| 48 | "service" { return tok_service; } |
| 49 | "enum" { return tok_enum; } |
| 50 | "const" { return tok_const; } |
| 51 | |
| 52 | if version >= 508 || !exists("did_thrift_syn_inits") |
| 53 | if version < 508 |
| 54 | let did_thrift_syn_inits = 1 |
| 55 | command! -nargs=+ HiLink hi link <args> |
| 56 | else |
| 57 | command! -nargs=+ HiLink hi def link <args> |
| 58 | endif |
| 59 | |
| 60 | HiLink thriftComment Comment |
| 61 | HiLink thriftKeyword Special |
| 62 | HiLink thriftBasicTypes Type |
| 63 | HiLink thriftStructure StorageClass |
| 64 | HiLink thriftTodo Todo |
| 65 | HiLink thriftString String |
| 66 | HiLink thriftNumber Number |
| 67 | HiLink thriftSpecial Special |
| 68 | HiLink thriftStructure Structure |
| 69 | endif |
| 70 | |
| 71 | let b:currenct_syntax = "thrift" |