Skip to content

Commit 226ea58

Browse files
author
Marcin Szamotulski
committed
fix #2: reset indentation after an empty line
``` newtype MInt = MInt Int -- this line will be indent but if empty and one presses <C-M> the next line will not ``` So tyyping `<C-M>` twice will reset indentation. This works for any declaration starting in the first colum, but still one can have indentent code if one starts a multi line declaration.
1 parent eeb39c0 commit 226ea58

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

indent/purescript.vim

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ setlocal indentexpr=GetPurescriptIndent()
6565
setlocal indentkeys=!^F,o,O,},=where,=in,=::,=->,==>
6666

6767
function! GetPurescriptIndent()
68+
let ppline = getline(v:lnum - 2)
6869
let prevline = getline(v:lnum - 1)
6970
let line = getline(v:lnum)
7071
let synStackP = map(synstack(v:lnum - 1, col(".")), { key, val -> synIDattr(val, "name") })
@@ -86,7 +87,7 @@ function! GetPurescriptIndent()
8687
return s + g:purescript_indent_in
8788
endif
8889

89-
let s = match(prevline, '^\s*\zs\(--\|import\>\)')
90+
let s = match(prevline, '^\s*\zs\(--\|import\)')
9091
if s >= 0
9192
" comments
9293
" imports
@@ -107,10 +108,14 @@ function! GetPurescriptIndent()
107108
endif
108109

109110
if prevline =~ '^\S'
110-
" starting type signature or function body on next line
111+
" starting type signature, function body, data & newtype on next line
111112
return &shiftwidth
112113
endif
113114

115+
if ppline =~ '^\S' && prevline =~ '^\s*$'
116+
return 0
117+
endif
118+
114119
if line =~ '^\s*::'
115120
return match(prevline, '\S') + &shiftwidth
116121
endif

0 commit comments

Comments
 (0)