Fixes#35884
Problem: Since `once_buf_loaded` might call a callback passed to it at a
later point (which is it's reason to exist) that callback might end up
referring to stale diagnostics in a handler's `show` function. For
example, if we first call `vim.diagnostic.set` for an unloaded buffer,
then call `vim.diagnostic.reset` and only then load the buffer, we might
still see diagnostics from `vim.diagnostic.set` call, which are stale at
this point.
Solution: only keep one autocommand from the most reset `show` call and
delete it when `hide` is called.
The current description (especially the "unlimited width" part) is
inaccurate in several ways:
- The size of virtual text can depend on window width. In particular,
the size of "above" virtual text can be equal to window width.
- A double-width character that doesn't fit adds 1 to the virtual column
of the following characters.
- The size of 'showbreak' and 'breakindent' is counted.
related: vim/vim#5713closes: vim/vim#18447014c731fa5
Problem:
Autocmds in inline_completion Completor are not scoped to specific
buffers. When multiple buffers have inline completion enabled, events
(InsertEnter, CursorMovedI, TextChangedP, InsertLeave) in any buffer
trigger callbacks for all Completor instances, causing incorrect
behavior across buffers.
Solution:
Add `buffer = bufnr` parameter to nvim_create_autocmd() calls to make
them buffer-local. Each Completor instance now only responds to events
in its own buffer.
Change the second "if" to "because", otherwise it may be misinterpreted
that preinserted() can return non-zero just because these options are
set.
closes: vim/vim#184094edaf89233
Problem: completion: autocompletion can be improved
Solution: Add support for "longest" and "preinsert" in 'autocomplete';
add preinserted() (Girish Palya)
* Add support for "longest" in 'completeopt' when 'autocomplete'
is enabled. (Note: the cursor position does not change automatically
when 'autocomplete' is enabled.)
* Add support for "preinsert" when 'autocomplete' is enabled. Ensure
"preinsert" works the same with and without 'autocomplete'
* introduce the preinserted() Vim script function, useful for defining
custom key mappings.
fixes: vim/vim#18314closes: vim/vim#18387c05335082a
Co-authored-by: Girish Palya <girishji@gmail.com>
Problem: 'nowrap' in a modeline may hide malicious code.
Solution: Forcibly use '>' as 'listchars' "extends" if 'nowrap' was set
from a modeline (zeertzjq).
Manual `:setlocal nowrap` disables this behavior. There is a separate
problem with `:set nowrap` that also applies to some other options.
related: vim/vim#18214
related: vim/vim#18399closes: vim/vim#184259d5208a931
Cherry-pick some test_modeline.vim changes from patches 9.0.{0363,0626}.
fix(extui): set options and buffer name after 'eventignorewin'
Problem: Setting up extui buffers emits OptionSet and BufFilePost events.
Solution: Set options and buffer name after 'eventignorewin'.
Problem: filetype: not all Sway config files are recognized
Solution: Detect files within */sway/config.d/* as swayconfig filetype
(Felix Pehla).
Sways default config automatically includes files placed in
@sysconfdir@/sway/config.d/* (see config.in), so it makes sense to use
the sway syntax for those.
related: vim/vim#1829324f0dbba8c
Co-authored-by: Felix Pehla <29adc1fd92@gmail.com>
Problem:
Diagnostics set on unloaded buffers are not shown when the buffer loads.
Solution:
Use `once_buf_loaded()` to show the diagnostics on BufRead is the buffer
is not yet loaded.
Problem:
pyenv-virtualenv sets a different path for VIRTUAL_ENV than the path to the
python binary it provides, but these paths both symlink to the same file, so
there should be no disparity. The python health-check reports an error, since it
only checks if these paths are equal, not where they point to (resolve to).
Solution:
- Resolve the python symlinks before checking if they are equal.
- Deduplicate some code.
Problem: completion: 'autocomplete' cannot be enabled per buffer
(Tomasz N)
Solution: Make 'autocomplete' global or local to buffer (Girish Palya)
fixes: vim/vim#18320closes: vim/vim#183330208b3e80a
Co-authored-by: Girish Palya <girishji@gmail.com>
Problem: cannot calculate sha256() of a Blob
Solution: Change sha256() to accept a Blob or String argument
(thinca).
closes: vim/vim#183364150283b83
Co-authored-by: thinca <thinca@gmail.com>
Problem:
Scripts named with 'python-…' prefix may not be valid python bins. If
such a script is found in a venv, the Python healthcheck fails hard.
.venv/python-argcomplete-check-easy-install-script
.venv/bin/python3.13
.venv/bin/python
Solution:
- Discard known false-positives such as `python-argcomplete*`.
- Call `health.warn()` instead of `assert()` in `python_exepath()`.
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
Problem: Some filetype autocmds with patterns ending in * do not skip
filenames matching g:ignored_patterns.
Solution: Move these autocmds to the appropriate section and call
s:StarSetf() to set the filetype.
- Affected filetypes: dosini, execline, foam, messages, nginx, tmux.
- Convert foam filetype patterns to use wildcard matching.
closes: vim/vim#174226701480c43
Co-authored-by: Doug Kearns <dougkearns@gmail.com>
Problem:
If there are 2 language servers with different trigger chars (`-` and
`>`), and a keymap inputs both simultaneously (`->`), then `>` doesn't
trigger. We get completion items from server1 only.
This happens because the `completion_timer` for the `-` trigger is still
pending.
Solution:
If the next character arrived enough quickly (< 25 ms), replace the
existing deferred autotrigger with a new one that matches this later
character.
Problem: filetype: kitty config files are not recognized
Solution: Detect */kitty/*.conf as kitty filetype, include a syntax
script (Shawon).
closes: vim/vim#18280a946ccf5ff
Co-authored-by: Shawon <mdmoinulhossainshawon@gmail.com>
This fixes a regression from #33796.
I tried for several hours and cannot write a working test for this, but
this does fix the following warning in tests run with ASAN or TSAN:
-------- Running tests from test/functional/plugin/lsp_spec.lua
RUN T4667 LSP server_name specified start_client(), stop_client(): 114.00 ms OK
RUN T4668 LSP server_name specified stop_client() also works on client objects: 97.00 ms OK
RUN T4669 LSP server_name specified does not reuse an already-stopping client #33616: 31.00 ms OK
nvim took 2022 milliseconds to exit after last test
This indicates a likely problem with the test even if it passed!
Problem: The registerCapability handler re-enables document_color,
making it impossible to disable it in LspAttach.
Solution: Enable it once on initialization and avoid re-enabling
on registerCapability.
- If tick == 0 at the last chunk, the first :echo will print an empty
string, which isn't really helpful, and may cause :redraw to move
cursor to the message area for 'showmode'.
- If tick > 0 at the last chunk, there'll be another :echo that prints
an empty string immediately after the :redraw.
This also fixes the following warning in tests with ASAN or TSAN:
-------- Running tests from test/functional/plugin/lsp/inline_completion_spec.lua
RUN T4604 vim.lsp.inline_completion enable() requests or abort when entered/left insert mode: 225.00 ms OK
RUN T4605 vim.lsp.inline_completion get() applies the current candidate: 212.00 ms OK
nvim took 2013 milliseconds to exit after last test
This indicates a likely problem with the test even if it passed!
RUN T4606 vim.lsp.inline_completion get() accepts on_accept callback: 212.00 ms OK
RUN T4607 vim.lsp.inline_completion select() selects the next candidate: 220.00 ms OK
-------- 4 tests from test/functional/plugin/lsp/inline_completion_spec.lua (3437.00 ms total)
-------- Running tests from test/functional/plugin/lsp/linked_editing_range_spec.lua
nvim took 2011 milliseconds to exit after last test
This indicates a likely problem with the test even if it passed!
This fixes the following warning in tests with ASAN or TSAN:
-------- Running tests from test/functional/lua/watch_spec.lua
RUN T4253 vim._watch watch() ignores nonexistent paths: 29.00 ms OK
nvim took 2006 milliseconds to exit after last test
This indicates a likely problem with the test even if it passed!
Problem: There is no way to ensure a stable key order when encoding a JSON string,
which can be useful for comparisons and producing cleaner diffs.
Solution: Introduce a `sort_keys` option for `vim.json.encode()`,which
is disabled by default. When enabled, object keys are sorted in
alphabetical order.
Problem:
LSP logs show misleading "cannot start" messages when editing a filetype
NOT listed in the `config.filetypes` field.
[ERROR][2025-09-13 18:55:56] …/runtime//lua/vim/lsp/log.lua:151
"cannot start cssls due to config error: …/runtime//lua/vim/lsp.lua:423:
cmd: expected expected function or table with executable command,
got table: 0x0104701b18. Info: vscode-css-language-server is not executable"
Solution:
- `can_start`: check `config.filetypes` before checking the rest of the
config.
Problem:
Multigrid UIs have to find out which window to send the input by using
the Nvim focus rules, which are not fully documented.
Furthermore,`getmousepos()` has several problems when multigrid is
enabled, with the main one being that screenrow and screencol are window
relative instead of screen relative, due to the fact that the UI don't
send any absolute coordinates.
Solution:
Allow passing 0 as grid to `nvim_input_mouse`, with absolute
coordinates, which lets nvim determine the actual window to send the
mouse input to. This works as long as nvim is in charge of the window
positioning. If the UI repositions or resizes the windows, it can still
pass the grid it determines like before.
Problem: First clean start with config containing multiple
`vim.pack.add()` calls requires to explicitly confirm each one.
Although usually a rare occurrence, it still might be tedious.
Solution: Add a third choice during installation confirmation that
approves current and all next installs within current session. It is
reset after session restart.
Problem: defaults: 'diffopt' option value can be improved
Solution: Update diffopt defaults to include "indent-heuristic" and
"inline:char" (Yee Cheng Chin)
The default diff options have not been updated much despite new
functionality having been added to Vim.
- indent-heurstic: This has been enabled by default in Git since
33de716387 in 2017. Given that Vim uses xdiff from Git, it makes sense
to track the default configuration from Git.
- inline:char: This turns on character-wise inline highlighting which is
generally much better than the default inline:simple. It has been
implemented since vim/vim#16881 and we have not seen reports of any issues
with it, and it has received good feedbacks.
closes: vim/vim#18255976b365305
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
Problem: completion: preinserted text highlighed using ComplMatchIns
Solution: Use highlighting group PreInsert and update the documentation
(Girish Palya).
When "preinsert" is included in 'completeopt', only the PreInsert
highlight group should be applied, whether autocompletion is active or not.
Previously, ComplMatchIns was used when autocompletion was not enabled.
Related to https://github.com/vim/vim/pull/18213.
closes: vim/vim#182542525c56e42
Co-authored-by: Girish Palya <girishji@gmail.com>
This partially reverts 0b8a72b739,
that is unreverts 15e77a56b7
"priority" is an internal neovim concept which does not occur in shared
queries. Ideally a single priority space should eventually be enough
for our needs. But as we don't want to poke at the usages of
priorities right now in the wider ecosystem,
introduce the "subpriorities" so that treesitter code can distinguish
highlights of the same priorities with different tree nesting depth.
This mainly affects `injection.combined` as parent-tree nodes might appear
in the middle of child-tree nodes which otherwise is not possible.
Continuing the work of #31400
That PR allowed the provider to be invoked multiple times per line.
We want only to do that when there actually is more data later on the
line. Additionally, we want to skip over lines which contain no new
highlight items. The TS query cursor already tells us what the next
position with more data is, so there is no need to reinvoke the range
callback before that.
NB: this removes the double buffering introduced in #32619 which
is funtamentally incompatible with this (nvim core is supposed to keep
track of long ranges by itself, without requiring a callback reinvoke
blitz). Need to adjust the priorities some other way to fix the same issue.