Movatterモバイル変換


[0]ホーム

URL:


Api-ui-events

Nvim:help pages,generated fromsource using thetree-sitter-vimdoc parser.


Nvim UI protocoluiapi-ui-events
This document describes the UI protocol. Seegui andtui for user-facingUI components and features.

UI Eventsui-protocolui-events

UIs can be implemented as external client processes communicating with Nvimover the RPC API. The default UI model is a terminal-like grid with a single,monospace font. The UI can opt-in to have windows drawn on separate grids, andhave some elements ("widgets") presented by the UI itself rather than by Nvim("externalized").
ui-option
Callnvim_ui_attach() to tell Nvim that your program wants to draw the Nvimscreen grid with a size of width × height cells. This is typically done by anembedder at startup (seeui-startup), but UIs can also connect to a runningNvim instance and invoke nvim_ui_attach(). Theoptions parameter is a mapwith these (optional) keys:
ui-rgb
rgb Decides the color format.
true: (default) 24-bit RGB colors
false: Terminal colors (8-bit, max 256)
ui-override
override Decides how UI capabilities are resolved.
true: Enable requested UI capabilities, even if not supported by all connected UIs (includingTUI).
false: (default) Disable UI capabilities not supported by all connected UIs (including TUI).
ui-ext-options
ext_cmdline Externalize the cmdline.ui-cmdline
ext_hlstate Detailed highlight state.ui-hlstateSetsext_linegrid implicitly.
ext_linegrid Line-based grid events.ui-linegridDeactivatesui-grid-old implicitly.
ext_messages Externalize messages.ui-messagesSetsext_linegrid andext_cmdline implicitly.
ext_multigrid Per-window grid events.ui-multigridSetsext_linegrid implicitly.
ext_popupmenu Externalizepopupmenu-completion and'wildmenu'.ui-popupmenu
ext_tabline Externalize the tabline.ui-tabline
ext_termcolors Use external default colors.
term_name Sets the name of the terminal'term'.
term_colors Sets the number of supported colors 't_Co'.
stdin_fd Read buffer 1 from this fd as if it were stdin--.Only from--embed UI on startup.ui-startup-stdin
stdin_tty Tells ifstdin is atty or not.
stdout_tty Tells ifstdout is atty or not.
Specifying an unknown option is an error; UIs can check theapi-metadataui_options key for supported options.
By default Nvim requires all connected UIs to support the same capabilities,thus the active capabilities are the intersection of those requested. UIs mayspecifyui-override to invert this behavior (useful for debugging). The"option_set" event announces which capabilities are active.
Nvim sends RPC notifications to all attached UIs, with method name "redraw"and a single argument: an array (batch) of screen "update events". Each updateevent is itself an array whose first element is the event name and remainingelements are event-parameter tuples. Thus multiple events of the same kind canbe sent contiguously without repeating the event name.
Example of a typical "redraw" batch in a single RPC notification:
['notification', 'redraw',  [    ['grid_resize', [2, 77, 36]],    ['grid_line',      [2, 0, 0, [[' ' , 0, 77]], false],      [2, 1, 0, [['~', 7], [' ', 7, 76]], false],      [2, 9, 0, [['~', 7], [' ', 7, 76]], false],      ...      [2, 35, 0, [['~', 7], [' ', 7, 76]], false],      [1, 36, 0, [['[', 9], ['N'], ['o'], [' '], ['N'], ['a'], ['m'], ['e'], [']']], false],      [1, 36, 9, [[' ', 9, 50]], false],      [1, 36, 59, [['0', 9], [','], ['0'], ['-' ], ['1'], [' ', 9, 10], ['A'], ['l', 9, 2]], false]    ],    ['msg_showmode', [[]]],    ['win_pos', [2, 1000, 0, 0, 77, 36]],    ['grid_cursor_goto', [2, 0, 0]],    ['flush', []]  ]]
Events must be handled in-order. Nvim sends a "flush" event when it hascompleted a redraw of the entire screen (so all windows have a consistent viewof buffer state, options, etc.). Multiple "redraw" batches may be sent beforethe entire screen has been redrawn, with "flush" following only the lastbatch. The user should only see the final state (when "flush" is sent), notany intermediate state while processing part of the batch array, nor aftera batch not ending with "flush".
By default, Nvim sendsui-global andui-grid-old events (for backwardscompatibility); these suffice to implement a terminal-like interface. Howeverthe newui-linegrid represents text more efficiently (especially highlightedtext), and allows UI capabilities requiring multiple grids. New UIs shouldimplementui-linegrid instead ofui-grid-old.
Nvim optionally sends various screen elements "semantically" as structuredevents instead of raw grid-lines, as specified byui-ext-options. The UImust present such elements itself, Nvim will not draw them on the grid.
Future versions of Nvim may add new update kinds and may append new parametersto existing update kinds. Clients must be prepared to ignore such extensions,for forward-compatibility.api-contract

UI startupui-startup

UI embedders (clients that start Nvim with--embed and later callnvim_ui_attach()) must start Nvim without--headless:
nvim --embed
Nvim will pause before loading startup files and reading buffers, so the UIhas a chance to invoke requests and do early initialization. Startup willcontinue when the UI invokesnvim_ui_attach().
A simple UI only needs to do a singlenvim_ui_attach() request and thenprepare to handle any UI event. A more featureful UI, which might needadditional configuration of the Nvim process, should use the following startupprocedure:
1. Invokenvim_get_api_info(), if needed to setup the client library and/or to get the list of supported UI extensions.
2. Do any configuration that should be happen before user config is loaded. Buffers and windows are not available at this point, but this could be used to setg: variables visible to init.vim
3. If the UI wants to do additional setup after user config is loaded, register a VimEnter autocmd:
nvim_command("autocmd VimEnter * call rpcrequest(1, 'vimenter')")
4. Now invokenvim_ui_attach(). The UI must handle user input by now: sourcing init.vim and loading buffers might lead to blocking prompts.
5. If step 3 was used, Nvim will send a blocking "vimenter" request to the UI. Inside this request handler, the UI can safely do any initialization before entering normal mode, for example reading variables set by init.vim.
ui-startup-stdin
UIs can support reading from stdin (likecommand | nvim -, see--) as follows:
1. The embedding process detects that the stdin fd is not a terminal.2. It then needs to forward this fd to Nvim. Because fd=0 is already is used to send RPC data from embedder to Nvim, it must use some other file descriptor, like fd=3 or higher.3. Then pass the fd as thestdin_fd parameter ofnvim_ui_attach. Nvim will read it as text into buffer 1.

Global Eventsui-global

The following UI events are always emitted, and describe global state ofthe editor.
["set_title", title]
["set_icon", icon]
Set the window title, and icon (minimized) window title, respectively.In windowing systems not distinguishing between the two, "set_icon"can be ignored.
["mode_info_set", cursor_style_enabled, mode_info]
cursor_style_enabled is a boolean indicating if the UI should setthe cursor style.mode_info is a list of mode property maps. Thecurrent mode is given by themode_idx field of themode_changeevent.
Each mode property map may contain these keys:
KEYDESCRIPTION
cursor_shape:"block", "horizontal", "vertical"cell_percentage: Cell % occupied by the cursor.blinkwait,blinkon,blinkoff: Seecursor-blinking.attr_id:Cursor attribute id (defined byhl_attr_define).When attr_id is 0, the background and foregroundcolors should be swapped.attr_id_lm:Cursor attribute id for when:lmap is on.short_name:Mode code name, see'guicursor'.name:Mode descriptive name.mouse_shape:(To be implemented.)
Some keys are missing in some modes.
The following keys are deprecated:
hl_id:Useattr_id instead.id_lm:Useattr_id_lm instead.
["option_set", name, value]
UI-related option changed, wherename is one of:
'arabicshape'
'ambiwidth'
'emoji'
'guifont'
'guifontwide'
'linespace'
'mousefocus'
'mousehide'
'mousemoveevent'
'pumblend'
'showtabline'
'termguicolors'
"ext_*" (allui-ext-options)
Triggered when the UI first connects to Nvim, and whenever an optionis changed by the user or a plugin.
Options are not represented here if their effects are communicated inother UI events. For example, instead of forwarding the'mouse' optionvalue, the "mouse_on" and "mouse_off" UI events directly indicate ifmouse support is active. Some options like'ambiwidth' have alreadytaken effect on the grid, where appropriate empty cells are added,however a UI might still use such options when rendering raw textsent from Nvim, like forui-cmdline.
["chdir", path]
Thecurrent-directory changed topath.
["mode_change", mode, mode_idx]
Editor mode changed. Themode parameter is a string representingthe current mode.mode_idx is an index into the array emitted inthemode_info_set event. UIs should change the cursor styleaccording to the properties specified in the corresponding item. Theset of modes reported will change in new versions of Nvim, forinstance more submodes and temporary states might be represented asseparate modes.
["mouse_on"]
["mouse_off"]
'mouse' was enabled/disabled in the current editor mode. Useful fora terminal UI, or embedding into an application where Nvim mouse wouldconflict with other usages of the mouse. Other UI:s may ignore this event.
["busy_start"]
["busy_stop"]
Indicates to the UI that it must stop rendering the cursor. This eventis misnamed and does not actually have anything to do with busyness.
["restart", progpath, argv]
:restart command has been used and the Nvim server is about to exit.The UI should wait for the server to exit, and then start a new serverusingprogpath as the full path to the Nvim executablev:progpath andargv as its argumentsv:argv, and reattach to the new server.Note:--embed and--headless are excluded fromargv, and the clientshould decide itself whether to add either flag.
["suspend"]
:suspend command orCTRL-Z mapping is used. A terminal client (oranother client where it makes sense) could suspend itself. Otherclients can safely ignore it.
["update_menu"]
The menu mappings changed.
["bell"]
["visual_bell"]
Notify the user with an audible or visual bell, respectively.
["flush"]
Nvim is done redrawing the screen. For an implementation that rendersto an internal buffer, this is the time to display the redrawn partsto the user.
["ui_send", content]
Write{content} to the connected TTY. Only UIs that have the"stdout_tty"ui-option set will receive this event.

Grid Events (line-based)ui-linegrid

Activated by theext_linegridui-option. Recommended for all new UIs.Deactivatesui-grid-old implicitly.
Unlikeui-grid-old, this UI extension emits a singlegrid_line event toupdate a screen-line (whereas the old protocol emitted separate cursor,highlight and text events per screen-line).
Most of these events take agrid index as first parameter. Grid 1 is theglobal grid used by default for the entire editor screen state. Theext_linegrid capability by itself will never cause any additional grids tobe created; to enable per-window grids, activateui-multigrid.
Highlight attribute groups are predefined. UIs should maintain a table to mapnumerical highlight ids to the actual attributes.
["grid_resize", grid, width, height]
Resize agrid. Ifgrid wasn't seen by the client before, a new grid isbeing created with this size.
["default_colors_set", rgb_fg, rgb_bg, rgb_sp, cterm_fg, cterm_bg]
The first three arguments set the default foreground, background andspecial colors respectively.cterm_fg andcterm_bg specifies thedefault color codes to use in a 256-color terminal.
The RGB values will always be valid colors, by default. If nocolors have been set, they will default to black and white, dependingon'background'. By setting theext_termcolors option, instead-1 will be used for unset colors. This is mostly useful for a TUIimplementation, where using the terminal builtin ("ANSI") defaultsare expected.
Note: Unlike the correspondingui-grid-old events, the screen is notalways cleared after sending this event. The UI must repaint thescreen with changed background color itself.
ui-event-hl_attr_define
["hl_attr_define", id, rgb_attr, cterm_attr, info]
Add a highlight withid to the highlight table, with theattributes specified by thergb_attr andcterm_attr dicts, with thefollowing (all optional) keys.
foreground:foreground color.background:background color.special:color to use for various underlines, whenpresent.reverse:reverse video. Foreground and background colorsare switched.italic:italic text.bold:bold text.strikethrough:struckthrough text.underline:underlined text. The line hasspecial color.undercurl:undercurled text. The curl hasspecial color.underdouble:double underlined text. The lines havespecial color.underdotted:underdotted text. The dots havespecial color.underdashed:underdashed text. The dashes havespecial color.altfont:alternative font.blend:blend level (0-100). Could be used by UIs tosupport blending floating windows to thebackground or to signal a transparent cursor.url:URL associated with this highlight. UIs shouldpresent the region as a clickable hyperlink.
For absent color keys the default color should be used. Don't storethe default value in the table, rather a sentinel value, so thata changed default color will take effect.All boolean keys default to false, and will only be sent when theyare true.
Highlights are always transmitted both for both the RGB format and asterminal 256-color codes, as thergb_attr andcterm_attr parametersrespectively. Theui-rgb option has no effect anymore.Most external UIs will only need to store and use thergb_attrattributes.
id 0 will always be used for the default highlight with colors definedbydefault_colors_set and no styles applied.
Note: Nvim may reuseid values if its internal highlight table is full.In that case Nvim will always issue redraws of screen cells that areaffected by redefined ids, so UIs do not need to keep track of thisthemselves.
info is an empty array unlessui-hlstate is enabled.
["hl_group_set", name, hl_id]
The built-in highlight groupname was set to use the attributeshl_iddefined by a previoushl_attr_define call. This event is not neededto render the grids which use attribute ids directly, but is usefulfor a UI who want to render its own elements with consistenthighlighting. For instance a UI usingui-popupmenu events, mightuse thehl-Pmenu family of builtin highlights.
ui-event-grid_line
["grid_line", grid, row, col_start, cells, wrap]
Redraw a continuous part of arow on agrid, starting at the columncol_start.cells is an array of arrays each with 1 to 3 items:[text(, hl_id, repeat)] .text is the UTF-8 text that should be put ina cell, with the highlighthl_id defined by a previoushl_attr_definecall. Ifhl_id is not present the most recently seenhl_id inthe same call should be used (it is always sent for the firstcell in the event). Ifrepeat is present, the cell should berepeatedrepeat times (including the first time), otherwise justonce.
The right cell of a double-width char will be represented as the emptystring. Double-width chars never userepeat.
If the array of cell changes doesn't reach to the end of the line, therest should remain unchanged. A whitespace char, repeatedenough to cover the remaining line, will be sent when the rest of theline should be cleared.
wrap is a boolean indicating that this line wraps to the next row.When redrawing a line which wraps to the next row, Nvim will emit agrid_line event covering the last column of the line withwrap setto true, followed immediately by agrid_line event starting at thefirst column of the next row.
["grid_clear", grid]
Clear agrid.
["grid_destroy", grid]
grid will not be used anymore and the UI can free any data associatedwith it.
["grid_cursor_goto", grid, row, col]
Makesgrid the current grid androw, col the cursor position on thisgrid. This event will be sent at most once in aredraw batch andindicates the visible cursor position.
["grid_scroll", grid, top, bot, left, right, rows, cols]
Scroll a region ofgrid. This is semantically unrelated to editorscrolling, rather this is an optimized way to say "copy these screencells".
The following diagrams show what happens per scroll direction."===" represents the SR (scroll region) boundaries."---" represents the moved rectangles.Note that dst and src share a common region.
Ifrows is bigger than 0, move a rectangle in the SR up, this canhappen while scrolling down.
+-------------------------+| (clipped above SR)      |            ^|=========================| dst_top    || dst (still in SR)       |            |+-------------------------+ src_top    || src (moved up) and dst  |            ||-------------------------| dst_bot    || src (invalid)           |            |+=========================+ src_bot
Ifrows is less than zero, move a rectangle in the SR down, this canhappen while scrolling up.
+=========================+ src_top| src (invalid)           |            ||------------------------ | dst_top    || src (moved down) and dst|            |+-------------------------+ src_bot    || dst (still in SR)       |            ||=========================| dst_bot    || (clipped below SR)      |            v+-------------------------+
cols is always zero in this version of Nvim, and reserved for futureuse.
Note when updating code fromui-grid-old events: ranges areend-exclusive, which is consistent with API conventions, but differentfromset_scroll_region which was end-inclusive.
The scrolled-in area will be filled usingui-event-grid_line directlyafter the scroll event. The UI thus doesn't need to clear this area aspart of handling the scroll event.

