Commit Graph

18934 Commits

Author SHA1 Message Date
Gregory Anders
32c0631183 fix(diagnostic): support severity_sort 2021-09-17 10:50:25 -06:00
Gregory Anders
f87779a24d fix(diagnostic): correctly handle folder level diagnostics 2021-09-17 09:28:11 -06:00
Gregory Anders
15fbc9b69e docs(diagnostics): fix typos 2021-09-17 08:57:51 -06:00
Gregory Anders
3fd145007c fix(diagnostic): fix wrong data type in setqflist() 2021-09-17 08:53:08 -06:00
Gregory Anders
71e0e6cc63 fix(diagnostic): don't overwrite existing sign definitions 2021-09-17 08:44:52 -06:00
dundargoc
867e888599
refactor(style): switch-case formatting, "uncrustify:indent-off" #15669
* refactor: disable formatting for attribute in macro
* fixup: disable/enable uncrustify with uncrustify:indent-off/on
* fixup: stop indenting contents inside braces in case
* fixup: remove case brace if no variable declaration
2021-09-17 07:38:16 -07:00
Jan Edmund Lazo
1ec3d37192
Merge pull request #15580 from seandewar/vim-8.2.3378
vim-patch:8.2.{3378,3379,3384,3386,3398,3400}
2021-09-17 09:39:36 -04:00
zeertzjq
5f144efefa
fix: prevent K_EVENT from stopping Select mode CTRL-O #15688
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.
2021-09-17 06:17:51 -07:00
Justin M. Keyes
c4b7744704
Merge #15693 fix(diagnostics)
fix(diagnostics): fixup for `show_line_diagnostics` and `lsp.diagnostics.get`
2021-09-17 04:58:31 -07:00
Christian Clason
22d146760e fix(diagnostic): don't convert diagnostic table twice
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
2021-09-17 13:35:57 +02:00
Christian Clason
3e230da90b fix(diagnostic): show_line_diagnostic with empty lnum
The documentation claims to default to the current line number if
the argument `lnum` is nil, but that was never actually done.

