Now parsing file on every normal mode cursor move

This is still fast & efficient because if we detect that the buffer hasn't been
changed (by examining b:changedtick), the parse doesn't proceed.

In effect, we now make sure we parse the file after every change to the buffer
as soon as that change happens. This means that compilation error feedback will
now be much, MUCH quicker.
This commit is contained in:
Strahinja Val Markovic 2013-08-13 14:03:57 -07:00
parent 76aa87cb22
commit 9d34fad24f
2 changed files with 14 additions and 0 deletions

View File

@ -327,6 +327,7 @@ function! s:OnCursorMovedNormalMode()
endif
call s:UpdateDiagnosticNotifications()
call s:OnFileReadyToParse()
endfunction

View File

@ -42,6 +42,12 @@ class ClangCompleter( Completer ):
self.flags = Flags()
self.diagnostic_store = None
# We set this flag when a compilation request comes in while one is already
# in progress. We use this to trigger the pending request after the previous
# one completes (from GetDiagnosticsForCurrentFile because that's the only
# method that knows when the compilation has finished).
self.extra_parse_desired = False
def SupportedFiletypes( self ):
return CLANG_FILETYPES
@ -220,6 +226,7 @@ class ClangCompleter( Completer ):
return
if self.completer.UpdatingTranslationUnit( filename ):
self.extra_parse_desired = True
return
flags = self.flags.FlagsForFile( filename )
@ -232,6 +239,8 @@ class ClangCompleter( Completer ):
self.GetUnsavedFilesVector(),
flags )
self.extra_parse_desired = False
def OnBufferUnload( self, deleted_buffer_file ):
self.completer.DeleteCachesForFileAsync( deleted_buffer_file )
@ -255,6 +264,10 @@ class ClangCompleter( Completer ):
self.last_prepared_diagnostics = [ DiagnosticToDict( x ) for x in
diagnostics[ : MAX_DIAGNOSTICS_TO_DISPLAY ] ]
self.parse_future = None
if self.extra_parse_desired:
self.OnFileReadyToParse()
return self.last_prepared_diagnostics