17 Commits

Author SHA1 Message Date
9e968635ef fix(extui): check if buffers/windows exist before deleting (#34886)
Problem: Disabling vim._extui may try to delete non-existent windows/buffers.
Solution: Check that window/buffer is valid before deleting.
2025-07-11 17:31:30 +02:00
54cde0674b test(ui/{cmdline,message}2_spec): reduce flakiness/runtime #34875
Problem:  Storing the configured 'cmdheight' value is scheduled and
          may happen after cmdline2_spec already entered block_mode.
          Excessive wait time for expected screen state due to delayed
          ruler after an error message.
Solution: Only schedule storing the user configured 'cmdheight' if
          v:vim_did_enter is unset. Use regular message instead of error.
2025-07-10 17:52:50 -07:00
7526fb449d feat(extui): use winborder for msg window #34859
Problem:  The message window is essentially a regular floating window
          but does not use 'winborder'.
          Still some "scratch" buffer options unset after it was removed
          from its window.
Solution: Do not set the border when opening the window message.
          Forego passing `scratch = true` when opening a buffer,
          set the options manually when necessary.

Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
2025-07-09 17:42:47 -07:00
bfe42c84de perf(extui): delay creating windows, buffers and parser (#34665)
Problem:  vim._extui unconditionally creates windows, buffers and the
          Vimscript cmdline highlighter when it is first loaded.
Solution: Schedule first creation of the window so that first redraw
          happens sooner (still need to create at least the cmdline
          window asap as it can have a different highlight through
          hl-MsgArea; thus further delaying until the first event that
          needs a particular target seems redundant). Load the cmdline
          highlighter on the first cmdline_show event.
2025-06-27 15:54:32 +02:00
5046ef4c8f fix(extui): clear cmdline buffer for first message (#34490)
Problem:  Cmdline buffer is not cleared for a new message (since c973c7ae),
          resulting in an incorrect spill indicator. When the cmdline
          buffer is cleared, "msg_row" is not invalidated, resulting in
          an error. The extui module is untested.
          Return value of `vim.ui_attach()->callback` is undocumented.
Solution: Clear the cmdline buffer for the first message in an event
          loop iteration. Ensure msg_row passed as end_row does not
          exceed buffer length.
          Add `messages_spec2.lua` to test the extui module, keeping in
          mind that test coverage will greatly increase if this UI is made
          the default. As such, only tests for specific extui functionality
          unlikely to be covered by tests leveraging the current message grid.
          Document the return value of `vim.ui_attach()->callback`, it seems
          to make sense, and is also used to suppress remote UI events in
          `messages_spec2.lua`.
2025-06-15 12:55:01 +02:00
9ec6c19c67 docs(extui): rename box->msg, more->pager, prompt->dialog
Includes breaking changes to the `opts` layout. "box" doesn't really
describe anything other than a floating window so was an unwanted synonym.
2025-06-13 14:28:01 +02:00
cb036cae5f fix(extui): use visible to determine active "more" (#34327)
Problem:  Current window is checked to determine whether "more" window
          is open. Making it the current window is scheduled in case the
          cmdwin is open so this can be too late.
          "cmdline_hide" may be emitted when the topline is
          temporarily invalid (after incsearch->restore_viewstate()).
Solution: Use the window visibility to determine an active "more"
          window instead.
          Don't nvim__redraw->flush the "cmdline_hide" event (a normal
          will already happen).
2025-06-06 16:04:45 +02:00
5e4700152b fix(extui): copy window config to new tabpage (#34308)
Problem:  When opening a new tabpage, extui windows are initialized with
          their default config. Window visiblity/dimensions on other
          tabpages may get out of sync with their buffer content.
Solution: Copy the config of the window to the new tabpage.
          No longer keep track of the various windows on each tabpage.
          Close windows on inactive tabpages instead (moving them could
          be more efficient but is currently not supported in the API).
2025-06-04 19:59:36 +02:00
ff95d7ff9a fix(extui): adjust "more" window routing (#34251)
Problem:  Message lines from multiple message events that end up
          spilling 'cmdheight' end up spread out over the cmdline
          and "more" window.
          Messages emitted as feedback to a typed :command (rather than
          its sole purpose like :echo/:=) are routed to the more window.
          The more window isn't closed when entering the cmdwin, and
          doesn't allow `vim.hl.on_yank()`.
Solution: When first opening the "more" window for spilled messages,
          move the message buffer to the more window.
          Restrict routing of typed commands to echo kinds.
          Ignore all events but WinLeave and TextYankPost.
2025-06-01 20:54:38 +02:00
d25eb246ef revert: show "g<" hint when message spills 'cmdheight'
Problem:  Hint message to press "g<" for message that spills
          'cmdheight' is too intrusive.
Solution: Remove the hint message. Document the meaning of the spill
          indicator instead.
2025-05-14 15:36:42 +02:00
302e59f734 feat(extui): assign 'filetype' to extui windows (#33924)
Problem:  Unable to discern windows used by the extui interface
          to configure their local options.
          'winblend' may be detrimental to legibility depending on the
          colorscheme and 'background'.
Solution: Assign the "cmdline", "msgmore", "msgprompt" and "msgbox" 
          'filetype' to the respective windows.
          Don't set 'winblend' for the message "box" window.
2025-05-09 14:47:36 +02:00
7e787f6a4f fix(extui): route interactive messages to more-window (#33885)
Problem:  Extui does not route messages emitted as a result of a typed
          command to the "more" window.
          Command message leading shell messages is missing a kind.
          Messages not routed to 'cmdheight' area after it was 0.
Solution: Route messages that were emitted in the same event loop as an
          entered command to the "more" window. Also append multiple
          messages in an already open more-window.
          Assign it the `shell_cmd` kind.
          Change message position when 'cmdheight' changes from 0.
2025-05-09 12:17:26 +02:00
6dee1672cc fix(extui): "box" window width calculated on last line (#33881)
Problem:  The "box" window width is calculated on the last line when
          applying "last" virt_text. There may be longer lines
          part of the same message.
Solution: Don't decrease box width if the calculated width is smaller.
          Minor unrelated changes.

Co-authored-by: Eike <eike.rackwitz@mail.de>
2025-05-07 10:02:53 +02:00
f1295fe76f fix(extui): hide inactive "more" window (#33831)
Problem:  More-window is left visible after leaving it. Cursor may be
          hidden behind it and it is hard to re-enter afterwards.
Solution: Close the more-window when another window is entered.
2025-05-04 13:39:07 +02:00
b2a5105c66 fix(extui): search highlighting in extui "more" pager #33792
Problem:  No search highlighting in extui "more" pager window.
Solution: Only use custom highlight namespace in cmdline window.
2025-05-03 12:30:08 -07:00
3c7c824bdc fix(extui): check option values after VimEnter (#33768)
Problem:  Not picking up configured option values when enabling _extui after startup.
Solution:  Check option values when enabing _extui.

Fix https://github.com/neovim/neovim/issues/33767
2025-05-02 13:13:12 +02:00
2c1c0b7af5 feat(ui): ext_cmdline/messages for the TUI #27855
Problem:  We have an unmaintained Vimscript parser and cmdline
highlighting mechanism, with which it is hard to leverage the
treesitter highlighter. Long messages result in a hit-enter-prompt.

Solution: Implement a vim.ui_attach() UI, that replaces the message
grid (orphaning some 3000+ LOC core C code). Introduce an experimental
vim._extui module, because removing the message grid at the same time is
too risky. The new UI leverages the bundled treesitter highlighter and
parser for Vimscript, as well as the matchparen plugin, to highlight the
cmdline. Messages are truncated in the cmdline area, or placed in a
floating message box in the bottom right corner. Special ("list_cmd")
messages and the message history are shown in a, "more prompt" (now a
fully interactive regular window). Various default UI elements ('showcmd',
'ruler') are also placed in the cmdline area, as virtual text.

`require('vim._extui').enable({})` enables the experimental UI.
`{ msg.pos = 'box' }` or `:set cmdheight=0` enables the message
box variant.

Followup:
  - Come to a consensus for how best to represent messages (by default).
  - Start removing message grid when this is deemed a successful replacement.
    When that is finished, make this new UI the default and update a lot of tests.
2025-05-02 02:02:02 -07:00