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