blob: 28afe40cbe0d02b1df319fdc3f33e3e69b912cc7 (
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
|
if polyglot#init#is_disabled(expand('<sfile>:p'), 'haskell', 'indent/cabal.vim')
finish
endif
" indentation for cabal
"
" author: raichoo (raichoo@googlemail.com)
"
if exists('b:did_indent')
finish
endif
let b:did_indent = 1
if !exists('g:cabal_indent_section')
"executable name
">>main-is: Main.hs
">>hs-source-dirs: src
let g:cabal_indent_section = 2
elseif exists('g:cabal_indent_section') && g:cabal_indent_section > 4
let g:cabal_indent_section = 4
endif
setlocal indentexpr=GetCabalIndent()
setlocal indentkeys=!^F,o,O,<CR>
function! GetCabalIndent()
let l:prevline = getline(v:lnum - 1)
if l:prevline =~ '\C^\(executable\|library\|flag\|source-repository\|test-suite\|benchmark\)'
return g:cabal_indent_section
else
return match(l:prevline, '\S')
endif
endfunction
|