Grid Events (cell-based)ui-grid-old

This is the legacy representation of the screen grid, emitted ifui-linegridis not active. New UIs should implementui-linegrid instead.
["resize", width, height]
The grid is resized towidth andheight cells.
["clear"]
Clear the grid.
["eol_clear"]
Clear from the cursor position to the end of the current line.
["cursor_goto", row, col]
Move the cursor to position (row, col). Currently, the same cursor isused to define the position for text insertion and the visible cursor.However, only the last cursor position, after processing the entirearray in the "redraw" event, is intended to be a visible cursorposition.
["update_fg", color]
["update_bg", color]
["update_sp", color]
Set the default foreground, background and special colorsrespectively.
ui-event-highlight_set
["highlight_set", attrs]
Set the attributes that the next text put on the grid will have.attrs is a dict with the keys below. Any absent key is resetto its default value. Color defaults are set by theupdate_fg etcupdates. All boolean keys default to false.
foreground:foreground color.background:background color.special:color to use for various underlines, when present.reverse:reverse video. Foreground and background colors areswitched.italic:italic text.bold:bold text.strikethrough: struckthrough text.underline:underlined text. The line hasspecial color.undercurl:undercurled text. The curl hasspecial color.underdouble:double underlined text. The lines havespecial color.underdotted:underdotted text. The dots havespecial color.underdashed:underdashed text. The dashes havespecial color.
["put", text]
The (utf-8 encoded) stringtext is put at the cursor position(and the cursor is advanced), with the highlights as set by thelasthighlight_set update.
["set_scroll_region", top, bot, left, right]
Define the scroll region used byscroll below.
Note: ranges are end-inclusive, which is inconsistent with APIconventions.
["scroll", count]
Scroll the text in the scroll region. The diagrams below illustratewhat will happen, depending on the scroll direction. "=" is used torepresent the SR(scroll region) boundaries and "-" the moved rectangles.Note that dst and src share a common region.
If count is bigger than 0, move a rectangle in the SR up, this canhappen while scrolling down.
+-------------------------+| (clipped above SR)      |            ^|=========================| dst_top    || dst (still in SR)       |            |+-------------------------+ src_top    || src (moved up) and dst  |            ||-------------------------| dst_bot    || src (cleared)           |            |+=========================+ src_bot
If count is less than zero, move a rectangle in the SR down, this canhappen while scrolling up.
+=========================+ src_top| src (cleared)           |            ||------------------------ | dst_top    || src (moved down) and dst|            |+-------------------------+ src_bot    || dst (still in SR)       |            ||=========================| dst_bot    || (clipped below SR)      |            v+-------------------------+

Highlight Eventsui-hlstate

Activated by theext_hlstateui-option.Activatesui-linegrid implicitly.
Ifext_hlstate is enabled, Nvim will emit detailed highlight state inui-linegrid events. Otherwise (by default) Nvim only describes grid cellsusing the final calculated highlight attributes described atui-event-highlight_set.
ext_hlstate provides a semantic description of active highlights for eachgrid cell. Highlights are predefined in a table, seeui-event-hl_attr_defineandui-event-grid_line.
Theinfo parameter inhl_attr_define contains a semantic description ofthe highlights. Because highlight groups can be combined, this is an arraywhere the highest-priority item is last. Each item is a dict with these keys:
kind:always present. One of the following values:"ui": Builtin UI highlight.highlight-groups"syntax": Highlight applied to a buffer by a syntax declaration or other runtime/plugin functionality such asnvim_buf_set_extmark() "terminal": highlight from a process running in aterminal-emulator. Contains no further semantic information.ui_name:Highlight name fromhighlight-groups. Only for "ui" kind.hi_name:Name of the final:highlight group where the usedattributes are defined.id:Unique numeric id representing this item.
Note: "ui" items will have bothui_name andhi_name present. These candiffer, because the builtin group was linked to another group:hi-link , orbecause'winhighlight' was used. UI items will be transmitted, even if thehighlight group is cleared, soui_name can always be used to reliably identifyscreen elements, even if no attributes have been applied.

