Commit Graph

34434 Commits

Author SHA1 Message Date
Cameron Ring
f11f8546e7 fix(vim.fs): root() should always return absolute path #36466 2025-11-16 21:41:26 -08:00
Jan Edmund Lazo
1be37c245f ci(vim-patches): add N/A tokens to version.c commit #36524 2025-11-16 20:48:43 -08:00
Justin M. Keyes
c8b6852363 docs: misc #36580
Co-authored-by: nguyenkd27 <nguyenkd27@gmail.com>
Co-authored-by: dundargoc <gocdundar@gmail.com>
Co-authored-by: Yochem van Rosmalen <git@yochem.nl>
Co-authored-by: Tuure Piitulainen <tuure.piitulainen@gmail.com>
Co-authored-by: Maria Solano <majosolano99@gmail.com>
Co-authored-by: tao <2471314@gmail.com>
2025-11-16 20:36:07 -08:00
tao
6e2b514813 fix(system): handle SIGINT in --headless mode #36557
Problem:
When running with `--headless --listen ./hello`, pressing Ctrl-C
doesn’t log anything and doesn’t clean up the socket file.

Solution:
handle SIGINT like SIGTERM.
2025-11-16 18:44:30 -08:00
zeertzjq
ef0c522077 vim-patch:9.1.1918: completion: crash with fuzzy completion (#36578)
Problem:  completion: crash with fuzzy completion
          (Christian Brabandt)
Solution: When completion candidates are gathered from a different
          window, and when completing `<c-p>`, linked list should be
          sorted only after all items are collected (Girish Palya).

fixes: vim/vim#18752
closes: vim/vim#18756

6437997d83

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-11-17 09:33:04 +08:00
tao
654303079b feat(lsp): skip invalid header lines #36402
Problem:
Some servers write log to stdout and there's no way to avoid it.
See https://github.com/neovim/neovim/pull/35743#pullrequestreview-3379705828

Solution:
We can extract `content-length` field byte by byte and skip invalid
lines via a simple state machine (name/colon/value/invalid), with minimal
performance impact.

I chose byte parsing here instead of pattern. Although it's a bit more complex,
it provides more stable performance and allows for more accurate error info when
needed.

Here is a bench result and script:

    parse header1 by pattern: 59.52377ms 45
    parse header1 by byte: 7.531128ms 45

    parse header2 by pattern: 26.06936ms 45
    parse header2 by byte: 5.235724ms 45

    parse header3 by pattern: 9.348495ms 45
    parse header3 by byte: 3.452389ms 45

    parse header4 by pattern: 9.73156ms 45
    parse header4 by byte: 3.638386ms 45

Script:

```lua
local strbuffer = require('string.buffer')

--- @param header string
local function get_content_length(header)
  for line in header:gmatch('(.-)\r?\n') do
    if line == '' then
      break
    end
    local key, value = line:match('^%s*(%S+)%s*:%s*(%d+)%s*$')
    if key and key:lower() == 'content-length' then
      return assert(tonumber(value))
    end
  end
  error('Content-Length not found in header: ' .. header)
end

--- @param header string
local function get_content_length_by_byte(header)
  local state = 'name'
  local i, len = 1, #header
  local j, name = 1, 'content-length'
  local buf = strbuffer.new()
  local digit = true
  while i <= len do
    local c = header:byte(i)
    if state == 'name' then
      if c >= 65 and c <= 90 then -- lower case
        c = c + 32
      end
      if (c == 32 or c == 9) and j == 1 then
        -- skip OWS for compatibility only
      elseif c == name:byte(j) then
        j = j + 1
      elseif c == 58 and j == 15 then
        state = 'colon'
      else
        state = 'invalid'
      end
    elseif state == 'colon' then
      if c ~= 32 and c ~= 9 then -- skip OWS normally
        state = 'value'
        i = i - 1
      end
    elseif state == 'value' then
      if c == 13 and header:byte(i + 1) == 10 then -- must end with \r\n
        local value = buf:get()
        return assert(digit and tonumber(value), 'value of Content-Length is not number: ' .. value)
      else
        buf:put(string.char(c))
      end
      if c < 48 and c ~= 32 and c ~= 9 or c > 57 then
        digit = false
      end
    elseif state == 'invalid' then
      if c == 10 then -- reset for next line
        state, j = 'name', 1
      end
    end
    i = i + 1
  end
  error('Content-Length not found in header: ' .. header)
end

--- @param fn fun(header: string): number
local function bench(label, header, fn, count)
  local start = vim.uv.hrtime()
  local value --- @type number
  for _ = 1, count do
    value = fn(header)
  end
  local elapsed = (vim.uv.hrtime() - start) / 1e6
  print(label .. ':', elapsed .. 'ms', value)
end

-- header starting with log lines
local header1 =
  'WARN: no common words file defined for Khmer - this language might not be correctly auto-detected\nWARN: no common words file defined for Japanese - this language might not be correctly auto-detected\nContent-Length: 45  \r\n\r\n'
-- header starting with content-type
local header2 = 'Content-Type: application/json-rpc; charset=utf-8\r\nContent-Length: 45  \r\n'
-- regular header
local header3 = '  Content-Length: 45\r\n'
-- regular header ending with content-type
local header4 = '  Content-Length: 45 \r\nContent-Type: application/json-rpc; charset=utf-8\r\n'

local count = 10000

collectgarbage('collect')
bench('parse header1 by pattern', header1, get_content_length, count)
collectgarbage('collect')
bench('parse header1 by byte', header1, get_content_length_by_byte, count)

collectgarbage('collect')
bench('parse header2 by pattern', header2, get_content_length, count)
collectgarbage('collect')
bench('parse header2 by byte', header2, get_content_length_by_byte, count)

collectgarbage('collect')
bench('parse header3 by pattern', header3, get_content_length, count)
collectgarbage('collect')
bench('parse header3 by byte', header3, get_content_length_by_byte, count)

collectgarbage('collect')
bench('parse header4 by pattern', header4, get_content_length, count)
collectgarbage('collect')
bench('parse header4 by byte', header4, get_content_length_by_byte, count)
```

Also, I removed an outdated test
accd392f4d/test/functional/plugin/lsp_spec.lua (L1950)
and tweaked the boilerplate in two other tests for reusability while keeping the final assertions the same.
accd392f4d/test/functional/plugin/lsp_spec.lua (L5704)
accd392f4d/test/functional/plugin/lsp_spec.lua (L5721)
2025-11-16 17:23:52 -08:00
Justin M. Keyes
f0294418d6 Merge #36435 vim.pack: improve default opts.load, handle src change 2025-11-16 13:21:47 -08:00
Evgeni Chasnovski
474e9e9408 fix(pack): show more informative error message if no git executable
Problem: Relaxing minimal Git version did not fully preserve previous
  behavior in case there no `git` executable. Instead it showed the same
  error as if after `vim.system({ 'does_not_exist' })`.

Solution: Show a more direct "No `git` executable" error message.
2025-11-16 22:26:19 +02:00
Evgeni Chasnovski
18e6ba90e2 docs(pack): add example workflow of how to revert after a bad update
Problem: No example workflow of how to revert after a bad update.

Solution: Add example workflow of how to revert after a bad update.

  In future this might be improved by utilizing other `vim.pack`
  features or via a dedicated function (like `vim.pack.restore()` that
  restores all installed plugins to a state from the lockfile).
2025-11-16 22:19:10 +02:00
Evgeni Chasnovski
2e533e364e feat(pack): update add() to handle source change for installed plugin
Problem: Changing `src` of an existing plugin cleanly requires manual
  `vim.pack.del()` prior to executing `vim.pack.add()` with a new `src`.

Solution: Autodetect `src` change for an existing plugin (by comparing
  against lockfile data). If different - properly delete immediately and
  treat this as new plugin installation.

  Alternative solution might be to update `origin` remote in the
  installed plugin after calling `vim.pack.update()`. Although, doable,
  this 1) requires more code; and 2) works only for Git plugins (which
  might be not the only type of plugins in the future). Automatic
  "delete and clean install" feels more robust.
