Maxim Kim | 2112110 | 2024-01-17 03:33:51 +1100 | [diff] [blame] | 1 | vim9script |
| 2 | |
Maxim Kim | e9a369f | 2025-03-30 15:00:00 +0200 | [diff] [blame] | 3 | # Vim syntax file |
Maxim Kim | 2112110 | 2024-01-17 03:33:51 +1100 | [diff] [blame] | 4 | # Language: Odin |
| 5 | # Maintainer: Maxim Kim <habamax@gmail.com> |
| 6 | # Website: https://github.com/habamax/vim-odin |
Maxim Kim | e9a369f | 2025-03-30 15:00:00 +0200 | [diff] [blame] | 7 | # Last Change: 2025-03-28 |
Maxim Kim | 2112110 | 2024-01-17 03:33:51 +1100 | [diff] [blame] | 8 | |
| 9 | if exists("b:current_syntax") |
| 10 | finish |
| 11 | endif |
| 12 | |
Maxim Kim | e9a369f | 2025-03-30 15:00:00 +0200 | [diff] [blame] | 13 | syntax keyword odinKeyword using transmute cast auto_cast distinct opaque where dynamic |
Maxim Kim | 2112110 | 2024-01-17 03:33:51 +1100 | [diff] [blame] | 14 | syntax keyword odinKeyword struct enum union const bit_field bit_set |
| 15 | syntax keyword odinKeyword package proc map import export foreign |
| 16 | syntax keyword odinKeyword size_of offset_of type_info_of typeid_of type_of align_of |
| 17 | syntax keyword odinKeyword return defer |
Maxim Kim | 2112110 | 2024-01-17 03:33:51 +1100 | [diff] [blame] | 18 | syntax keyword odinKeyword inline no_inline |
Maxim Kim | e9a369f | 2025-03-30 15:00:00 +0200 | [diff] [blame] | 19 | syntax keyword odinKeyword asm context |
Maxim Kim | 2112110 | 2024-01-17 03:33:51 +1100 | [diff] [blame] | 20 | |
Maxim Kim | e9a369f | 2025-03-30 15:00:00 +0200 | [diff] [blame] | 21 | syntax keyword odinConditional if when else do for switch case fallthrough |
| 22 | syntax keyword odinConditional continue or_continue break or_break or_return or_else |
Maxim Kim | 2112110 | 2024-01-17 03:33:51 +1100 | [diff] [blame] | 23 | syntax keyword odinType string cstring bool b8 b16 b32 b64 rune any rawptr |
| 24 | syntax keyword odinType f16 f32 f64 f16le f16be f32le f32be f64le f64be |
| 25 | syntax keyword odinType u8 u16 u32 u64 u128 u16le u32le u64le u128le u16be |
| 26 | syntax keyword odinType u32be u64be u128be uint uintptr i8 i16 i32 i64 i128 |
| 27 | syntax keyword odinType i16le i32le i64le i128le i16be i32be i64be i128be |
| 28 | syntax keyword odinType int complex complex32 complex64 complex128 matrix typeid |
| 29 | syntax keyword odinType quaternion quaternion64 quaternion128 quaternion256 |
| 30 | syntax keyword odinBool true false |
| 31 | syntax keyword odinNull nil |
| 32 | syntax match odinUninitialized '\s\+---\(\s\|$\)' |
| 33 | |
| 34 | syntax keyword odinOperator in notin not_in |
| 35 | syntax match odinOperator "?" display |
| 36 | syntax match odinOperator "->" display |
| 37 | |
| 38 | syntax match odinTodo "TODO" contained |
| 39 | syntax match odinTodo "XXX" contained |
| 40 | syntax match odinTodo "FIXME" contained |
| 41 | syntax match odinTodo "HACK" contained |
| 42 | |
| 43 | syntax region odinRawString start=+`+ end=+`+ |
| 44 | syntax region odinChar start=+'+ skip=+\\\\\|\\'+ end=+'+ |
| 45 | syntax region odinString start=+"+ skip=+\\\\\|\\'+ end=+"+ contains=odinEscape |
| 46 | syntax match odinEscape display contained /\\\([nrt\\'"]\|x\x\{2}\)/ |
| 47 | |
| 48 | syntax match odinProcedure "\v<\w*>(\s*::\s*proc)@=" |
| 49 | |
| 50 | syntax match odinAttribute "@\ze\<\w\+\>" display |
| 51 | syntax region odinAttribute |
| 52 | \ matchgroup=odinAttribute |
| 53 | \ start="@\ze(" end="\ze)" |
| 54 | \ transparent oneline |
| 55 | |
| 56 | syntax match odinInteger "\-\?\<\d\+\>" display |
| 57 | syntax match odinFloat "\-\?\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\%([eE][+-]\=[0-9_]\+\)\=" display |
| 58 | syntax match odinHex "\<0[xX][0-9A-Fa-f]\+\>" display |
| 59 | syntax match odinDoz "\<0[zZ][0-9a-bA-B]\+\>" display |
| 60 | syntax match odinOct "\<0[oO][0-7]\+\>" display |
| 61 | syntax match odinBin "\<0[bB][01]\+\>" display |
| 62 | |
| 63 | syntax match odinAddressOf "&" display |
| 64 | syntax match odinDeref "\^" display |
| 65 | |
| 66 | syntax match odinMacro "#\<\w\+\>" display |
| 67 | |
| 68 | syntax match odinTemplate "$\<\w\+\>" |
| 69 | |
| 70 | syntax region odinLineComment start=/\/\// end=/$/ contains=@Spell,odinTodo |
| 71 | syntax region odinBlockComment start=/\/\*/ end=/\*\// contains=@Spell,odinTodo,odinBlockComment |
| 72 | syn sync ccomment odinBlockComment |
| 73 | |
| 74 | highlight def link odinKeyword Statement |
| 75 | highlight def link odinConditional Conditional |
| 76 | highlight def link odinOperator Operator |
| 77 | |
| 78 | highlight def link odinString String |
| 79 | highlight def link odinRawString String |
| 80 | highlight def link odinChar Character |
| 81 | highlight def link odinEscape Special |
| 82 | |
| 83 | highlight def link odinProcedure Function |
| 84 | |
| 85 | highlight def link odinMacro PreProc |
| 86 | |
| 87 | highlight def link odinLineComment Comment |
| 88 | highlight def link odinBlockComment Comment |
| 89 | |
| 90 | highlight def link odinTodo Todo |
| 91 | |
| 92 | highlight def link odinAttribute Statement |
| 93 | highlight def link odinType Type |
| 94 | highlight def link odinBool Boolean |
| 95 | highlight def link odinNull Constant |
| 96 | highlight def link odinUninitialized Constant |
| 97 | highlight def link odinInteger Number |
| 98 | highlight def link odinFloat Float |
| 99 | highlight def link odinHex Number |
| 100 | highlight def link odinOct Number |
| 101 | highlight def link odinBin Number |
| 102 | highlight def link odinDoz Number |
| 103 | |
| 104 | b:current_syntax = "odin" |