Now showing red squiggle under diagnostic location
This commit is contained in:
parent
a3918788c0
commit
65e6b55268
@ -75,6 +75,7 @@ function! youcompleteme#Enable()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
call s:SetUpSigns()
|
call s:SetUpSigns()
|
||||||
|
call s:SetUpSyntaxHighlighting()
|
||||||
|
|
||||||
if g:ycm_allow_changing_updatetime
|
if g:ycm_allow_changing_updatetime
|
||||||
set ut=2000
|
set ut=2000
|
||||||
@ -194,6 +195,28 @@ function! s:SetUpSigns()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! s:SetUpSyntaxHighlighting()
|
||||||
|
" We try to ensure backwards compatibility with Syntastic if the user has
|
||||||
|
" already defined styling for Syntastic highlight groups.
|
||||||
|
|
||||||
|
if !hlexists( 'YcmErrorSection' )
|
||||||
|
if hlexists( 'SyntasticError' )
|
||||||
|
highlight link YcmErrorSection SyntasticError
|
||||||
|
else
|
||||||
|
highlight link YcmErrorSection SpellBad
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !hlexists( 'YcmWarningSection' )
|
||||||
|
if hlexists( 'SyntasticWarning' )
|
||||||
|
highlight link YcmWarningSection SyntasticWarning
|
||||||
|
else
|
||||||
|
highlight link YcmWarningSection SpellCap
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! s:SetUpBackwardsCompatibility()
|
function! s:SetUpBackwardsCompatibility()
|
||||||
let complete_in_comments_and_strings =
|
let complete_in_comments_and_strings =
|
||||||
\ get( g:, 'ycm_complete_in_comments_and_strings', 0 )
|
\ get( g:, 'ycm_complete_in_comments_and_strings', 0 )
|
||||||
|
@ -44,6 +44,7 @@ class DiagnosticInterface( object ):
|
|||||||
self._buffer_number_to_line_to_diags = _ConvertDiagListToDict( diags )
|
self._buffer_number_to_line_to_diags = _ConvertDiagListToDict( diags )
|
||||||
self._next_sign_id = _UpdateSigns( self._buffer_number_to_line_to_diags,
|
self._next_sign_id = _UpdateSigns( self._buffer_number_to_line_to_diags,
|
||||||
self._next_sign_id )
|
self._next_sign_id )
|
||||||
|
_UpdateSquiggles( self._buffer_number_to_line_to_diags )
|
||||||
|
|
||||||
|
|
||||||
def _EchoDiagnosticForLine( self, line_num ):
|
def _EchoDiagnosticForLine( self, line_num ):
|
||||||
@ -56,6 +57,17 @@ class DiagnosticInterface( object ):
|
|||||||
vimsupport.EchoTextVimWidth( diags[ 0 ][ 'text' ] )
|
vimsupport.EchoTextVimWidth( diags[ 0 ][ 'text' ] )
|
||||||
|
|
||||||
|
|
||||||
|
def _UpdateSquiggles( buffer_number_to_line_to_diags ):
|
||||||
|
vimsupport.ClearYcmSyntaxMatches()
|
||||||
|
line_to_diags = buffer_number_to_line_to_diags[ vim.current.buffer.number ]
|
||||||
|
|
||||||
|
for diags in line_to_diags.itervalues():
|
||||||
|
for diag in diags:
|
||||||
|
vimsupport.AddDiagnosticSyntaxMatch( diag[ 'lnum' ],
|
||||||
|
diag[ 'col' ],
|
||||||
|
_DiagnosticIsError( diag ) )
|
||||||
|
|
||||||
|
|
||||||
def _UpdateSigns( buffer_number_to_line_to_diags, next_sign_id ):
|
def _UpdateSigns( buffer_number_to_line_to_diags, next_sign_id ):
|
||||||
for buffer_number, line_to_diags in buffer_number_to_line_to_diags.iteritems():
|
for buffer_number, line_to_diags in buffer_number_to_line_to_diags.iteritems():
|
||||||
if not vimsupport.BufferIsVisible( buffer_number ):
|
if not vimsupport.BufferIsVisible( buffer_number ):
|
||||||
@ -67,7 +79,7 @@ def _UpdateSigns( buffer_number_to_line_to_diags, next_sign_id ):
|
|||||||
vimsupport.PlaceSign( next_sign_id,
|
vimsupport.PlaceSign( next_sign_id,
|
||||||
line,
|
line,
|
||||||
buffer_number,
|
buffer_number,
|
||||||
diag[ 'type' ] == 'E' )
|
_DiagnosticIsError( diag ) )
|
||||||
next_sign_id += 1
|
next_sign_id += 1
|
||||||
return next_sign_id
|
return next_sign_id
|
||||||
|
|
||||||
@ -83,3 +95,7 @@ def _ConvertDiagListToDict( diag_list ):
|
|||||||
diags.sort( key = lambda diag: itemgetter( 'col', 'type' ) )
|
diags.sort( key = lambda diag: itemgetter( 'col', 'type' ) )
|
||||||
return buffer_to_line_to_diags
|
return buffer_to_line_to_diags
|
||||||
|
|
||||||
|
|
||||||
|
def _DiagnosticIsError( diag ):
|
||||||
|
return diag[ 'type' ] == 'E'
|
||||||
|
|
||||||
|
@ -107,6 +107,7 @@ 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 UnplaceAllSignsInBuffer( buffer_number ):
|
def UnplaceAllSignsInBuffer( buffer_number ):
|
||||||
if buffer_number < 0:
|
if buffer_number < 0:
|
||||||
return
|
return
|
||||||
@ -119,6 +120,20 @@ def PlaceSign( sign_id, line_num, buffer_num, is_error = True ):
|
|||||||
sign_id, line_num, sign_name, buffer_num ) )
|
sign_id, line_num, sign_name, buffer_num ) )
|
||||||
|
|
||||||
|
|
||||||
|
def ClearYcmSyntaxMatches():
|
||||||
|
matches = VimExpressionToPythonType( 'getmatches()' )
|
||||||
|
for match in matches:
|
||||||
|
if match[ 'group' ].startswith( 'Ycm' ):
|
||||||
|
vim.eval( 'matchdelete({0})'.format( match[ 'id' ] ) )
|
||||||
|
|
||||||
|
|
||||||
|
# Returns the ID of the newly added match
|
||||||
|
def AddDiagnosticSyntaxMatch( line_num, column_num, is_error ):
|
||||||
|
group = 'YcmErrorSection' if is_error else 'YcmWarningSection'
|
||||||
|
return GetIntValue(
|
||||||
|
"matchadd('{0}', '\%{1}l\%{2}c')".format( group, line_num, column_num ) )
|
||||||
|
|
||||||
|
|
||||||
# Given a dict like {'a': 1}, loads it into Vim as if you ran 'let g:a = 1'
|
# Given a dict like {'a': 1}, loads it into Vim as if you ran 'let g:a = 1'
|
||||||
# When |overwrite| is True, overwrites the existing value in Vim.
|
# When |overwrite| is True, overwrites the existing value in Vim.
|
||||||
def LoadDictIntoVimGlobals( new_globals, overwrite = True ):
|
def LoadDictIntoVimGlobals( new_globals, overwrite = True ):
|
||||||
|
Loading…
Reference in New Issue
Block a user