Skip to content

Instantly share code, notes, and snippets.

@keyle
Last active December 3, 2025 11:01
Show Gist options
  • Select an option

  • Save keyle/4b5b380f7e88c525380cdafef2058dbb to your computer and use it in GitHub Desktop.

Select an option

Save keyle/4b5b380f7e88c525380cdafef2058dbb to your computer and use it in GitHub Desktop.
" Use filetype 'ox' for *.ox files
augroup filetypedetect
au!
au BufNewFile,BufRead *.ox setfiletype ox
augroup END
" Clear any existing syntax
if exists("b:current_syntax")
finish
endif
" Keywords
syntax keyword oxKeyword if else while fn fx for continue break struct typedef print print_ return
" Types
syntax keyword oxType int float str bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 f128 uint char chr void cstr voidp
" Constants
syntax keyword oxConstant true false null
" Comments: // EOL
syntax match oxComment "//.*$"
" Strings: "..."
syntax region oxString start=/"/ end=/"/ skip=/\\"/
" Char def
syntax match oxChar /'[^\']'/
syntax match oxCharError /'[^\']\{2,}'/
" Numbers
syntax match oxNumber "\v(\d+(\.\d+)?)"
" Operators
syntax match oxOperator /[?;!~#*\/+\-:=<>]/ containedin=ALL
" Types override
syntax match oxType2 /\<[i|u|f]\(8\|16\|32\|64\)\>/
" Highlight groups
hi def link oxOperator Operator
hi def link oxKeyword Keyword
hi def link oxType Type
hi def link oxType2 Type
hi def link oxConstant Constant
hi def link oxComment Comment
hi def link oxString String
hi def link oxChar Character
hi def link oxCharError Error
hi def link oxNumber Number
let b:current_syntax = "ox"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment