Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jan 4, 2024
2 parents c28772a + 71166ea commit 2d84788
Show file tree
Hide file tree
Showing 13 changed files with 341 additions and 109 deletions.
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ Installation

| Runtime | Min Version | Recommended Version (full support) | Python |
|---------|-------------|------------------------------------|--------|
| Vim | 8.1.2269 | 9.0.214 | 3.8 |
| Vim | 8.2.3995 | 9.0.214 | 3.8 |
| Neovim | 0.5 | Vim 9.0.214 | 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 20.04 which contains `vim-nox` at `v8.1.2269`.
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 @@ -417,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 20.04.
The following assume you're using Ubuntu 22.04.

#### Quick start, installing all completers

Expand Down Expand Up @@ -1088,7 +1088,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 20.04
* Linux glibc >= 2.31 (Intel, armv7-a, aarch64) - built on ubuntu 22.04
* MacOS >=10.15 (Intel, arm64)
- For Intel, compatibility per clang.llvm.org downloads
- For arm64, macOS 10.15+
Expand Down Expand Up @@ -1393,6 +1393,21 @@ def CSharpSolutionFile( filepath ):
If the path returned by `CSharpSolutionFile` is not an actual file, YCM will
fall back to the other way of finding the file.

#### Use with .NET 6.0 and .NET SDKs

YCM ships with older version of OmniSharp-Roslyn based on Mono runtime.
It is possible to use it with .NET 6.0 and newer, but it requires manual setup.

1. Download NET 6.0 version of the OmniSharp server for your system from
[releases](https://github.com/OmniSharp/omnisharp-roslyn/releases/)
1. Set `g:ycm_roslyn_binary_path` to the unpacked executable `OmniSharp`
1. Create a solution file if one doesn't already exist, it is currently required
by YCM for internal bookkeeping
1. Run `dotnet new sln` at the root of your project
1. Run `dotnet sln add <project1.csproj> <project2.csproj> ...`
for all of your projects
1. Run `:YcmRestartServer`

### Python Semantic Completion

YCM relies on the [Jedi][] engine to provide completion and code navigation. By
Expand Down
1 change: 1 addition & 0 deletions autoload/youcompleteme.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,7 @@ function! s:RequestSemanticCompletion() abort

if get( b:, 'ycm_completing' )
let s:force_semantic = 1
let s:current_cursor_position = getpos( '.' )
call s:StopPoller( s:pollers.completion )
py3 ycm_state.SendCompletionRequest( True )

Expand Down
179 changes: 101 additions & 78 deletions doc/youcompleteme.txt

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions plugin/youcompleteme.vim
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ function! s:restore_cpo()
unlet s:save_cpo
endfunction

" NOTE: The minimum supported version is 8.1.2269, but neovim always reports as
" NOTE: The minimum supported version is 8.2.3995, but neovim always reports as
" v:version 800, but will largely work.
let s:is_neovim = has( 'nvim' )

if exists( "g:loaded_youcompleteme" )
call s:restore_cpo()
finish
elseif ( v:version < 801 || (v:version == 801 && !has( 'patch2269' )) ) &&
elseif ( v:version < 802 || (v:version == 802 && !has( 'patch3995' )) ) &&
\ !s:is_neovim
echohl WarningMsg |
\ echomsg "YouCompleteMe unavailable: requires Vim 8.1.2269+." |
\ echomsg "YouCompleteMe unavailable: requires Vim 8.2.3995+." |
\ echohl None
call s:restore_cpo()
finish
Expand Down
10 changes: 6 additions & 4 deletions python/ycm/diagnostic_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,13 @@ def _UpdateSigns( self ):
def _ConvertDiagListToDict( self ):
self._line_to_diags = defaultdict( list )
for diag in self._diagnostics:
location = diag[ 'location' ]
bufnr = vimsupport.GetBufferNumberForFilename( location[ 'filepath' ] )
location_extent = diag[ 'location_extent' ]
start = location_extent[ 'start' ]
end = location_extent[ 'end' ]
bufnr = vimsupport.GetBufferNumberForFilename( start[ 'filepath' ] )
if bufnr == self._bufnr:
line_number = location[ 'line_num' ]
self._line_to_diags[ line_number ].append( diag )
for line_number in range( start[ 'line_num' ], end[ 'line_num' ] + 1 ):
self._line_to_diags[ line_number ].append( diag )

for diags in self._line_to_diags.values():
# We also want errors to be listed before warnings so that errors aren't
Expand Down
5 changes: 5 additions & 0 deletions python/ycm/semantic_highlighting.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
'regexp': 'String',
'operator': 'Operator',
'unknown': 'Normal',

# These are not part of the spec, but are used by clangd
'bracket': 'Normal',
# These are not part of the spec, but are used by jdt.ls
'annotation': 'Macro',
}
REPORTED_MISSING_TYPES = set()

