From a8f095ec0a15c7b851288c567af0128e494591e0 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Sun, 24 Jun 2012 12:04:45 -0700 Subject: [PATCH] Completion now off for comments and strings --- autoload/youcompleteme.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 5521f940..8d20e02b 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -104,11 +104,26 @@ function! s:AddIdentifierIfNeeded() endfunction +function! s:InsideCommentOrString() + " Has to be col('.') -1 because col('.') doesn't exist at this point. We are + " in insert mode when this func is called. + let syntax_group = synIDattr( synID( line( '.' ), col( '.' ) - 1, 1 ), 'name') + if stridx(syntax_group, 'Comment') > -1 || stridx(syntax_group, 'String') > -1 + return 1 + endif + return 0 +endfunction + + function! s:InvokeCompletion() if &completefunc != "youcompleteme#Complete" return endif + if s:InsideCommentOrString() + return + endif + py vim.command( "let cursor_text = '" + ycm.CurrentCursorTextVim() + "'" ) " infinite loops are bad, mkay?