714 Commits

Author SHA1 Message Date
Tomasz N
eaacdc9bdf fix(lsp): ignore empty response on trigger completion #37663
Problem:
Empty response affects server start boundary computed before.

Solution:
Ignore empty responses. This is mostly micro-optimization that avoids
extending existing results with empty responses.
2026-02-08 16:25:47 -05:00
GenchoXD
9c8d06e086 test(lsp/diagnostic): clearing diagnostics #37759
Problem:
Diagnostic lifecycle invariants (clearing on empty publish and buffer
deletion) were previously implicit and not directly covered by functional
tests, allowing regressions to go unnoticed.

Solution:
Add functional regression tests asserting that diagnostics are cleared
when an LSP server publishes an empty diagnostic set and when the
associated buffer is deleted. Assertions are scoped to the client
diagnostic namespace and use public diagnostic APIs only.
2026-02-08 16:22:13 -05:00
Mike J McGuirk
15ff454443 feat(lsp): display codelens as virtual lines, not virtual text #36469
Problem: Code lenses currently display as virtual text on the same line
and after the relevant item. While the spec does not say how lenses
should be rendered, above the line is most typical. For longer lines,
lenses rendered as virtual text can run off the side of the screen.

Solution: Display lenses as virtual lines above the text.

Closes https://github.com/neovim/neovim/issues/33923

Co-authored-by: Yi Ming <ofseed@foxmail.com>
2026-02-08 16:10:41 -05:00
Evgeni Chasnovski
0f73873d4f fix(pack): close confirmation buffer, not tabpage #37756 2026-02-08 09:15:16 -05:00
Justin M. Keyes
a124439559 test(lsp): retry "on_type_formatting enables formatting on type" #37711
FAILED   test/functional/plugin/lsp/on_type_formatting_spec.lua @ 59: vim.lsp.on_type_formatting enables formatting on type
    test/functional\plugin\lsp\on_type_formatting_spec.lua:65: retry() attempts: 1
    test/functional\plugin\lsp\on_type_formatting_spec.lua:66: Expected objects to be the same.
    Passed in:
    (table: 0x01772f47b6d8) {
      [1] = 'int main() {'
     *[2] = '  int hi = 5'
      [3] = '}' }
    Expected:
    (table: 0x017731aad3a8) {
      [1] = 'int main() {'
     *[2] = '  int hi = 5;'
      [3] = '}' }

    stack traceback:
            test\testutil.lua:89: in function 'retry'
            test/functional\plugin\lsp\on_type_formatting_spec.lua:65: in function <test/functional\plugin\lsp\on_type_formatting_spec.lua:59>
2026-02-05 00:03:06 +00:00
Tomasz N
90abd2613d fix(lsp): don't empty server start-boundary by next client response #37665
Problem:
Server start boundary can be emptied by response provided by next client.

Solution:
Don't empty it when extending the result list.
2026-02-03 15:30:05 -05:00
jdrouhard
9278f792c3 feat(lsp): support range + full semantic token requests #37611
From the LSP Spec:
> There are two uses cases where it can be beneficial to only compute
> semantic tokens for a visible range:
>
> - for faster rendering of the tokens in the user interface when a user
>   opens a file. In this use case, servers should also implement the
>   textDocument/semanticTokens/full request as well to allow for flicker
>   free scrolling and semantic coloring of a minimap.
> - if computing semantic tokens for a full document is too expensive,
>   servers can only provide a range call. In this case, the client might
>   not render a minimap correctly or might even decide to not show any
>   semantic tokens at all.

This commit unifies the usage of range and full/delta requests as
recommended by the LSP spec and aligns neovim with the way other LSP
clients use these request types for semantic tokens.

When a server supports range requests, neovim will simultaneously send a
range request and a full/delta request when first opening a file, and
will continue to issue range requests until a full response is
processed. At that point, range requests cease and full (or delta)
requests are used going forward. The range request should allow servers
to return a result faster for quicker highlighting of the file while it
works on the potentially more expensive full result. If a server decides
the full result is too expensive, it can just error out that request,
and neovim will continue to use range requests.

This commit also fixes and cleans up some other things:

- gen_lsp: registrationMethod or registrationOptions imply dynamic
  registration support
- move autocmd creation/deletion to on_attach/on_detach
- debounce requests due to server refresh notifications
- fix off by one issue in tokens_to_ranges() iteration
2026-02-03 13:16:12 -05:00
Yi Ming
965468fca1 feat(lsp): support workspace/codeLens/refresh 2026-02-03 22:25:21 +08:00
Yi Ming
fe23168e2b feat(lsp)!: reimplement textDocument/codeLens as decoration provider 2026-02-03 22:25:18 +08:00
Harsh Kapse
36db6ff2c1 fix(lsp): use LSP textEdit range for completion start boundary (#37491)
Previously, adjust_start_col returned nil when completion items had
different start position from lsp textEdit range
This caused the completion to fall back to \k*$ which ignores the
non-keyword characters

Changes:
- adjust_start_col: now returns the minimum start postion among all
items instead of nil
- _lsp_to_complete_items - normalizes the items by adding the gap between
  current and minimum start

Fixes: https://github.com/neovim/neovim/issues/37441
2026-01-30 15:34:42 +01:00
Evgeni Chasnovski
164cab405b test(pack): cover that events work when installing from the lockfile 2026-01-29 16:25:02 +02:00
Justin M. Keyes
75114fe7bb Merge #37428 vim.pack tests 2026-01-28 06:48:57 -05:00
phanium
fd45bc8cab fix: lsp.enable() don't work correctly inside FileType event #37538
Problem:
Two cases lsp.enable() won't work in the first FileType event
1. lsp.enable luals inside FileType or ftplugin/lua.lua, then:
```
nvim a.lua
```

2. lsp.enable luals inside FileType or ftplugin/lua.lua, then:
```
nvim -> :edit a.lua -> :mksession! | restart +qa! so Session.vim
```

Solution:
Currently `v:vim_did_enter` is used to detected two cases:
1. "maunally enabled" (lsp.enable() or `:lsp enable`)
2. "inside FileType event"

To detect 2. correctly we use did_filetype().
2026-01-27 17:59:36 -05:00
jdrouhard
8ed68fda50 feat(lsp): semantic token range improvements #37451
* cache all tokens from various range requests for a given document
  version
  - all new token highlights are merged with previous highlights to
    maintain order and the "marked" property
  - this allows the tokens to stop flickering once they've loaded once
    per document version
* abandon the processing coroutine if the request_id has changed instead
  of relying only on the document version
  - this will improve efficiency if a new range request is made while a
    previous one was processing its result
* apply new highlights from processing coroutine directly to the current
  result when the version hasn't changed
  - this allows new highlights to be immediately drawable once they've
    processed instead of waiting for the whole response to be processed
    at once
* rpc layer was changed to provide the request ID back in success
  callbacks, which is then provided as a request_id field on the handler
  context to lsp handlers
2026-01-27 08:56:52 -05:00
Evgeni Chasnovski
b4dd11cd5d test(pack): use a helper to vim.pack.add inside testnvim instance
Problem: A lot of test cases require executing `vim.pack.add()` inside
  `testnvim` instance to install and/or add plugins. This requires
  access to the information about tested repo sources (stored in a Lua
  variable inside a runner instance), so it needs to go
  `exec_lua(function() vim.pack.add({...}) end)` route, which in
  formatted form adds two more lines. Since it is very frequent, it pads
  test files with (mostly avoidable and unncessary) lines.

Solution: Add `vim_pack_add()` helper specifically to execute
  `vim.pack.add` inside `testnvim` instance. Use it where possible:
  usually when `vim.pack.add` is not a subject of the test. It is not
  quite doable for some cases, though:
  - When error in `vim.pack.add` is tested.
  - When specification includes `vim.version.range` (since `exec_lua`
    seems to not transfer necessary class metatables).

  This removes ~100 lines from the file at the cost of sometimes using
  `vim_pack_add` and sometimes having to reside to `vim.pack.add`.
  Which seems like a positive trade-off.

  This also allows making a more compact `exec_lua('vim.pack.update()')`
  instructions since `vim.pack.update` doesn't depend on the upvalues
  stored in test runner instance.
2026-01-16 18:49:14 +02:00
Evgeni Chasnovski
0232a63fa5 test(pack): make various small cleanups
Problem: `vim.pack` tests might benefit from a cleanup

Solution: Do the cleanup:
  - Use `t.retry` instead of full `vim.uv.sleep` to make tests quicker.
  - Use `pack_assert_content` helper for a common task of checking the
    content of a special Lua file inside an installed plugin. This is
    used as a proxy of installed plugin's state on the disk.
  - Use `([[...]]):format()` approach (instead of array of strings) in
    one more place. Should improve readability.
2026-01-16 18:31:53 +02:00
zeertzjq
cabf82be5a test(lsp/diagnostic_spec): fix creating unused clients (#37397)
Fix #36793

Also fix some `integer?` -> `integer` conversion warnings while at it.
2026-01-15 00:23:55 +00:00
Evgeni Chasnovski
bac4cde9cd fix(pack): actually checkout proper version of submodules
Problem: Installing plugin with submodules doesn't check out their
  state (due to `git clone --no-checkout` to not end up with default
  branch code in case of invalid `version`).

  Updating a plugin with submodules doesn't update their state.

Solution: Update `git_checkout` helper to account for submodules.
  Another approach would be `git checkout --recurse-submodules ...`,
  but that doesn't seem to allow `--filter=blob:none` for submodules,
  which is nice to have.

  Also make `git_clone` wrapper simpler since `--no-checkout` makes
  `--recurse-submodules` and `--also-filter-submodules` do nothing.
2026-01-12 22:57:38 +02:00
Evgeni Chasnovski
09edb145f5 test(pack): adjust add startup tests to just sleep with longer timeout
Problem: The `add` startup tests mock startup process which requires
  *some* amount of time to be done. Previous solution with `vim.wait`
  to wait just enough time to register that startup script has finished
  doesn't seem to work as intended (it just wait full time). Its timeout
  is also seems to be barely enough to pass on Windows CI. Which will be
  a problem with more `git` actions done on startup in the future/next
  commit.

Solution: Just sleep predetermined amount of time and explicitly check
  if startup script finished executing.
2026-01-12 22:30:56 +02:00
Evgeni Chasnovski
8f0b8a2c27 fix(pack): skip git stash during install
Problem: Installing plugin is done via `git clone --no-checkout ...`
  (to not end up with default branch code in case of invalid `version`).
  This leaves cloned repo in a state that `git stash` will actually add
  an entry to the stash list. Although not critical, better to not have
  that if possible.

Solution: explicitly skip `git stash` step in checkout during install.
2026-01-12 15:53:36 +02:00
zeertzjq
7a6e8d4430 docs: misc (#37281)
Close #37289
Close #37348

Co-authored-by: Marc Jakobi <marc@jakobi.dev>
Co-authored-by: Anton Kesy <anton@kesy.de>
2026-01-12 03:50:57 +00:00
Robert Muir
1629493f72 perf(lsp): avoid textDocument/definition requests during tag completion (#37260)
Problem:
vim.lsp.tagfunc looks for the presence of 'c' (cursor) flag and issues
sync textDocument/definition requests to all clients, otherwise
workspace/symbol requests. But 'c' flag can also be set during the
insert mode completion, e.g. with an empty tag completion query, the tag
func receives pattern of '\<\k\k' with flags 'cir'.

Solution:
check for 'i' (insert mode completion) flag and don't issue any LSP
requests, return vim.NIL for immediate fallback to tags.
2026-01-11 14:41:26 -08:00
Yochem van Rosmalen
f19653e370 fix(health): emit Progress message #37123
Problem:
The `"Running healthchecks..."` message doesn't inform the user much and
is a hack from before we got a way to emit actual progress messages.

Solution:
Use `nvim_echo` to emit progress messages showing the name of the report
that is currently running.
2026-01-09 17:00:09 -05:00
Tristan Knight
ed562c296a fix(lsp): improve dynamic registration handling #37161
Work on #37166 

- Dynamic Registration Tracking via Provider
- Supports_Method
    - Multiple Registrations
    - RegistrationOptions may dictate support for a method
2026-01-02 01:46:13 -05:00
altermo
170992c8d2 test(tohtml): test syntax, not just treesitter #37181 2025-12-31 18:00:05 -05:00
Christian Clason
f3ee2440c7 build(deps): bump tree-sitter-lua to v0.4.1 2025-12-31 16:49:24 +01:00
Justin M. Keyes
b24522e77b Merge #37113 from echasnovski/pack-better-revert 2025-12-30 10:40:19 -05:00
Evgeni Chasnovski
28ba99e026 feat(pack)!: suggest "delete" code action only for not active plugins
Problem: Deleting active plugins can lead to a situation when it is
  reinstalled after restart.

Solution: Suggest "delete" code action only for not active plugins.
  Whether a plugin is not active is visible by a hint in its header.
2025-12-28 18:39:26 +02:00
Evgeni Chasnovski
c339b83a4a feat(pack): hint in confirmation buffer that plugin is not active
Problem: After `vim.pack.update()` it is not clear if plugin is active
  or not. This can be useful to detect cases when plugin was removed
  from 'init.lua' but there was no `vim.pack.del()`.

Solution: Add ` (not active)` suffix with distinctive highlighting to
  header of plugins that are not active.
  It will also be shown in in-process LSP document symbols to have quick
  reference about which plugins are not active.
2025-12-28 18:39:26 +02:00
Evgeni Chasnovski
f5707a9c42 feat(pack)!: make del() only remove non-active plugins by default
Problem: Using `vim.pack.del()` to delete active plugin can lead to
  a situation when this plugin is reinstalled after restart. Removing
  plugin from 'init.lua' is documented, but can be missed.

Solution: Make `del()` only remove non-active plugins by default and
  throw an informative error if there is an active plugin.

  Add a way to force delete any plugin by adding `opts.force`. This also
  makes `del()` signature be the same as other functions, which is nice.
2025-12-28 18:39:26 +02:00
Evgeni Chasnovski
c9965491d0 feat(pack): allow running update() without Internet connection
Problem: There is now way to run `update()` without Internet connection
  while there are some workflows that do not require it. Like "switch
  plugin version" and "revert latest update".

Solution: Add `opts.offline` to `update()`. This also allows now to
  treat `vim.pack.update(nil, { offline = true })` as a way to
  interactively explore currently installed plugins.
2025-12-26 20:05:12 +02:00
Evgeni Chasnovski
8c28507fcf feat(pack): allow choosing update target in update()
Problem: There are two fairly common workflows that involve lockfile and
  can be made more straightforward in `vim.pack`:

    1. Revert latest update. Like if it introduced unwanted behavior.

    2. Update to a revision in the lockfile. Like if already updated
       on another machine, verified that everything works, `git add` +
       `git commit` + `git push` the config, and want to have the same
       plugin states on current machine.

Solution: Make `update` allow `opts.target`. By default it uses
  `version` from a plugin specification (like a regular "get new changes
  from source" workflow). But it also allows `"lockfile"` value to
  indicate that target revision after update should be taken from the
  current lockfile verbatim.

  With this, the workflows are:

    1. Revert (somehow) to the lockfile before the update, restart, and
       `vim.pack.update({ 'plugin' }, { target = 'lockfile' })`. If Git
       tracked, revert with `git checkout HEAD -- nvim-pack-lock.json`.
       For non-VCS tracked lockfile, the revisions can be taken from the
       log file. It would be nicer if `update()` would backup a lockfile
       before doing an update, but that might require discussions.

    2. `git pull` + `:restart` +
       `vim.pack.update(nil, { target = 'lockfile' })`.
       The only caveats are for new and deleted plugins:
        - New plugins (not present locally but present in the lockfile)
          will be installed at lockfile revision during restart.
        - Deleted plugins (present locally but not present in the
          lockfile) will still be present: both locally *and* in the
          lockfile. They can be located by
          `git diff -- nvim-pack-lock.json` and require manual
          `vim.pack.del({ 'old-plugin1', 'old-plugin2' })`.
2025-12-26 18:32:59 +02:00
Evgeni Chasnovski
0353d33b00 feat(pack)!: change src of installed plugin inside update() in place
Problem: Changing `src` of already installed plugin currently takes
  effect immediately inside `vim.pack.add()` and acts as "delete and
  later fresh install". Although more robust, this might lead to
  unintentional data loss (since plugin is deleted) if the plugin was
  manually modified or the new source is not valid.
  Also this introduces unnecessary differentiation between "change
  `version`" and "change `src`" of already installed plugin.

Solution: Require an explicit `vim.pack.update()` to change plugin's
  source. It is done by conditionally changing `origin` remote of the
  Git repo. The effect does not require update confirmation in order to
  have new changes fetched from the new `src` right away.

  If in the future there are more types of plugins supported (i.e. not
  only Git repos), also do extra work (like delete + install) during
  `vim.pack.update()`.
2025-12-25 12:57:59 +02:00
glepnir
856391bc7f fix(health): "q" keymap not set when health.style=float #37007
Problem:
The q keymap is already set in open_floating_preview, so maparg('q') is not empty.

Solution:
Add a health.style check before setting the q keymap.
2025-12-17 10:53:08 -05:00
glepnir
0197f13ed4 fix(lsp): sort items when completeopt include fuzzy #36974
Problem: When fuzzy is enabled and the prefix is not empty,
items are not sorted by fuzzy score before calling fn.complete.

Solution: Use matchfuzzypos to get the scores and sort the items
by fuzzy score before calling fn.complete.
2025-12-16 22:39:47 -05:00
Tristan Knight
8165427b4d fix(lsp): correct capability checks for dynamic registration (#36932)
Refactor capability checks in Client:_supports_registration and
Client:supports_method to properly handle dynamicRegistration and unknown
methods. Now, dynamic capabilities are checked before assuming support for
unknown methods, ensuring more accurate LSP feature detection.
2025-12-15 13:23:57 -05:00
Jaehwang Jung
63737e6e73 fix(treesitter): no injection highlighting on last line #36951
Problem:
If the last visible line in a window is not fully displayed, this line
may not get injection highlighting. This happens because line('w$')
actually means the last *completely displayed* line.

Solution:
Use line('w$') + 1 for the botline.

This reverts 4244a96774
"test: fix failing lsp/utils_spec #36609",
which changed the test based on the wrong behavior.
2025-12-14 19:01:49 -05:00
Mathias Fußenegger
c5d4050586 Revert "feat(lsp): support version in textDocument/publishDiagnostics #36754" (#36865)
This reverts commit 03d6cf7aae.

See https://github.com/neovim/neovim/pull/36754#issuecomment-3626115697
The change was supposed to avoid showing stale diagnostics but had the
opposite effect.
2025-12-09 13:29:21 +01:00
Tristan Knight
0f3e3c87b7 feat(lsp): support dynamic registration for diagnostics (#36841) 2025-12-06 15:55:07 -08:00
Olivia Kinnear
4e1644d4d3 feat(spell): opt-out of confirm when downloading spellfiles #36836 2025-12-06 17:20:02 -05:00
Pig Fang
6aa80b1ab2 refactor(lsp): fix lint 2025-12-05 15:51:46 +00:00
Pig Fang
b9eba5cde2 test(lsp): accept callback for diagnostic 2025-12-05 15:51:46 +00:00
Pig Fang
03f944b0fe refactor(lsp): fix lint 2025-12-05 15:51:46 +00:00
Pig Fang
016335a7d0 feat(lsp): support refreshing workspace diagnostics 2025-12-05 15:51:46 +00:00
Pig Fang
a7c21f4b17 test(lsp): polish tests of refreshing diagnostics 2025-12-05 15:51:46 +00:00
Pig Fang
bcb110482b test(lsp): update test name 2025-12-05 15:51:46 +00:00
Pig Fang
02067a9892 feat(lsp): support diagnostic refresh request 2025-12-05 15:51:46 +00:00
Tristan Knight
23ddb2028b feat(lsp): semanticTokens/range #36705
Problem:
Nvim supports `textDocument/semanticTokens/full` and `…/full/delta`
already, but most servers don't support `…/full/delta` and Nvim will try
to request and process full semantic tokens response on every buffer
change. Even though the request is debounced, there is noticeable lag if
the token response is large (in a big file).

Solution:
Support `textDocument/semanticTokens/range`, which requests semantic
tokens for visible screen only.
2025-11-30 21:06:56 -05:00
Riley Bruins
03d6cf7aae feat(lsp): support version in textDocument/publishDiagnostics #36754
This commit makes it so that push diagnostics received for an outdated
document version are ignored.
2025-11-29 23:38:11 -05:00
altermo
caa9419355 refactor!: optwin.lua #36505
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2025-11-19 20:43:15 -08:00