From c394895c4eea4f597f6a734212e5cb5e38c630e7 Mon Sep 17 00:00:00 2001 From: micbou Date: Sat, 31 Dec 2016 09:51:10 +0100 Subject: [PATCH 1/2] Fix large file message appearing twice Use PostVimMessage to avoid "Press ENTER or type command to continue" message. --- autoload/youcompleteme.vim | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 80551c3d..9350d6c3 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -431,13 +431,16 @@ endfunction function! s:DisableOnLargeFile( filename ) + if exists( 'b:ycm_largefile' ) + return + endif + let threshold = g:ycm_disable_for_files_larger_than_kb * 1024 if threshold > 0 && getfsize( a:filename ) > threshold - echohl WarningMsg | - \ echomsg "YouCompleteMe is disabled in this buffer; " . - \ "the file exceeded the max size (see YCM options)." | - \ echohl None + exec s:python_command "vimsupport.PostVimMessage(" + \ "'YouCompleteMe is disabled in this buffer;" + \ "the file exceeded the max size (see YCM options).')" let b:ycm_largefile = 1 endif endfunction From c67c581d8198ebf8d5f89e28e9c8a292181cb827 Mon Sep 17 00:00:00 2001 From: micbou Date: Sun, 1 Jan 2017 13:57:03 +0100 Subject: [PATCH 2/2] Always use dot operator to concatenate strings Vim automatically adds a space between strings when concatenating them without the dot operator. This is not obvious so we always use the dot operator. Minor coding style changes when writing statements on multiple lines to be more consistent. --- autoload/youcompleteme.vim | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 9350d6c3..cbfa0f25 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -333,8 +333,8 @@ function! s:AllowedToCompleteInBuffer( buffer ) let buffer_filetype = getbufvar( a:buffer, '&filetype' ) if empty( buffer_filetype ) || - \ getbufvar( a:buffer, '&buftype' ) ==# 'nofile' || - \ buffer_filetype ==# 'qf' + \ getbufvar( a:buffer, '&buftype' ) ==# 'nofile' || + \ buffer_filetype ==# 'qf' return 0 endif @@ -373,9 +373,9 @@ function! s:SetUpCommands() command! YcmShowDetailedDiagnostic call s:ShowDetailedDiagnostic() command! YcmDebugInfo call s:DebugInfo() command! -nargs=* -complete=custom,youcompleteme#LogsComplete - \ YcmToggleLogs call s:ToggleLogs() + \ YcmToggleLogs call s:ToggleLogs() command! -nargs=* -complete=custom,youcompleteme#SubCommandsComplete - \ YcmCompleter call s:CompleterCommand() + \ YcmCompleter call s:CompleterCommand() command! YcmForceCompileAndDiagnostics call s:ForceCompileAndDiagnostics() command! YcmDiags call s:ShowDiagnostics() endfunction @@ -438,9 +438,9 @@ function! s:DisableOnLargeFile( filename ) let threshold = g:ycm_disable_for_files_larger_than_kb * 1024 if threshold > 0 && getfsize( a:filename ) > threshold - exec s:python_command "vimsupport.PostVimMessage(" - \ "'YouCompleteMe is disabled in this buffer;" - \ "the file exceeded the max size (see YCM options).')" + exec s:python_command "vimsupport.PostVimMessage(" . + \ "'YouCompleteMe is disabled in this buffer; " . + \ "the file exceeded the max size (see YCM options).' )" let b:ycm_largefile = 1 endif endfunction @@ -498,7 +498,7 @@ function! s:OnBufferUnload() endif let deleted_buffer_file = expand( ':p' ) - exec s:python_command "ycm_state.OnBufferUnload(" + exec s:python_command "ycm_state.OnBufferUnload(" . \ "vim.eval( 'deleted_buffer_file' ) )" endfunction @@ -757,7 +757,7 @@ function! youcompleteme#OmniComplete( findstart, base ) return -2 endif let s:omnifunc_mode = 1 - exec s:python_command "ycm_state.CreateCompletionRequest(" + exec s:python_command "ycm_state.CreateCompletionRequest(" . \ "force_semantic = True )" return s:Pyeval( 'base.CompletionStartColumn()' ) else @@ -813,15 +813,15 @@ function! s:CompleterCommand(...) let arguments = arguments[1:] endif - exec s:python_command "ycm_state.SendCommandRequest(" - \ "vim.eval( 'l:arguments' ), vim.eval( 'l:completer' ) ) " + exec s:python_command "ycm_state.SendCommandRequest(" . + \ "vim.eval( 'l:arguments' ), vim.eval( 'l:completer' ) )" endfunction function! youcompleteme#OpenGoToList() - exec s:python_command "vimsupport.PostVimMessage(" - \ "'WARNING: youcompleteme#OpenGoToList function is deprecated." - \ "Do NOT use it.')" + exec s:python_command "vimsupport.PostVimMessage(" . + \ "'WARNING: youcompleteme#OpenGoToList function is deprecated. " . + \ "Do NOT use it.' )" exec s:python_command "vimsupport.OpenQuickFixList( True, True )" endfunction @@ -838,8 +838,8 @@ endfunction function! s:ForceCompile() if !s:Pyeval( 'ycm_state.NativeFiletypeCompletionUsable()' ) - echom "Native filetype completion not supported for current file, " - \ . "cannot force recompilation." + echom "Native filetype completion not supported for current file, " . + \ "cannot force recompilation." return 0 endif