vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

odin.vim (4320B)


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