Multigrid Eventsui-multigrid

Activated by theext_multigridui-option.Activatesui-linegrid implicitly.
Seeui-linegrid for grid events.Seenvim_ui_try_resize_grid() to request changing the grid size.Seenvim_input_mouse() for sending mouse events to Nvim.
The multigrid extension gives UIs more control over how windows are displayed:
UIs receive updates on a separate grid for each window.
UIs can set the grid size independently of how much space the window occupies on the global layout. So the UI could use a different font size per-window. Or reserve space around the border of the window for its own elements, such as scrollbars from the UI toolkit.
A dedicated grid is used for messages, which may scroll over the window area. (Alternativelyui-messages can be used).
By default, the grid size is handled by Nvim and set to the outer grid size(i.e. the size of the window frame in Nvim) whenever the split is created.Once a UI sets a grid size, Nvim does not handle the size for that grid andthe UI must change the grid size whenever the outer size is changed. Todelegate grid-size handling back to Nvim, request the size (0, 0).
A window can be hidden and redisplayed without its grid being deallocated.This can happen multiple times for the same window, for instance when switchingtabs.
["win_pos", grid, win, start_row, start_col, width, height]
Set the position and size of the grid in Nvim (i.e. the outer gridsize). If the window was previously hidden, it should now be shownagain.
["win_float_pos", grid, win, anchor, anchor_grid, anchor_row, anchor_col, mouse_enabled, zindex, compindex, screen_row, screen_col]
Display or reconfigure floating windowwin.
There are two alternative ways of positioning the window
Manually - The window should be displayed above another gridanchor_grid at the specified positionanchor_row andanchor_col. For the meaning ofanchor and more details of positioning, seenvim_open_win(). NOTE: you have to manually ensure that the window fits the screen, possibly by further reposition it. Ignorescreen_row andscreen_col in this case.
Let nvim take care of the positioning - You can ignoreanchor and display the window atscreen_row andscreen_col.
mouse_enabled is true if the window can receive mouse events.
zindex is the configured zindex, whilecompindex is the exactrendering order of the windows determined by nvim. To render exactlylike the TUI, first render all the non-floating windows, then renderin thecompindex order, overwriting any floating window cells.Finally, blend the floating window cells against the non-floatingbackground. To add more blending, you can group the windows by zindex,and blend between the layers. But note that windows inside the samezindex should still overwrite previous cells inside the same layerwithout blending. This ensures that plugins that render multiplewindows, to add borders for example, work as expected.
["win_external_pos", grid, win]
Display or reconfigure external windowwin. The window should bedisplayed as a separate top-level window in the desktop environment,or something similar.
["win_hide", grid]
Stop displaying the window. The window can be shown again later.
["win_close", grid]
Close the window.
["msg_set_pos", grid, row, scrolled, sep_char, zindex, compindex]
Display messages ongrid. The grid will be displayed atrow onthe default grid (grid=1), covering the full column width.scrolledindicates whether the message area has been scrolled to cover othergrids. It can be useful to draw a separator thenmsgsep. The BuiltinTUI draws a full line filled withsep_char ('fillchars' msgsepfield) andhl-MsgSeparator highlight.
Whenui-messages is active, no message grid is used, and this eventwill not be sent.
zindex andcompindex have the same meaning as forwin_float_pos.Thezindex always has a fixed value of 200 and included forcompleteness.
["win_viewport", grid, win, topline, botline, curline, curcol, line_count, scroll_delta]
Indicates the range of buffer text displayed in the window, as wellas the cursor position in the buffer. All positions are zero-based.botline is set to one more than the line count of the buffer, ifthere are filler lines past the end.scroll_delta contains how muchthe top line of a window moved sincewin_viewport was last emitted.It is intended to be used to implement smooth scrolling. For thispurpose it only counts "virtual" or "displayed" lines, so foldsonly count as one line. When scrolling more than a full screen it isan approximate value.
All updates, such asgrid_line, in a batch affects the new viewport,despite the fact thatwin_viewport is received after the updates.Applications implementing, for example, smooth scrolling should takethis into account and keep the grid separated from what's displayed onthe screen and copy it to the viewport destination oncewin_viewportis received.
["win_viewport_margins", grid, win, top, bottom, left, right]
Indicates the margins of a window grid which are _not_ part of theviewport as indicated by thewin_viewport event. This happense.g. in the presence of'winbar' and floating window borders.
["win_extmark", grid, win, ns_id, mark_id, row, col]
Updates the position of an extmark which is currently visible in awindow. Only emitted if the mark has theui_watched attribute.

