summaryrefslogtreecommitdiffstats
path: root/indent/cabal.vim
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2015-10-18 16:08:51 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2015-10-18 16:08:51 +0200
commit1f1e821192d25d630587aa9d53bd8d428fb09c4d (patch)
tree7b342264b1c5e2e8d2a644fbff86204061530fd4 /indent/cabal.vim
parentae882e85f81869dbf81b5c888c337aa4481fc8c3 (diff)
downloadvim-polyglot-2.2.2.tar.gz
vim-polyglot-2.2.2.zip
Change haskell provider to neovimhaskell/haskell-vim, closes #75v2.2.2
Diffstat (limited to 'indent/cabal.vim')
-rw-r--r--indent/cabal.vim35
1 files changed, 35 insertions, 0 deletions
diff --git a/indent/cabal.vim b/indent/cabal.vim
new file mode 100644
index 00000000..b2089a5e
--- /dev/null
+++ b/indent/cabal.vim
@@ -0,0 +1,35 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'haskell') == -1
+
+" 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
+
+endif