blob: 279d39efb34a8abc9047991f7e55f17184a4e7df (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
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
|