Browse Source

Bump vim requirement to version 9.1.0016

Since Ubuntu 24.04 is out, we can clean up a bit.
Some of the `VimSupportsFoo()` functions will always return `True` in
vim, but we also need to take into account othervim.
Boris Staletic 6 months ago
parent
commit
dd365b28d8

+ 10 - 10
README.md

@@ -211,13 +211,12 @@ Installation
 
 | Runtime | Min Version | Recommended Version (full support) | Python |
 |---------|-------------|------------------------------------|--------|
-| Vim     | 8.2.3995    | 9.0.214                            | 3.8    |
-| Neovim  | 0.5         | Vim 9.0.214                        | 3.8    |
+| Vim     | 9.1.0016    | 9.1.0016                           | 3.8    |
+| Neovim  | 0.5         | Vim 9.1.0016                       | 3.8    |
 
 #### Supported Vim Versions
 
 Our policy is to support the Vim version that's in the latest LTS of Ubuntu.
-That's currently Ubuntu 22.04 which contains `vim-nox` at `v8.2.3995`.
 
 Vim must have a [working Python 3 runtime](#supported-python-runtime).
 
@@ -418,7 +417,7 @@ that are conservatively turned off by default that you may want to turn on.
 
 ### Linux 64-bit
 
-The following assume you're using Ubuntu 22.04.
+The following assume you're using Ubuntu 24.04.
 
 #### Quick start, installing all completers
 
@@ -1091,7 +1090,7 @@ On supported architectures, the `install.py` script will download a suitable
 clangd (`--clangd-completer`) or libclang (`--clang-completer`) for you.
 Supported architectures are:
 
-* Linux glibc >= 2.31 (Intel, armv7-a, aarch64) - built on ubuntu 22.04
+* Linux glibc >= 2.39 (Intel, armv7-a, aarch64) - built on ubuntu 24.04
 * MacOS >=10.15 (Intel, arm64)
   - For Intel, compatibility per clang.llvm.org downloads
   - For arm64, macOS 10.15+
@@ -1617,10 +1616,10 @@ let g:ycm_language_server =
   \     'filetypes': [ 'yaml' ]
   \   },
   \   {
-  \     'name': 'rust',
-  \     'cmdline': [ 'ra_lsp_server' ],
-  \     'filetypes': [ 'rust' ],
-  \     'project_root_files': [ 'Cargo.toml' ]
+  \     'name': 'csharp',
+  \     'cmdline': [ 'OmniSharp', '-lsp' ],
+  \     'filetypes': [ 'csharp' ],
+  \     'project_root_files': [ '*.csproj', '*.sln' ]
   \   },
   \   {
   \     'name': 'godot',
@@ -1639,7 +1638,8 @@ Each dictionary contains the following keys:
 * `filetypes` (list of string, mandatory): List of Vim filetypes this server
   should be used for.
 * `project_root_files` (list of string, optional): List of filenames to search
-  for when trying to determine the project's root.
+  for when trying to determine the project's root. Uses python's pathlib for
+  glob matching.
 * `cmdline` (list of strings, optional): If supplied, the server is started with
   this command line (each list element is a command line word). Typically, the
   server should be started with STDIO communication. If not supplied, `port`

+ 2 - 2
plugin/youcompleteme.vim

@@ -31,10 +31,10 @@ let s:is_neovim = has( 'nvim' )
 if exists( "g:loaded_youcompleteme" )
   call s:restore_cpo()
   finish
-elseif ( v:version < 802 || (v:version == 802 && !has( 'patch3995' )) ) &&
+elseif ( v:version < 901 || (v:version == 901 && !has( 'patch0016' )) ) &&
       \ !s:is_neovim
   echohl WarningMsg |
-        \ echomsg "YouCompleteMe unavailable: requires Vim 8.2.3995+." |
+        \ echomsg "YouCompleteMe unavailable: requires Vim 9.1.0016+." |
         \ echohl None
   call s:restore_cpo()
   finish

+ 2 - 2
python/ycm/diagnostic_interface.py

@@ -133,7 +133,7 @@ class DiagnosticInterface:
     if not self._diag_message_needs_clearing:
       return
 
-    if ( vimsupport.VimSupportsVirtualText() and
+    if ( not vimsupport.VimIsNeovim() and
          self._user_options[ 'echo_current_diagnostic' ] == 'virtual-text' ):
       tp.ClearTextProperties( self._bufnr,
                               prop_types = [ 'YcmVirtDiagPadding',
@@ -149,7 +149,7 @@ class DiagnosticInterface:
   def _EchoDiagnosticText( self, line_num, first_diag, text ):
     self._ClearCurrentDiagnostic( bool( text ) )
 
-    if ( vimsupport.VimSupportsVirtualText() and
+    if ( not vimsupport.VimIsNeovim() and
          self._user_options[ 'echo_current_diagnostic' ] == 'virtual-text' ):
       if not text:
         return

+ 1 - 1
python/ycm/inlay_hints.py

@@ -32,7 +32,7 @@ REPORTED_MISSING_TYPES = set()
 
 
 def Initialise():
-  if not vimsupport.VimSupportsVirtualText():
+  if vimsupport.VimIsNeovim():
     return False
 
   props = tp.GetTextPropertyTypes()

+ 24 - 14
python/ycm/tests/test_utils.py

@@ -41,6 +41,13 @@ BWIPEOUT_REGEX = re.compile(
   '^(?:silent! )bwipeout!? (?P<buffer_number>[0-9]+)$' )
 GETBUFVAR_REGEX = re.compile(
   '^getbufvar\\((?P<buffer_number>[0-9]+), "(?P<option>.+)"\\)( \\?\\? 0)?$' )
+PROP_LIST_REGEX = re.compile(
+        '^prop_list\\( '                       # A literal at the start
+        '(?P<lnum>\\d+), '                     # Start line
+        '{ "bufnr": (?P<bufnr>\\d+), '         # Corresponding buffer number
+        '"end_lnum": (?P<end_lnum>[0-9-]+), '  # End line, can be negative.
+        '"types": (?P<prop_types>\\[.+\\]) } ' # Property types
+        '\\)$' )
 PROP_ADD_REGEX = re.compile(
         '^prop_add\\( '            # A literal at the start
         '(?P<start_line>\\d+), '   # First argument - number
@@ -249,14 +256,16 @@ def _MockVimFunctionsEval( value ):
 
 
 def _MockVimPropEval( value ):
-  match = re.match( 'prop_list\\( (?P<lnum>\\d+), '
-                    '{ "bufnr": (?P<bufnr>\\d+) } \\)', value )
-  if match:
-    return [ p for p in VIM_PROPS_FOR_BUFFER[ int( match.group( 'bufnr' ) ) ]
-             if p.start_line == int( match.group( 'lnum' ) ) ]
-
-  match = PROP_ADD_REGEX.search( value )
-  if match:
+  if match := PROP_LIST_REGEX.search( value ):
+    if int( match.group( 'end_lnum' ) ) == -1:
+      return [ p for p in VIM_PROPS_FOR_BUFFER[ int( match.group( 'bufnr' ) ) ]
+               if p.start_line >= int( match.group( 'lnum' ) ) ]
+    else:
+      return [ p for p in VIM_PROPS_FOR_BUFFER[ int( match.group( 'bufnr' ) ) ]
+               if int( match.group( 'end_lnum' ) ) >= p.start_line and
+                  p.start_line >= int( match.group( 'lnum' ) ) ]
+
+  if match := PROP_ADD_REGEX.search( value ):
     prop_start_line = int( match.group( 'start_line' ) )
     prop_start_column = int( match.group( 'start_column' ) )
     import ast
@@ -265,14 +274,13 @@ def _MockVimPropEval( value ):
         opts[ 'type' ],
         prop_start_line,
         prop_start_column,
-        int( opts[ 'end_lnum' ] ) if opts[ 'end_lnum' ] else prop_start_line,
-        int( opts[ 'end_col' ] ) if opts[ 'end_col' ] else prop_start_column
+        int( opts[ 'end_lnum' ] ),
+        int( opts[ 'end_col' ] )
     )
     VIM_PROPS_FOR_BUFFER[ int( opts[ 'bufnr' ] ) ].append( vim_prop )
     return vim_prop.id
 
-  match = PROP_REMOVE_REGEX.search( value )
-  if match:
+  if match := PROP_REMOVE_REGEX.search( value ):
     prop, lin_num = eval( match.group( 'prop' ) )
     vim_props = VIM_PROPS_FOR_BUFFER[ prop[ 'bufnr' ] ]
     for index, vim_prop in enumerate( vim_props ):
@@ -577,8 +585,8 @@ class VimProp:
                 prop_type,
                 start_line,
                 start_column,
-                end_line = None,
-                end_column = None ):
+                end_line,
+                end_column ):
     current_buffer = VIM_MOCK.current.buffer.number
     self.id = len( VIM_PROPS_FOR_BUFFER[ current_buffer ] ) + 1
     self.prop_type = prop_type
@@ -613,6 +621,8 @@ class VimProp:
       return self.start_column
     elif key == 'length':
       return self.end_column - self.start_column
+    elif key == 'lnum':
+      return self.start_line
 
 
   def get( self, key, default = None ):

+ 1 - 1
python/ycm/tests/youcompleteme_test.py

@@ -762,7 +762,7 @@ class YouCompleteMeTest( TestCase ):
     test_utils.VIM_PROPS_FOR_BUFFER[ current_buffer.number ] = [
       VimProp( 'YcmWarningProperty', 3, 5, 3, 7 ),
       VimProp( 'YcmWarningProperty', 3, 3, 3, 9 ),
-      VimProp( 'YcmErrorProperty', 3, 8 )
+      VimProp( 'YcmErrorProperty', 3, 8, 3, 9 )
     ]
 
     with MockVimBuffers( [ current_buffer ], [ current_buffer ] ):

+ 2 - 11
python/ycm/text_properties.py

@@ -104,14 +104,5 @@ def ClearTextProperties(
   if not isinstance( prop_types, list ):
     prop_types = [ prop_types ]
 
-  # 9.0.233 added types list to prop_remove, so use that
-  if vimsupport.VimVersionAtLeast( '9.0.233' ):
-    props[ 'types' ] = prop_types
-    return prop_remove()
-
-  # Older versions we have to run prop_remove for each type
-  removed = 0
-  for prop_type in prop_types:
-    props[ 'type' ] = prop_type
-    removed += prop_remove()
-  return removed
+  props[ 'types' ] = prop_types
+  return prop_remove()

+ 20 - 59
python/ycm/vimsupport.py

@@ -60,10 +60,6 @@ NO_COMPLETIONS = {
 
 YCM_NEOVIM_NS_ID = vim.eval( 'g:ycm_neovim_ns_id' )
 
-# Virtual text is not a feature in itself and early patches don't work well, so
-# we need to keep changing this at the moment
-VIM_VIRTUAL_TEXT_VERSION_REQ = '9.0.214'
-
 
 def CurrentLineAndColumn():
   """Returns the 0-based current line and 0-based current column."""
@@ -308,55 +304,30 @@ def GetTextPropertyForDiag( buffer_number, line_number, diag ):
     property_name = 'YcmErrorProperty'
   else:
     property_name = 'YcmWarningProperty'
-  if HasFastPropList():
-    vim_props = vim.eval( f'prop_list( { line_number }, '
-                          f'{{ "bufnr": { buffer_number }, '
-                             f'"types": [ "{ property_name }" ] }} )' )
-    return next( filter(
-        lambda p: column == int( p[ 'col' ] ) and
-                  length == int( p[ 'length' ] ),
-        vim_props ) )
-  else:
-    vim_props = vim.eval( f'prop_list( { line_number }, '
-                                     f'{{ "bufnr": { buffer_number } }} )' )
-    return next( filter(
-        lambda p: start[ 'column_num' ] == int( p[ 'col' ] ) and
-                  length == int( p[ 'length' ] ) and
-                  property_name == p[ 'type' ],
-        vim_props ) )
+  vim_props = vim.eval( f'prop_list( { line_number }, '
+                        f'{{ "bufnr": { buffer_number }, '
+                           f'"types": [ "{ property_name }" ] }} )' )
+  return next( filter(
+      lambda p: column == int( p[ 'col' ] ) and
+                length == int( p[ 'length' ] ),
+      vim_props ) )
 
 
 def GetTextProperties( buffer_number ):
   if not VimIsNeovim():
-    if HasFastPropList():
-      return [
-        DiagnosticProperty(
-            int( p[ 'id' ] ),
-            p[ 'type' ],
-            int( p[ 'lnum' ] ),
-            int( p[ 'col' ] ),
-            int( p[ 'length' ] ) )
-        for p in vim.eval(
-            f'prop_list( 1, '
-                         f'{{ "bufnr": { buffer_number }, '
-                             '"end_lnum": -1, '
-                             '"types": [ "YcmErrorProperty", '
-                                        '"YcmWarningProperty" ] } )' ) ]
-    else:
-      properties = []
-      for line_number in range( len( vim.buffers[ buffer_number ] ) ):
-        vim_props =  vim.eval( f'prop_list( { line_number + 1 }, '
-                               f'{{ "bufnr": { buffer_number } }} )' )
-        properties.extend(
-          DiagnosticProperty(
-            int( p[ 'id' ] ),
-            p[ 'type' ],
-            line_number + 1,
-            int( p[ 'col' ] ),
-            int( p[ 'length' ] ) )
-          for p in vim_props if p.get( 'type', '' ).startswith( 'Ycm' )
-        )
-      return properties
+    return [
+      DiagnosticProperty(
+          int( p[ 'id' ] ),
+          p[ 'type' ],
+          int( p[ 'lnum' ] ),
+          int( p[ 'col' ] ),
+          int( p[ 'length' ] ) )
+      for p in vim.eval(
+          f'prop_list( 1, '
+                       f'{{ "bufnr": { buffer_number }, '
+                           '"end_lnum": -1, '
+                           '"types": [ "YcmErrorProperty", '
+                                      '"YcmWarningProperty" ] } )' ) ]
   else:
     ext_marks = vim.eval(
       f'nvim_buf_get_extmarks( { buffer_number }, '
@@ -1464,11 +1435,6 @@ def VimIsNeovim():
   return GetBoolValue( 'has( "nvim" )' )
 
 
-@memoize()
-def HasFastPropList():
-  return GetBoolValue( 'has( "patch-8.2.3652" )' )
-
-
 @memoize()
 def VimSupportsPopupWindows():
   return VimHasFunctions( 'popup_create',
@@ -1480,11 +1446,6 @@ def VimSupportsPopupWindows():
                           'popup_close' )
 
 
-@memoize()
-def VimSupportsVirtualText():
-  return not VimIsNeovim() and VimVersionAtLeast( VIM_VIRTUAL_TEXT_VERSION_REQ )
-
-
 @memoize()
 def VimHasFunction( func ):
   return bool( GetIntValue( f"exists( '*{ EscapeForVim( func ) }' )" ) )

+ 1 - 1
python/ycm/youcompleteme.py

@@ -807,7 +807,7 @@ class YouCompleteMe:
     debug_info += ( '\nSemantic highlighting supported: ' +
                     str( not vimsupport.VimIsNeovim() ) )
     debug_info += ( '\nVirtual text supported: ' +
-                    str( vimsupport.VimSupportsVirtualText() ) )
+                    str( not vimsupport.VimIsNeovim() ) )
     debug_info += ( '\nPopup windows supported: ' +
                     str( vimsupport.VimSupportsPopupWindows() ) )
     return debug_info