Popupmenu Eventsui-popupmenu

Activated by theext_popupmenuui-option.
This UI extension delegates presentation of thepopupmenu-completion andcommand-line'wildmenu'.
The UI decides how to present the menu. For example, depending on the lastmode_change event, command-line wildmenu may be presented horizontally,while insert-mode completion would show a vertical popupmenu.
["popupmenu_show", items, selected, row, col, grid]
Showpopupmenu-completion.items is an array of completion itemsto show; each item is an array of the form [word, kind, menu, info] asdefined atcomplete-items, except thatword is replaced byabbrif present.selected is the initially-selected item, a zero-basedindex into the array of items (-1 if no item is selected).row andcol give the anchor position, where the first character of thecompleted word will be. Whenui-multigrid is used,grid is thegrid for the anchor position. Whenext_cmdline is active,grid isset to -1 to indicate the popupmenu should be anchored to the externalcmdline. Thencol will be a byte position in the cmdline text.
["popupmenu_select", selected]
Select an item in the current popupmenu.selected is a zero-basedindex into the array of items from the last popupmenu_show event, or-1 if no item is selected.
["popupmenu_hide"]
Hide the popupmenu.

Tabline Eventsui-tabline

Activated by theext_tablineui-option.
["tabline_update", curtab, tabs, curbuf, buffers]
Tabline was updated. UIs should present this data in a custom tablinewidget. Note: optionscurbuf +buffers were added in API7.curtab: Current Tabpagetabs: List of Dicts [{ "tab": Tabpage, "name": String }, ...]curbuf: Current buffer handle.buffers: List of Dicts [{ "buffer": buffer handle, "name": String}, ...]

Cmdline Eventsui-cmdline

Activated by theext_cmdlineui-option.
This UI extension delegates presentation of thecmdline (except'wildmenu').For command-line'wildmenu' UI events, activateui-popupmenu.
["cmdline_show", content, pos, firstc, prompt, indent, level, hl_id]
content: List of [attrs, string, hl_id] [[{}, "t", hl_id], [attrs, "est", hl_id], ...]
Triggered when the cmdline is displayed or changed.Thecontent is the full content that should be displayed in thecmdline, and thepos is the position of the cursor that in thecmdline. The content is divided into chunks with different highlightattributes represented as a dict (seeui-event-highlight_set).
firstc andprompt are text, that if non-empty should bedisplayed in front of the command line.firstc always indicatesbuilt-in command lines such as: (ex command) and/? (search),whileprompt is aninput() prompt, highlighted withhl_id.indent tells how many spaces the content should be indented.
The Nvim command line can be invoked recursively, for instance bytyping<c-r>= at the command line prompt. Thelevel field is usedto distinguish different command lines active at the same time. Thefirst invoked command line has level 1, the next recursively-invokedprompt has level 2. A command line invoked from thecmdline-windowhas a higher level than the edited command line.
["cmdline_pos", pos, level]
Change the cursor position in the cmdline.
["cmdline_special_char", c, shift, level]
Display a special char in the cmdline at the cursor position. This istypically used to indicate a pending state, e.g. afterc_CTRL-V. Ifshift is true the text after the cursor should be shifted, otherwiseit should overwrite the char at the cursor.
Should be hidden at next cmdline_show.
["cmdline_hide", level, abort]
Hide the cmdline.level is the nesting level of the cmdline being hidden.abort is true if the cmdline is hidden after an aborting condition(c_Esc orc_CTRL-C).
["cmdline_block_show", lines]
Show a block of context to the current command line. For example ifthe user defines a:function interactively:
:function Foo():  echo "foo":
lines is a list of lines of highlighted chunks, in the same form asthe "cmdline_show"contents parameter.
["cmdline_block_append", line]
Append a line at the end of the currently shown block.
["cmdline_block_hide"]
Hide the block.

