Files
vim-polyglot/indent/odin.vim
Adam Stankiewicz 2838800832 Fix conditions, #608
2020-10-25 21:08:27 +01:00

42 lines
593 B
VimL

if has_key(g:polyglot_is_disabled, 'odin')
finish
endif
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
setlocal nosmartindent
setlocal nolisp
setlocal autoindent
setlocal indentexpr=GetOdinIndent(v:lnum)
if exists("*GetOdinIndent")
finish
endif
function! GetOdinIndent(lnum)
let prev = prevnonblank(a:lnum-1)
if prev == 0
return 0
endif
let prevline = getline(prev)
let line = getline(a:lnum)
let ind = indent(prev)
if prevline =~ '[({]\s*$'
let ind += &sw
endif
if line =~ '^\s*[)}]'
let ind -= &sw
endif
return ind
endfunction