When using Goneovim, Select mode `CTRL-O` returns back to Select mode
immediately (even with `--clean`). Neovim TUI (with some plugins) also randomly
returns to Select mode even if no keys are pressed when using `CTRL-O` in Select
mode.
The recursive implementation of vim.lsp.diagnostic.get() applied
`diagnostic_vim_to_lsp` twice, and the second time gave wrong
results because of the unexpected format.
Fixes https://github.com/neovim/neovim/issues/15689
These links were actually defined backwards: the highlight groups
actually being used for display are the new "Diagnostic*" groups, so
linking the old "LspDiagnostics*" groups to these does absolutely
nothing, since there is nothing actually being highlighted with the
LspDiagnostics* groups.
These links were made in an attempt to preserve backward compatibility
with existing colorschemes. We could reverse the links to maintain this
preservation, but then that disallows us from actually defining default
values for the new highlight groups.
Instead, just remove the links and be done with the old LspDiagnostics*
highlight groups.
This is not technically a breaking change: the breaking change already
happened in #15585, but this PR just makes that explicit.
Problem: User function completion fails with dict function.
Solution: Do not stop sequencing through the list if user functions when
encountering an empty name. (Naohiro Ono, closesvim/vim#8765,
closesvim/vim#8774)
5aec755b67
Problem: Completing "call g:" returns entries with just "g:". (Naohiro Ono)
Solution: Skip empty strings returned by get_user_func_name(). (closesvim/vim#8753)
069f90852f
Problem: Some code is not tested.
Solution: Add some more tests. (Dominique Pellé, closesvim/vim#8735)
bd9e796125
Include Test_confirm_write_partial_file() anyway, even though it will
not be run.
Problem: Finding completions may cause an endless loop.
Solution: Use a better way to check coming back where the search started.
(Andy Gozas, closesvim/vim#8672, closesvim/vim#8671)
6a230c6b32
Problem: win_enter_ext() has too many boolean arguments.
Solution: use one flags argument with defined values.
d61f2f772a
Include some style changes to appease the linter.
N/A patches for version.c:
vim-patch:8.2.3289: compiler warning for unused variable with small features
Problem: Compiler warning for unused variable with small features.
Solution: Rearrange #ifdefs.
f18e8a969a
vim-patch:8.2.3298: build failure with small features
Problem: Build failure with small features.
Solution: Add #ifdef.
6f6d58c380
vim-patch:8.2.3331: Coverity warns for using value without boundary check
Problem: Coverity warns for using value without boundary check.
Solution: Add a boundary check.
ed7cb2df35
vim-patch:8.2.3354: build failure with +byte_offset but without +textprop
Problem: Build failure with +byte_offset but without +textprop. (John
Marriott)
Solution: Adjust the #ifdef.
92755bba30
vim-patch:8.2.3355: MS-Windows: compiler warning for 64-32 bit conversion
Problem: MS-Windows: compiler warning for 64-32 bit conversion.
Solution: Add type casts.
434df7a401
## Overview
- Move vim.lsp.diagnostic to vim.diagnostic
- Refactor client ids to diagnostic namespaces
- Update tests
- Write/update documentation and function signatures
Currently, non-LSP diagnostics in Neovim must hook into the LSP subsystem. This
is what e.g. null-ls and nvim-lint do. This is necessary because none of the
diagnostic API is exposed separately from the LSP subsystem.
This commit addresses this by generalizing the diagnostic subsystem beyond the
scope of LSP. The `vim.lsp.diagnostic` module is now simply a specific
diagnostic producer and primarily maintains the interface between LSP clients
and the broader diagnostic API.
The current diagnostic API uses "client ids" which only makes sense in the
context of LSP. We replace "client ids" with standard API namespaces generated
from `nvim_create_namespace`.
This PR is *mostly* backward compatible (so long as plugins are only using the
publicly documented API): LSP diagnostics will continue to work as usual, as
will pseudo-LSP clients like null-ls and nvim-lint. However, the latter can now
use the new interface, which looks something like this:
```lua
-- The namespace *must* be given a name. Anonymous namespaces will not work with diagnostics
local ns = vim.api.nvim_create_namespace("foo")
-- Generate diagnostics
local diagnostics = generate_diagnostics()
-- Set diagnostics for the current buffer
vim.diagnostic.set(ns, diagnostics, bufnr)
```
Some public facing API utility methods were removed and internalized directly in `vim.diagnostic`:
* `vim.lsp.util.diagnostics_to_items`
## API Design
`vim.diagnostic` contains most of the same API as `vim.lsp.diagnostic` with
`client_id` simply replaced with `namespace`, with some differences:
* Generally speaking, functions that modify or add diagnostics require a namespace as their first argument, e.g.
```lua
vim.diagnostic.set({namespace}, {bufnr}, {diagnostics}[, {opts}])
```
while functions that read or query diagnostics do not (although in many cases one may be supplied optionally):
```lua
vim.diagnostic.get({bufnr}[, {namespace}])
```
* We use our own severity levels to decouple `vim.diagnostic` from LSP. These
are designed similarly to `vim.log.levels` and currently include:
```lua
vim.diagnostic.severity.ERROR
vim.diagnostic.severity.WARN
vim.diagnostic.severity.INFO
vim.diagnostic.severity.HINT
```
In practice, these match the LSP diagnostic severity levels exactly, but we
should treat this as an interface and not assume that they are the same. The
"translation" between the two severity types is handled transparently in
`vim.lsp.diagnostic`.
* The actual "diagnostic" data structure is: (**EDIT:** Updated 2021-09-09):
```lua
{
lnum = <number>,
col = <number>,
end_lnum = <number>,
end_col = <number>,
severity = <vim.diagnostic.severity>,
message = <string>
}
```
This differs from the LSP definition of a diagnostic, so we transform them in
the handler functions in vim.lsp.diagnostic.
## Configuration
The `vim.lsp.with` paradigm still works for configuring how LSP diagnostics are
displayed, but this is a specific use-case for the `publishDiagnostics` handler.
Configuration with `vim.diagnostic` is instead done with the
`vim.diagnostic.config` function:
```lua
vim.diagnostic.config({
virtual_text = true,
signs = false,
underline = true,
update_in_insert = true,
severity_sort = false,
}[, namespace])
```
(or alternatively passed directly to `set()` or `show()`.)
When the `namespace` argument is `nil`, settings are set globally (i.e. for
*all* diagnostic namespaces). This is what user's will typically use for their
local configuration. Diagnostic producers can also set configuration options for
their specific namespace, although this is generally discouraged in order to
respect the user's global settings. All of the values in the table passed to
`vim.diagnostic.config()` are resolved in the same way that they are in
`on_publish_diagnostics`; that is, the value can be a boolean, a table, or
a function:
```lua
vim.diagnostic.config({
virtual_text = function(namespace, bufnr)
-- Only enable virtual text in buffer 3
return bufnr == 3
end,
})
```
## Misc Notes
* `vim.diagnostic` currently depends on `vim.lsp.util` for floating window
previews. I think this is okay for now, although ideally we'd want to decouple
these completely.
Port VimL's Blob type - vim-patch:8.1.{0735,0736,0738,0741,0742,0755,0756,0757,0765,0793,0797,0798,0802,1022,1023,1671},8.2.{0121,0184,0404,0521,0829,1473,1866,2712}
Problem:
13748512f6#15610 The no-colors codepath of the nvim.lua test output
handler does not handle nil, leading to weird symptoms if e.g. a test
has a syntax error:
test/busted/outputHandlers/nvim.lua:105: attempt to concatenate a nil value
Solution:
Coerce to string in no-colors handler.
Problem:
`buftype=help` occasionally propagates from help to man buffer. As a result the
next time you open help it opens in the man window, replacing the manpage.
Test case:
nvim -u NORC
:Man man
:set bt? " should print `buftype=nofile`
:help
<C-W><C-W><C-W>c " go back to :Man window and close it
:help " focus help window
:Man man " open window with manpage again
:set bt? " prints `buftype=help`
Solution:
- call s:set_options()
- man#read_page() (called by autocmd BufReadCmd man://*) should already do
this. But BufReadCmd doesn't fire for already-existing man:// buffers.
Fix#15650
Also includes some small relevant nearby non-Blob changes and typo
fixes.
Changes are included from:
- v8.1.0815
- v8.1.0846
- v8.1.1084
- v8.1.2326
- v8.2.1969
- d89682477c
- d09091d495
- 53f7fccc94
Note that it is not possible for msgpack_unpack_next() and
msgpack_unpacker_next() to return MSGPACK_UNPACK_EXTRA_BYTES, so it
should be fine to abort() on that.
Lua 5.1 doesn't support string hex escapes (\xXX) like VimL does (though
LuaJIT does), so convert them to decimal escapes (\DDD) in tests.
For example, implicitly converting a table to a string works in LuaJIT,
but needs to be done explicitly with tostring() in Lua 5.1.
This can cause issues when testing a non-JIT build if eq(), for example,
fails with a table argument. E.g: eq({}, {1}) will not print the details
of the assertion failure, but will instead print a less helpful "string
expected, got table" error.
These were issues that I found while porting that I fixed upstream. :^)
Very little of the patch can be exactly ported as we're a bit behind on
dependant patches (we also can't use the exact :for emsg, as we don't
support iterating over Strings yet), so just translate the fixes as best
as we can for now.
Include latest relevant doc changes from:
- v8.1.0815
- v8.2.2658
Fixes remove() copying one extra byte after the end of a Blob's buffer.
Can't be fully ported as the change is from blob_remove(), which hasn't
been ported yet.
Problem: Items in a list given to :const can still be modified.
Solution: Work like ":lockvar! name" but don't lock referenced items.
Make locking a blob work.
021bda5671
Problem: filter() may give misleading error message.
Solution: Also mention Blob as an allowed argument.
fcb0b61d15
Rename Test_map_fails() to Test_map_filter_fails() from v8.2.0610 and
include the modeline.
Problem: Crash when reading a blob fails.
Solution: Avoid keeping a pointer to a freed blob object. (Dominique Pelle,
closesvim/vim#5890) Adjust error messages.
15352dc6ec
Problem: Blob test fails.
Solution: Check for different error when float feature is missing.
92be6e3f46
Nvim always has the float feature, but include the changes to the test
anyway.