mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-08 03:23:51 -05:00
42 lines
627 B
VimL
42 lines
627 B
VimL
if polyglot#init#is_disabled(expand('<sfile>:p'), 'odin', 'indent/odin.vim')
|
|
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
|