2025-11-16 22:19:10 +02:00
Evgeni Chasnovski
a39171f532 fix(pack)!: make default opts.load in add() to work inside 'plugin/'
Problem: Plain `vim.pack.add()` calls (with default `opts.load`) does
  not fully work if called inside 'plugin/' runtime directory. In
  particular, 'plugin/' files of newly added plugins are not sourced.
  This is because `opts.load` is `false` during the whole startup, which
  means `:packadd!` is used (modify 'runtimepath' but not force source
  newly added 'plugin/' files).

  This use case is common due to users organizing their config as
  separate files in '~/.config/nvim/plugin/'.

Solution: Use newly added `v:vim_did_init` to decide default `opts.load`
  value instead of `v:vim_did_enter`.
2025-11-16 22:19:10 +02:00
alf171
d464dffd2f fix: make :restart respect 'confirm' option #36531
When 'confirm' is set and there are unsaved buffers,
:restart now prompts before quitting, matching the behavior of :quit.
2025-11-16 11:08:38 -08:00
Evgeni Chasnovski
e4e6605943 fix(pack): relax minimal Git version to be 2.0 #36573
Problem: Current requirement is Git>=2.36 as `--also-filter-submodules`
  flag for `git clone` was introduced there. This is problematic since
  default Git version on Ubuntu 22.04 is 2.34.

