5373 Commits

Author SHA1 Message Date
Olivia Kinnear
a03ab03a10 fix(lsp): :lsp restart restarts on client exit #37125
Problem:
`:lsp restart` detects when a client has exited by using the `LspDetach`
autocommand. This works correctly in common cases, but breaks when
restarting a client which is not attached to any buffer. It also breaks
if a client is detached in between `:lsp restart` and the actual
stopping of the client.

Solution:
Move restart logic into `vim/lsp/client.lua`, so it can hook in to
`_on_exit()`. The public `on_exit` callback cannot be used for this, as
`:lsp restart` needs to ensure the restart only happens once, even if
the command is run multiple times on the same client.
2026-01-02 01:58:10 -05:00
Justin M. Keyes
b24522e77b Merge #37113 from echasnovski/pack-better-revert 2025-12-30 10:40:19 -05:00
Justin M. Keyes
ea3562d739 Merge #37142 from echasnovski/pack-safer-del 2025-12-30 04:20:33 -05:00
Phạm Bình An
f8d0190491 docs(prompt): Lua example, adjust for multiline input #37121 2025-12-30 03:57:35 -05:00
Justin M. Keyes
20e77c5d88 build: ship "_core/*" as bytecode (built-into Nvim binary)
Problem:
We want to encourage implementing core features in Lua instead of C, but
it's clumsy because:
- Core Lua code (built into `nvim` so it is available even if VIMRUNTIME
  is missing/invalid) requires manually updating CMakeLists.txt, or
  stuffing it into `_editor.lua`.
- Core Lua modules are not organized similar to C modules, `_editor.lua`
  is getting too big.

Solution:
- Introduce `_core/` where core Lua code can live. All Lua modules added
  there will automatically be included as bytecode in the `nvim` binary.
- Move these core modules into `_core/*`:
  ```
  _defaults.lua
  _editor.lua
  _options.lua
  _system.lua
  shared.lua
  ```

