Skip to content

Commit

Permalink
hdevtools: Preserve multi-line comments
Browse files Browse the repository at this point in the history
but trim unnecessary line white space above (empty lines) and left
(commont indentation). This fixes vim-syntastic#1700.
  • Loading branch information
nomeata committed Feb 17, 2016
1 parent c3882ef commit 3b91614
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions autoload/syntastic/postprocess.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,27 @@ function! syntastic#postprocess#compressWhitespace(errors) abort " {{{2
return a:errors
endfunction " }}}2

" remove initial empty lines
function! syntastic#postprocess#removeEmptyLines(errors) abort " {{{2
for e in a:errors
let e['text'] = substitute(e['text'], '\m^\n\+', '', '')
endfor

return a:errors
endfunction " }}}2

" unindent consistently
function! syntastic#postprocess#unindent(errors) abort " {{{2
for e in a:errors
let lines = split(e['text'], '\n', 1)
let indent = min(map(copy(lines), 'len(matchstr(v:val,"^ \\+"))'))
let lines = map(lines, 'v:val[' . indent . ':]')
let e['text'] = join(lines, "\n")
endfor

return a:errors
endfunction " }}}2

" remove spurious CR under Cygwin
function! syntastic#postprocess#cygwinRemoveCR(errors) abort " {{{2
if has('win32unix')
Expand Down
2 changes: 1 addition & 1 deletion syntax_checkers/haskell/hdevtools.vim
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function! SyntaxCheckers_haskell_hdevtools_GetLocList() dict
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'defaults': {'vcol': 1},
\ 'postprocess': ['compressWhitespace'] })
\ 'postprocess': ['removeEmptyLines', 'unindent'] })
endfunction

call g:SyntasticRegistry.CreateAndRegisterChecker({
Expand Down

0 comments on commit 3b91614

Please sign in to comment.