summaryrefslogtreecommitdiffstatshomepage
path: root/src/nvim/api/ui.c
AgeCommit message (Collapse)AuthorFiles
2026-04-02feat(:restart): reattach all UIs (#38683)zeertzjq1
This is quite easy since [command] is now only executed once on UIEnter.
2026-03-31fix(:restart): only pass --headless when there is no UI (#38580)zeertzjq1
Change --embed so that the first UI can be on non-stdio channel even if neither --headless nor --listen is passed.
2026-03-29refactor(:restart): execute [command] on UIEnter (#38541)zeertzjq1
This avoids having to pass it in the UI event.
2026-03-28fix(:restart): formalize restart event #35223Sathya Pramodh1
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>
2026-03-16fix(api): use standard error messagesJustin M. Keyes1
2026-02-14fix(restart): append `-c <cmd>` at end, drop `-- [files…]` #37846Justin M. Keyes1
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.)
2026-01-31fix(ui): don't crash if maximum UI count reached (#37636)zeertzjq1
2025-11-28fix(restart): preserve original args on repeat invocations #36740Andrew Braxton1
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.
2025-10-26fix(tui): don't treat remote TUI as GUI (#36319)zeertzjq1
Set "stdin_tty" and "stdout_tty" UI options, so that a remote TUI is not treated as a GUI.
2025-10-04vim-patch:partial:8.1.1939: code for handling v: variables in generic eval ↵Jan Edmund Lazo1
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>
2025-09-04docs: api eventsJustin M. Keyes1
2025-08-24docs: misc #35459Justin M. Keyes1
2025-08-22feat(tui): add nvim_ui_send (#35406)Gregory Anders1
This function allows the Nvim core to write arbitrary data to a TTY connected to a UI's stdout.
2025-08-14feat(ui): :connect command #34586Siddhant Agarwal1
Add the `:connect <address>` command which connects the currently running TUI to the server at the given address.
2025-08-14refactor(build): remove INCLUDE_GENERATED_DECLARATIONS guardsbfredl1
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.
2025-08-02feat: ":restart [cmd]" can run commands #35045Sathya Pramodh1
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.
2025-07-09feat(tui): use DA1 response to determine OSC 52 supportGregory Anders1
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.
2025-06-26refactor(ui.c): deduplicate validation logic #34647Justin M. Keyes1
2025-06-12fix(msgpack): flush incomplete big UI event before packing RPC eventbfredl1
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
2025-06-11feat(tui): support APC queries in TermResponse (#34426)Gregory Anders1
Add support for APC sequences to libtermkey and the TermResponse autocommand event.
2025-06-10fix(tui): wait for embedded server's exit codezeertzjq1
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.
2025-06-07feat: make :restart work for remote UI (#34354)zeertzjq1
2025-03-08fix(events): always allow some events to be nested (#32706)zeertzjq1
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.
2025-03-05feat(terminal)!: include cursor position in TermRequest event data (#31609)Gregory Anders1
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
2025-02-10feat(ui): UI :detach commandJustin M. Keyes1
Problem: Cannot detach the current UI. Solution: - Introduce `:detach`. - Introduce `Channel.detach`. Co-authored-by: bfredl <bjorn.linse@gmail.com>
2025-01-30docs: miscdundargoc1
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>
2024-12-23refactor: iwyu #31637Justin M. Keyes1
Result of `make iwyu` (after some "fixups").
2024-09-23refactor(api)!: rename Dictionary => DictJustin M. Keyes1
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.
2024-09-02feat(startup): validate --listen addressJustin M. Keyes1
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`.
2024-08-30feat(mbyte): support extended grapheme clusters including more emojibfredl1
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-05refactor(shada): rework msgpack decoding without msgpack-cbfredl1
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.
2024-07-15fix(ui): avoid ambiguity about last chunk when flushing halfway (#29718)zeertzjq1
2024-05-12fix(ui): data corruption in remote_ui_raw_linebfredl1
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
2024-05-01fix(ui): avoid recursiveness and invalid memory access #28578luukvbaal1
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.
2024-03-15fix(ui): fix edge case around flushingbfredl1
ui_flush_buf() doesn't know about `lenpos` so `remote_ui_raw_line` needs to always handle it before flushing
2024-03-09docs: support inline markdownLewis Russell1
- Tags are now created with `[tag]()` - References are now created with `[tag]` - Code spans are no longer wrapped
2024-03-08refactor(ui): remove outdated UI vs UIData distinctionbfredl1
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".
2024-03-07refactor(msgpack): allow flushing buffer while packing msgpackbfredl1
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).
2024-02-27feat(docs): replace lua2dox.luaLewis Russell1
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).
2024-02-18refactor(api): use arena for channel info and terminal infobfredl1
2024-02-15refactor(eval): use arena when converting typvals to Objectbfredl1
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.
2024-02-12Merge pull request #27348 from fredizzimo/fsundvik/fix-ext-hlstatebfredl1
fix: crashes with large msgpack messages
2024-02-09refactor(api): use arena for nvim_list_uis()bfredl1
2024-02-09refactor(api): make cstr_as_string accept "const char*"bfredl1
In the context a String inside an Object/Dictionary etc is consumed, it is considered to be read-only.
2024-02-06fix: splitting of big UI messagesFred Sundvik1
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.
2024-01-24feat(ui): add support for OSC 8 hyperlinks (#27109)Gregory Anders1
Extmarks can contain URLs which can then be drawn in any supporting UI. In the TUI, for example, URLs are "drawn" by emitting the OSC 8 control sequence to the TTY. On terminals which support the OSC 8 sequence this will create clickable hyperlinks. URLs are treated as inline highlights in the decoration subsystem, so are included in the `DecorSignHighlight` structure. However, unlike other inline highlights they use allocated memory which must be freed, so they set the `ext` flag in `DecorInline` so that their lifetimes are managed along with other allocated memory like virtual text. The decoration subsystem then adds the URLs as a new highlight attribute. The highlight subsystem maintains a set of unique URLs to avoid duplicating allocations for the same string. To attach a URL to an existing highlight attribute we call `hl_add_url` which finds the URL in the set (allocating and adding it if it does not exist) and sets the `url` highlight attribute to the index of the URL in the set (using an index helps keep the size of the `HlAttrs` struct small). This has the potential to lead to an increase in highlight attributes if a URL is used over a range that contains many different highlight attributes, because now each existing attribute must be combined with the URL. In practice, however, URLs typically span a range containing a single highlight (e.g. link text in Markdown), so this is likely just a pathological edge case. When a new highlight attribute is defined with a URL it is copied to all attached UIs with the `hl_attr_define` UI event. The TUI manages its own set of URLs (just like the highlight subsystem) to minimize allocations. The TUI keeps track of which URL is "active" for the cell it is printing. If no URL is active and a cell containing a URL is printed, the opening OSC 8 sequence is emitted and that URL becomes the actively tracked URL. If the cursor is moved while in the middle of a URL span, we emit the terminating OSC sequence to prevent the hyperlink from spanning multiple lines. This does not support nested hyperlinks, but that is a rare (and, frankly, bizarre) use case. If a valid use case for nested hyperlinks ever presents itself we can address that issue then.
2024-01-11refactor(IWYU): fix headersdundargoc1
Remove `export` pramgas from defs headers as it causes IWYU to believe that the definitions from the defs headers comes from main header, which is not what we really want.
2024-01-08refactor(options): use schar_T representation for fillchars and listcharsbfredl1
A bit big, but practically it was a lot simpler to change over all fillchars and all listchars at once, to not need to maintain two parallel implementations. This is mostly an internal refactor, but it also removes an arbitrary limitation: that 'fillchars' and 'listchars' values can only be single-codepoint characters. Now any character which fits into a single screen cell can be used.
2023-12-21refactor: run IWYU on entire repodundargoc1
Reference: https://github.com/neovim/neovim/issues/6371.
2023-12-17refactor: move non-symbols to defs.h headersdundargoc1