In vim.lsp.buf.references, the key vim.type_idx (which evaluates to a
boolean) was set to equal vim.types.dictionary. This resulted in a
boolean key in json which is not allowed by the json spec, and which
lua-cjson fails to serialize.
Rather than relying on the order in which signs are placed to dictate
the order in which they are displayed, explicitly set the priority of
the sign according to the severity of the diagnostic and the value of
severity_sort. If severity_sort is false or unset then all signs use the
same priority.
Initially, we planned to set the NVIM environment variable to detect that
neovim is running in the neovim built-in terminal. At the time this code
was written, there was no way for a parent to set environment variables
for a program running in an embedded terminal. Later it was implemented in
#12937, but the code to set the NVIM was not added. #11390 now uses ConPTY
instead of winpty when possible, so it is no longer necessary to force the
use of win32con even when running inside an embedded terminal. Therefore,
we now do not need this code.
site packages must be sourced before user config
NOTE: we only consider dirs exactly matching "after" to be an AFTER dir.
vim8 considers all dirs like "foo/bar_after", "Xafter" etc, as an
"after" dir in SOME codepaths not not in ALL codepaths.
* add vim.json.encode and vim.json.decode
* use vim.NIL instead of cjson.null
* resolve strict-prototypes warnings
* The following benchmark shows an approximately 2.5x (750 ms vs 300 ms) improvement in deserialization performance over
vim.fn.json_decode on a medium package.json
```lua
local uv = vim.loop
local function readfile(path)
return
end
local json_url = "https://raw.githubusercontent.com/rust-analyzer/rust-analyzer/b24c8d5c89ee93d1172b4127564f5da3b0c88dad/editors/code/package.json"
io.popen(string.format('curl -v -f -L -O %q &> /dev/null', json_url))
local json_string = io.open('package.json'):read '*a'
uv.update_time()
local start = uv.hrtime()
for i = 1,1000 do
vim.fn.json_decode(json_string)
end
uv.update_time()
print(string.format("Deserialization time vim.fn.json_decode: %s ms", (uv.hrtime() - start) * (1e-6)))
uv.update_time()
local start = uv.hrtime()
for i = 1,1000 do
vim.json.decode(json_string)
end
uv.update_time()
print(string.format("Deserialization time vim.json.decode: %s ms", (uv.hrtime() - start) * (1e-6)))
```
Co-Authored-By: Björn Linse <bjorn.linse@gmail.com>
Problem:
This crashes Nvim:
tabedit
call nvim_win_set_option(1000, 'statusline', 'status')
split
wincmd J
wincmd j
Solution:
- Change `no_display` parameter value to be the same as in matching
`restore_win_noblock` call. In case of different values `topframe`
isn't restored to `curtab->tp_topframe`.
- Call `restore_win_noblock` if `switch_win_noblock` returns `FAIL`
(`switch_win` must always have matching `restore_win`)
- Change `switch_win`/`restore_win` to `_noblock` versions to allow
autocommands.
fixes#14097fixes#13577
Fix was already applied in 5f144efefa#15688,
but this commit adds another dimension to the test.
Test correctly fails after reverting 5f144efefa.
ref #15288
PVS is worried about typos. Now we need it to stop worrying...
Disable these checks entirely, they are all false positives.
tui.c:1873 V1074 Boundary between escape sequence and string is unclear. The escape sequence ends with a letter and the next character is also a letter. Check for typos.
tui.c:1983 V1074 Boundary between escape sequence and string is unclear. The escape sequence ends with a letter and the next character is also a letter. Check for typos.
regexp_nfa.c:6189 V1051 Consider checking for misprints. It's possible that the 'pim->result' should be checked here.
screen.c:2928 V1051 Consider checking for misprints. It's possible that the 'vcol_sbr' should be checked here.
screen.c:3187 V1051 Consider checking for misprints. It's possible that the 'line_attr' should be checked here.
screen.c:3267 V1051 Consider checking for misprints. It's possible that the 'multi_attr' should be checked here.
screen.c:4747 V1051 Consider checking for misprints. It's possible that the 'redraw_next' should be checked here.
syntax.c:3448 V1051 Consider checking for misprints. It's possible that the 'arg_end' should be checked here.
syntax.c:3625 V1051 Consider checking for misprints. It's possible that the 'arg_end' should be checked here.
tui.c:1836 V1051 Consider checking for misprints. It's possible that the 'data->unibi_ext.set_cursor_style' should be checked here.
tui.c:1863 V1051 Consider checking for misprints. It's possible that the 'data->unibi_ext.set_cursor_style' should be checked here.
tui.c:1882 V1051 Consider checking for misprints. It's possible that the 'data->unibi_ext.set_cursor_style' should be checked here.
https://pvs-studio.com/en/docs/warnings/v507/
"Pointer to local array 'sourcing_name_buf' is stored outside the scope
of this array. Such a pointer will become invalid."
False positive: `sourcing_name = save_sourcing_name` before returning
from this scope.
Problem:
Error executing vim.schedule lua callback: ...ovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/buf.lua:502: command: expected string, got
nil
stack traceback:
...ovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/buf.lua:502: in function 'execute_command'
...HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/handlers.lua:151: in function <...HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/handlers.lua:113>
...ovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/buf.lua:465: in function 'callback'
...r/neovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp.lua:1325: in function 'handler'
...r/neovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp.lua:899: in function 'cb'
vim.lua:281: in function <vim.lua:281>
Solution:
This is a follow-up to the work done in
6c03601e3a.
There are valid situations where a `textDocument/codeAction` is returned
without a command, since a command in optional. For example from Metals,
the Scala language server when you get a code action to add a missing
import, it looks like this:
```json
Result: [
{
"title": "Import \u0027Instant\u0027 from package \u0027java.time\u0027",
"kind": "quickfix",
"diagnostics": [
{
"range": {
"start": {
"line": 6,
"character": 10
},
"end": {
"line": 6,
"character": 17
}
},
"severity": 1,
"source": "bloop",
"message": "not found: value Instant"
}
],
"edit": {
"changes": {
"file:///Users/ckipp/Documents/scala-workspace/sanity/src/main/scala/Thing.scala": [
{
"range": {
"start": {
"line": 6,
"character": 10
},
"end": {
"line": 6,
"character": 17
}
},
"newText": "Instant"
},
{
"range": {
"start": {
"line": 1,
"character": 0
},
"end": {
"line": 1,
"character": 0
}
},
"newText": "\nimport java.time.Instant\n"
}
]
}
}
}
]
```
This change just wraps the logic that grabs the command in a conditional
to skip it if there is no command.
diagnostic_lines() returns a table, so make the early exit condition an
empty table rather than 'nil'. This way, functions that use the input
from diagnostic_lines don't have to do a bunch of defensive nil checking
and can always assume they're operating on a table.
Problem: setreg() does not always clear the register.
Solution: Clear the register if the dict argument is empty. (Andy Massimino,
closesvim/vim#3370)
7633fe595e
Do not getdigits for block_len strictly. For example, a user could
previously abort Nvim using:
:call setreg("0", "abort!", "\<C-V>999999999999999999")
or, after v8.2.0924's port:
:call setreg("0", #{regcontents: ["abort!"],
\ regtype: "\<C-V>999999999999999999"})
Instead, default to 0 so block_len is -1, which acts like the selection
width was omitted (defaults to length of longest line).
Problem: ":call setreg('"', [])" reports an internal error.
Solution: Make the register empty. (Yasuhiro Matsumoto)
659c94d483
Required for v8.2.1035.
Note that setreg('"', []) didn't cause an internal error for us, but
didn't clear the register properly either...
Problem: Cannot save and restore a register properly.
Solution: Add getreginfo() and make setreg() accept a dictionary. (Andy
Massimino, closesvim/vim#3370)
bb861e293e
Cherry-pick eval.txt changes for getreginfo() from:
6aa57295cf207f009326
Problem: Test_eval is old style.
Solution: Change some tests to a new style test.
90455cfa87
Cherry-pick Test_setreg_basic changes from v8.2.0610.
Note that the old-style version of the tests (and the cherry-picked
changes) exist in legacy/eval_spec.lua; keep them as they've already
been Lua'd.
Required for v8.2.0924.