The current 'clamp_line_numbers' implementation modifies diagnostics in
place, which can have adverse downstream side effects. Before clamping
line numbers, make a copy of the diagnostic. This commit also merges the
'clamp_line_numbers' method into a new 'get_diagnostics' local function
which also implements the more general "get" method. The public
'vim.diagnostic.get()' API now just uses this function (without
clamping). This has the added benefit that other internal API functions
that need to use get() no longer have to go through vim.validate.
Finally, reorganize the source code a bit by grouping all of the data
structures together near the top of the file.
Problem: getcwd() is unclear about how 'autochdir' is used.
Solution: Update the help for getcwd(). Without any arguments always return
the actual current directory. (closesvim/vim#9142)
851c7a699a
If the quickfixlist item doesn't contain a column it is reported as 0.
Rather than using a nil value in such a case (which breaks diagnostics
elsewhere), just keep the 0 value.
Problem: No event is triggered when closing a window.
Solution: Add the WinClosed event. (Naohiro Ono, closesvim/vim#9110)
23beefed73
Nvim has already implemented this feature, so this only changes tests
and docs.
the prior signature did not assume an active language client
this function can now be used directly by passing an offset encoding
defaults to utf-16 (standard for LSP)
Make the bufnr argument have similar semantics across API functions;
namely, a nil value means "all buffers" while 0 means "current buffer".
This increases the flexibility of the API by allowing functions such as
enable() and disable() to apply globally or per-namespace, rather than
only on a specific buffer.
If a LSP server sent a workspace edit containing a rename the buffers
file name changed without the server receiving a close notification for
the old buffer and without the client properly re-attaching on the new
file.
This affected `Move` code-actions in nvim-jdtls, but also
`vim.lsp.buf.rename` on a class level.
* use codeunits/points instead of byte ranges when applicable
* take into account different file formats when computing range and
sending text (dos, unix, and mac supported)
* add tests of incremental sync
Also fix a few other small bugs regarding saving and restoring extmarks.
In particular, now that the virtual text and underline handlers have
their own dedicated namespaces, they should be responsible for saving
and restoring their own extmarks. Also fix the wrong argument ordering
in the call to `clear_diagnostic_cache` in the `on_detach` callback.
* vim.ui.input is an overridable function that prompts for user input
* take an opts table and the `on_confirm` callback, see `:help vim.ui.input` for more details
* defaults to a wrapper around vim.fn.input(opts)
* switches the built-in client's rename handler to use vim.ui.input by default
Sometimes plugins use pseudo-client IDs (e.g. nvim-lint or null-ls) in
order to hook into the LSP infrastructure without being a bona fide LSP
client. In these cases, get_client_by_id() will return nil since the
client ID given does not correspond to a real client recognized by the
LSP subsystem. When this happens, use "unknown" for the client name.
Fixes a bug introduced by https://github.com/neovim/neovim/pull/15949
When no supported clients for a given method are available, buf_request
returns early with a nil value. If buf_request_sync is called on a
buffer with no clients that support a given method, the returned
`cancel` method (which is nil), is invoked, resulting in an error.
Solution: return an empty function handle
Problem:
1. "unpack" has an unrelated meaning in Lua:
https://www.lua.org/manual/5.1/manual.html#pdf-unpack
2. We already have msgpackparse()/msgpackdump() and
json_encode()/json_decode(), so introducing another name for the same
thing is entropy.
Solution:
- Rename vim.mpack.pack/unpack => vim.mpack.encode/decode
Caveat:
This is incongruent with the `Unpacker` and `Packer` functions.
- It's probably too invasive to rename those.
- They also aren't part of our documented interface.
- This commit is "reversible" in the sense that we can always revert
it and add `vim.mpack.encode/decode` as _aliases_ to
`vim.mpack.pack/unpack`, at any time in the future, if we want
stricter fidelity with upstream libmpack. Meanwhile,
`vim.mpack.encode/decode` is currently the total _documented_
interface of `vim.mpack`, so this change serves the purpose of
consistent naming in the Nvim stdlib.
Rather than treating virtual_text, signs, and underline specially,
introduce the concept of generic "handlers", of which those three are
simply the defaults bundled with Nvim. Handlers are called in
`vim.diagnostic.show()` and `vim.diagnostic.hide()` and are used to
handle how diagnostics are displayed.
* This flag allows customizing the time before sending kill -15 to the
server. If set to false, neovim exits immediately after sending
request('shutdown'). Otherwise, polls until all servers have shutdown,
and then kills remaining servers via kill -15 at exit_timeout
duration. Defaults to 500 ms.
closes https://github.com/neovim/neovim/issues/16058
* add client.attached_buffers
* only update client.attached_buffers in on_attach
* use table instead of list for attached_buffers to avoid duplication
The spacing fix drew attention to a couple of places that were using
incorrect formatting such as the key listing for `nvim_open_win`, so
those were fixed too.
vim.bo can target a specific buffer by indexing with a number, e.g:
`vim.bo[2].filetype` can get/set the filetype for buffer 2. This change
replicates that behaviour for the variable namespace.
'show_line_diagnostics()' and 'show_position_diagnostics()' are
almost identical; they differ only in the fact that the latter also
accepts a column to form a full position, rather than just a line. This
is not enough to justify two separate interfaces for this common
functionality.
Renaming this to simply 'show_diagnostics()' is one step forward, but
that is also not a good name as the '_diagnostics()' suffix is
redundant. However, we cannot name it simply 'show()' since that
function already exists with entirely different semantics.
Instead, combine these two into a single 'open_float()' function that
handles all of the cases of showing diagnostics in a floating window.
Also add a "float" key to 'vim.diagnostic.config()' to provide global
values of configuration options that can be overridden ephemerally.
This makes the float API consistent with the rest of the diagnostic API.
BREAKING CHANGE
It looks a bit off with the extmark going over the cursorline.
(With hl_mode combine it keeps the background of the cursorline under the codelens virtualtext)
PostgreSQL ships with man pages for SQL statements like `CREATE TABLE`,
which are provided with underscores as `man 7 CREATE_TABLE`. This patch
updates `man#open_page` (as used by `:Man`) such that visually selecting
the words `CREATE TABLE` in SQL code and pressing `K` properly opens the
desired man page.
Writing `:Man CREATE TABLE` still does not work, since `CREATE` is
interpreted as a section name. (Similarly, `:Man CREATE TABLE AS` fails
because there are too many arguments to `:Man`.) But this is okay,
because if you're typing it anyway then you can just enter underscores
and also tab-completion properly suggests `:Man CREATE_TABLE(7)`.
This is a bit bespoke, but my box has over 9000 man pages (as reported
by `man -k '' | wc -l`), and not one of them has a space in the man page
name, whereas the Postgres manuals do exist and are actually useful.
Test Plan:
On a machine with Postgres manual pages, running
nvim -u NORC +'exe "norm iCREATE TABLE foo(x int);" | norm 0veeK'
should open the appropriate man page.
wchargin-branch: man-spaces-to-underscores
Persist configuration settings set with `vim.lsp.with` and
`vim.lsp.diagnostic.on_publish_diagnostics` by setting the config for
the namespace associated with the client.
When using `true` as the value of a configuration option, the option is
configured to use default values. For example, if a user configures
virtual text to include the source globally (using
vim.diagnostic.config) and a specific namespace or producer configures
virtual text with `virt_text = true`, the user's global configuration is
overriden.
Instead, interpret a value of `true` to mean "use existing settings if
defined, otherwise use defaults".
Problem: :pwd does not give a hint about the scope of the directory
Solution: Make ":verbose pwd" show the scope. (Takuya Fujiwara, closesvim/vim#5469)
950587242c
Problem: Not easy to change directory and restore.
Solution: Add the chdir() function. (Yegappan Lakshmanan, closesvim/vim#4358)
1063f3d200
Also includes some documentation changes from patch 8.1.1218.
Problem: Cannot handle change of directory.
Solution: Add the DirChanged autocommand event. (Andy Massimino,
closesvim/vim#888) Avoid changing directory for 'autochdir' too often.
b7407d3fc9
Only add "auto" pattern. "window" and "global" are already implemented.
Skip `Test_dirchanged_auto` using `CheckFunction test_autochdir`.
Part of PR #15952. More information can be found there.
N/A patches for version.c:
vim-patch:8.0.1460: missing file in patch
Problem: Missing file in patch.
Solution: Add changes to missing file.
b5cb65ba2b
vim-patch:8.0.1461: missing another file in patch
Problem: Missing another file in patch.
Solution: Add changes to missing file.
15833239a4
closes https://github.com/neovim/neovim/issues/15261
* normalize uri path to forward slashes on windows
* use a capture group on windows that avoids mistaking drive letters as uri scheme
Closes https://github.com/neovim/neovim/issues/15174
Instead of invoking handlers with unsupported methods, pre-compute which
clients support a given method and only notify the user if no clients
support the given method.
Problem: Cannot distinguish Normal and Terminal-Normal mode.
Solution: Make mode() return "nt" for Terminal-Normal mode. (issue vim/vim#8856)
72406a4bd2
Problem: Some plugins have structure `lua/nvim-someplugin/..`
Since `-` is not allowed in vim function names, healthcheck names in
lua and in vim can not have the same name (typically vim will use `_`
instead of `-`).
Solution: Normalize the names before checking for duplicates.
This is a simple fix for #15899, as it should at least stop calling
`prepareRename` on servers that don't support renaming.
I imagine a better fix would be to inspect the actual value for, but
that requires some plumbing changes on how capabilities are evaluated
before sending requests out.
Co-authored-by: francisco souza <fsouza@users.noreply.github.com>
Users can pass string values for severities that match with the enum
names (e.g. "Warn" or "Info") which are converted to the corresponding
numerical value in `to_severity`. Invalid strings were simply left
as-is, which caused confusing errors later on. Instead, report an
invalid severity string right up front to make the problem clear.