Solution: Relax minimal Git version to be (at least) 2.0 by selectively
  applying necessary flags based on the current Git version.
  As 2.0.0 was released in 2014-05-28 (almost the same age as Neovim
  project itself), it is reasonable to drop any mention and checks on
  minimal version altogether.
2025-11-16 10:27:19 -08:00
Christian Clason
e6cdb7d481 build(deps): bump uncrustify to 0.82.0 2025-11-16 12:38:54 +01:00
zeertzjq
c924d68021 test(api/server_requests_spec): fix flaky test (again) (#36570)
Use a fast API, as a deferred API request may be aborted by EOF.
2025-11-16 09:47:16 +00:00
Justin M. Keyes
39e27d64ad Merge #36322 docs 2025-11-15 22:11:57 -08:00
Justin M. Keyes
f01c212e37 docs: rework main help page 2025-11-16 00:55:28 -05:00
Justin M. Keyes
3f16037e45 docs: getpos, getregion, lsp 2025-11-15 22:47:38 -05:00
zeertzjq
30634f63e2 vim-patch:fb8ebf1: runtime(compiler): Remove version check in rustc compiler (#36568)
closes: vim/vim#18347

fb8ebf1ee0

Co-authored-by: Konfekt <Konfekt@users.noreply.github.com>
2025-11-15 23:46:08 +00:00
zeertzjq
8d72d1ceb4 vim-patch:9.1.1916: WinEnter autocommand confuses Vim when closing tabpage (#36567)
Problem:  WinEnter autocommand may confuse Vim when closing tabpage
          (hokorobi)
Solution: Verify that curwin did not change in close_others()

fixes: vim/vim#18722
closes: vim/vim#18733

61b73b89a3

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-11-15 23:18:39 +00:00
Chip Senkbeil
c123b7245c refactor(path)!: support RFC3986 in path_with_url() #36564
Problem:
Nvim does not recognize URI scheme with numeric characters. While rare, there
are URIs that contain numbers (e.g. [ed2k://](https://en.wikipedia.org/wiki/Ed2k_URI_scheme))
and characters like `+` (e.g. `svn+ssh`). I use it in
[distant.nvim](https://github.com/chipsenkbeil/distant.nvim) to support
multiple, distinct connections using `distant+1234://` as the scheme.
Otherwise, if you open a file with the same name & path on two different
machines from the same Nvim instance, their buffer names will conflict
when just using `distant://`.

Solution:
Adds full support for detecting URI scheme per
[RFC3986](https://www.rfc-editor.org/rfc/rfc3986#section-3.1)
2025-11-15 13:40:01 -08:00
zeertzjq
b3c099b1dd vim-patch:d0dd561: runtime(compiler): add biome linter (#36562)
closes: vim/vim#18685

d0dd5614db

Co-authored-by: Konfekt <Konfekt@users.noreply.github.com>
2025-11-15 11:21:19 +00:00
zeertzjq
dc682bcbcf vim-patch:9.1.1915: :breaklist accepts unprocessed arguments. (#36561)
Problem:  :breaklist accepts unprocessed arguments.
Solution: Remove EX_EXTRA flag from the Ex command definition.
          (Doug Kearns)

The command should emit an "E488: Trailing characters" error rather than
silently accept arguments.

closes: vim/vim#18746

de7049ede1

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-11-15 19:09:19 +08:00
zeertzjq
e0ac78f707 Merge pull request #36560 from zeertzjq/vim-fe24972
vim-patch: Vim syntax updates
2025-11-15 19:03:51 +08:00
zeertzjq
d1c5c11ee0 vim-patch:f46616f: runtime(vim): Update base syntax and generator, match :cd commands
Match :cd commands explicitly.

fixes: vim/vim#17964
closes: vim/vim#18736

Reported by Maxim Kim.

f46616f0c4

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-11-15 18:28:00 +08:00
zeertzjq
2fdf097fa5 vim-patch:4f19d27: runtime(vim): Update base syntax, match :prompt command args
closes: vim/vim#18732

4f19d2768a

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-11-15 18:26:56 +08:00
zeertzjq
2c9b102a9f vim-patch:fe24972: runtime(vim): Update base syntax, refine object constructor matching
Match "object" and "<" ... ">" separately with dedicated syntax groups
to allow for highlighting distinct from that generally used for types.

closes: vim/vim#18721

fe24972139

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-11-15 18:26:14 +08:00
Christian Clason
776d6442bd build(deps): bump luajit to 5c8cee3df 2025-11-15 10:38:49 +01:00
zeertzjq
d017f3c9a0 vim-patch:9.1.1914: runtime(netrw): wipes unnamed buffers (#36551)
Problem:  runtime(netrw): LocalBrowseCheck() wipes unnamed buffers when
          g:netrw_fastbrowse=0 (Carlos Falgueras García)
Solution: Check that bufname() is not empty

fixes: vim/vim#18740
closes: vim/vim#18741

384685fade

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-11-13 23:59:35 +00:00
zeertzjq
16e9c21d8d vim-patch:9.1.1913: Error message with :unlet! and non-existing dictionary item (#36549)
Problem:  Error message with :unlet! and non-existing dictionary item
          (Coacher)
Solution: Set GLV_QUIET when using unlet with bang attribute

fixes: vim/vim#18516
closes: vim/vim#18734

b8119920eb

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-11-13 23:32:42 +00:00
zeertzjq
1a5f0ba201 vim-patch:eb732ed: runtime(doc): Wrap overlength lines in uganda.txt (#36550)
Wrap overlength lines and normalise URL indentation.

closes: vim/vim#18737

eb732ed26d

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-11-13 23:28:34 +00:00
Christian Clason
31d5730995 build(deps): bump utf8proc to v2.11.1 2025-11-13 22:07:15 +01:00
Justin M. Keyes
72110da567 Merge #36468 from echasnovski/pack-consistency
`vim.pack` consistency improvements: full hashes, state->revision, buffer URI name
2025-11-13 02:00:05 -05:00
Jan Edmund Lazo
d2517acdc5 fix(vim-patch.sh): 'vim-patch:<hash>' token for 'non-patch' commits #36534
Vim may tag runtime-only commits without the 2-liner version.c change.
Inspect both tag and commit message to "guess" if it the patch
should go to version.c or not.
2025-11-12 20:46:22 -08:00
Toby She
4dd9137215 fix(lsp): reuse_win prioritizes windows/tabs currently displayed #36486
Problem: reuse_win will always jump to the first window containing the
target buffer rather even if the buffer is displayed in the current
window/tab

Solution: check to see if the buffer is already displayed in the
current window or any window of the current buffer
2025-11-12 20:43:25 -08:00
Andrey Starodubtsev
4143bcbd37 fix(tutor): escape tutor filename #36539
Since NeoVim is installed in `Program Files` directory by default, path
to tutor filename must be quoted before passing to `:drop`.
2025-11-12 19:27:24 -08:00
zeertzjq
756043760b vim-patch:9.1.1909: filetype: .mom files recognized as nroff files (#36543)
Problem:  filetype: .mom files recognized as nroff files
Solution: Detect *.mom files as groff filetype instead
          (Callum Andrew)

Reference:
- mom macros are written specifically for groff:
  https://www.schaffter.ca/mom/

closes: vim/vim#18718

23e12c0b7e

Co-authored-by: Callum Andrew <dev@candrew.net>
2025-11-13 00:22:11 +00:00
Maria Solano
5582005ac7 fix(docs): add --clean arg to LSP bug report (#36530) 2025-11-12 19:07:17 -05:00
zeertzjq
fbcdbd458f vim-patch:e9d296e: runtime(erlang): recognize -if/-elif as erlangPreCondit in syntax script (#36542)
The -if(Condition)/-elif(Condition) are compiler macros that evaluate
the following lines only if Condition evaluates to true.  This patch
enables syntax highlighting for these macros.

https://www.erlang.org/doc/system/macros.html#conditional-compilation

closes: vim/vim#18729

e9d296e52a

Co-authored-by: Vadim Yanitskiy <fixeria@osmocom.org>
2025-11-12 23:45:50 +00:00
zeertzjq
1571fde23e vim-patch:9ab6a22: runtime(doc): Improve :help :ls description formatting (#36541)
Quote the special buffer names for consistency (see :help bufname()) and
so that they're not incorrectly highlighted as optional command
arguments.

closes: vim/vim#18730

9ab6a22c90

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-11-12 23:04:06 +00:00
Yochem van Rosmalen
94ae48ff29 docs(undotree): rename help tag #36497
Problem: confusing that there is the tag `undo-tree` (the Vim
implementation) and `undotree` (the Lua plugin for visualization).

Solution: rename tag to undotree-plugin. Mention the plugin in the docs of
|undotree|.
2025-11-12 09:00:27 -08:00
Christian Clason
4110e6730a build(deps): bump luajit to eba91fceb 2025-11-12 16:08:15 +01:00
bfredl
d84e786112 fix(tests): use correct signature for unpacker_teardown() 2025-11-12 14:19:06 +01:00
Christian Clason
ce8842998b build(deps): bump luajit to 5c647754a 2025-11-12 14:19:06 +01:00
Christian Clason
587a933cea build(deps): bump luajit to eba91fceb 2025-11-12 14:19:06 +01:00
zeertzjq
8bce9342d1 fix(vim-patch.sh): don't treat 1-file runtime-only patch as N/A (#36525)
If the patch in question does not change src/version.c, `git log -1`
instead shows the previous patch that changes src/version.c, which
causes 1-file runtime-only patches to be considered N/A.

Check that the remaining file is src/version.c to fix this problem.
Also use `git diff-tree` instead of `git log -1` for version.c.
2025-11-12 14:45:20 +08:00
Andrey Starodubtsev
b15b22fc73 fix(trust): :trust command on Windows #36509
`:trust` command calculated SHA-256 on file content reading it as a
text. While it doesn't matter on Unices, on Windows hash was calculated
incorectly. SHA-256 for buffer content was calculated fine though.

After this fix hashes in `%LOCALAPPDATA%/nvim-data/trust` are the same
as in output of `sha256sum -t`.
2025-11-11 21:57:09 -08:00
Maria Solano
653871da1b fix(lsp): check nvim.lsp.enable before doautoall #36518 2025-11-11 21:04:31 -08:00
Maria Solano
1bc85d29c1 fix(lsp): check for non-nil buffer state on reset (#36519) 2025-11-11 17:47:33 -08:00
zeertzjq
3606b74d24 vim-patch:f85951f: runtime(css): improve cssBoxProp matches (#36528)
closes: vim/vim#18717

f85951fee0

Co-authored-by: Neil Lambert <nlambert@pm.me>
2025-11-12 08:23:35 +08:00