From 3b916142781ae1189d12d23935132c86e5533b45 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Wed, 17 Feb 2016 12:39:59 +0100 Subject: [PATCH] hdevtools: Preserve multi-line comments but trim unnecessary line white space above (empty lines) and left (commont indentation). This fixes #1700. --- autoload/syntastic/postprocess.vim | 21 +++++++++++++++++++++ syntax_checkers/haskell/hdevtools.vim | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/autoload/syntastic/postprocess.vim b/autoload/syntastic/postprocess.vim index 136fa589c..6f63f5b4d 100644 --- a/autoload/syntastic/postprocess.vim +++ b/autoload/syntastic/postprocess.vim @@ -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') diff --git a/syntax_checkers/haskell/hdevtools.vim b/syntax_checkers/haskell/hdevtools.vim index 4b0a80fbc..b547b7cb2 100644 --- a/syntax_checkers/haskell/hdevtools.vim +++ b/syntax_checkers/haskell/hdevtools.vim @@ -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({