Fixes https://github.com/neovim/neovim/issues/15690
2021-09-17 13:33:54 +02:00
Christian Clason
4881456e83
fix(diagnostic): nvim_echo takes three args (#15687)
Fixup for https://github.com/neovim/neovim/pull/15585
Closes https://github.com/neovim/neovim/issues/15686
2021-09-17 09:21:17 +02:00
Gregory Anders
c13242cf47
fix(diagnostic): remove useless highlight links (#15683)
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.
2021-09-17 08:17:54 +02:00
Gregory Anders
c2a65921d7
fix(diagnostic): don't override existing highlight groups #15682
Use the 'default' keyword to prevent overriding existing highlight groups.

ref #15585
2021-09-16 14:51:29 -07:00
Björn Linse
0c66289cba
Merge pull request #15668 from bfredl/logmenu
fix(tests): don't attempt to call ui functions in free_all_mem()
2021-09-16 23:36:53 +02:00
Justin M. Keyes
2e8103475e
Merge #15585 refactor: move vim.lsp.diagnostic to vim.diagnostic
## 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.
2021-09-16 14:23:42 -07:00
Gregory Anders
4fca63dbf7 fix(lint): remove unused parameters from deprecated functions 2021-09-16 15:01:09 -06:00
Gregory Anders
888a6ec6ce fix(lint): remove unused function from diagnostic spec 2021-09-16 14:40:13 -06:00
Jan Edmund Lazo
7d21b95869
Merge pull request #15211 from seandewar/blob-port
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}
2021-09-16 16:31:41 -04:00
Justin M. Keyes
2d81f19279
Merge #15680 fix(eval): add the vimscript-1 feature to has() 2021-09-16 13:25:26 -07:00
Sean Dewar
89f7f7a991
vim-patch:8.2.1866: Vim9: appending to pushed blob gives wrong result
Problem:    Vim9: appending to pushed blob gives wrong result.
Solution:   Set ga_maxlen when copying a blob.
66fa5fd54f

Vim9script is N/A.
2021-09-16 20:20:43 +01:00
Sean Dewar
26d728fe7c
test(oldtest): re-order test_eval_stuff tests to match Vim 2021-09-16 20:09:56 +01:00
Sean Dewar
18b32fca67
fix(eval): add the vimscript-1 feature to has()
Include Test_string_concat_scriptversion1 to test that
has('vimscript-1') works (excluding the :scriptversion 1 bit).
2021-09-16 19:50:13 +01:00
Justin M. Keyes
9d5d72c388
fix(test runner): handle nil in no-colors output handler #15679
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.
2021-09-16 11:42:00 -07:00
Gregory Anders
d140d3bd33
fix(docs): ignore _*.lua files from auto doc generation #15678 2021-09-16 10:49:11 -07:00
Gregory Anders
0c86bf563c refactor: remove UTF to byte col conversion 2021-09-16 11:26:45 -06:00
zeertzjq
29bc648d2b
fix(man.vim): ensure buftype=nofile after :tag or :stag #15675
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
2021-09-16 06:51:26 -07:00
Gregory Anders
4fa3865588 test: add test case for severity ranges 2021-09-15 19:09:21 -06:00
Sean Dewar
10283915d6
doc(eval): include latest relevant Blob changes
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
2021-09-16 00:14:48 +01:00
Sean Dewar
6eb41e5c8d
test(oldtest): unskip existing tests that use Blobs 2021-09-16 00:14:48 +01:00
Sean Dewar
e53b71627f
feat(f_msgpackparse): support parsing from Blob
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.
2021-09-16 00:14:47 +01:00
Sean Dewar
ddaa0cc9be
fix(test/dumplog): tostring(rv) before formatting as string
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.
2021-09-16 00:14:47 +01:00
Sean Dewar
5fdf741f77
feat(f_msgpackdump): support dumping to Blob 2021-09-16 00:14:47 +01:00
Sean Dewar
7e9ea08321
feat(f_chansend): support Blob data argument 2021-09-16 00:14:47 +01:00
Sean Dewar
e88961943b
fix(eval): partially port v8.2.3284
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
2021-09-16 00:14:46 +01:00
Sean Dewar
3d6bb8b3fb
fix(f_remove): partially port v8.2.2779
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.
2021-09-16 00:14:46 +01:00
Sean Dewar
ecb54238e0
vim-patch:8.2.2712: memory leak when adding to a blob fails
Problem:    Memory leak when adding to a blob fails.
Solution:   Clear the second typval before returning.
f2dd9cb995
2021-09-16 00:14:46 +01:00
Sean Dewar
9e38c4a79f
vim-patch:8.2.1473: items in a list given to :const can still be modified
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
2021-09-16 00:13:41 +01:00
Sean Dewar
ffaf881b42
vim-patch:8.2.0829: filter() may give misleading error message
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.
2021-09-15 22:57:55 +01:00
Sean Dewar
19232593ba
fix(f_insert): partially port v8.2.0634
Fixes a crash in f_insert() when inserting into a NULL blob.
Include blob-related test changes and some other simple changes.
2021-09-15 22:57:54 +01:00
Sean Dewar
9b5c9dbfa7
vim-patch:8.2.0521: crash when reading a blob fails
Problem:    Crash when reading a blob fails.
Solution:   Avoid keeping a pointer to a freed blob object. (Dominique Pelle,
            closes vim/vim#5890)  Adjust error messages.
15352dc6ec
2021-09-15 22:57:54 +01:00
Sean Dewar
ba34afb378
vim-patch:8.2.0404: writefile() error does not give a hint
Problem:    Writefile() error does not give a hint.
Solution:   Add remark about first argument.
18a2b87ca2
2021-09-15 22:57:54 +01:00
Sean Dewar
53f28f024c
vim-patch:8.2.0184: blob test fails
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.
2021-09-15 22:57:53 +01:00
Sean Dewar
ef76238548
vim-patch:8.2.0121: filter() and map() on blob don't work
Problem:    filter() and map() on blob don't work.
Solution:   Correct the code. (closes vim/vim#5483)
49c57ce500
2021-09-15 22:57:53 +01:00
Sean Dewar
726b255288
vim-patch:8.1.1671: copying a blob may result in it being locked
Problem:    Copying a blob may result in it being locked.
Solution:   Reset v_lock. (Ken Takata, closes vim/vim#4648)
b7b9efbccf
2021-09-15 22:57:53 +01:00
Sean Dewar
e7772c051f
vim-patch:8.1.1023: may use NULL pointer when indexing a blob
Problem:    May use NULL pointer when indexing a blob. (Coverity)
Solution:   Break out of loop after using index on blob
61be376337
2021-09-15 22:57:52 +01:00
Sean Dewar
bd9c787b4f
vim-patch:8.1.0802: negative index doesn't work for Blob
Problem:    Negative index doesn't work for Blob.
Solution:   Make it work, add a test. (closes vim/vim#3856)
a5be9b6248

Leave tv_blob_get()'s return type untouched.
2021-09-15 22:57:47 +01:00
Sean Dewar
23f5999d28
vim-patch:8.1.0798: changing a blob while iterating over it works strangely
Problem:    Changing a blob while iterating over it works strangely.
Solution:   Make a copy of the Blob before iterating.
dd29ea1805
2021-09-15 22:30:31 +01:00
Sean Dewar
e140eec441
vim-patch:8.1.0797: error E898 is used twice
Problem:    Error E898 is used twice.
Solution:   Rename the Blob error to E899. (closes vim/vim#3853)
bf821bccf1
2021-09-15 22:30:31 +01:00
Sean Dewar
c57132ec2a
vim-patch:8.1.0793: incorrect error messages for functions that take a Blob
Problem:    Incorrect error messages for functions that now take a Blob
            argument.
Solution:   Adjust the error messages. (Dominique Pelle, closes vim/vim#3846)
0d17f0d1c0
2021-09-15 22:30:31 +01:00