aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/ui.c
Commit message (Collapse)AuthorAge
* fix(windows): server dies with terminal after :restartJustin M. Keyes11 days
| | | | | | | | | | | | | Problem: On Windows, a server started by :restart attaches to the TUI's console. Closing the host-terminal kills the server, even after :detach or :detach!: the swap to a hidden console only happens when a stdio UI disconnects, but after :restart the TUI is on a socket. Solution: Track whether the console is inherited from the parent. When the last UI disconnects and the server keeps running, swap an inherited console for a hidden one.
* refactor(ui): remove "stop" UI eventJustin M. Keyes11 days
| | | | | | | | | Problem: "stop" has been a no-op since the TUI moved out-of-process. Remote UIs only see EOF, and nothing implements it. Solution: Remove it.
* feat(api): nvim_chan_set()Justin M. Keyes11 days
| | | | | | | | | | | | | | | | | | | Problem: Only the stdio channel can "own" a server (self-exit on close). After :restart the TUI reconnects over a socket, so the restarted server does not have "self-exit" behavior when the channel closes (e.g. by UI disconnect, host-terminal close, etc.), which leaves a dangling server. Solution: - Introduce `nvim_chan_set`. (`nvim_set_client_info` doesn't fit: exposing it to Lua would require a `channel` param, which is not backwards-compatible, plus it's awkward because it doesn't merge info.) - Broadcast per-channel properties in the "restart" UI event as an opaque dict (a potentially useful pattern for other UI-events in the future). - UIs are expected to restore the channel properties on restart. - `nvim_get_chan_info()` reports "detach". - Remove `nvim__chan_set_detach()`.
* refactor(detach): eliminate `nvim__ui_detach` #40793Justin M. Keyes2026-07-17
| | | | | | | | | | | | | | | Problem: `nvim__ui_detach` was added in 85e0559d46c7 in order to implement `detach_others` from Lua. Using Lua in this case is doing more harm than good. Solution: Extract `ui_detach_channel`, which also allows it to be used for the "self detach" path from `ex_detach`. Bonus: the old MSWIN path always called `os_swap_to_hidden_console()`; now `ui_detach_channel` only does so for a stdio channel. For the common stdio TUI this is identical; for a socket UI it's more correct (no parent console to swap).
* feat(ui): ":%detach!" detaches all other UIs #39216Jason Woodland2026-07-17
| | | | | | | Problem: Not easy for one UI to kick the others off a shared Nvim server. Solution: Treat `:%detach` as detach-other-UIs.
* feat(:restart): reattach all UIs (#38683)zeertzjq2026-04-02
| | | This is quite easy since [command] is now only executed once on UIEnter.
* fix(:restart): only pass --headless when there is no UI (#38580)zeertzjq2026-03-31
| | | | Change --embed so that the first UI can be on non-stdio channel even if neither --headless nor --listen is passed.
* refactor(:restart): execute [command] on UIEnter (#38541)zeertzjq2026-03-29
| | | This avoids having to pass it in the UI event.
* fix(:restart): formalize restart event #35223Sathya Pramodh2026-03-28
| | | | | | | | | | | | | | | | | | | Problem: The "restart" event has some problems: - all UI clients must implement a somewhat complex set of setups - UI must be on the same machine as the server - only works for the "current" UI - race/edge case: If the user config has errors / waiting for input, are all UIs able to attach while Nvim is waiting for input? Solution: - Perform the restart on the server, not the client. - Pass listen address (instead of CLI args) in the UI event. - Simplifies UI logic: they only need to attach to new address. - Opens the door for more enhancements in the future, such as allowing all UIs to reattach instead of only the "current" UI. Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* fix(api): use standard error messagesJustin M. Keyes2026-03-16
|
* fix(restart): append `-c <cmd>` at end, drop `-- [files…]` #37846Justin M. Keyes2026-02-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: - `:restart <cmd>` prepends `-c <cmd>` before the original `-c` args (if any). So the original `-c` args may "override" it, which is surprising. - Confusing logic: `v:argv` is partially prepared in `ex_docmd.c`, and then later `ui.c` skips other parts of it. Current behavior is nonsense, for example this sequence: :restart echo "Hello" :restart +qall echo "Hello" | echo "World" results in this v:argv: [ 'nvim' '-c' 'echo "Hello" | echo "World"' '--embed' '-c' 'echo "Hello"' ... ] Whereas after this commit, v:argv is: [ 'nvim' '--embed' ... '-c' 'echo "Hello" | echo "World"' ] Solution: - Append `-c <cmd>` at the _end_ of `v:argv`, not the start. - Use a dummy placeholder `+:::` to mark where the "restart command" appears in `v:argv`. - Do all `v:argv` preparation in `ex_docmd.c`. This simplifies `ui.c`. - Drop `-- [files…]` from `v:argv` since it is probably more annoying than useful. (Users can use sessions to restore files on restart.)
* fix(ui): don't crash if maximum UI count reached (#37636)zeertzjq2026-01-31
|
* fix(restart): preserve original args on repeat invocations #36740Andrew Braxton2025-11-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Calling `:restart` twice erases the original args passed to `nvim`. This is caused by interactions between the `:restart` command handler, the `v:argv` parsing logic in the UI restart handler, and the options added to `v:argv` by the server upon restart. For example, * Launch `nvim` as `nvim foo`: * initial argv: `nvim foo` * after nvim server launch: `nvim --embed foo` * Run `:restart` * after `ex_restart()`: `nvim -c '' --embed foo` * after `remote_ui_restart()`: `nvim -c '' foo` * after nvim server launch: `nvim --embed -c '' foo` * Run `:restart` again * after `ex_restart()`: `nvim -c '' --embed -c '' foo` * after `remote_ui_restart()`: `nvim -c ''` * after nvim server launch: `nvim --embed -c ''` The intention of the argv parser in `remote_ui_restart()` is to only take the first `-c cmd` and ignore any additional ones, but it actually ignores the rest of argv when it encounters a second `-c` and there are no `-` or `--` remaining. Solution: Fix the argv parser to reset the `skipping_minc` flag at the end of every iteration that does not reach the `continue` statement.
* fix(tui): don't treat remote TUI as GUI (#36319)zeertzjq2025-10-26
| | | | Set "stdin_tty" and "stdout_tty" UI options, so that a remote TUI is not treated as a GUI.
* vim-patch:partial:8.1.1939: code for handling v: variables in generic eval ↵Jan Edmund Lazo2025-10-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | file (#35968) Problem: Code for handling v: variables in generic eval file. Solution: Move v: variables to evalvars.c. (Yegappan Lakshmanan, closes vim/vim#4872) https://github.com/vim/vim/commit/e5cdf153bcb348c68011b308c8988cea42d6ddeb Remove direct reference to "vimvars" for following functions: - assert_error() - get_vim_var_nr() - get_vim_var_list() - get_vim_var_dict() - get_vim_var_str() - set_cmdarg() - set_reg_var() - set_vcount() - set_vexception() - set_vthrowpoint() - set_vim_var_bool() - set_vim_var_dict() - set_vim_var_list() - set_vim_var_nr() - set_vim_var_special() - set_vim_var_string() - set_vim_var_type() Reorder functions based on v8.2.4930 for eval_one_expr_in_str() and eval_all_expr_in_str(). Co-authored-by: Bram Moolenaar <Bram@vim.org>
* docs: api eventsJustin M. Keyes2025-09-04
|
* docs: misc #35459Justin M. Keyes2025-08-24
|
* feat(tui): add nvim_ui_send (#35406)Gregory Anders2025-08-22
| | | | This function allows the Nvim core to write arbitrary data to a TTY connected to a UI's stdout.
* feat(ui): :connect command #34586Siddhant Agarwal2025-08-14
| | | | Add the `:connect <address>` command which connects the currently running TUI to the server at the given address.
* refactor(build): remove INCLUDE_GENERATED_DECLARATIONS guardsbfredl2025-08-14
| | | | | | | | | These are not needed after #35129 but making uncrustify still play nice with them was a bit tricky. Unfortunately `uncrustify --update-config-with-doc` breaks strings with backslashes. This issue has been reported upstream, and in the meanwhile auto-update on every single run has been disabled.
* feat: ":restart [cmd]" can run commands #35045Sathya Pramodh2025-08-02
| | | | | | | Problem: Not easy for a user to tell ":restart" to "run this command(s) after restarting". Solution: All ":restart" args following the optional +cmd arg are treated as a big cmdline that is passed as a "-c" CLI arg when restarting nvim.
* feat(tui): use DA1 response to determine OSC 52 supportGregory Anders2025-07-09
| | | | | | Many terminals now include support for OSC 52 in their Primary Device Attributes (DA1) response. This is preferable to using XTGETTCAP because DA1 is _much_ more broadly supported.
* refactor(ui.c): deduplicate validation logic #34647Justin M. Keyes2025-06-26
|
* fix(msgpack): flush incomplete big UI event before packing RPC eventbfredl2025-06-12
| | | | | | | This might happen, e.g. if we send a fast RPC reply in a os_breakcheck() in the middle of redrawing and big ui_ext events are produced. fixes #31316
* feat(tui): support APC queries in TermResponse (#34426)Gregory Anders2025-06-11
| | | | Add support for APC sequences to libtermkey and the TermResponse autocommand event.
* fix(tui): wait for embedded server's exit codezeertzjq2025-06-10
| | | | | | Uses the undocumented "error_exit" UI event for a different purpose: When :detach is used on the server, send an "error_exit" with 0 `status` to indicate that the server shouldn't wait for client exit.
* feat: make :restart work for remote UI (#34354)zeertzjq2025-06-07
|
* fix(events): always allow some events to be nested (#32706)zeertzjq2025-03-08
| | | | | | | | | | | | | | | Always allow the following four events to be nested, as they may contain important information, and are triggered on the event loop, which may be processed by a blocking call inside another autocommand. - ChanInfo - ChanOpen - TermRequest - TermResponse There are some other events that are triggered on the event loop, but they are mostly triggered by user actions in a UI client, and therefore not very likely to happen during another autocommand, so leave them unchanged for now.
* feat(terminal)!: include cursor position in TermRequest event data (#31609)Gregory Anders2025-03-05
| | | | | | | | | | | | | | | | | | When a plugin registers a TermRequest handler there is currently no way for the handler to know where the terminal's cursor position was when the sequence was received. This is often useful information, e.g. for OSC 133 sequences which are used to annotate shell prompts. Modify the event data for the TermRequest autocommand to be a table instead of just a string. The "sequence" field of the table contains the sequence string and the "cursor" field contains the cursor position when the sequence was received. To maintain consistency between TermRequest and TermResponse (and to future proof the latter), TermResponse's event data is also updated to be a table with a "sequence" field. BREAKING CHANGE: event data for TermRequest and TermResponse is now a table
* feat(ui): UI :detach commandJustin M. Keyes2025-02-10
| | | | | | | | | | | Problem: Cannot detach the current UI. Solution: - Introduce `:detach`. - Introduce `Channel.detach`. Co-authored-by: bfredl <bjorn.linse@gmail.com>
* docs: miscdundargoc2025-01-30
| | | | | | | | | Co-authored-by: Dustin S. <dstackmasta27@gmail.com> Co-authored-by: Ferenc Fejes <fejes@inf.elte.hu> Co-authored-by: Maria José Solano <majosolano99@gmail.com> Co-authored-by: Yochem van Rosmalen <git@yochem.nl> Co-authored-by: brianhuster <phambinhanctb2004@gmail.com> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* refactor: iwyu #31637Justin M. Keyes2024-12-23
| | | Result of `make iwyu` (after some "fixups").
* refactor(api)!: rename Dictionary => DictJustin M. Keyes2024-09-23
| | | | | | | | | | | | | | In the api_info() output: :new|put =map(filter(api_info().functions, '!has_key(v:val,''deprecated_since'')'), 'v:val') ... {'return_type': 'ArrayOf(Integer, 2)', 'name': 'nvim_win_get_position', 'method': v:true, 'parameters': [['Window', 'window']], 'since': 1} The `ArrayOf(Integer, 2)` return type didn't break clients when we added it, which is evidence that clients don't use the `return_type` field, thus renaming Dictionary => Dict in api_info() is not (in practice) a breaking change.
* feat(startup): validate --listen addressJustin M. Keyes2024-09-02
| | | | | | | | | | | | | Problem: `nvim --listen` does not error on EADDRINUSE. #30123 Solution: Now that `$NVIM_LISTEN_ADDRESS` is deprecated and input *only* (instead of the old, ambiguous situation where it was both an input *and* an output), we can be fail fast instead of trying to "recover". This reverts the "recovery" behavior of 704ba4151e7f67999510ee0ac19fdabb595d530c, but that was basically a workaround for the fragility of `$NVIM_LISTEN_ADDRESS`.
* feat(mbyte): support extended grapheme clusters including more emojibfredl2024-08-30
| | | | | | | | | 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.
* refactor(shada): rework msgpack decoding without msgpack-cbfredl2024-08-05
| | | | | | | This also makes shada reading slightly faster due to avoiding some copying and allocation. Use keysets to drive decoding of msgpack maps for shada entries.
* fix(ui): avoid ambiguity about last chunk when flushing halfway (#29718)zeertzjq2024-07-15
|
* fix(ui): data corruption in remote_ui_raw_linebfredl2024-05-12
| | | | | | This particular repro is quite niche but there could be other cases, whenever the the second last cell plus the "fill" cell togheter are too complex
* fix(ui): avoid recursiveness and invalid memory access #28578luukvbaal2024-05-01
| | | | | | | | Problem: Calling :redraw from vim.ui_attach() callback results in recursive cmdline/message events. Solution: Avoid recursiveness where possible and replace global "call_buf" with separate, temporary buffers for each event so that when a Lua callback for one event fires another event, that does not result in invalid memory access.
* fix(ui): fix edge case around flushingbfredl2024-03-15
| | | | | ui_flush_buf() doesn't know about `lenpos` so `remote_ui_raw_line` needs to always handle it before flushing
* docs: support inline markdownLewis Russell2024-03-09
| | | | | | - Tags are now created with `[tag]()` - References are now created with `[tag]` - Code spans are no longer wrapped
* refactor(ui): remove outdated UI vs UIData distinctionbfredl2024-03-08
| | | | | | | | Just some basic spring cleaning. In the distant past, not all UI:s where remote UI:s. They still aren't, but both of the "UI" and "UIData" structs are now only for remote UI:s. Thus join them as "RemoteUI".
* refactor(msgpack): allow flushing buffer while packing msgpackbfredl2024-03-07
| | | | | | | | | | | | | | Before, we needed to always pack an entire msgpack_rpc Object to a continous memory buffer before sending it out to a channel. But this is generally wasteful. it is better to just flush whatever is in the buffer and then continue packing to a new buffer. This is also done for the UI event packer where there are some extra logic to "finish" of an existing batch of nevents/ncalls. This doesn't really stop us from flushing the buffer, just that we need to update the state machine accordingly so the next call to prepare_call() always will start with a new event (even though the buffer might contain overflow data from a large event).
* feat(docs): replace lua2dox.luaLewis Russell2024-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: The documentation flow (`gen_vimdoc.py`) has several issues: - it's not very versatile - depends on doxygen - doesn't work well with Lua code as it requires an awkward filter script to convert it into pseudo-C. - The intermediate XML files and filters makes it too much like a rube goldberg machine. Solution: Re-implement the flow using Lua, LPEG and treesitter. - `gen_vimdoc.py` is now replaced with `gen_vimdoc.lua` and replicates a portion of the logic. - `lua2dox.lua` is gone! - No more XML files. - Doxygen is now longer used and instead we now use: - LPEG for comment parsing (see `scripts/luacats_grammar.lua` and `scripts/cdoc_grammar.lua`). - LPEG for C parsing (see `scripts/cdoc_parser.lua`) - Lua patterns for Lua parsing (see `scripts/luacats_parser.lua`). - Treesitter for Markdown parsing (see `scripts/text_utils.lua`). - The generated `runtime/doc/*.mpack` files have been removed. - `scripts/gen_eval_files.lua` now instead uses `scripts/cdoc_parser.lua` directly. - Text wrapping is implemented in `scripts/text_utils.lua` and appears to produce more consistent results (the main contributer to the diff of this change).
* refactor(api): use arena for channel info and terminal infobfredl2024-02-18
|
* refactor(eval): use arena when converting typvals to Objectbfredl2024-02-15
| | | | | | | | | | | | Note: this contains two _temporary_ changes which can be reverted once the Arena vs no-Arena distinction in API wrappers has been removed. Both nlua_push_Object and object_to_vim_take_luaref() has been changed to take the object argument as a pointer. This is not going to be necessary once these are only used with arena (or not at all) allocated Objects. The object_to_vim() variant which leaves luaref untouched might need to stay for a little longer.
* Merge pull request #27348 from fredizzimo/fsundvik/fix-ext-hlstatebfredl2024-02-12
|\ | | | | fix: crashes with large msgpack messages
| * fix: splitting of big UI messagesFred Sundvik2024-02-06
| | | | | | | | | | | | | | | | | | Determine the needed buffer space first, instead of trying to revert the effect of prepare_call if message does not fit. The previous code did not revert the full state, which caused corrupted messages to be sent. So, rather than trying to fix all of that, with fragile and hard to read code as a result, the code is now much more simple, although slightly slower.
* | refactor(api): use arena for nvim_list_uis()bfredl2024-02-09
| |
* | refactor(api): make cstr_as_string accept "const char*"bfredl2024-02-09
|/ | | | | In the context a String inside an Object/Dictionary etc is consumed, it is considered to be read-only.