19134 Commits

Author SHA1 Message Date
65170e8dad fix(api): wrong return value with reverse range + overlap #32956
Problem:  When iterating in reverse with {start} > {end} in
          `nvim_buf_get_extmarks()`, marks that overlap {start} and are
          greater than {end} are included in the return value twice.
          Marks that overlap {end} and do not overlap {start} are not
          not included in the return value at all. Marks are not
          actually returned in a meaningful "traversal order".

Solution: Rather than actually iterating in reverse, (also possible but
          requires convoluted conditions and would require fetching
          overlapping marks for both the {start} and {end} position,
          while still ending up with non-traversal ordered marks),
          iterate normally and reverse the return value.
2025-04-21 16:18:03 -07:00
28e31f5d3d feat(options): default statusline expression #33036
Problem:
Default 'statusline' is implemented in C and not representable as
a statusline expression. This makes it hard for user configs/plugins to
extend it.

Solution:
- Change the default 'statusline' slightly to a statusline expression.
- Remove the C implementation.
2025-04-21 15:05:34 -07:00
ab72799841 fix(coverity/530026,530028): free resources on early exit in nlua_exec_file #33502
Problem: The stdin reading path does not close `stdin_dup` or free `sb`
upon early exit.

Solution: Free the resources before returning false.
2025-04-21 08:43:38 -07:00
986b92eb07 fix(messages): single msg_show event for multiple :set options #33555
Problem:  :set opt1 opt2... emits a separate event for each option.

Solution: Only set the kind for the first printed option value.
2025-04-21 07:51:47 -07:00
7ba0f623d7 feat(ui): avoid setting 'cmdheight' with vim.ui_attach()
Problem:  We allow setting 'cmdheight' to 0 with ext_messages enabled
          since b72931e7. Enabling ext_messages with vim.ui_attach()
          implicitly sets 'cmdheight' to 0 for BWC. When non-zero
          'cmdheight' is wanted, this behavior make it unnecessarily
          hard to keep track of the user configured value.
Solution: Add set_cmdheight to vim.ui_attach() opts table that can be
          set to false to avoid setting 'cmdheight' to 0.
