From 54086304b3ad5f37d0ab81802d5f4dbf305f00ff Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Fri, 17 Oct 2014 08:35:05 +0300 Subject: [PATCH] Cache balloons' contents. Cleanup. --- autoload/syntastic/util.vim | 2 +- doc/syntastic.txt | 2 +- plugin/syntastic.vim | 2 +- plugin/syntastic/balloons.vim | 20 ++++++-------------- plugin/syntastic/loclist.vim | 23 +++++++++++++++++++++++ 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/autoload/syntastic/util.vim b/autoload/syntastic/util.vim index e58b00bc..4d067e1e 100644 --- a/autoload/syntastic/util.vim +++ b/autoload/syntastic/util.vim @@ -274,7 +274,7 @@ endfunction " }}}2 function! syntastic#util#dictFilter(errors, filter) " {{{2 let rules = s:_translateFilter(a:filter) - " call syntastic#log#debug(g:SyntasticDebugFilters, "applying filter:", rules) + " call syntastic#log#debug(g:SyntasticDebugTrace, "applying filter:", rules) try call filter(a:errors, rules) catch /\m^Vim\%((\a\+)\)\=:E/ diff --git a/doc/syntastic.txt b/doc/syntastic.txt index 336f0f51..b497263b 100644 --- a/doc/syntastic.txt +++ b/doc/syntastic.txt @@ -725,7 +725,7 @@ for python in syntastic (see |syntastic_mode_map|), or disable lint checks in Syntastic can be used together with the 'YouCompleteMe' Vim plugin (see http://valloric.github.io/YouCompleteMe/). However, by default 'YouCompleteMe' -disables syntastic"s checkers for the "c", "cpp", "objc", and "objcpp" +disables syntastic's checkers for the "c", "cpp", "objc", and "objcpp" filetypes, in order to allow its own checkers to run. If you want to use YCM's identifier completer but still run syntastic's checkers for those filetypes you have to set |ycm_show_diagnostics_ui| to 0. E.g.: > diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim index 353e2dc7..940f0aec 100644 --- a/plugin/syntastic.vim +++ b/plugin/syntastic.vim @@ -19,7 +19,7 @@ if has('reltime') lockvar! g:syntastic_start endif -let g:syntastic_version = '3.5.0-69' +let g:syntastic_version = '3.5.0-70' lockvar g:syntastic_version " Sanity checks {{{1 diff --git a/plugin/syntastic/balloons.vim b/plugin/syntastic/balloons.vim index 6bf6edb9..1ac468c1 100644 --- a/plugin/syntastic/balloons.vim +++ b/plugin/syntastic/balloons.vim @@ -22,20 +22,11 @@ endfunction " }}}2 " Update the error balloons function! g:SyntasticBalloonsNotifier.refresh(loclist) " {{{2 - let b:syntastic_balloons = {} + unlet! b:syntastic_balloons if self.enabled() && !a:loclist.isEmpty() - call syntastic#log#debug(g:SyntasticDebugNotifications, 'balloons: refresh') - let buf = bufnr('') - let issues = filter(a:loclist.copyRaw(), 'v:val["bufnr"] == buf') - if !empty(issues) - for i in issues - if has_key(b:syntastic_balloons, i['lnum']) - let b:syntastic_balloons[i['lnum']] .= "\n" . i['text'] - else - let b:syntastic_balloons[i['lnum']] = i['text'] - endif - endfor - set beval bexpr=SyntasticBalloonsExprNotifier() + let b:syntastic_balloons = a:loclist.balloons() + if !empty(b:syntastic_balloons) + set ballooneval balloonexpr=SyntasticBalloonsExprNotifier() endif endif endfunction " }}}2 @@ -46,7 +37,8 @@ function! g:SyntasticBalloonsNotifier.reset(loclist) " {{{2 let b:syntastic_balloons = {} if has('balloon_eval') call syntastic#log#debug(g:SyntasticDebugNotifications, 'balloons: reset') - set nobeval + unlet! b:syntastic_balloons + set noballooneval endif endfunction " }}}2 " @vimlint(EVL103, 0, a:loclist) diff --git a/plugin/syntastic/loclist.vim b/plugin/syntastic/loclist.vim index 19a61984..c94201e4 100644 --- a/plugin/syntastic/loclist.vim +++ b/plugin/syntastic/loclist.vim @@ -173,6 +173,29 @@ function! g:SyntasticLoclist.decorate(tag) " {{{2 endfor endfunction " }}}2 +function! g:SyntasticLoclist.balloons() " {{{2 + if !exists("self._cachedBalloons") + let sep = has("balloon_multiline") ? "\n" : ' | ' + + let self._cachedBalloons = {} + for e in self._rawLoclist + let buf = e['bufnr'] + + if !has_key(self._cachedBalloons, buf) + let self._cachedBalloons[buf] = {} + endif + + if has_key(self._cachedBalloons[buf], e['lnum']) + let self._cachedBalloons[buf][e['lnum']] .= sep . e['text'] + else + let self._cachedBalloons[buf][e['lnum']] = e['text'] + endif + endfor + endif + + return get(self._cachedBalloons, bufnr(''), {}) +endfunction " }}}2 + function! g:SyntasticLoclist.errors() " {{{2 if !exists("self._cachedErrors") let self._cachedErrors = self.filter({'type': "E"})