Problem:
Currently, we recommend always inserting text above prompt-line in
prompt-buffer. This can be done using the `:` mark. However, although
we recommend it this way it can sometimes get confusing how to do it
best.
Solution:
Provide an api to append text to prompt buffer. This is a common
use-case for things using prompt-buffer.
Problem: Progress reports via `nvim_echo()` gained an ability to set
`source` and `vim.pack` doesn't currently set one.
Solution: Set `source` to 'vim.pack'. Ideally, the title then can be
something else more informative (like "update", "download", etc.), but
it is used when showing progress messages. So it has to be "vim.pack"
in this case.
Problem:
Currently, there's no way to distinguish progress messages coming from
different sources. Nor can Progress event be easily filtered based on
source.
Solution:
- Add "source" field to nvim_echo-opts.
- The Progress event pattern is now defined by the "source" field.
- Include the "title" as ev.data.
- Unrelated change: set force=false to disable nesting.
fix(ui2): prevent <CR> from focusing pager in insert/terminal mode
Problem: <CR> in insert/terminal mode can focus pager unexpectedly.
Solution: Don't enter the pager when <CR> is pressed during expanded
cmdline in insert/terminal mode.
Problem: When entering the cmdline below expanded messages, those
messages are moved to the dialog window. The dialog window
supports paging but that is unexpected in this situation where
it just serves to keep (some of, exactly those that were
visible before the cmdline was entered) the messages visible.
Wrong highlight group for dialog "more" message.
Solution: Don't create the `vim.on_key()` dialog pager callback after
entering the cmdline below expanded messages.
Use the MsgMore highlight group for the paging hint title.
Problem:
Currently we are using
if 1 item then
{title}: {percent}%
else
Progress: {AVG}%({N})
dropping {title} and Progress text saves up space in statusline plus makes the format consistent, less jumping around.
Solution:
Use `{AVG}%({N})` for all cases.
Problem:
The fold refresh path for foldminlines/foldnestmax creates a new
FoldInfo and starts an async parse. If FileType or BufUnload re-enters
before that callback returns, foldinfos[bufnr] can be cleared or
replaced. The callback then indexes a stale slot and raises an "attempt
to index a nil value" error.
Solution:
Capture the FoldInfo created for the refresh and carry that object
through the async callback. Before calling foldupdate(), verify that the
buffer still points at the same FoldInfo generation; otherwise ignore
the stale callback.
AI-assisted: Codex
Fixes#38461
Problem: nvim_set_hl always replaces all attributes.
Solution: Add update field. When true, merge with existing
attributes instead of replacing. Unspecified attributes are preserved.
If highlight group doesn't exist, falls back to reset mode.
Problem: JSON files should end with a trailing newline so that Unix
tools work as expected, Git doesn't report "No newline at end of file"
and to avoid noise in diffs from editors and other tools adding the
missing newline.
Solution: Add trailing newline.
Problem: - With expanded messages exceeding cfg.msg.cmd.height, entering
the cmdline scrolls to the bottom and expands to the full "cmd"
buffer text height.
- Cursor in the pager is not always at the last message and at
the bottom of the window when appending to the pager.
- unreliable test: messages2_spec: "closed msg window timer removes
empty lines".
Solution: - Achieve separation of the cmdline and message text by moving
messages to the dialog window when entering the cmdline below
expanded messages.
- Set cursor to start of the first message only when first
entering the pager. Use `norm! zb` to position last message
at the bottom of the window (which shouldn't crash anymore
since 911337eb).
- Increase cfg.msg.msg.timeout used in the test file.
Problem:
Currently same progress stat get's displayed on statusline of all
windows. This is repeatitive and noisy.
Solultion:
Only display progress-status on the focused window
Problem:
Currently, when multiple progress are on going we show it as Progress:
{N} items {percent}% format. It can be simplified sinnce items doesn't
really add enough value for the valuable space it takes in statusline
Solution:
Change format to Progress: {percent}%({N})
Problem:
on_response(err, response) handler doesn't receive a response when an
output buffer or path is supplied to vim.net.request. User might want to
both output output to a file/buffer and also do something with it on
response.
Solution:
If an on_response handler was given, then pass the response to it.
Problem:
Non-trivial to write output of vim.net.request to buffer. Requires extra
code in plugin/net.lua which can't be reused by other plugin authors.
```
vim.net.request('https://neovim.io', {}, function(err, res)
if not err then
local buf = vim.api.nvim_create_buf(true, false)
if res then
local lines = vim.split(res.body, '\n', { plain = true })
vim.api.nvim_buf_set_lines(buf, 0, -1, true, lines)
end
end
end)
```
Solution:
Accept an optional `outbuf` argument to indicate the buffer to write output
to, similar to `outpath`.
vim.net.request('https://neovim.io', { outbuf = buf })
Other fixes / followups:
- Make plugin/net.lua smaller
- Return objection with close() method
- vim.net.request.Opts class
- vim.validate single calls
- Use (''):format(...) instead of `..`
Problem: clangd prepends a space/bullet indicator to label. With
labelDetailsSupport enabled, the signature moves to labelDetails,
making label shorter. This flips the length comparison in
get_completion_word, causing it to use item.label directly and
insert the indicator into the buffer.
Solution: only prefer filterText over label when label starts with non-keyword
character in get_completion_word fallback branch.
Problem:
`vim.keymap.*.Opts.buf` allows `boolean` aliases for more widely
used `integer?` values, `true` -> `0` and `false` -> `nil`. This
conversion is unnecessary and can be handled at call sites.
Solution:
As a follow-up to deprecating the `buffer` option, drop support for
boolean values for the new `buf` option. The deprecated `buffer`
continues to support booleans for backward compatibility.
Problem: Generating snippet preview in get_doc() populated the
documentation field before resolve, so the resolve request was
never sent.
Solution: Move snippet preview logic into on_completechanged and
the resolve callback so it no longer blocks the resolve request.
Problem: `vim.lsp.enable()` skips all buffers with non-empty `buftype`,
including `help` buffers. LSPs targeting `filetype='help'` never
auto-attach despite help buffers being real files.
Solution: Expand the `buftype` guard in `lsp_enable_callback` to allow
`help` alongside `""`.
Problem: Default swatch unicode character got lost.
Solution: Put it back where it belongs.
---------
Co-authored-by: vnadgaonkar-spec <vnadgaonkar@gmail.com>
Co-authored-by: Christian Clason <ch.clason+github@icloud.com>
The `buffer` option remains functional but is now undocumented.
Providing both will raise an error. Since providing `buf` was disallowed
before, there is no code that will break due to using `buffer` alongside
`buf`.
Problem:
- Window height is set dynamically to match the text height,
making it difficult for the user to use a different height.
- Cmdwin is closed to enter the pager but still taken into
account for the pager position, and not restored when
the pager is closed.
- Dialog pager handler may unnecessarily consume <Esc>.
Solution:
- Add maximum height config fields for each of the UI2 windows,
where a number smaller than one is a fraction of 'lines',
absolute height otherwise (i.e. `cfg.msg.pager.height = 0.5`).
- If the cmdwin will be closed to enter the pager, don't try
to position the pager above it. Re-enter the cmdwin when the
pager is closed.
- Only add vim.on_key() handler for the dialog paging is actually
possible.
Problem:
f9b2189b28 started using namespaces
for pull diagnostics that look like this `<id>:<identifier>`.
`vim.lsp.buf.codeaction` passes `true` instead of an identifier
to `vim.lsp.diagnostic.get_namespace`, resulting in a namespace that
looks like `<id>:nil`. The end result is that none of the diagnostics are
passed to `textDocument/codeAction` request. Because of that server
might not send any code actions back. For example, eslint lsp responds
with an empty list of actions if it receives no diagnostics.
Solution:
use `_provider_foreach` to collect diagnostics from all `identifiers`
and use that identifier to get a namespace instead of `true`.
Problem: It is possible (and documented in `:h vim.pack`) that plugin's
`src` uses "insteadOf" Git config. In that case comparing it directly
to repo's `origin` will error.
Solution: Add extra check that lockfile's `src` is not equal to repo's
`origin` when taking Git's "insteadOf" into account.
However, still report the original lockfile's `src` in the
`:checkhealth` output, as it seems to be a clearer indication of what
actually is wrong.
If a user accepts completion and immediately exits insert mode, it
could happen that `Context.cursor` was nil by the time the
`completion/resolve` response arrives, leading to an error.
Problem:
Default statusline doesn't show progress status.
Solution:
- Provide `vim.ui.progress_status()`.
- Include it in the default 'statusline'.
How it works:
Status text summarizes "running" progress messages.
- If none: returns empty string
- If one running item: "title: percent%"
- If multiple running items: "Progress: N items avg-percent%"
Problem:
Checking the extension of a file is done often, e.g. in Nvim's codebase
for differentiating Lua and Vimscript files in the runtime. The current
way to do this in Lua is (1) a Lua pattern match, which has pitfalls
such as not considering filenames starting with a dot, or (2)
fnamemodify() which is both hard to discover and hard to use / read if
not very familiar with the possible modifiers.
vim.fs.ext() returns the file extension including the leading dot of
the extension. Similar to the "file extension" implementation of many
other stdlibs (including fnamemodify(file, ":e")), a leading dot
doesn't indicate the start of the extension. E.g.: the .git folder in a
repository doesn't have the extension .git, but it simply has no
extension, similar to a folder named git or any other filename without
dot(s).
Problem
The format of LSP log messages is inconsistent; some include underscores, while others are not logged at all.
Solution
Standardize log recording and unify the log message prefixes with the module names.
Problem:
The capability attach path for client/registerCapability can initialize a capability even when the capability was only registered in specific buffers
Solution:
Check supports_method() before attaching capabilities from the dynamic registration handler so unsupported registrations are ignored.
AI-assisted: OpenCode
- Add TODO comments for aggregating diagnostics from all pull namespaces
and for clearing diagnostics when an empty array is received, referencing
the LSP specification.
- Update diagnostics refresh logic to safely access previousResultId,
preventing potential nil errors.
Previously, resultId for diagnostics was keyed only by client_id, which
could cause issues when multiple identifiers are used by the same client.
This change introduces a composite key of client_id and identifier for
client_result_id, ensuring correct tracking of diagnostic results per
identifier. Updates all relevant logic to use the new keying scheme.
Previously, the LSP client assumed all providers had subcapabilities,
which could cause issues when a provider did not. This change adds a
check for the presence of subcapabilities before attempting to access
them, ensuring correct handling of both cases. This improves
compatibility with servers that register providers without additional
capabilities.