diff --git a/README.md b/README.md index 23f646b4..63279a2b 100644 --- a/README.md +++ b/README.md @@ -523,6 +523,15 @@ Default: `1` let g:ycm_allow_changing_updatetime = 1 +### The `g:ycm_complete_in_comments_and_strings` option + +When this option is set to `1`, YCM will show the completion menu even when +typing inside strings and comments. + +Default: `0` + + let g:ycm_complete_in_comments_and_strings = 0 + ### The `g:ycm_add_preview_to_completeopt` option When this option is set to `1`, YCM will add the `preview` string to Vim's diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index c817eaec..1b3b344f 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -331,6 +331,10 @@ endfunction function! s:InsideCommentOrString() + if g:ycm_complete_in_comments_and_strings + return 0 + endif + " 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( synIDtrans( synID( line( '.' ), col( '.' ) - 1, 1 ) ), 'name') diff --git a/plugin/youcompleteme.vim b/plugin/youcompleteme.vim index 6eadd5cc..98a40907 100644 --- a/plugin/youcompleteme.vim +++ b/plugin/youcompleteme.vim @@ -74,6 +74,9 @@ let g:ycm_allow_changing_updatetime = let g:ycm_add_preview_to_completeopt = \ get( g:, 'ycm_add_preview_to_completeopt', 0 ) +let g:ycm_complete_in_comments_and_strings = + \ get( g:, 'ycm_complete_in_comments_and_strings', 0 ) + let g:ycm_autoclose_preview_window_after_completion = \ get( g:, 'ycm_autoclose_preview_window_after_completion', 0 )