PR #23689 assumes `client.config.capabilities.workspace.didChangeWatchedFiles`
exists when checking `dynamicRegistration`, but thats's true only if it was
passed to `vim.lsp.start{_client}`.
This caused #23806 (still an issue in v0.9.1; needs manual backport), but #23681
fixed it by defaulting `config.capabilities` to `make_client_capabilities` if
not passed to `vim.lsp.start{_client}`.
However, the bug resurfaces on HEAD if you provide a non-nil `capabilities` to
`vim.lsp.start{_client}` with missing fields (e.g: not made via
`make_client_capabilities`).
From what I see, the spec says such missing fields should be interpreted as an
absence of the capability (including those indicated by missing sub-fields):
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#clientCapabilities
Also, suggest `vim.empty_dict()` for an empty dict in
`:h vim.lsp.start_client()` (`{[vim.type_idx]=vim.types.dictionary}`
no longer works anyway, probably since the cjson switch).
Problem:
- Notifications are missing from `lsp.Methods`.
- Need a way to represent `$/` prefixed methods.
Solution:
- Generate notifications.
- Use "dollar_" prefix for `$/` methods.
Now that we "own" builtin.txt, we cant remove the repetitive mention of
Vimscript's UFCS syntax. It's noisy to mention this for each function,
and it's also not a Vimscript feature that should be encouraged.
Also change the builtin.txt heading to "NVIM REFERENCE MANUAL", which
indicates when a help file is Nvim-owned.
Problem: cache paths are derived by replacing each reserved/filesystem-
path-sensitive char with a `%` char in the original path. With this
method, two different files at two different paths (each containing `%`
chars) can erroneously resolve to the very same cache path in certain
edge-cases.
Solution: derive cache paths by url-encoding the original (path) instead
using `vim.uri_encode()` with `"rfc2396"`. Increment `Loader.VERSION` to
denote this change.
Problem:
"Failed to delete autocmd" error when deleting LspNotify autocmd. #24456
Solution:
Change a few things in the inlay_hint and diagnostic LSP code:
1. Re-introduce the `enabled` flag for the buffer state tables. Previously I was
relying on the presence of an autocmd id in the state table to track whether
inlay_hint / diagnostic was enabled for a buffer. There are two reasons why
this doesn't work well:
- Each time inlay_hint / diagnostic is enabled, we call `nvim_buf_attach` on
the buffer, resulting in multiple `on_reload` or `on_detach` callbacks being
registered.
- Commands like `bwipeout` delete buffer local autocmds, sometimes before our
`on_detach` callbacks have a chance to delete them first. This causes the
- Use module local enabled state for diagnostic as well. bwipeout can race
with on_detach callbacks for deleting autocmds. Error referenced in #24456.
2. Change the `LspDetach` autocmd to run each time (i.e., remove the `once`
flag). Since we're only registering autocmds once per buffer now, we
need to make sure that we set the enabled flag properly each time the LSP
client detaches from the buffer.
- Remove `once` from the LspDetach autocmds for inlay_hint and diagnostic.
We only set up the autocmd once now. Gets removed when buffer is deleted.
3. Have the `LspNotify` handler also refresh the inlay_hint / diagnostics when
receiving the `textDocument/didOpen` event. Before this point, the LSP
backend doesn't have the contents of the buffer, so can't provide inlay hints
or diagnostics.
Downsides of this approach:
* When inlay_hint / diagnostics are disabled on a buffer, it will continue to
receive `LspNotify` events for that buffer. The callback exits early since the
`enabled` flag is false.
Alternatives:
* Can we wrap the call to `nvim_del_autocmd` in `pcall` to swallow any errors
resulting from trying to delete the autocmd?
Fixes#24456
Helped-by: Maria José Solano <majosolano99@gmail.com>
Problem: Using nvim_feedkeys in default mappings makes it hard to use
them as a part of another mapping.
Solution: Use an expression mapping and stop Visual mode later.
Fix#24518.
- eval.lua is now the source of truth.
- Formatting is much more consistent.
- Fixed Lua type generation for polymorphic functions (get(), etc).
- Removed "Overview" section from builtin.txt
- Can generate this if we really want it.
- Moved functions from sign.txt and testing.txt into builtin.txt.
- Removed the *timer* *timers* tags since libuv timers via vim.uv should be preferred.
- Removed the temp-file-name tag from tempname()
- Moved lueval() from lua.txt to builtin.txt.
* Fix indent
* fixup!
* fixup! fixup!
* fixup! better tag formatting
* fixup: revert changes no longer needed
* fixup! CI
---------
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
This aligns its behaviour better with `nvim_win_close`.
Note that `:hide` is actually incapable of closing the cmdwin, unlike `:close`
and `:quit`, so this is a bit of a difference in behaviour.
Problem: As discussed on Matrix, there was some interest in having
`nvim_open_win` again be able to open floats in the cmdwin (e.g: displaying a
hover doc related to what's in the cmdwin). After #23228, this was disallowed.
Solution: Allow `nvim_open_win` in the cmdwin as long as `!enter` and
`buffer != curbuf` (the former can cause all sorts of issues, and the latter
can crash Nvim after closing cmdwin). Also allow `nvim_win_set_buf` in a similar
fashion.
Note that we're not *entirely* sure if this is 100% safe (cmdwin is a
global-state-using-main-loop-calling beast), but this seems to work OK..?
Also:
- Check the buffer argument of `nvim_open_win` earlier, and abort if it's
invalid (it used to still open a window in this case).
- Untranslate `e_cmdwin` errors in the API (other errors in the API are not
translated: although not detailed in the API contract yet, errors are
supposed to be stable).
When signature is a bit long or there are too many tags, the tags appear
before the signature's line. Don't include the line with tags in the
previous function' docs.
Also fix lint warnings.
Problem: No test for bad use of spaces in help files.
Solution: Add checks for use of spaces in help files. Ignore intentional
spaces. (Hirohito Higashi, closesvim/vim#11952)
d950984489
Cherry-pick changes from patch 9.0.1604.
Co-authored-by: h-east <h.east.727@gmail.com>
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem:
Content that has codeblocks with different languages, results in
multiple calls to:
syntax include vim syntax/vim.vim
which raises error:
E403: syntax sync: line continuations pattern specified twice
Before ba8f19ebb6, this was avoided by
using pcall() to ignore the error.
Solution:
Restore the use of pcall() to ignore the error.
We plan to replace this logic with a treesitter approach, so this is
good enough for now.
Fix#24431
* fix(lsp): replace @private with @nodoc for public client functions
To prevent lua-ls warnings in plugins which use the functions.
* fix(lsp): remove duplicate type annotations/class definitions
These annotations became duplicate with https://github.com/neovim/neovim/pull/23750
When adding `workspace/didChangeWorkspaceFolders` support to my [language server](https://github.com/elixir-tools/next-ls), I noticed that when neovim removes a workspace, it sends an empty table (which is serialized to an empty JSON array) for the value in the `added` field.
This does not follow the spec; the `added` table should just be empty.
The following error led me to this discovery. Note the payload includes `"added" => [[]]`:
```
22:46:48.476 [error] LSP Exited.
Last message received: handle_notification %{"jsonrpc" => "2.0", "method" => "workspace/didChangeWorkspaceFolders", "params" => %{"event" => %{"added" => [[]], "removed" => [%{"name" => "/Users/mitchell/src/gen_lsp", "uri" => "file:///Users/mitchell/src/gen_lsp"}]}}}
** (MatchError) no match of right hand side value: {:error, %{"params" => %{"event" => %{"added" => [error: "expected a map"]}}}}
(gen_lsp 0.4.0) lib/gen_lsp.ex:265: anonymous fn/4 in GenLSP.loop/3
(gen_lsp 0.4.0) lib/gen_lsp.ex:292: GenLSP.attempt/3
(stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
```
In the case you hit this warning in a buffer (like with C++ and clangd),
this message potentially fires over and over again making it difficult
to use the editor at all.
Problem:
netrw may conflict with the Nvim default "gx" mapping.
Solution:
Initialize keymapping earlier by moving it to vim._init_default_mappings().
That also avoids needing to check maparg().