diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 20ff57f4..cc776654 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -140,11 +140,9 @@ endfunction function! s:OnInsertLeave() - " TODO: Also, look at the current identifier under the cursor on InsertLeave - " and add it to the identifier database; this should catch the cases where the - " user slightly changes a variable name in-place let s:omnifunc_mode = 0 call s:UpdateDiagnosticNotifications() + py identcomp.AddIdentifierUnderCursor() endfunction diff --git a/python/ycm.py b/python/ycm.py index 3327e5fd..1b8300e6 100644 --- a/python/ycm.py +++ b/python/ycm.py @@ -82,6 +82,20 @@ class IdentifierCompleter( Completer ): self.AddIdentifier( PreviousIdentifier() ) + def AddIdentifierUnderCursor( self ): + cursor_identifier = vim.eval( 'expand("")' ) + if not cursor_identifier: + return + + stripped_cursor_identifier = ''.join( ( x for x in + cursor_identifier if + IsIdentifierChar( x ) ) ) + if not stripped_cursor_identifier: + return + + self.AddIdentifier( stripped_cursor_identifier ) + + def AddBufferIdentifiers( self ): filetype = vim.eval( "&filetype" ) filepath = vim.eval( "expand('%:p')" )