Skip to content

Commit 8c1fac4

Browse files
authored
Merge pull request #88 from alx741/disable_indentation
Disable indentation - configuration variable
2 parents e6f3093 + 99f9b1a commit 8c1fac4

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ Disabling Template Haskell and Quasiquoting syntax is possible by setting
6464

6565
To configure indentation in `haskell-vim` you can use the following variables to change indentation depth, just add the according line to your `.vimrc`.
6666

67+
If you dislike how indentation works you can disable it by setting `g:haskell_indent_disable` to
68+
`1`.
69+
70+
Additionally you can use the
71+
[vim-hindent](https://github.com/alx741/vim-hindent) plugin to achieve automatic
72+
indentation using *hindent*.
73+
6774
#### Haskell
6875

6976
* `let g:haskell_indent_if = 3`

doc/haskell-vim.txt

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ INDENTATION *haskell-vim-indentation
7676
To configure indentation in `haskell-vim` you can use the following variables to
7777
change indentation depth, just add the according line to your `.vimrc`.
7878

79+
You can disable the indentation by setting `g:haskell_indent_disable` to `1`.
80+
7981
Haskell~
8082

8183
* |haskell-vim-indent-if|

indent/haskell.vim

+12-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ endif
1313

1414
let b:did_indent = 1
1515

16+
if !exists('g:haskell_indent_disable')
17+
let g:haskell_indent_disable = 0
18+
endif
19+
1620
if !exists('g:haskell_indent_if')
1721
" if x
1822
" >>>then ...
@@ -57,8 +61,14 @@ if !exists('g:haskell_indent_guard')
5761
let g:haskell_indent_guard = 2
5862
endif
5963

60-
setlocal indentexpr=GetHaskellIndent()
61-
setlocal indentkeys=0{,0},0(,0),0[,0],!^F,o,O,0\=,0=where,0=let,0=deriving,<space>
64+
if exists("g:haskell_indent_disable") && g:haskell_indent_disable == 0
65+
setlocal indentexpr=GetHaskellIndent()
66+
setlocal indentkeys=0{,0},0(,0),0[,0],!^F,o,O,0\=,0=where,0=let,0=deriving,<space>
67+
else
68+
setlocal nocindent
69+
setlocal nosmartindent
70+
setlocal autoindent
71+
endif
6272

6373
function! s:isInBlock(hlstack)
6474
return index(a:hlstack, 'haskellParens') > -1 || index(a:hlstack, 'haskellBrackets') > -1 || index(a:hlstack, 'haskellBlock') > -1 || index(a:hlstack, 'haskellBlockComment') > -1 || index(a:hlstack, 'haskellPragma') > -1

0 commit comments

Comments
 (0)