diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index d6a6ca0b..dc25cc7a 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -438,13 +438,27 @@ function! s:ForceCompile() if diagnostics_ready break endif + + let getting_completions = pyeval( + \ 'ycm_state.GettingCompletions()' ) + + if !getting_completions + echom "Unable to retrieve diagnostics." + return 0 + endif + sleep 100m endwhile + return 1 endfunction function! s:ForceCompileAndDiagnostics() - call s:ForceCompile() + let compilation_succeeded = s:ForceCompile() + if !compilation_succeeded + return + endif + call s:UpdateDiagnosticNotifications() echom "Diagnostics refreshed." endfunction diff --git a/python/completers/completer.py b/python/completers/completer.py index 2a80fa6a..0281a20e 100644 --- a/python/completers/completer.py +++ b/python/completers/completer.py @@ -81,6 +81,9 @@ class Completer( object ): def ShowDetailedDiagnostic( self ): pass + def GettingCompletions( self ): + return False + @abc.abstractmethod def SupportedFiletypes( self ): diff --git a/python/completers/cpp/clang_completer.py b/python/completers/cpp/clang_completer.py index 2c720855..1e6873ff 100644 --- a/python/completers/cpp/clang_completer.py +++ b/python/completers/cpp/clang_completer.py @@ -146,6 +146,10 @@ class ClangCompleter( Completer ): return self.parse_future.ResultsReady() + def GettingCompletions( self ): + return self.completer.UpdatingTranslationUnit( vim.current.buffer.name ) + + def GetDiagnosticsForCurrentFile( self ): if self.DiagnosticsForCurrentFileReady(): diagnostics = self.completer.DiagnosticsForFile( vim.current.buffer.name ) diff --git a/python/ycm.py b/python/ycm.py index f7b5c190..67c7c4b5 100644 --- a/python/ycm.py +++ b/python/ycm.py @@ -141,6 +141,12 @@ class YouCompleteMe( object ): return self.GetFiletypeCompleterForCurrentFile().ShowDetailedDiagnostic() + def GettingCompletions( self ): + if self.FiletypeCompletionEnabledForCurrentFile(): + return self.GetFiletypeCompleterForCurrentFile().GettingCompletions() + return False + + def OnCurrentIdentifierFinished( self ): self.identcomp.OnCurrentIdentifierFinished()