From 7eda5de0ca83d4e460c21c9859dbc29948a80456 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Mon, 12 Aug 2013 22:46:20 +0300 Subject: [PATCH 1/5] Haskell cleanup. Make the "compressWhitespace" filter kill \001 characters. Make the ghc-mod checker use the "compressWhitespace" filter. Minor formatting of the hlint checker. --- syntax_checkers/haskell/ghc-mod.vim | 21 ++++++++++----------- syntax_checkers/haskell/hlint.vim | 18 ++++++++---------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/syntax_checkers/haskell/ghc-mod.vim b/syntax_checkers/haskell/ghc-mod.vim index f3677dc1..3dcc6e7e 100644 --- a/syntax_checkers/haskell/ghc-mod.vim +++ b/syntax_checkers/haskell/ghc-mod.vim @@ -10,16 +10,21 @@ " "============================================================================ -if exists("g:loaded_syntastic_haskell_ghc_mod_checker") +if exists('g:loaded_syntastic_haskell_ghc_mod_checker') finish endif -let g:loaded_syntastic_haskell_ghc_mod_checker=1 +let g:loaded_syntastic_haskell_ghc_mod_checker = 1 function! SyntaxCheckers_haskell_ghc_mod_IsAvailable() return executable('ghc-mod') endfunction function! SyntaxCheckers_haskell_ghc_mod_GetLocList() + let makeprg = syntastic#makeprg#build({ + \ 'exe': 'ghc-mod check', + \ 'filetype': 'haskell', + \ 'subchecker': 'ghc_mod' }) + let errorformat = \ '%-G%\s%#,' . \ '%f:%l:%c:%trror: %m,' . @@ -30,16 +35,10 @@ function! SyntaxCheckers_haskell_ghc_mod_GetLocList() \ '%E%f:%l:%c:,' . \ '%Z%m' - let makeprg = syntastic#makeprg#build({ - \ 'exe': 'ghc-mod check', - \ 'filetype': 'haskell', - \ 'subchecker': 'ghc_mod' }) - - let loclist = SyntasticMake({ + return SyntasticMake({ \ 'makeprg': makeprg, - \ 'errorformat': errorformat }) - - return loclist + \ 'errorformat': errorformat, + \ 'postprocess': ['compressWhitespace'] }) endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({ diff --git a/syntax_checkers/haskell/hlint.vim b/syntax_checkers/haskell/hlint.vim index c748b77c..f9f0fcd4 100644 --- a/syntax_checkers/haskell/hlint.vim +++ b/syntax_checkers/haskell/hlint.vim @@ -5,32 +5,30 @@ "License: BSD "============================================================================ -if exists("g:loaded_syntastic_haskell_hlint_checker") +if exists('g:loaded_syntastic_haskell_hlint_checker') finish endif -let g:loaded_syntastic_haskell_hlint_checker=1 +let g:loaded_syntastic_haskell_hlint_checker = 1 function! SyntaxCheckers_haskell_hlint_IsAvailable() return executable('hlint') endfunction function! SyntaxCheckers_haskell_hlint_GetLocList() - let errorformat = - \ '%E%f:%l:%c: Error: %m,' . - \ '%W%f:%l:%c: Warning: %m,' . - \ '%C%m' - let makeprg = syntastic#makeprg#build({ \ 'exe': 'hlint', \ 'filetype': 'haskell', \ 'subchecker': 'hlint' }) - let loclist = SyntasticMake({ + let errorformat = + \ '%E%f:%l:%c: Error: %m,' . + \ '%W%f:%l:%c: Warning: %m,' . + \ '%C%m' + + return SyntasticMake({ \ 'makeprg': makeprg, \ 'errorformat': errorformat, \ 'postprocess': ['compressWhitespace'] }) - - return loclist endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({ From 7550c860160e6983e3157b8e41cbbdd051b47913 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Tue, 13 Aug 2013 09:01:04 +0300 Subject: [PATCH 2/5] Leftover from 7eda5de. How embarrasing. --- autoload/syntastic/postprocess.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/autoload/syntastic/postprocess.vim b/autoload/syntastic/postprocess.vim index e3ac70e6..845b535e 100644 --- a/autoload/syntastic/postprocess.vim +++ b/autoload/syntastic/postprocess.vim @@ -29,6 +29,7 @@ function syntastic#postprocess#compressWhitespace(errors) let llist = [] for e in a:errors + let e['text'] = substitute(e['text'], "\001", '', 'g') let e['text'] = substitute(e['text'], '\n', ' ', 'g') let e['text'] = substitute(e['text'], '\s\{2,}', ' ', 'g') call add(llist, e) From 148021e348c75031e8b06a65793d1f4420874306 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Tue, 13 Aug 2013 09:31:43 +0300 Subject: [PATCH 3/5] Reuse loclists when possible, to allow :lolder and :lnewer. This is not completely safe: if a loclist is created by something other than syntastic before the error window is displayed, syntastic will obliterate it. There is currently no way to tell if a loclist was created by syntastic or not. Undocumented variable g:syntastic_reuse_loc_lists can be used to disable reuse of loclists. --- plugin/syntastic.vim | 11 +++++++++-- plugin/syntastic/loclist.vim | 7 ++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim index 9c92e117..02ca11a6 100644 --- a/plugin/syntastic.vim +++ b/plugin/syntastic.vim @@ -64,6 +64,12 @@ if !exists("g:syntastic_full_redraws") let g:syntastic_full_redraws = !( has('gui_running') || has('gui_macvim')) endif +" TODO: not documented +if !exists("g:syntastic_reuse_loc_lists") + " a relevant bug has been fixed in one of the pre-releases of Vim 7.4 + let g:syntastic_reuse_loc_lists = (v:version >= 704) +endif + let s:registry = g:SyntasticRegistry.Instance() let s:notifiers = g:SyntasticNotifiers.Instance() let s:modemap = g:SyntasticModeMap.Instance() @@ -145,8 +151,10 @@ function! s:UpdateErrors(auto_invoked, ...) let loclist = g:SyntasticLoclist.current() + let w:syntastic_loclist_set = 0 if g:syntastic_always_populate_loc_list || g:syntastic_auto_jump call setloclist(0, loclist.filteredRaw()) + let w:syntastic_loclist_set = 1 if run_checks && g:syntastic_auto_jump && loclist.hasErrorsOrWarningsToDisplay() silent! lrewind endif @@ -356,7 +364,6 @@ endfunction function! SyntasticMake(options) call syntastic#util#debug('SyntasticMake: called with options: '. string(a:options)) - let old_loclist = getloclist(0) let old_shell = &shell let old_shellredir = &shellredir let old_errorformat = &errorformat @@ -396,7 +403,7 @@ function! SyntasticMake(options) exec 'lcd ' . fnameescape(old_cwd) endif - call setloclist(0, old_loclist) + silent! lolder let &errorformat = old_errorformat let &shellredir = old_shellredir let &shell=old_shell diff --git a/plugin/syntastic/loclist.vim b/plugin/syntastic/loclist.vim index d5cd6e39..104470dc 100644 --- a/plugin/syntastic/loclist.vim +++ b/plugin/syntastic/loclist.vim @@ -143,7 +143,12 @@ endfunction "display the cached errors for this buf in the location list function! g:SyntasticLoclist.show() - call setloclist(0, self.filteredRaw()) + if !exists('w:syntastic_loclist_set') + let w:syntastic_loclist_set = 0 + endif + call setloclist(0, self.filteredRaw(), g:syntastic_reuse_loc_lists && w:syntastic_loclist_set ? 'r' : ' ') + let w:syntastic_loclist_set = 1 + if self.hasErrorsOrWarningsToDisplay() let num = winnr() exec "lopen " . g:syntastic_loc_list_height From 929f92ddd6dadbef47ee025223d10bbe95d46500 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Tue, 13 Aug 2013 17:48:37 +0300 Subject: [PATCH 4/5] Bug fix: allow loclist cleanup. --- plugin/syntastic.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim index 02ca11a6..fb788a3b 100644 --- a/plugin/syntastic.vim +++ b/plugin/syntastic.vim @@ -397,7 +397,7 @@ function! SyntasticMake(options) endif lgetexpr err_lines - let errors = getloclist(0) + let errors = copy(getloclist(0)) if has_key(a:options, 'cwd') exec 'lcd ' . fnameescape(old_cwd) From 5d123a3a6afd6a949eb17c1194904fd04805e741 Mon Sep 17 00:00:00 2001 From: Asa Ayers Date: Tue, 13 Aug 2013 15:52:14 -0400 Subject: [PATCH 5/5] Coffeelint: Fixed errorformat, last line is optional --- syntax_checkers/coffee/coffeelint.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax_checkers/coffee/coffeelint.vim b/syntax_checkers/coffee/coffeelint.vim index 4b59a8c2..2099359c 100644 --- a/syntax_checkers/coffee/coffeelint.vim +++ b/syntax_checkers/coffee/coffeelint.vim @@ -26,9 +26,9 @@ function! SyntaxCheckers_coffee_coffeelint_GetLocList() \ 'subchecker': 'coffeelint' }) let errorformat = - \ '%f\,%l\,%\d%\+\,%trror\,%m,' . + \ '%f\,%l\,%\d%#\,%trror\,%m,' . \ '%f\,%l\,%trror\,%m,' . - \ '%f\,%l\,%\d%\+\,%tarn\,%m,' . + \ '%f\,%l\,%\d%#\,%tarn\,%m,' . \ '%f\,%l\,%tarn\,%m' return SyntasticMake({