| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | |
| | if exists('b:did_indent') |
| | finish |
| | endif |
| | let b:did_indent = 1 |
| |
|
| | |
| | setlocal expandtab |
| | setlocal indentexpr=GetElmIndent() |
| | setlocal indentkeys+=0=else,0=if,0=of,0=import,0=then,0=type,0\|,0},0\],0),=-},0=in |
| | setlocal nolisp |
| | setlocal nosmartindent |
| |
|
| | let b:undo_indent = "setl et< inde< indk< lisp< si<" |
| |
|
| | |
| | if exists('*GetElmIndent') |
| | finish |
| | endif |
| |
|
| | |
| | function! s:FindPair(pstart, pmid, pend) |
| | |
| | return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"')) |
| | endfunction |
| |
|
| | function! GetElmIndent() |
| | let l:lnum = v:lnum - 1 |
| |
|
| | |
| | if l:lnum == 0 |
| | return 0 |
| | endif |
| |
|
| | let l:ind = indent(l:lnum) |
| | let l:lline = getline(l:lnum) |
| | let l:line = getline(v:lnum) |
| |
|
| | |
| | if l:line =~? '^\s*}' |
| | return s:FindPair('{', '', '}') |
| |
|
| | |
| | elseif l:line =~# '^\s*else\>' |
| | if l:lline !~# '^\s*\(if\|then\)\>' |
| | return s:FindPair('\<if\>', '', '\<else\>') |
| | endif |
| |
|
| | |
| | elseif l:line =~# '^\s*then\>' |
| | if l:lline !~# '^\s*\(if\|else\)\>' |
| | return s:FindPair('\<if\>', '', '\<then\>') |
| | endif |
| |
|
| | |
| | elseif l:line =~# '->' && l:line !~# ':' && l:line !~# '\\' |
| | return indent(search('^\s*case', 'bWn')) + &shiftwidth |
| |
|
| | |
| | elseif l:lline =~# '^\s*--' |
| | return l:ind |
| |
|
| | |
| | elseif l:line =~# '^\s*-}' |
| | return indent(search('{-', 'bWn')) |
| |
|
| | |
| | elseif l:lline =~# '\<let\>.*\s=$' |
| | return l:ind + 4 + &shiftwidth |
| |
|
| | |
| | elseif l:line =~# '^\s*in\>' |
| | return indent(search('^\s*let', 'bWn')) |
| |
|
| | |
| | elseif l:lline =~# '\<let\>' |
| | return l:ind + 4 |
| |
|
| | |
| | elseif l:lline =~# '^\s*in\>' |
| | return l:ind |
| |
|
| | endif |
| |
|
| | |
| | if l:lline =~# '\(|\|=\|->\|<-\|(\|\[\|{\|\<\(of\|else\|if\|then\)\)\s*$' |
| | let l:ind = l:ind + &shiftwidth |
| |
|
| | |
| | elseif l:lline =~# '^\s*type' && l:line =~# '^\s*=' |
| | let l:ind = l:ind + &shiftwidth |
| |
|
| | |
| | elseif l:lline =~# '-}\s*$' |
| | call search('-}', 'bW') |
| | let l:ind = indent(searchpair('{-', '', '-}', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"')) |
| |
|
| | |
| | elseif l:line =~# '^\s*\(!\|&\|(\|`\|+\||\|{\|[\|,\)=' && l:lline !~# '^\s*\(!\|&\|(\|`\|+\||\|{\|[\|,\)=' && l:lline !~# '^\s*$' |
| | let l:ind = l:ind + &shiftwidth |
| |
|
| | elseif l:lline ==# '' && getline(l:lnum - 1) !=# '' |
| | let l:ind = indent(search('^\s*\S+', 'bWn')) |
| |
|
| | endif |
| |
|
| | return l:ind |
| | endfunc |
| |
|