2025-04-21 15:38:23 +02:00
7ba043f0f3 feat(api): add "max_height" argument to nvim_win_text_height (#32835)
Useful to e.g. limit the height to the window height, avoiding unnecessary
work. Or to find out how many buffer lines beyond "start_row" take up a
certain number of logical lines (returned in "end_row" and "end_vcol").
2025-04-21 19:48:26 +08:00
98ec3fdf74 vim-patch:9.1.1328: too many strlen() calls in indent.c (#33563)
Problem:  too many strlen() calls in indent.c
Solution: refactor indent.c slightly and remove strlen() calls
          (John Marriott)

closes: vim/vim#17156

eac45c558e

Co-authored-by: John Marriott <basilisk@internode.on.net>
2025-04-21 19:16:29 +08:00
4b02d1f6f6 fix(gen_vimdoc): unnecessary assert for non-source files
Problem:  The presence of non-source files breaks `make doc`.
Solution: Replace assert with if statement to skip non-matching files.
2025-04-21 10:15:33 +02:00
d3cded796c vim-patch:9.1.1326: invalid cursor position after 'tagfunc' (#33556)
Problem:  invalid cursor position after 'tagfunc'
          (gandalf4a)
Solution: call check_cursor() after executing the 'tagfunc'

9919085491

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-04-20 23:04:02 +00:00
c7d8812ca7 vim-patch:2398460: runtime(doc): clarify 'includeexpr' is not used for <cfile> (#33540)
fixes: vim/vim#17139

2398460232

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-04-19 19:10:43 +08:00
7380f8ec71 vim-patch:cb3b752: runtime(doc): clarify "nearest" value for 'completeopt' (#33534)
closes: vim/vim#17146

cb3b752f95

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-04-19 08:42:48 +08:00
dca8b3fede vim-patch:9.1.1322: small delete register cannot paste multi-line correctly (#33531)
Problem:  small delete register cannot paste multi-line correctly
          (after v8.2.2189)
Solution: caused by 032a2d050b82b146d70d6ff714838ee62c07d8ad, so make
          this logic handle charwise only (phanium)

closes: vim/vim#17151

7e93d4c617
2025-04-19 08:01:51 +08:00
c67398d31b vim-patch:9.1.1319: Various typos in the code, issue with test_inst_complete.vim (#33527)
Problem:  Various typos in the code, redundant and strange use of
          :execute in test_ins_complete.vim (after 9.1.1315).
Solution: Fix typos in the code and in the documentation, use the
          executed command directly (zeertzjq).

closes: vim/vim#17143

98800979dc

Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
2025-04-19 07:23:20 +08:00
9397fdafe1 Merge pull request #33519 from zeertzjq/vim-9.1.1314
vim-patch:9.1.{1314,1318}: max allowed string width too small
2025-04-19 07:22:39 +08:00
Au.
44f1dbee0d fix(spell): save spell files to stdpath('data')/site/spell #33528 2025-04-18 08:56:20 -07:00
0251a25541 vim-patch:9.1.1318: tests: test_format fails
Problem:  tests: test_format fails (after 9.1.1314).
Solution: Increase the string size.  Add missing test_format.res in
          NEW_TESTS_RES (zeertzjq).

closes: vim/vim#17144

e9a27ef373
2025-04-18 17:00:34 +08:00
ccdb37b075 vim-patch:9.1.1314: max allowed string width too small
Problem:  max allowed string width too small
Solution: increased MAX_ALLOWED_STRING_WIDTH from 6400 to 1MiB
          (Hirohito Higashi)

closes: vim/vim#17138

06fdfa11c5

Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
Co-authored-by: John Marriott <basilisk@internode.on.net>
2025-04-18 16:58:10 +08:00
8e5ef60540 vim-patch:3dca512: runtime(vim): Update base-syntax and generator, only match valid predefined variables
- Only match valid predefined and option variables.
- Match scope dictionaries.
- Highlight scope prefixed variables as a scope dictionary accessor. The
  vimVarScope syntax group can be linked to vimVar to disable this.
- Include support for Neovim-only predefined and option variables.

Temporary collateral damage - scope dictionaries match instead of keys
in dictionary literals.

closes: vim/vim#16727

3dca512939

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-04-18 14:31:34 +08:00
e2e6c159d3 vim-patch:9.1.1317: noisy error when restoring folds from session fails
Problem:  noisy error when restoring folds from session fails
Solution: ignore errors silently when sourcing session file.
          (Igor Lacerda)

fixes: vim/vim#15813
closes: vim/vim#17127

cca5dea76e

Co-authored-by: Igor Lacerda <igorlfs@ufmg.br>
2025-04-18 08:11:41 +08:00
b4c759716a vim-patch:9.1.1315: completion: issue with fuzzy completion and 'completefuzzycollect' (#33520)
Problem:  chain complete does not work when 'cot' includes fuzzy
          and 'completefuzzycollect' collects wrong next word.
          (Konfekt)
Solution: compl_startpos is not set correctly, remove next word check
          in search_for_fuzzy_match (glepnir).

fixes vim/vim#17131
fixes vim/vim#16942
closes: vim/vim#17136

cfe502c575

Co-authored-by: glepnir <glephunter@gmail.com>
2025-04-18 07:22:50 +08:00
2fcdeb0128 refactor(lsp): gen_lsp
- Simplify usage:
  - Instead of `nvim -l src/gen/gen_lsp.lua gen` now just
    run `./src/gen/gen_lsp.lua`

- Removed `--methods` and `--capabilities` options.

- Improved rendering code in various areas.
2025-04-17 15:44:46 +01:00
d7e0d46ffa feat(lsp): use stricter types for methods
This change modifies gen_lsp.lua so alias types are generated for
various types of lsp methods to distinguish between notifications
and requests:
 - vim.lsp.protocol.Method.ServerToClient.Request
 - vim.lsp.protocol.Method.ServerToClient.Notification
 - vim.lsp.protocol.Method.ClientToServer.Request
 - vim.lsp.protocol.Method.ClientToServer.Notification

 These types are then used instead of `string` where appropriate.
2025-04-17 11:40:45 +01:00
f9f6dc4262 vim-patch:9.1.1310: completion: redundant check for preinsert effect (#33505)
Problem:  Duplicate check for preinsert effect, particularly for Ctrl_w
          and Ctrl_U.
Solution: Remove the specific check for Ctrl_w and Ctrl_U to eliminate
          redundancy (glepnir).

closes: vim/vim#17129

1c2b258250

Co-authored-by: glepnir <glephunter@gmail.com>
2025-04-16 23:44:12 +00:00
54d6055098 vim-patch:9.1.1306: completion menu rendering can be improved
Problem:  Parts of the popup menu were rendered twice when the popup was
          at maximum width because the truncation flag was being set too
          liberally.
Solution: Make the truncation condition more precise by only setting it
          when there's exactly one character of space remaining
          (glepnir).

closes: vim/vim#17108

32f2bb6e1e

Co-authored-by: glepnir <glephunter@gmail.com>
2025-04-17 06:46:34 +08:00
6e5671b00d vim-patch:9.1.1296: completion: incorrect truncation logic
Problem:  completion: incorrect truncation logic (after: v9.1.1284)
Solution: replace string allocation with direct screen rendering and
          fixe RTL/LTR truncation calculations (glepnir)

closes: vim/vim#17081

d4dbf822dc

Co-authored-by: glepnir <glephunter@gmail.com>
2025-04-17 06:46:34 +08:00
1c723b2e6f vim-patch:9.1.1284: not possible to configure pum truncation char
Problem:  not possible to configure the completion menu truncation
          character
Solution: add the "trunc" suboption to the 'fillchars' setting to
          configure the truncation indicator (glepnir).

closes: vim/vim#17006

b87620466c

Co-authored-by: glepnir <glephunter@gmail.com>
2025-04-17 06:46:34 +08:00
fd973c0a4e fix(env.c): drop envmap, free os_getenv() result #32683
Problem:
vim.uv.os_setenv gets "stuck" per-key. #32550
Caused by the internal `envmap` cache. #7920

    :echo $FOO  <-- prints nothing
    :lua vim.uv.os_setenv("FOO", "bar")
    :echo $FOO  <-- prints bar (as expected)
    :lua vim.uv.os_setenv("FOO", "fizz")
    :echo $FOO  <-- prints bar, still (not expected. Should be "fizz")
    :lua vim.uv.os_unsetenv("FOO")
    :echo $FOO  <-- prints bar, still (not expected. Should be nothing)
    :lua vim.uv.os_setenv("FOO", "buzz")
    :echo $FOO  <-- prints bar, still (not expected. Should be "buzz")

Solution:
- Remove the `envmap` cache.
  - Callers to `os_getenv` must free the result.
- Update all call-sites.
- Introduce `os_getenv_noalloc`.
- Extend `os_env_exists()` the `nonempty` parameter.
2025-04-16 03:36:07 -07:00
7432781e71 fix(mouse): do not fetch clipboard twice when pasting with middle button #33494
Problem:
When doing paste operation mouse code tries to figure out it it is
dealing with a multi-line register by calling yank_register_mline(),
which fetches register data and checks its type. Later the code calls
either do_put() or insert_reg() which fetch register data again. This is
unnoticeable when working with internal neovim registers, but starts
hurting when dealing with clipboards, especially remote one (forwarded X
or socket tunnel or similar).

Solution:
Change yank_register_mline() to also return pointer to the
register structure prepared for pasting, and insert_reg() to accept
such register pointer and use it if it is supplied. do_put() already
has support for accepting a register structure to be used for pasting.

Fixes #33493
2025-04-16 03:08:41 -07:00
07d06dd396 docs(man): fix mandoc warnings, prettify #33484
Problem:
mandoc warnings:

    $ cd src/man
    $ mandoc -Tlint -Wall nvim.1
    mandoc: nvim.1:83:95: STYLE: input text line longer than 80 bytes: Remaining arguments ...
    mandoc: nvim.1:251:8: WARNING: undefined escape, printing literally: \+
    mandoc: nvim.1:283:46: WARNING: new sentence, new line
    mandoc: nvim.1:330:115: STYLE: input text line longer than 80 bytes: When supplied with -...
    mandoc: nvim.1:44:2: WARNING: skipping paragraph macro: Pp before Bl
    mandoc: nvim.1:114:7: STYLE: no blank before trailing delimiter: Ic :w!
    mandoc: nvim.1:313:12: STYLE: no blank before trailing delimiter: Ic :source!

Solution:
- wrap text lines (80 at maximum)
- new sentence, new line
- fix inconsistency in macro usage

see
- mandoc_char(7)
- mandoc_man(7)
- mandoc_mdoc(7)

Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
2025-04-16 03:03:36 -07:00
1de276bbcd vim-patch:9.1.1308: completion: cannot order matches by distance to cursor (#33491)
Problem:  During insert-mode completion, the most relevant match is often
          the one closest to the cursor—frequently just above the current line.
          However, both `<C-N>` and `<C-P>` tend to rank candidates from the
          current buffer that appear above the cursor near the bottom of the
          completion menu, rather than near the top. This ordering can feel
          unintuitive, especially when `noselect` is active, as it doesn't
          prioritize the most contextually relevant suggestions.

Solution: This change introduces a new sub-option value "nearest" for the
          'completeopt' setting. When enabled, matches from the current buffer
          are prioritized based on their proximity to the cursor position,
          improving the relevance of suggestions during completion
          (Girish Palya).

Key Details:
- Option: "nearest" added to 'completeopt'
- Applies to: Matches from the current buffer only
- Effect: Sorts completion candidates by their distance from the cursor
- Interaction with other options:
  - Has no effect if the `fuzzy` option is also present

This feature is helpful especially when working within large buffers where
multiple similar matches may exist at different locations.

You can test this feature with auto-completion using the snippet below. Try it
in a large file like `vim/src/insexpand.c`, where you'll encounter many
potential matches. You'll notice that the popup menu now typically surfaces the
most relevant matches—those closest to the cursor—at the top. Sorting by
spatial proximity (i.e., contextual relevance) often produces more useful
matches than sorting purely by lexical distance ("fuzzy").

Another way to sort matches is by recency, using an LRU (Least Recently Used)
cache—essentially ranking candidates based on how recently they were used.
However, this is often overkill in practice, as spatial proximity (as provided
by the "nearest" option) is usually sufficient to surface the most relevant
matches.

```vim
set cot=menuone,popup,noselect,nearest inf

def SkipTextChangedIEvent(): string
    # Suppress next event caused by <c-e> (or <c-n> when no matches found)
    set eventignore+=TextChangedI
    timer_start(1, (_) => {
        set eventignore-=TextChangedI
    })
    return ''
enddef

autocmd TextChangedI * InsComplete()

def InsComplete()
    if getcharstr(1) == '' && getline('.')->strpart(0, col('.') - 1) =~ '\k$'
        SkipTextChangedIEvent()
        feedkeys("\<c-n>", "n")
    endif
enddef

inoremap <silent> <c-e> <c-r>=<SID>SkipTextChangedIEvent()<cr><c-e>

inoremap <silent><expr> <tab>   pumvisible() ? "\<c-n>" : "\<tab>"
inoremap <silent><expr> <s-tab> pumvisible() ? "\<c-p>" : "\<s-tab>"
```

closes: vim/vim#17076

b156588eb7

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-04-16 02:48:08 +00:00
b0f97177d4 vim-patch:9.1.1305: completion menu active after switching windows/tabs (#33488)
Problem:  When switching to another window or tab page while the
          completion menu is active, the menu stays visible, although it
          belongs to the previous window/tab page context (Evgeni
          Chasnovski).
Solution: Track the window and tab page where completion started. Detect
          changes in the main editing loop and cancel completion mode if
          the current window or tab page differs from where completion
          started.

fixes: vim/vim#17090
closes: vim/vim#17101

cf7f01252f

Co-authored-by: glepnir <glephunter@gmail.com>
2025-04-16 07:50:08 +08:00
d2d1b5e944 vim-patch:9.1.1303: missing out-of-memory check in linematch.c (#33487)
Problem:  missing out-of-memory check in linematch.c
Solution: return early in case of memory allocation failure, move the
          pow() calculation ouside of the for() loop
          (John Marriott)

closes: vim/vim#17118

2137710b43

Co-authored-by: John Marriott <basilisk@internode.on.net>
2025-04-16 06:47:51 +08:00
f29856d034 feat(ui): include compositor info with multigrid
Provide compositor information, like composition index and absolute
position.
2025-04-15 10:52:57 +02:00
9272dc9597 vim-patch:9.1.1300: wrong detection of -inf (#33474)
Problem:  wrong detection of -inf
Solution: correctly compare 4 characters and not 3
          (John Marriott)

closes: vim/vim#17109

10f69298b4

Co-authored-by: John Marriott <basilisk@internode.on.net>
2025-04-15 08:58:00 +08:00
3341ab0776 fix(marks): clamp conceal_lines corrected line number #33464
Problem:  Line number corrected for conceal_lines may be set beyond eob
          when the last buffer line is concealed, causing ml_get errors.

Solution: Avoid setting line number beyond eob.
2025-04-14 04:19:07 -07:00
aa47c8efa9 vim-patch:9.1.1297: Ctrl-D scrolling can get stuck #33453
Problem:  cursor_correct() calculates a valid cursor position which
	  is later changed by update_topline() and causes Ctrl-D
          scrolling to be stuck (Daniel Steinberg, after v9.1.0258).
Solution: Update the valid cursor position before validating topline
          (Luuk van Baal).

c98250377d
2025-04-14 04:10:36 -07:00
51caf0a3af fix(completion): avoid freeing uninitialized value (#33459) 2025-04-14 05:02:58 +00:00
fd76646a95 vim-patch:9.1.1298: define_function() is too long (#33457)
Problem:  define_function() is too long
Solution: refactor and split up into smaller functions
          (Yegappan Lakshmanan)

closes: vim/vim#17105

3956c5b53c

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2025-04-14 02:07:36 +00:00
0f4623d346 vim-patch:f4b1a60: runtime(doc): update options.txt and clarify 'wildmode' further
related: vim/vim#17100

f4b1a60dd1

Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Girish Palya <girishji@gmail.com>
2025-04-14 08:22:29 +08:00
52be3b14e3 vim-patch:eded336: runtime(doc): Improve 'wildmode' setting desciption
closes: vim/vim#17100

eded33621b

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-04-14 08:21:33 +08:00
2f8fb4f28a fix(mouse): mouseclick after conceal_lines is miscalculated #33451
Problem:  Computed buffer line for mouse position does not take into
          account concealed lines on the reached row.

Solution: Adjust for concealed lines at the end of the loop computing
          the buffer position.
2025-04-13 14:30:24 -07:00
0814086a23 docs: misc (#33093)
Co-authored-by: Jx <JxJxxJxJ@github.com>
Co-authored-by: Richard Dzenis <richard@dzenis.dev>
Co-authored-by: Shixian Sheng <shixian_sheng-2@protonmail.com>
Co-authored-by: Sourabh Kumar <sourabh7.tech@gmail.com>
Co-authored-by: Yegor Yefremov <yegorslists@googlemail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2025-04-13 07:41:54 +08:00
60af1a1db2 fix(treesitter): clear parse options state #33437
Apparently after parsing with options in tree-sitter, the options data
persists in the parser object, and thus successive calls to
`ts_parser_parse()` will act like `ts_parser_parse_with_options()`. This
is problematic because `languagetree.lua` makes coroutine-environment
assumptions based on if a nullptr has been returned by the parser
function. This commit makes it so that the parse options state is reset
upon a regular parse (would be nice if this was done upstream).

Fixes #33277
2025-04-12 15:51:29 -07:00
74ca73d545 docs: misc #33330 2025-04-12 10:21:03 -07:00
d77d961b35 feat(defaults): shelltemp=false #33012
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2025-04-12 08:24:42 -07:00
4a706a7092 fix(column): don't count signs on lines beyond eob #33410
Problem:  Computed previous buffer line count may be beyond end of
          buffer. This results in signs being removed from `b_signcols`
          that were never included in it, tripping an assertion.

Solution: Store the previous line count as it was before appending or
          deleting lines. Use it to clamp the edited region when
          clearing signs before a splice, after which it is reset.
2025-04-11 04:46:55 -07:00
064ff74cdb fix(marks): wrong display after inserting/deleting lines #33389
Problem:  Lines to/from which virt_lines or inline virt_text may have
          moved are left valid. Similarly the modified region may be
          too small to account for moved decorations after inserting
          or deleting lines. `redrawOneLine()` can be replaced with
          a call to `changed_lines_redraw_buf()`.

Solution: Invalidate the line after a change if there is virt_lines, or
          inline virt_text in the buffer with 'wrap' enabled. Extend the
          modified region for inserted or deleted lines if there may be
          decorations in the buffer. Remove `redrawOneLine()`.
          Simplify the logic for `changed_lines_invalidate_win()`.

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2025-04-11 04:36:49 -07:00
c73a827564 vim-patch:9.1.1288: Using wrong window in ll_resize_stack() (#33397)
Problem:  Using wrong window in ll_resize_stack()
          (after v9.1.1287)
Solution: Use "wp" instead of "curwin", even though they are always the
          same value.  Fix typos in documentation (zeertzjq).

closes: vim/vim#17080

b71f1309a2
2025-04-09 07:40:55 +08:00
jyn
3647b821ea fix(editor): respect [+cmd] when executing :drop #33339
Problem:
Normally, `:drop +41 foo.txt` will open foo.txt with the cursor on line
41. But if foo.txt is already open, it instead is a no-op, even if the
cursor is on a different line.

Steps to reproduce:

    nvim --clean foo.txt
    :drop +30 foo.txt

Solution:
Handle +cmd in ex_drop().
2025-04-08 05:54:32 -07:00
5b1561bb71 fix(display): scroll redrawing doesn't account for virt_lines above fold #33374
Problem:  Logic computing the new height of the modified area does not
          take into account virtual lines attached to a folded line.

Solution: Remove `hasFolding()` branch and let `plines_win_full()` do its job.
2025-04-08 05:47:18 -07:00