Only removing our signs in buffer, no all
We used to remove all the signs in a buffer. Now we just remove the ones we set. This prevents conflicts with other Vim plugins.
This commit is contained in:
parent
8866f798b6
commit
182848050e
@ -31,6 +31,7 @@ class DiagnosticInterface( object ):
|
|||||||
self._next_sign_id = 1
|
self._next_sign_id = 1
|
||||||
self._previous_line_number = -1
|
self._previous_line_number = -1
|
||||||
self._diag_message_needs_clearing = False
|
self._diag_message_needs_clearing = False
|
||||||
|
self._buffer_number_to_sign_ids = defaultdict( set )
|
||||||
|
|
||||||
|
|
||||||
def OnCursorMoved( self ):
|
def OnCursorMoved( self ):
|
||||||
@ -47,8 +48,7 @@ class DiagnosticInterface( object ):
|
|||||||
self._buffer_number_to_line_to_diags = _ConvertDiagListToDict( diags )
|
self._buffer_number_to_line_to_diags = _ConvertDiagListToDict( diags )
|
||||||
|
|
||||||
if self._user_options[ 'enable_diagnostic_signs' ]:
|
if self._user_options[ 'enable_diagnostic_signs' ]:
|
||||||
self._next_sign_id = _UpdateSigns( self._buffer_number_to_line_to_diags,
|
self._UpdateSigns()
|
||||||
self._next_sign_id )
|
|
||||||
|
|
||||||
if self._user_options[ 'enable_diagnostic_highlighting' ]:
|
if self._user_options[ 'enable_diagnostic_highlighting' ]:
|
||||||
_UpdateSquiggles( self._buffer_number_to_line_to_diags )
|
_UpdateSquiggles( self._buffer_number_to_line_to_diags )
|
||||||
@ -71,6 +71,40 @@ class DiagnosticInterface( object ):
|
|||||||
self._diag_message_needs_clearing = True
|
self._diag_message_needs_clearing = True
|
||||||
|
|
||||||
|
|
||||||
|
def _UnplaceSignsInBuffer( self, buffer_number ):
|
||||||
|
vimsupport.UnplaceSignsInBuffer(
|
||||||
|
buffer_number,
|
||||||
|
self._buffer_number_to_sign_ids[ buffer_number ] )
|
||||||
|
|
||||||
|
self._buffer_number_to_sign_ids[ buffer_number ].clear()
|
||||||
|
|
||||||
|
|
||||||
|
def _PlaceSignInBuffer( self, line, buffer_number, is_error ):
|
||||||
|
vimsupport.PlaceSign( self._next_sign_id,
|
||||||
|
line,
|
||||||
|
buffer_number,
|
||||||
|
is_error )
|
||||||
|
self._buffer_number_to_sign_ids[ buffer_number ].add( self._next_sign_id )
|
||||||
|
self._next_sign_id += 1
|
||||||
|
|
||||||
|
|
||||||
|
def _UpdateSigns( self ):
|
||||||
|
self._UnplaceSignsInBuffer( vim.current.buffer.number )
|
||||||
|
|
||||||
|
for buffer_number, line_to_diags in \
|
||||||
|
self._buffer_number_to_line_to_diags.iteritems():
|
||||||
|
if not vimsupport.BufferIsVisible( buffer_number ):
|
||||||
|
continue
|
||||||
|
|
||||||
|
self._UnplaceSignsInBuffer( buffer_number )
|
||||||
|
|
||||||
|
for line, diags in line_to_diags.iteritems():
|
||||||
|
for diag in diags:
|
||||||
|
self._PlaceSignInBuffer( line,
|
||||||
|
buffer_number,
|
||||||
|
_DiagnosticIsError( diag ) )
|
||||||
|
|
||||||
|
|
||||||
def _UpdateSquiggles( buffer_number_to_line_to_diags ):
|
def _UpdateSquiggles( buffer_number_to_line_to_diags ):
|
||||||
vimsupport.ClearYcmSyntaxMatches()
|
vimsupport.ClearYcmSyntaxMatches()
|
||||||
line_to_diags = buffer_number_to_line_to_diags[ vim.current.buffer.number ]
|
line_to_diags = buffer_number_to_line_to_diags[ vim.current.buffer.number ]
|
||||||
@ -102,23 +136,6 @@ def _UpdateSquiggles( buffer_number_to_line_to_diags ):
|
|||||||
is_error = is_error )
|
is_error = is_error )
|
||||||
|
|
||||||
|
|
||||||
def _UpdateSigns( buffer_number_to_line_to_diags, next_sign_id ):
|
|
||||||
vimsupport.UnplaceAllSignsInBuffer( vim.current.buffer.number )
|
|
||||||
for buffer_number, line_to_diags in buffer_number_to_line_to_diags.iteritems():
|
|
||||||
if not vimsupport.BufferIsVisible( buffer_number ):
|
|
||||||
continue
|
|
||||||
|
|
||||||
vimsupport.UnplaceAllSignsInBuffer( buffer_number )
|
|
||||||
for line, diags in line_to_diags.iteritems():
|
|
||||||
for diag in diags:
|
|
||||||
vimsupport.PlaceSign( next_sign_id,
|
|
||||||
line,
|
|
||||||
buffer_number,
|
|
||||||
_DiagnosticIsError( diag ) )
|
|
||||||
next_sign_id += 1
|
|
||||||
return next_sign_id
|
|
||||||
|
|
||||||
|
|
||||||
def _ConvertDiagListToDict( diag_list ):
|
def _ConvertDiagListToDict( diag_list ):
|
||||||
buffer_to_line_to_diags = defaultdict( lambda: defaultdict( list ) )
|
buffer_to_line_to_diags = defaultdict( lambda: defaultdict( list ) )
|
||||||
for diag in diag_list:
|
for diag in diag_list:
|
||||||
|
@ -107,11 +107,11 @@ def GetBufferFilepath( buffer_object ):
|
|||||||
return os.path.join( os.getcwd(), str( buffer_object.number ) )
|
return os.path.join( os.getcwd(), str( buffer_object.number ) )
|
||||||
|
|
||||||
|
|
||||||
# TODO: only unplace our signs, not all signs
|
def UnplaceSignsInBuffer( buffer_number, signs ):
|
||||||
def UnplaceAllSignsInBuffer( buffer_number ):
|
|
||||||
if buffer_number < 0:
|
if buffer_number < 0:
|
||||||
return
|
return
|
||||||
vim.command( 'sign unplace * buffer={0}'.format( buffer_number ) )
|
for sign in signs:
|
||||||
|
vim.command( 'sign unplace {0} buffer={1}'.format( sign, buffer_number ) )
|
||||||
|
|
||||||
|
|
||||||
def PlaceSign( sign_id, line_num, buffer_num, is_error = True ):
|
def PlaceSign( sign_id, line_num, buffer_num, is_error = True ):
|
||||||
|
Loading…
Reference in New Issue
Block a user