Message/Dialog Eventsui-messages

Activated by theext_messagesui-option.Activatesui-linegrid andui-cmdline implicitly.
This UI extension delegates presentation of messages and dialogs. Messagesthat would otherwise render in the message/cmdline screen space, are emittedas UI events.
Nvim will not allocate screen space for the cmdline or messages.'cmdheight'will be set to zero, but can be changed and used for the replacing cmdline ormessage window. Cmdline state is emitted asui-cmdline events, which the UImust handle.
["msg_show", kind, content, replace_last, history, append, msg_id]
Display a message to the user. Update (replace) any existing messagematchingmsg_id.
kind Name indicating the message kind:"" (empty)Unknown (consider afeature-request)"empty"Empty message (:echo ""), with emptycontent.Should clear messages sharing the'cmdheight'area if it is the only message in a batch."bufwrite":write message"confirm"Message preceding a prompt (:confirm,confirm(),inputlist(),z=, …)"emsg"Error (errors, internal error,:throw, …)"echo":echo message"echomsg":echomsg message"echoerr":echoerr message"completion"ins-completion-menu message"list_cmd"List output for various commands (:ls,:set, …)"lua_error"Error in:lua code"lua_print"print() from:lua code"progress"Progress message emitted bynvim_echo()"rpc_error"Error response fromrpcrequest()"quickfix"Quickfix navigation message"search_cmd"Entered search command"search_count"Search count message ("S" flag of'shortmess')"shell_cmd":!cmd executed command"shell_err":!cmd shell stderr output"shell_out":!cmd shell stdout output"shell_ret":!cmd shell return code"undo":undo and:redo message"verbose"'verbose' message"wildlist"'wildmode' "list" message"wmsg"Warning ("search hit BOTTOM",W10, …) New kinds may be added in the future; clients should treat unknown kinds as the empty kind.
content Array of[attr_id, text_chunk, hl_id] tuples, building up the message text of chunks of different highlights. No extra spacing should be added between chunks, thetext_chunk by itself contains any necessary whitespace. Messages can contain line breaks "\n".
replace_last Decides how multiple messages should be displayed: false: Display the message together with all previous messages that are still visible. true: Replace the message in the most-recentmsg_show call, but any other visible message should still remain.
history True if the message was added to the:messages history.
append True if the message should be appended to the previous message, rather than started on a new line. Is set for:echon.
msg_id Unique identifier for the message. It can either be an integer or string. When message of same id appears it should replace the older message.
["msg_clear"]
Clear all messages currently displayed by "msg_show", emitted afterclearing the screen (messages sent by other "msg_" events below shouldnot be affected).
Guidance: The "clear messages" behavior is UI-specific. If the UIpresents messages in a new window, it may choose to clear messagesafter a few seconds. If the UI presents messages in a persistent area(e.g. cmdline), it should clear messages at the start of the nextbatch (typically, the next event-loop cycle).
["msg_showmode", content]
Shows'showmode' andrecording messages.content has the sameformat as in "msg_show". This event is sent with emptycontent tohide the last message.
["msg_showcmd", content]
Shows'showcmd' messages.content has the same format as in "msg_show".This event is sent with emptycontent to hide the last message.
["msg_ruler", content]
Used to display'ruler' when there is no space for the ruler in astatusline.content has the same format as in "msg_show". This event issent with emptycontent to hide the last message.
["msg_history_show", entries, prev_cmd]
Sent when:messages org< command is invoked. History is sent as alist of entries, where each entry is a[kind, content, append] tuple.
prev_cmd True when sent withg< command, false with:messages.
Main
Commands index
Quick reference

UI Events
UI startup
Global Events
Grid Events (line-based)
Grid Events (cell-based)
Highlight Events
Multigrid Events
Popupmenu Events
Tabline Events
Cmdline Events
Message/Dialog Events

[8]ページ先頭

©2009-2025 Movatter.jp