runtime(odin): update syntax, indent

- syntax: highlight attributes, e.g. @static, @(static), @(someattribute ....)
- indent: fix incorrect case: indent if previous case: has oneliner as `if ... do ...`

closes: #21067

Signed-off-by: Maxim Kim <habamax@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Maxim Kim authored and Christian Brabandt committed 2026-08-17 17:54:47 +00:00
1 parent 3cd5d1d1aa
commit 58e44cfbca
4 files changed
+15 -10

No files matched your search

+4 -2
View File
@@ -4,7 +4,7 @@ vim9script
# Language: Odin
# Maintainer: Maxim Kim <habamax@gmail.com>
# Website: https://github.com/habamax/vim-odin
# Last Change: 2026-06-28
# Last Change: 2026 Aug 17
if exists("b:did_indent")
finish
@@ -109,7 +109,9 @@ def GetOdinIndent(lnum: number): number
endfor
elseif pline =~ '{[^{]*}\s*$' && line !~ '^\s*[})]\s*$' # https://github.com/habamax/vim-odin/issues/2
indent = pindent
elseif line !~ '^\s*}' && pline =~ '^\s*\%(if\|for\).*\s\+do\%(\s\+\|$\)' # https://github.com/habamax/vim-odin/issues/15
elseif line !~ '^\s*}'
&& line !~ '^\s*case\s\+.\{-}:'
&& pline =~ '^\s*\%(if\|for\).*\s\+do\%(\s\+\|$\)' # https://github.com/habamax/vim-odin/issues/15
indent = pindent
elseif pline =~ '^\s*}\s*$' # https://github.com/habamax/vim-odin/issues/3
# Find line with opening { and check if there is a label:
+1 -1
View File
@@ -1317,7 +1317,7 @@ switch f {
case .A:
fmt.println("HITHER")
case .B:
fmt.println("NEVER")
if true do fmt.println("NEVER")
case .C:
fmt.println("FOREVER")
}
+1 -1
View File
@@ -1317,7 +1317,7 @@ implicit_selector_expression :: proc() {
case .A:
fmt.println("HITHER")
case .B:
fmt.println("NEVER")
if true do fmt.println("NEVER")
case .C:
fmt.println("FOREVER")
}
+9 -6
View File
@@ -4,7 +4,7 @@ vim9script
# Language: Odin
# Maintainer: Maxim Kim <habamax@gmail.com>
# Website: https://github.com/habamax/vim-odin
# Last Change: 2026-06-01
# Last Change: 2026 Aug 16
if exists("b:current_syntax")
finish
@@ -55,11 +55,13 @@ syntax match odinEscape display contained /\\\([abefnrtv\\'"]\|\o\{3}\|x\x\{2}\|
syntax match odinProcedure "\v<\w*>(\s*::\s*proc)@="
syntax match odinAttribute "@\ze\<\w\+\>" display
syntax region odinAttribute
syntax match odinAttribute "@" display nextgroup=odinAttributeName,odinAttributeBraces
syntax match odinAttributeName "\<\w\+\>" display contained
syntax region odinAttributeBraces
\ matchgroup=odinAttribute
\ start="@\ze(" end="\ze)"
\ start="(\w\+" end=")"
\ transparent oneline
\ contained
syntax match odinInteger "\v-?<[0-9]+%(_[0-9]+)*>" display
syntax match odinFloat "\v-?<[0-9]+%(_[0-9]+)*%(\.[0-9]+%(_[0-9]+)*)%([eE][+-]=[0-9]+%(_[0-9]+)*)=" display
@@ -98,13 +100,14 @@ highlight def link odinBlockComment Comment
highlight def link odinTodo Todo
highlight def link odinAttribute Statement
highlight def link odinAttribute PreProc
highlight def link odinAttributeName odinAttribute
highlight def link odinType Type
highlight def link odinBool Boolean
highlight def link odinNull Constant
highlight def link odinUninitialized Constant
highlight def link odinInteger Number
highlight def link odinFloat Float
highlight def link odinInteger Number
highlight def link odinHex Number
highlight def link odinOct Number
highlight def link odinBin Number