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