Commit Graph

212 Commits

Author SHA1 Message Date
f5b5f2095e refactor(tests): lint decorations_spec, float_spec, multigrid_spec #33274
Problem:
decorations_spec.lua, float_spec.lua, multigrid_spec.lua are not
auto-formatted.

Solution:
Add a special `formatlua2` cmake target, which invokes `stylua` with
an alternative `.stylua2.toml` config.
2025-05-06 18:00:20 -07:00
fc2dee1736 feat(messages): cleanup Lua error messages
"Error" in error messages is redundant. Just provide the context, don't
say "Error ...".
2025-05-04 11:22:57 -04:00
97a6259442 fix(display): adjust setting winline info for concealed lines (#33717)
Problem:  Wrong winline info after partial redraw. Setting
          `conceal_cursor_used` is unnecessarily spread out.
Solution: Rather than adjusting `wl_lastlnum` for the previous
          winline, adjust it when setting the current winline.
          Set `conceal_cursor_used` when the current window is redrawn.
2025-05-01 09:51:51 +02: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
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
ca16b54c86 fix(decor): enable decoration provider in on_start #33337
Problem:  An on_win-disabled decoration provider is left disabled for
          the on_buf callback during the next redraw (if the provider
          does not subscribe to on_end).

Solution: Move re-activation of the provider from after the on_end
          callback to before the on_start callback.
2025-04-07 03:58:18 -07:00
7e8b7bba21 fix(display): wrong cursor column with 'concealcursor' = "n" and virt_text (#33218)
Problem:  Inline virtual text placed in a decor provider callback
          invalidates `w_virtcol`, which must be valid for `win_line()`.
Solution: Call `validate_virtcol()` after "line" decor provider callbacks.
2025-04-01 07:56:36 +02:00
32325a66ca fix(move): adjust for concealed lines above topline after scrolling up (#33211)
Problem:  Scrolling up does not adjust `w_topline` for concealed lines
          directly above it, resulting in (non-visual) asymmetry when
          scrolling up/down.
Solution: Adjust `w_topline` for concealed lines after scrolling up.
2025-04-01 07:56:16 +02:00
ce0c0c31a0 fix(display): scroll logic does not take into account concealed topline (#33054) 2025-03-27 12:51:57 +01:00
958df63606 test(log): use tempfile for expected error logs #33017 2025-03-23 16:12:50 -07:00
c908c2560d fix(log): unify error messages for vim.ui_attach/decor providers #33005
Problem:  Error messages that cause a vim.ui_attach() namespace to
          detach are not visible in the message history. Decoration
          provider and vim.ui_attach error messages are dissimilar.
Solution: Emit vim.ui_attach() errors as an actual message in addition
          to logging it. Adjust error message format.
2025-03-21 03:05:01 -07:00
d6653e1cc9 fix(marks): ensure decor is removed with proper range (#32973)
Problem:  Paired mark whose end is in front of its start should not have
          its decor removed (as fixed by 72f630f9), but may still need to
          have its range redrawn.
Solution: Still call `buf_decor_remove()` but ensure it is not called with
          an inverse range when `extmark_del()` is called on an end mark.
2025-03-19 10:00:42 +00:00
72f630f92d fix(marks): issues with invalid marks and marks beyond eob (#32862)
Problem:  Marks that go beyond the end of the buffer, and paired marks
          whose end is in front of its start mark are added to and
          removed from the decor. This results in incorrect tracking
          of the signcolumn.
Solution: Ensure such marks are not added to and removed from the decor.
2025-03-16 12:15:50 +01:00
8da59060c6 fix(marks): mark winline as invalid if change is in a concealed line (#32766)
Code that checks whether a `w_lines` entry has become invalid due to
a change in a folded line should now also check for concealed lines.
2025-03-07 16:21:20 +01:00
b31132f1c1 feat(defaults): jump between :terminal shell prompts with ]]/[[ #32736 2025-03-07 05:45:34 -08:00
7371abf755 fix(marks): wrong winline info for concealed line with below virt line (#32747)
Problem:  Skipping over a concealed line for which `win_line()`
          _should_ be called because it has `virt_lines_above = false`
          lines associated with it.
Solution: Don't include such a line in `wl_lastlnum` from the line
          above.
2025-03-06 16:36:10 +01:00
f25dd7a8d5 fix(display): correctly store winline info for concealed lines (#32656)
Off-by-one error in storing last line number for a logical line.
2025-02-27 13:15:47 +01:00
f58e7d5fac feat(marks): add conceal_lines to nvim_buf_set_extmark()
Implement an extmark property that conceals lines vertically.
2025-02-25 13:09:01 +01:00
cdedfc3743 fix(marks): truncate double-width inline virt_text consistently (#32560)
- Fix wrong cursor position with 'listchars' "precedes".
- Always show the '<' truncation character.
2025-02-21 22:35:10 +00:00
2e0a563828 test: adjust multibyte virtual text test (#32557)
Having more chars after a double-width char makes it easier to spot the
bug where truncating it causes the pending chars to be lost.
2025-02-21 20:57:41 +08:00
51cf84daf9 feat(marks): virtual lines support horizontal scrolling (#32497)
Add a new field `virt_lines_overflow` that enables horizontal scrolling
for virtual lines when set to "scroll".
2025-02-20 21:47:12 +08:00
906ad04ddd fix(marks): handle composing in inline virt_text with 'nowrap' (#32477) 2025-02-16 22:54:32 +08:00
8452032554 fix(marks): handle double-with inline virt_text with 'nowrap' (#32476) 2025-02-16 14:05:13 +00:00
931ee5591f feat(extmarks): virtual text can be right-aligned, truncated #31921
Problem: Right aligned virtual text can cover up buffer text if virtual
text is too long

Solution: An additional option for `virt_text_pos` called
`eol_right_align` has been added to truncate virtual text if it would
have otherwise covered up buffer text. This ensures the virtual text
extends no further left than EOL.
2025-01-24 19:57:45 -08:00
4cced601c8 feat(extmark): stack multiple highlight groups in hl_group
This has been possible in the "backend" for a while but
API was missing.

Followup: we will need a `details2=true` mode for `nvim_get_hl_id_by_name`
to return information in a way forward compatible with even further
enhancements.
2025-01-21 12:00:24 +01:00
33ff546b50 fix(decoration): fix crash when on_lines decor provider modifies marktree
If a "on_lines" callback changes the structure of the marktree, the
iterator (which is used for an entire window viewport) might now
point to invalid memory. Restore the iterator to the beginning of the
line in this case.

fixes #29484
2025-01-09 11:17:42 +01:00
433b342baa feat(ui): sign/statuscolumn can combine highlight attrs #31575
Problem:
Since e049c6e4c0, most statusline-like UI elements can combine
highlight attrs, except for sign/statuscolumn.

Solution:
Implement for sign/statuscolumn.
2024-12-14 10:21:50 -08:00
e61228a214 fix(tests): needing two calls to setup a screen is cringe
Before calling "attach" a screen object is just a dummy container for
(row, col) values whose purpose is to be sent as part of the "attach"
function call anyway.

Just create the screen in an attached state directly. Keep the complete
(row, col, options) config together. It is still completely valid to
later detach and re-attach as needed, including to another session.
2024-11-14 12:40:57 +01:00
376de1483e fix(drawline): correct highlight priority with Visual selection (#30706) 2024-10-08 06:24:36 +08:00
34ded4d97b fix(decor): exclude invalid marks from meta total
Problem:  Marktree meta count still includes invalidated marks, making
          guards that check the meta total ineffective.
Solution: Revise marktree metadata when in/revalidating a mark.
2024-09-04 15:13:12 +02:00
cfdf68a7ac feat(mbyte): support extended grapheme clusters including more emoji
Use the grapheme break algorithm from utf8proc to support grapheme
clusters from recent unicode versions.

Handle variant selector VS16 turning some codepoints into double-width
emoji. This means we need to use ptr2cells rather than char2cells when
possible.
2024-08-30 11:49:09 +02:00
a8fbe1d409 fix(decor): don't use separate DecorSignHighlight for url (#30096) 2024-08-20 08:20:19 +08:00
0dfcf3fe12 fix(plines): don't count invalidated virt text in char size (#29863)
Also:
- Remove mt_end() and MT_FLAG_DECOR_VIRT_TEXT_INLINE checks, as they are
  already checked by marktree_itr_check_filter().
- Move ns_in_win() to the last check in decor_redraw_col().
2024-07-26 02:01:12 +00:00
5af9c065ad fix(decor): don't draw invalidated virtual lines (#29858) 2024-07-26 09:04:17 +08:00
35b35cb93c vim-patch:9.1.0601: Wrong cursor position with 'breakindent' when wide char doesn't fit (#29793)
Problem:  Wrong cursor position with 'breakindent' when a double-width
          character doesn't fit in a screen line (mikoto2000)
Solution: Include the width of the 'breakindent' properly.
          (zeertzjq)

fixes: vim/vim#15289
closes: vim/vim#15290

b5d6b5caac
2024-07-19 03:54:42 +00:00
f3632e14e3 feat: get/set namespace properties #28728
ref https://github.com/neovim/neovim/pull/28432
ref https://github.com/neovim/neovim/issues/28469
2024-06-07 08:33:40 -07:00
f2083bd55c fix(column): crash with 'signcolumn' set to "number" (#29003)
Problem:  Numberwidth may depend on number of signs with text in the
          buffer and is not handled correctly for extmark signs.
Solution: Move legacy sign code for changed numberwidth so that it is
          handled properly for legacy and extmark signs alike.
2024-06-01 18:10:35 +08:00
ad191be65e feat(signs)!: place higher-priority signs from the left #27781
Problem:
Higher-priority signs may be hidden by lower-priority signs.

Solution:
Place higher-priority signs from the left.

Example:

    nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='H', priority=1})
    nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='W', priority=2})
    nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='E', priority=3})

Before:

            |     |
          H | W E |
          ^ |     |
Not visible

After:

  |     |
  | E W | H
  |     | ^
          Not visible

Fixes #16632
2024-05-21 09:21:42 -07:00
97c7646501 refactor(api): nvim_win_xx_ns are EXPERIMENTAL
Problem:
The nvim_win_xx_ns function family introduced in ba0370b1d7
needs more bake-time. Currently it's narrowly defined for windows, but
other scopes ("buffer") and features are likely in the future.

Solution:
- Rename the API with double-underscore to mark it as EXPERIMENTAL.

TODO/FUTURE:
- Rename and change the signature to support more than just "window"
  scope, and for other flexibility.
- Open question: we could choose either:
  - "store scopes on namespaces", or
  - "store namespaces on scopes (w:/b:/…)"
2024-05-12 23:53:24 +02:00
8f0a166da4 refactor(api): rename nvim_win_remove_ns
Problem:
nvim_win_remove_ns does not follow `help dev-naming` API naming conventions.

Solution:
Rename it.
2024-05-12 23:41:00 +02:00
0b8a72b739 revert: "feat(extmarks): subpriorities (relative to declaration order) (#27131)" (#28585)
This reverts commit 15e77a56b7.

Subpriorities were added in https://github.com/neovim/neovim/pull/27131
as a mechanism for enforcing query order when using iter_matches in the
Tree-sitter highlighter. However, iter_matches proved to have too many
complications to use in the highlighter so we eventually reverted back
to using iter_captures (https://github.com/neovim/neovim/pull/27901).
Thus, subpriorities are no longer needed and can be removed.
2024-05-01 08:08:22 -05:00
052498ed42 test: improve test conventions
Specifically, functions that are run in the context of the test runner
are put in module `test/testutil.lua` while the functions that are run
in the context of the test session are put in
`test/functional/testnvim.lua`.

Closes https://github.com/neovim/neovim/issues/27004.
2024-04-23 18:17:04 +02:00
ea1c9f60e0 vim-patch:9.1.0357: Page scrolling should place cursor at window boundaries (#28429)
Problem:  Page scrolling does not always place the cursor at the top or
          bottom of the window (Mathias Rav)
Solution: Place the cursor at the top or bottom of the window.
          (Luuk van Baal)

4b6b0c4024
2024-04-22 21:24:32 +08:00
780509aedf fix(move): fix using the wrong window (#28312) 2024-04-13 10:32:49 +08:00
64aa0f7d0b fix(move): check for filler lines properly (#28307)
vim-patch:9.1.0310: Filler lines not checked properly in get_scroll_overlap()
2024-04-13 06:18:45 +08:00
81fc27124b refactor(test): inject after_each differently 2024-04-10 15:53:50 +01:00
889f81c65f fix(drawline): don't invoke on_line for filler line (#28219)
Problem:
Decoration provider `on_line` handler is invoked for diff filler line
below the last buffer line. This does not match the documentation:
"called for each buffer line".

Solution:
Check `end_fill`.
2024-04-10 20:18:14 +08:00
7035125b2b test: improve test conventions
Work on https://github.com/neovim/neovim/issues/27004.
2024-04-08 22:51:00 +02:00
fa74f75710 refactor(tests): allow to extend the new base set of attrs
We start at 100 so we can make the base set larger if needed. (It might need to
grow/shrink as a result of adopting the new default color scheme as the
default for tests)

Usage best illustrataded by example.

Improving the workflow for making new tests with `screen:snapshot_util()` will
be a follow up.
2024-04-02 20:28:27 +02:00
34b57508a7 fix(drawline): check filler_todo in place of removed draw_state (#27889)
The only place it matters is the conceal wcol check, but it can avoid
unnecessary computations at other places.
2024-03-17 05:43:14 +08:00