TODO:
- Move `_extui/ => _core/ui2/`
2025-12-30 01:44:24 -05:00
Kyle
03377b9552 feat(terminal): include sequence terminator in TermRequest event (#37152)
Problem:
Terminals should respond with the terminator (either BEL or ST) used in
the query so that clients can reliably parse the responses. The
`TermRequest` autocmd used to handle background color requests in the
terminal does not have access to the original sequence terminator, so it
always uses BEL. #37018

Solution:
Update vterm parsing to include the terminator type, then forward this
data into the emitted `TermRequest` events for OSC/DCS/APC sequences.
Update the foreground/background `TermRequest` callback to use the same
terminator as the original request.

Details:
I didn't add the terminator to the `TermResponse` event. However, I
assume the `TermResponse` event doesn't care about the terminator
because the sequence is already parsed. I also didn't update any of the
functions in `src/nvim/vterm/state.c` that write out responses. It
looked like those all pretty much used ST, and it would be a much larger
set of changes. In that same file, there's also logic for 8 bit ST
sequences, but from what I can tell, 8 bit doesn't really work (see `:h
xterm-8bit`), so I didn't use the 8 bit ST at all.
2025-12-29 16:30:23 -06: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
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
zeertzjq
5670dde1af vim-patch:a7f703c: runtime(doc): improve :catch documentation (#37131)
related: vim/vim#18984
closes:  vim/vim#19029

a7f703c215

Co-authored-by: Mao-Yining <101858210+mao-yining@users.noreply.github.com>
2025-12-28 08:18:48 +08:00
zeertzjq
1e44a001ec vim-patch:9.1.2024: 'fsync' option cannot be set per buffer (#37129)
Problem:  'fsync' option cannot be set per buffer
Solution: Make 'fsync' option global-local
          (glepnir)

closes: vim/vim#19019

4d5b303726

Co-authored-by: glepnir <glephunter@gmail.com>
2025-12-28 08:14:45 +08: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
Yi Ming
e855a23c02 feat(lsp): on_accept can return item to customize behavior #37092
Problem:
`on_accept` is a bit cumbersome to customize.

Solution:
* Before: users had to override the entire `on_accept` logic for their changes to be applied.
* Now: users can modify the item and return it to apply the modified changes, or return `nil` to fully customize how the changes are applied.
2025-12-26 00:08:12 -05:00
Evgeni Chasnovski
c8ea8374c8 docs(pack): use more tags and add "Use shorter source" example 2025-12-25 12:57: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
Olivia Kinnear
29494f042c fix(ex): error handling for :lsp #37061 2025-12-25 03:19:12 -05:00
zeertzjq
20c96f1515 vim-patch:2006415: runtime(doc): add reference to searchcount() function
2006415016

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-12-24 08:53:31 +08:00
zeertzjq
0981d4e871 vim-patch:6d211bc: runtime(doc): Improve :catch documentation
fixes: vim/vim#18984

6d211bc4f0

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-12-24 08:52:21 +08:00
zeertzjq
e1aceb0068 vim-patch:e09ff34: runtime(ty): include ty compiler plugin (#37066)
closes: vim/vim#18960

e09ff34129

Co-authored-by: Konfekt <Konfekt@users.noreply.github.com>
2025-12-22 08:13:20 +08:00
Justin M. Keyes
4485e715fb fix(options): deprecate 'gdefault', 'magic' 2025-12-20 22:07:27 -05:00
Justin M. Keyes
060993e438 docs: misc, lsp 2025-12-20 22:07:27 -05:00
Bryan Turns
bef68ba266 docs(lua): iInconsistent vim.keymap param name #37026
Problem: vim.keymap.del has 'modes' as it's first argument while vim.keymap.set
has 'mode' as it's first argument despite both 'mode' and 'modes' taking in the
same type input of String or String[].

Solution: Updated vim.keymap.set docs to refer to it's first argument
as 'modes'.
2025-12-20 19:26:44 -05:00
zeertzjq
9b55f037d2 vim-patch:64799a5: runtime(doc): clarify the behavior of CTRL-Z
fixes: vim/vim#18975

64799a5080

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-12-21 07:12:38 +08:00
zeertzjq
03aef8fd2a vim-patch:fe8c8b1: runtime(doc): fix outdated :function help
Since patch 7.4.264 a leading "g:" is skipped.

closes: vim/vim#18976

fe8c8b1e85
2025-12-21 07:12:38 +08:00
Sean Dewar
eac2f0443e feat(tag): respect jumpoptions=view when popping tagstack (#37021)
Problem: jumpoptions=view has no effect when popping from the tagstack.
Solution: make it work.
2025-12-19 23:32:09 +00:00
zeertzjq
c08139d790 fix(lua): don't remove first char of non-file stacktrace source (#37008) 2025-12-18 08:09:16 +08:00
Olivia Kinnear
bd225422a5 fix(lsp): tests for :lsp, rename start/stop
- Rename :lsp start/stop to enable/disable
- Move lua section of `:lsp` to `vim/_core`
- Add tests
2025-12-16 13:46:08 -05:00
brianhuster
63abb1a88f feat(lsp): builtin :lsp command
Problem:
- Despite [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig)
  claims to be a "data-only" plugin, in fact it still provides some
  user-facing commands because they haven't been upstreamed to Nvim.

Solution:
- Upstream `:LspRestart`, `:LspStart` and `:LspStop` commands as `:lsp
  restart`, `:lsp start` and `:lsp stop` respectively.

Co-authored-by: glepnir <glephunter@gmail.com>
2025-12-16 13:46:04 -05:00
zeertzjq
1d22b05f8d docs: update support.txt (#36903) 2025-12-16 12:55:32 +08:00
Justin M. Keyes
d5cfca5b76 feat(docs): numbered listitems 2025-12-15 13:55:15 -05:00
Justin M. Keyes
31dfecb458 docs: misc, editorconfig
fix https://github.com/neovim/neovim/issues/36858
2025-12-15 13:55:15 -05:00
Riley Bruins
976a47e81b Revert "refactor(treesitter): use scratch buffer for string parser" #36964
This reverts commit 2a7cb32959.
2025-12-15 02:09:36 -05:00
Justin M. Keyes
981ea41abb feat(tui): ghostty builtin terminfo #36963
Problem:
The builtin terminfo defs don't include xterm-ghostty, so features like
`kTerm_set_underline_style` are missing when building without unibilium.

Solution:
- Add ghostty to `gen_terminfo.lua`.
  - Note: The ncurses defs are somewhat different than what ghostty ships.
- Special-case ghostty in `terminfo_from_builtin`.
2025-12-15 02:07:51 -05:00
zeertzjq
1bde5a91c4 vim-patch:bfb9f5c: runtime(doc): Rename NoDefaultCurrentDirectoryInExePath tag (#36921)
- Add leading "$" to match other environment variable tags.
- Clarify :help $NoDefaultCurrentDirectoryInExePath.

closes: vim/vim#18895

bfb9f5c40e

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-12-12 09:13:15 +08:00
zeertzjq
5a83f23430 vim-patch:98a0cbf: patch 9.1.1971: crash with invalid positional argument 0 in printf() (#36919)
Problem:  crash with invalid positional argument 0 in printf()
Solution: Reject positional arguments <= 0.

closes: vim/vim#18898

98a0cbf05b

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-12-12 08:14:58 +08:00
skewb1k
b87bdef2a8 fix(lua): relax vim.wait() timeout validation #36900
Problem:
After bc0635a9fc `vim.wait()` rejects floats
and NaN values.

Solution:
Restore the prior behavior, while still supporting `math.huge`. Update
tests to cover float case.
2025-12-10 09:44:05 -05:00
ymich9963
d2e445e1bd docs(options): shell-powershell #36881
Problem:
Current options for powershell and pwsh had mistakes and rationale
behind them was not clear.

Solution:
Update the suggested options by splitting up powershell and pwsh, as
well as ensuring that all options work and rationale is documented and
discussed.
2025-12-10 00:57:16 -05:00
zeertzjq
747cf30c37 vim-patch:9.1.1965: q can accidentally start recording at more prompt (#36879)
Problem:  When exiting at the end of the more prompt (at the hit enter
          prompt) by hitting q the recording mode will be started.
          (Jakub Łuczyński)
Solution: Don't add the q key to the typeahead buffer
          in the function wait_return (Bjoern Foersterling)

fixes: vim/vim#2589
closes: vim/vim#18889

ecce3497fa

Co-authored-by: Bjoern Foersterling <bjoern.foersterling@gmail.com>
2025-12-09 22:25:47 +08:00
zeertzjq
3bc9a5b5d2 vim-patch:9.1.1963: diff: missing diff size limit for xdiff (#36877)
Problem:  diff: missing diff size limit for xdiff
Solution: Impose file size limit for internal diff (xdiff)
          (Yee Cheng Chin).

Git imposes a hard cap on file size for content that it passes to xdiff
(added to Git in dcd1742e56e, defined in xdiff-interface.h), due to
integer overflow concerns in xdiff. Vim doesn't specify such a limit
right now, which means it's possible for a user to diff a large file
(1GB+) and trigger these overflow issues.

Add the same size limit (1GB minus 1MB) to Vim and simply throws an
error when Vim encounters files larger than said limit. For now, reuse
the same error message regarding internal diff failures. There is no
need to add the same limit for external diff as it's up to each tool to
error check their input to decide what is appropriate or not.

closes: vim/vim#18891

4af6d9755c

Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2025-12-09 22:25:18 +08:00
zeertzjq
58d5d97719 vim-patch:98ef843: runtime(rust): use textwidth=100 for the Rust recommended style (#36875)
The help text here said 99 was the recommended style for the standard
library, but I can't find a citation for this anywhere. In contrast the
Rust Style Guide hosted on rust-lang.org
[says](https://doc.rust-lang.org/stable/style-guide/#indentation-and-line-width)
the maximum line width is 100, and rustfmt
[agrees](37aa2135b5/src/tools/rustfmt/src/config/options.rs (L570)).

Having the two disagree causes an annoying off-by-one error in vim: if
you configure vim to highlight too-long lines then it will occasionally
complain about a line that rustfmt refuses to fix.

closes: vim/vim#18892

98ef8433b6

Co-authored-by: Aaron Jacobs <jacobsa@google.com>
2025-12-09 20:42:12 +08:00
zeertzjq
c24cc4c352 vim-patch:b22c145: runtime(doc): document change in Windows behavior for patch 9.1.1947 (#36874)
closes: vim/vim#18886

b22c145c22

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-12-09 20:41:49 +08: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
zeertzjq
2f9f77cd72 vim-patch:9.1.1962: filetype: Erlang application resource files are not recognized (#36868)
Problem:  filetype: Erlang application resource files are not recognized
Solution: Add content-based filetype detection for application resource
          files matching extension '*.app' (Doug Kearns)

related: vim/vim#18835
closes:  vim/vim#18842

cf5c255260

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-12-09 09:08:09 +08:00
Justin M. Keyes
0bb5bc5557 refactor: clint.py => clint.lua
Problem:
`clint.py` is the last python in our codebase, and beyond that it needs
some cleanup. And it lacks tests, so modifying it can be painful.

Also, we need a way to add ad-hoc lint rules for *Lua*, so it will help
to have our ad-hoc rules for C in the same language (the scripts may
share functions/techniques): https://github.com/neovim/neovim/issues/28372

Solution:
- convert to `clint.lua` (mostly AI-generated, but it now has test
  coverage, unlike `clint.py`)
- drop rules that are no longer needed:
  - "readability/multiline_string"
    - technially still relevant, but very uncommon so doesn't really matter.
  - "--line-length"
    - Not used in the old clint.py, nor the new clint.lua.
  - "comment whitespace" check
    - It is enforced by uncrustify.
  - "TODO" check
    - The `-google-readability-function-size` clang-tidy rule enforces
      "TODO(user)" format. (It was already enabled long ago.)
2025-12-08 01:43:02 -05:00
zeertzjq
69f4fd84aa vim-patch:9.1.1949: :stag does not use 'swichtbuf' option
Problem:  :stag does not use 'swichtbuf' option, though the
          documentation states differently
          (Christian Brabandt)
Solution: Respect 'switchbuf' option (Yegappan Lakshmanan).

related: vim/vim#18845
closes: vim/vim#18856

efc7509be2

Cherry-pick some test_tagjump.vim changes from patches 9.0.{0363,0767}.

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2025-12-08 08:09:17 +08:00
Nathan Smith
551bb63d44 feat(events): MarkSet event, aucmd_defer() #35793
Problem:
- Can't subscribe to "mark" events.
- Executing events is risky because they can't be deferred.

Solution:
- Introduce `MarkSet` event.
- Introduce `aucmd_defer()`.

Helped-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2025-12-07 15:13:31 -05:00
Justin M. Keyes
ebb7c38ca2 docs: misc
fix https://github.com/neovim/neovim.github.io/issues/419

Co-authored-by: Rob Pilling <robpilling@gmail.com>
2025-12-06 20:33:02 -05:00
Tristan Knight
0f3e3c87b7 feat(lsp): support dynamic registration for diagnostics (#36841) 2025-12-06 15:55:07 -08:00
Tristan Knight
9e9cdcaa18 refactor(lsp): unify capability checks and registration #36781
Problem:
Our LSP type system didnt have a concept of RegistrationMethods, this is where the method to dynamically register for a capability is sent to a different method endpoint then is used to call it. Eg `textDocument/semanticTokens` rather than the specific full/range/delta methods

Solution:
Extended generator to create `vim.lsp.protocol.Methods.Registration` with these registration methods. Also extend `_request_name_to_client_capability` to cover these methods. Adjust typing to suit
2025-12-06 18:31:11 -05:00
Olivia Kinnear
4e1644d4d3 feat(spell): opt-out of confirm when downloading spellfiles #36836 2025-12-06 17:20:02 -05:00