Expand Down
29 changes: 26 additions & 3 deletions python/ycm/tests/youcompleteme_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,14 @@ def YouCompleteMe_UpdateDiagnosticInterface( ycm, post_vim_message, *args ):
'line_num': 2,
'column_num': 31
},
# Looks strange but this is really what ycmd is returning.
'location_extent': {
'start': {
'filepath': '',
'filepath': 'buffer',
'line_num': 2,
'column_num': 31,
},
'end': {
'filepath': '',
'filepath': 'buffer',
'line_num': 2,
'column_num': 32,
}
Expand Down Expand Up @@ -624,6 +623,18 @@ def test_YouCompleteMe_ShowDiagnostics_DiagnosticsFound_DoNotOpenLocationList(
'filepath': 'buffer',
'line_num': 19,
'column_num': 2
},
'location_extent': {
'start': {
'filepath': 'buffer',
'line_num': 19,
'column_num': 2
},
'end': {
'filepath': 'buffer',
'line_num': 19,
'column_num': 3
}
}
}

Expand Down Expand Up @@ -673,6 +684,18 @@ def test_YouCompleteMe_ShowDiagnostics_DiagnosticsFound_OpenLocationList(
'filepath': 'buffer',
'line_num': 19,
'column_num': 2
},
'location_extent': {
'start': {
'filepath': 'buffer',
'line_num': 19,
'column_num': 2
},
'end': {
'filepath': 'buffer',
'line_num': 19,
'column_num': 2
}
}
}

Expand Down
17 changes: 16 additions & 1 deletion python/ycm/vimsupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,22 @@ def GetTextPropertyForDiag( buffer_number, line_number, diag ):
range = diag[ 'location_extent' ]
start = range[ 'start' ]
end = range[ 'end' ]
length = end[ 'column_num' ] - start[ 'column_num' ]
start_line = start[ 'line_num' ]
end_line = end[ 'line_num' ]
if start_line == end_line:
length = end[ 'column_num' ] - start[ 'column_num' ]
elif start_line == line_number:
# -1 switches to 0-based indexing.
current_line_len = len( vim.buffers[ buffer_number ][ line_number - 1 ] )
# +2 includes the start columnand accounts for properties at the end of line
# covering \n as well.
length = current_line_len - start[ 'column_num' ] + 2
elif end_line == line_number:
length = end[ 'column_num' ] - 1
else:
# -1 switches to 0-based indexing.
# +1 accounts for properties at the end of line covering \n as well.
length = len( vim.buffers[ buffer_number ][ line_number - 1 ] ) + 1
if diag[ 'kind' ] == 'ERROR':
property_name = 'YcmErrorProperty'
else:
Expand Down
44 changes: 44 additions & 0 deletions test/completion_info.test.vim
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,47 @@ function! Test_DontResolveCompletion_AlreadyResolved()

call test_override( 'ALL', 0 )
endfunction

function! Test_SwitchingToSemanticCompletionAfterSelectingIdentifierCandidate()
call youcompleteme#test#setup#OpenFile( '/test/testdata/cpp/identifier_semantic_switch.cpp', {} )
call setpos( '.', [ 0, 3, 0 ] )
call test_override( 'char_avail', 1 )

function! Check1( id )
call WaitForCompletion()
call CheckCompletionItemsContainsExactly( [ 'ZbCdE' ], 'word' )
let compl = complete_info()
call assert_equal( -1, compl.selected )
call assert_equal( 1, len( compl.items ) )
let ZbCdE = compl.items[ 0 ]
call assert_equal( 'ZbCdE', ZbCdE.word )
call assert_equal( '[ID]', ZbCdE.menu )
call assert_equal( '', ZbCdE.kind )
call FeedAndCheckAgain( "\<Tab>", funcref( 'Check2' ) )
endfunction

function! Check2( id )
call WaitForCompletion()
call assert_match( 'ZbCdE', getline( '.' ) )
call FeedAndCheckAgain( "\<C-Space>", funcref( 'Check3' ) )
endfunction

function! Check3( id )
call WaitForCompletion()
call CheckCompletionItemsContainsExactly( [ 'ZbCdE' ], 'word' )
let compl = complete_info()
call assert_equal( -1, compl.selected )
call assert_match( 'ZbCdE', getline( '.' ) )
call assert_equal( 1, len( compl.items ) )
let ZbCdE = compl.items[ 0 ]
call assert_equal( 'ZbCdE', ZbCdE.word )
call assert_equal( 'void', ZbCdE.menu )
call assert_equal( 'f', ZbCdE.kind )
call feedkeys( "\<Esc>" )
endfunction


call FeedAndCheckMain( 'ZCE', funcref( 'Check1' ) )
call assert_false( pumvisible(), 'pumvisible()' )
call test_override( 'ALL', 0 )
endfunction
Loading

0 comments on commit 2d84788

Please sign in to comment.