Browse Source

Better detection of shortmess 'c' availability

Also noting that the annoying messages during completion go away with Vim
7.3.314.

Related to #642.
Strahinja Val Markovic 10 years ago
parent
commit
666cf3859a
3 changed files with 17 additions and 16 deletions
  1. 1 7
      README.md
  2. 4 9
      autoload/youcompleteme.vim
  3. 12 0
      python/ycm/vimsupport.py

+ 1 - 7
README.md

@@ -1654,13 +1654,7 @@ landed in Vim 7.3.584 (and a few commits before that).
 ### I get annoying messages in Vim's status area when I type
 
 If you're referring to the `User defined completion <bla bla> back at original`
-and similar, then sadly there's no fix for those. Vim will emit them no matter
-how hard I try to silence them.
-
-You'll have to learn to ignore them. It's a shitty "solution", I know.
-
-There's an [outstanding patch for Vim that fixes this issue][status-mes], but at
-the time of writing Vim upstream hasn't yet merged it in.
+and similar, then just update to Vim 7.4.314 and they'll go away.
 
 ### Nasty bugs happen if I have the `vim-autoclose` plugin installed
 

+ 4 - 9
autoload/youcompleteme.vim

@@ -109,6 +109,7 @@ function! s:SetUpPython()
   py base.LoadJsonDefaultsIntoVim()
   py from ycmd import user_options_store
   py user_options_store.SetAll( base.BuildServerConf() )
+  py from ycm import vimsupport
 
   if !pyeval( 'base.CompatibleWithYcmCore()')
     echohl WarningMsg |
@@ -283,16 +284,10 @@ function! s:SetUpCpoptions()
   set cpoptions+=B
 
   " This prevents the display of "Pattern not found" & similar messages during
-  " completion.
-  " Patch: https://groups.google.com/forum/#!topic/vim_dev/WeBBjkXE8H8
-  " At the time of writing, the patch hasn't been merged into Vim upstream, but
-  " will at some point.
-  " TODO: Check the Vim version (when patch lands) instead of doing try-catch
-  " here.
-  try
+  " completion. This is only available since Vim 7.4.314
+  if pyeval( 'vimsupport.VimVersionAtLeast("7.4.314")' )
     set shortmess+=c
-  catch
-  endtry
+  endif
 endfunction
 
 

+ 12 - 0
python/ycm/vimsupport.py

@@ -55,6 +55,18 @@ def TextAfterCursor():
   return vim.current.line[ CurrentColumn(): ]
 
 
+# Expects version_string in 'MAJOR.MINOR.PATCH' format, e.g. '7.4.301'
+def VimVersionAtLeast( version_string ):
+  major, minor, patch = [ int( x ) for x in version_string.split( '.' ) ]
+
+  # For Vim 7.4.301, v:version is '704'
+  actual_major_and_minor = GetIntValue( 'v:version' )
+  if actual_major_and_minor != major * 100 + minor:
+    return False
+
+  return GetBoolValue( 'has("patch{0}")'.format( patch ) )
+
+
 # Note the difference between buffer OPTIONS and VARIABLES; the two are not
 # the same.
 def GetBufferOption( buffer_object, option ):