blob: 3a5bd9cc31f6de00b92743f6dc2db9599b5a990e (
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 !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
|