Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New vim #4260

Merged
merged 4 commits into from
Sep 12, 2024
Merged

New vim #4260

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
submodules: recursive
fetch-depth: 0
- name: Install dependencies
run: sudo -H pip3 install -r python/test_requirements.txt
run: sudo -H pip3 install --break-system-packages -r python/test_requirements.txt
- name: Install Java
uses: actions/setup-java@v4
with:
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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+
Expand Down Expand Up @@ -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',
Expand All @@ -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`
Expand Down
4 changes: 2 additions & 2 deletions plugin/youcompleteme.vim
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
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+." |

Check warning on line 37 in plugin/youcompleteme.vim

View check run for this annotation

Codecov / codecov/patch

plugin/youcompleteme.vim#L37

Added line #L37 was not covered by tests
\ echohl None
call s:restore_cpo()
finish
Expand Down
5 changes: 2 additions & 3 deletions python/test_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ flake8 >= 3.0.0
flake8-comprehensions >= 1.4.1
flake8-ycm >= 0.1.0
PyHamcrest >= 1.10.1
coverage <5.0
click <8.0.0
covimerage >= 0.2.0
# Use the updated fork
git+https://github.com/bstaletic/covimerage
4 changes: 2 additions & 2 deletions python/ycm/diagnostic_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _ClearCurrentDiagnostic( self, will_be_replaced=False ):
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',
Expand All @@ -149,7 +149,7 @@ def _ClearCurrentDiagnostic( self, will_be_replaced=False ):
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
Expand Down
2 changes: 1 addition & 1 deletion python/ycm/inlay_hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@


def Initialise():
if not vimsupport.VimSupportsVirtualText():
if vimsupport.VimIsNeovim():
return False

props = tp.GetTextPropertyTypes()
Expand Down
38 changes: 24 additions & 14 deletions python/ycm/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
'^(?: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
Expand Down Expand Up @@ -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
Expand All @@ -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 ):
Expand Down Expand Up @@ -577,8 +585,8 @@ def __init__( self,
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
Expand Down Expand Up @@ -613,6 +621,8 @@ def __getitem__( self, key ):
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 ):
Expand Down
2 changes: 1 addition & 1 deletion python/ycm/tests/youcompleteme_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ def test_YouCompleteMe_UpdateMatches_ClearDiagnosticMatchesInNewBuffer(
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 ] ):
Expand Down
13 changes: 2 additions & 11 deletions python/ycm/text_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,5 @@
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()

Check warning on line 108 in python/ycm/text_properties.py

View check run for this annotation

Codecov / codecov/patch

python/ycm/text_properties.py#L107-L108

Added lines #L107 - L108 were not covered by tests
79 changes: 20 additions & 59 deletions python/ycm/vimsupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@

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."""
Expand Down Expand Up @@ -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 }, '
Expand Down Expand Up @@ -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',
Expand All @@ -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 ) }' )" ) )
Expand Down
2 changes: 1 addition & 1 deletion python/ycm/youcompleteme.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ def DebugInfo( self ):
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
Expand Down
18 changes: 6 additions & 12 deletions test/docker/ci/image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
FROM ubuntu:22.04
FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive
ENV LC_ALL C.UTF-8

ARG VIM_VERSION=v9.0.0214
ARG VIM_VERSION=v9.1.0016
ARG YCM_VIM_PYTHON=python3
ARG NODE_MAJOR=18

RUN apt-get update && \
apt-get -y dist-upgrade && \
apt-get -y --no-install-recommends install ca-cacert \
apt-get -y --no-install-recommends install \
gnupg \
locales \
tzdata \
language-pack-en \
curl \
sudo \
libncurses5-dev libncursesw5-dev && \
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
apt-get update && apt-get -y upgrade && apt-get -y --no-install-recommends install \
libncurses5-dev libncursesw5-dev \
git \
build-essential \
cmake \
python3-dev \
python3-pip \
python3-setuptools \
python3-wheel \
openjdk-11-jdk-headless \
nodejs \
npm \
vim-nox \
zlib1g-dev && \
apt-get -y autoremove
Expand All @@ -50,9 +47,6 @@ RUN mkdir -p $HOME/vim && \
make -j 4 && \
make install

# Python
RUN ${YCM_VIM_PYTHON} -m pip install --upgrade pip setuptools wheel

# clean up
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* &&\
rm -rf ~/.cache && \
Expand Down