ui.txt 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811
  1. *ui.txt* Nvim
  2. NVIM REFERENCE MANUAL
  3. Nvim UI protocol *UI* *ui*
  4. Type |gO| to see the table of contents.
  5. ==============================================================================
  6. UI Events *ui-events*
  7. UIs can be implemented as external client processes communicating with Nvim
  8. over the RPC API. The default UI model is a terminal-like grid with a single,
  9. monospace font. The UI can opt-in to have windows drawn on separate grids, and
  10. have some elements ("widgets") presented by the UI itself rather than by Nvim
  11. ("externalized").
  12. *ui-option*
  13. Call |nvim_ui_attach()| to tell Nvim that your program wants to draw the Nvim
  14. screen grid with a size of width × height cells. This is typically done by an
  15. embedder at startup (see |ui-startup|), but UIs can also connect to a running
  16. Nvim instance and invoke nvim_ui_attach(). The `options` parameter is a map
  17. with these (optional) keys:
  18. *ui-rgb*
  19. - `rgb` Decides the color format.
  20. - true: (default) 24-bit RGB colors
  21. - false: Terminal colors (8-bit, max 256)
  22. *ui-override*
  23. - `override` Decides how UI capabilities are resolved.
  24. - true: Enable requested UI capabilities, even if not
  25. supported by all connected UIs (including |TUI|).
  26. - false: (default) Disable UI capabilities not
  27. supported by all connected UIs (including TUI).
  28. *ui-ext-options*
  29. - `ext_cmdline` Externalize the cmdline. |ui-cmdline|
  30. - `ext_hlstate` Detailed highlight state. |ui-hlstate|
  31. Sets `ext_linegrid` implicitly.
  32. - `ext_linegrid` Line-based grid events. |ui-linegrid|
  33. Deactivates |ui-grid-old| implicitly.
  34. - `ext_messages` Externalize messages. |ui-messages|
  35. Sets `ext_linegrid` and `ext_cmdline` implicitly.
  36. - `ext_multigrid` Per-window grid events. |ui-multigrid|
  37. Sets `ext_linegrid` implicitly.
  38. - `ext_popupmenu` Externalize |popupmenu-completion| and
  39. 'wildmenu'. |ui-popupmenu|
  40. - `ext_tabline` Externalize the tabline. |ui-tabline|
  41. - `ext_termcolors` Use external default colors.
  42. - `term_name` Sets the name of the terminal 'term'.
  43. - `term_colors` Sets the number of supported colors 't_Co'.
  44. - `term_background` Sets the default value of 'background'.
  45. - `stdin_fd` Read buffer from `fd` as if it was a stdin pipe
  46. This option can only used by |--embed| ui,
  47. see |ui-startup-stdin|.
  48. Specifying an unknown option is an error; UIs can check the |api-metadata|
  49. `ui_options` key for supported options.
  50. By default Nvim requires all connected UIs to support the same capabilities,
  51. thus the active capabilities are the intersection of those requested. UIs may
  52. specify |ui-override| to invert this behavior (useful for debugging). The
  53. "option_set" event announces which capabilities are active.
  54. Nvim sends RPC notifications to all attached UIs, with method name "redraw"
  55. and a single argument: an array (batch) of screen "update events". Each update
  56. event is itself an array whose first element is the event name and remaining
  57. elements are event-parameter tuples. Thus multiple events of the same kind can
  58. be sent contiguously without repeating the event name.
  59. Example of a typical "redraw" batch in a single RPC notification: >
  60. ['notification', 'redraw',
  61. [
  62. ['grid_resize', [2, 77, 36]],
  63. ['grid_line',
  64. [2, 0, 0, [[' ' , 0, 77]]],
  65. [2, 1, 0, [['~', 7], [' ', 7, 76]]],
  66. [2, 9, 0, [['~', 7], [' ', 7, 76]]],
  67. ...
  68. [2, 35, 0, [['~', 7], [' ', 7, 76]]],
  69. [1, 36, 0, [['[', 9], ['N'], ['o'], [' '], ['N'], ['a'], ['m'], ['e'], [']']]],
  70. [1, 36, 9, [[' ', 9, 50]]],
  71. [1, 36, 59, [['0', 9], [','], ['0'], ['-' ], ['1'], [' ', 9, 10], ['A'], ['l', 9, 2]]]
  72. ],
  73. ['msg_showmode', [[]]],
  74. ['win_pos', [2, 1000, 0, 0, 77, 36]],
  75. ['grid_cursor_goto', [2, 0, 0]],
  76. ['flush', []]
  77. ]
  78. ]
  79. Events must be handled in-order. Nvim sends a "flush" event when it has
  80. completed a redraw of the entire screen (so all windows have a consistent view
  81. of buffer state, options, etc.). Multiple "redraw" batches may be sent before
  82. the entire screen has been redrawn, with "flush" following only the last
  83. batch. The user should only see the final state (when "flush" is sent), not
  84. any intermediate state while processing part of the batch array, nor after
  85. a batch not ending with "flush".
  86. By default, Nvim sends |ui-global| and |ui-grid-old| events (for backwards
  87. compatibility); these suffice to implement a terminal-like interface. However
  88. the new |ui-linegrid| represents text more efficiently (especially highlighted
  89. text), and allows UI capabilities requiring multiple grids. New UIs should
  90. implement |ui-linegrid| instead of |ui-grid-old|.
  91. Nvim optionally sends various screen elements "semantically" as structured
  92. events instead of raw grid-lines, as specified by |ui-ext-options|. The UI
  93. must present such elements itself, Nvim will not draw them on the grid.
  94. Future versions of Nvim may add new update kinds and may append new parameters
  95. to existing update kinds. Clients must be prepared to ignore such extensions,
  96. for forward-compatibility. |api-contract|
  97. ==============================================================================
  98. UI startup *ui-startup*
  99. UI embedders (clients that start Nvim with |--embed| and later call
  100. |nvim_ui_attach()|) must start Nvim without |--headless|: >
  101. nvim --embed
  102. Nvim will pause before loading startup files and reading buffers, so the UI
  103. has a chance to invoke requests and do early initialization. Startup will
  104. continue as soon as the UI invokes |nvim_ui_attach()|.
  105. A simple UI only needs to do a single |nvim_ui_attach()| request and then
  106. prepare to handle any UI event. A more featureful UI, which might need
  107. additional configuration of the Nvim process, should use the following startup
  108. procedure:
  109. 1. Invoke |nvim_get_api_info()|, if needed to setup the client library and/or
  110. to get the list of supported UI extensions.
  111. 2. Do any configuration that should be happen before user config is loaded.
  112. Buffers and windows are not available at this point, but this could be used
  113. to set |g:| variables visible to init.vim
  114. 3. If the UI wants to do additional setup after user config is loaded,
  115. register a VimEnter autocmd: >
  116. nvim_command("autocmd VimEnter * call rpcrequest(1, 'vimenter')")
  117. 4. Now invoke |nvim_ui_attach()|. The UI must handle user input by now:
  118. sourcing init.vim and loading buffers might lead to blocking prompts.
  119. 5. If step 3 was used, Nvim will send a blocking "vimenter" request to the UI.
  120. Inside this request handler, the UI can safely do any initialization before
  121. entering normal mode, for example reading variables set by init.vim.
  122. *ui-startup-stdin*
  123. An UI can support the native read from stdin feature as invoked with
  124. `command | nvim -` for the builtin TUI. |--|
  125. The embedding process can detect that its stdin is open to a file which
  126. not is a terminal, just like nvim does. It then needs to forward this fd
  127. to Nvim. As fd=0 is already is used to send rpc data from the embedder to
  128. Nvim, it needs to use some other file descriptor, like fd=3 or higher.
  129. Then, `stdin_fd` option should be passed to `nvim_ui_attach` and nvim will
  130. implicitly read it as a buffer. This option can only be used when Nvim is
  131. launched with `--embed` option, as described above.
  132. ==============================================================================
  133. Global Events *ui-global*
  134. The following UI events are always emitted, and describe global state of
  135. the editor.
  136. ["set_title", title] ~
  137. ["set_icon", icon] ~
  138. Set the window title, and icon (minimized) window title, respectively.
  139. In windowing systems not distinguishing between the two, "set_icon"
  140. can be ignored.
  141. ["mode_info_set", cursor_style_enabled, mode_info] ~
  142. `cursor_style_enabled` is a boolean indicating if the UI should set
  143. the cursor style. `mode_info` is a list of mode property maps. The
  144. current mode is given by the `mode_idx` field of the `mode_change`
  145. event.
  146. Each mode property map may contain these keys:
  147. KEY DESCRIPTION ~
  148. `cursor_shape`: "block", "horizontal", "vertical"
  149. `cell_percentage`: Cell % occupied by the cursor.
  150. `blinkwait`, `blinkon`, `blinkoff`: See |cursor-blinking|.
  151. `attr_id`: Cursor attribute id (defined by `hl_attr_define`).
  152. When attr_id is 0, the background and foreground
  153. colors should be swapped.
  154. `attr_id_lm`: Cursor attribute id for when 'langmap' is active.
  155. `short_name`: Mode code name, see 'guicursor'.
  156. `name`: Mode descriptive name.
  157. `mouse_shape`: (To be implemented.)
  158. Some keys are missing in some modes.
  159. The following keys are deprecated:
  160. `hl_id`: Use `attr_id` instead.
  161. `hl_lm`: Use `attr_id_lm` instead.
  162. ["option_set", name, value] ~
  163. UI-related option changed, where `name` is one of:
  164. - 'arabicshape'
  165. - 'ambiwidth'
  166. - 'emoji'
  167. - 'guifont'
  168. - 'guifontwide'
  169. - 'linespace'
  170. - 'mousefocus'
  171. - 'mousemoveevent'
  172. - 'pumblend'
  173. - 'showtabline'
  174. - 'termguicolors'
  175. - "ext_*" (all |ui-ext-options|)
  176. Triggered when the UI first connects to Nvim, and whenever an option
  177. is changed by the user or a plugin.
  178. Options are not represented here if their effects are communicated in
  179. other UI events. For example, instead of forwarding the 'mouse' option
  180. value, the "mouse_on" and "mouse_off" UI events directly indicate if
  181. mouse support is active. Some options like 'ambiwidth' have already
  182. taken effect on the grid, where appropriate empty cells are added,
  183. however a UI might still use such options when rendering raw text
  184. sent from Nvim, like for |ui-cmdline|.
  185. ["mode_change", mode, mode_idx] ~
  186. Editor mode changed. The `mode` parameter is a string representing
  187. the current mode. `mode_idx` is an index into the array emitted in
  188. the `mode_info_set` event. UIs should change the cursor style
  189. according to the properties specified in the corresponding item. The
  190. set of modes reported will change in new versions of Nvim, for
  191. instance more submodes and temporary states might be represented as
  192. separate modes.
  193. ["mouse_on"] ~
  194. ["mouse_off"] ~
  195. 'mouse' was enabled/disabled in the current editor mode. Useful for
  196. a terminal UI, or embedding into an application where Nvim mouse would
  197. conflict with other usages of the mouse. Other UI:s may ignore this event.
  198. ["busy_start"] ~
  199. ["busy_stop"] ~
  200. Indicates to the UI that it must stop rendering the cursor. This event
  201. is misnamed and does not actually have anything to do with busyness.
  202. ["suspend"] ~
  203. |:suspend| command or |CTRL-Z| mapping is used. A terminal client (or
  204. another client where it makes sense) could suspend itself. Other
  205. clients can safely ignore it.
  206. ["update_menu"] ~
  207. The menu mappings changed.
  208. ["bell"] ~
  209. ["visual_bell"] ~
  210. Notify the user with an audible or visual bell, respectively.
  211. ["flush"] ~
  212. Nvim is done redrawing the screen. For an implementation that renders
  213. to an internal buffer, this is the time to display the redrawn parts
  214. to the user.
  215. ==============================================================================
  216. Grid Events (line-based) *ui-linegrid*
  217. Activated by the `ext_linegrid` |ui-option|. Recommended for all new UIs.
  218. Deactivates |ui-grid-old| implicitly.
  219. The biggest change compared to |ui-grid-old| is to use a single `grid_line`
  220. event to update the contents of a screen line (whereas the old protocol used
  221. a combination of cursor, highlight and text events)
  222. Most of these events take a `grid` index as first parameter. Grid 1 is the
  223. global grid used by default for the entire editor screen state. The
  224. `ext_linegrid` capability by itself will never cause any additional grids to
  225. be created; to enable per-window grids, activate |ui-multigrid|.
  226. Highlight attribute groups are predefined. UIs should maintain a table to map
  227. numerical highlight ids to the actual attributes.
  228. ["grid_resize", grid, width, height] ~
  229. Resize a `grid`. If `grid` wasn't seen by the client before, a new grid is
  230. being created with this size.
  231. ["default_colors_set", rgb_fg, rgb_bg, rgb_sp, cterm_fg, cterm_bg] ~
  232. The first three arguments set the default foreground, background and
  233. special colors respectively. `cterm_fg` and `cterm_bg` specifies the
  234. default color codes to use in a 256-color terminal.
  235. The RGB values will always be valid colors, by default. If no
  236. colors have been set, they will default to black and white, depending
  237. on 'background'. By setting the `ext_termcolors` option, instead
  238. -1 will be used for unset colors. This is mostly useful for a TUI
  239. implementation, where using the terminal builtin ("ANSI") defaults
  240. are expected.
  241. Note: Unlike the corresponding |ui-grid-old| events, the screen is not
  242. always cleared after sending this event. The UI must repaint the
  243. screen with changed background color itself.
  244. *ui-event-hl_attr_define*
  245. ["hl_attr_define", id, rgb_attr, cterm_attr, info] ~
  246. Add a highlight with `id` to the highlight table, with the
  247. attributes specified by the `rgb_attr` and `cterm_attr` dicts, with the
  248. following (all optional) keys.
  249. `foreground`: foreground color.
  250. `background`: background color.
  251. `special`: color to use for various underlines, when
  252. present.
  253. `reverse`: reverse video. Foreground and background colors
  254. are switched.
  255. `italic`: italic text.
  256. `bold`: bold text.
  257. `strikethrough`: struckthrough text.
  258. `underline`: underlined text. The line has `special` color.
  259. `undercurl`: undercurled text. The curl has `special` color.
  260. `underdouble`: double underlined text. The lines have `special` color.
  261. `underdotted`: underdotted text. The dots have `special` color.
  262. `underdashed`: underdashed text. The dashes have `special` color.
  263. `blend`: Blend level (0-100). Could be used by UIs to
  264. support blending floating windows to the
  265. background or to signal a transparent cursor.
  266. For absent color keys the default color should be used. Don't store
  267. the default value in the table, rather a sentinel value, so that
  268. a changed default color will take effect.
  269. All boolean keys default to false, and will only be sent when they
  270. are true.
  271. Highlights are always transmitted both for both the RGB format and as
  272. terminal 256-color codes, as the `rgb_attr` and `cterm_attr` parameters
  273. respectively. The |ui-rgb| option has no effect effect anymore.
  274. Most external UIs will only need to store and use the `rgb_attr`
  275. attributes.
  276. `id` 0 will always be used for the default highlight with colors defined
  277. by `default_colors_set` and no styles applied.
  278. Note: Nvim may reuse `id` values if its internal highlight table is full.
  279. In that case Nvim will always issue redraws of screen cells that are
  280. affected by redefined ids, so UIs do not need to keep track of this
  281. themselves.
  282. `info` is an empty array by default, and will be used by the
  283. |ui-hlstate| extension explained below.
  284. ["hl_group_set", name, hl_id] ~
  285. The bulitin highlight group `name` was set to use the attributes `hl_id`
  286. defined by a previous `hl_attr_define` call. This event is not needed
  287. to render the grids which use attribute ids directly, but is useful
  288. for an UI who want to render its own elements with consistent
  289. highlighting. For instance an UI using |ui-popupmenu| events, might
  290. use the |hl-Pmenu| family of builtin highlights.
  291. *ui-event-grid_line*
  292. ["grid_line", grid, row, col_start, cells] ~
  293. Redraw a continuous part of a `row` on a `grid`, starting at the column
  294. `col_start`. `cells` is an array of arrays each with 1 to 3 items:
  295. `[text(, hl_id, repeat)]` . `text` is the UTF-8 text that should be put in
  296. a cell, with the highlight `hl_id` defined by a previous `hl_attr_define`
  297. call. If `hl_id` is not present the most recently seen `hl_id` in
  298. the same call should be used (it is always sent for the first
  299. cell in the event). If `repeat` is present, the cell should be
  300. repeated `repeat` times (including the first time), otherwise just
  301. once.
  302. The right cell of a double-width char will be represented as the empty
  303. string. Double-width chars never use `repeat`.
  304. If the array of cell changes doesn't reach to the end of the line, the
  305. rest should remain unchanged. A whitespace char, repeated
  306. enough to cover the remaining line, will be sent when the rest of the
  307. line should be cleared.
  308. ["grid_clear", grid] ~
  309. Clear a `grid`.
  310. ["grid_destroy", grid] ~
  311. `grid` will not be used anymore and the UI can free any data associated
  312. with it.
  313. ["grid_cursor_goto", grid, row, column] ~
  314. Makes `grid` the current grid and `row, column` the cursor position on this
  315. grid. This event will be sent at most once in a `redraw` batch and
  316. indicates the visible cursor position.
  317. ["grid_scroll", grid, top, bot, left, right, rows, cols] ~
  318. Scroll a region of `grid`. This is semantically unrelated to editor
  319. |scrolling|, rather this is an optimized way to say "copy these screen
  320. cells".
  321. The following diagrams show what happens per scroll direction.
  322. "===" represents the SR (scroll region) boundaries.
  323. "---" represents the moved rectangles.
  324. Note that dst and src share a common region.
  325. If `rows` is bigger than 0, move a rectangle in the SR up, this can
  326. happen while scrolling down.
  327. >
  328. +-------------------------+
  329. | (clipped above SR) | ^
  330. |=========================| dst_top |
  331. | dst (still in SR) | |
  332. +-------------------------+ src_top |
  333. | src (moved up) and dst | |
  334. |-------------------------| dst_bot |
  335. | src (invalid) | |
  336. +=========================+ src_bot
  337. <
  338. If `rows` is less than zero, move a rectangle in the SR down, this can
  339. happen while scrolling up.
  340. >
  341. +=========================+ src_top
  342. | src (invalid) | |
  343. |------------------------ | dst_top |
  344. | src (moved down) and dst| |
  345. +-------------------------+ src_bot |
  346. | dst (still in SR) | |
  347. |=========================| dst_bot |
  348. | (clipped below SR) | v
  349. +-------------------------+
  350. <
  351. `cols` is always zero in this version of Nvim, and reserved for future
  352. use.
  353. Note when updating code from |ui-grid-old| events: ranges are
  354. end-exclusive, which is consistent with API conventions, but different
  355. from `set_scroll_region` which was end-inclusive.
  356. The scrolled-in area will be filled using |ui-event-grid_line| directly
  357. after the scroll event. The UI thus doesn't need to clear this area as
  358. part of handling the scroll event.
  359. ==============================================================================
  360. Grid Events (cell-based) *ui-grid-old*
  361. This is the legacy representation of the screen grid, emitted if |ui-linegrid|
  362. is not active. New UIs should implement |ui-linegrid| instead.
  363. ["resize", width, height] ~
  364. The grid is resized to `width` and `height` cells.
  365. ["clear"] ~
  366. Clear the grid.
  367. ["eol_clear"] ~
  368. Clear from the cursor position to the end of the current line.
  369. ["cursor_goto", row, col] ~
  370. Move the cursor to position (row, col). Currently, the same cursor is
  371. used to define the position for text insertion and the visible cursor.
  372. However, only the last cursor position, after processing the entire
  373. array in the "redraw" event, is intended to be a visible cursor
  374. position.
  375. ["update_fg", color] ~
  376. ["update_bg", color] ~
  377. ["update_sp", color] ~
  378. Set the default foreground, background and special colors
  379. respectively.
  380. *ui-event-highlight_set*
  381. ["highlight_set", attrs] ~
  382. Set the attributes that the next text put on the grid will have.
  383. `attrs` is a dict with the keys below. Any absent key is reset
  384. to its default value. Color defaults are set by the `update_fg` etc
  385. updates. All boolean keys default to false.
  386. `foreground`: foreground color.
  387. `background`: background color.
  388. `special`: color to use for various underlines, when present.
  389. `reverse`: reverse video. Foreground and background colors are
  390. switched.
  391. `italic`: italic text.
  392. `bold`: bold text.
  393. `strikethrough`: struckthrough text.
  394. `underline`: underlined text. The line has `special` color.
  395. `undercurl`: undercurled text. The curl has `special` color.
  396. `underdouble`: double underlined text. The lines have `special` color.
  397. `underdotted`: underdotted text. The dots have `special` color.
  398. `underdashed`: underdashed text. The dashes have `special` color.
  399. ["put", text] ~
  400. The (utf-8 encoded) string `text` is put at the cursor position
  401. (and the cursor is advanced), with the highlights as set by the
  402. last `highlight_set` update.
  403. ["set_scroll_region", top, bot, left, right] ~
  404. Define the scroll region used by `scroll` below.
  405. Note: ranges are end-inclusive, which is inconsistent with API
  406. conventions.
  407. ["scroll", count] ~
  408. Scroll the text in the scroll region. The diagrams below illustrate
  409. what will happen, depending on the scroll direction. "=" is used to
  410. represent the SR(scroll region) boundaries and "-" the moved rectangles.
  411. Note that dst and src share a common region.
  412. If count is bigger than 0, move a rectangle in the SR up, this can
  413. happen while scrolling down.
  414. >
  415. +-------------------------+
  416. | (clipped above SR) | ^
  417. |=========================| dst_top |
  418. | dst (still in SR) | |
  419. +-------------------------+ src_top |
  420. | src (moved up) and dst | |
  421. |-------------------------| dst_bot |
  422. | src (cleared) | |
  423. +=========================+ src_bot
  424. <
  425. If count is less than zero, move a rectangle in the SR down, this can
  426. happen while scrolling up.
  427. >
  428. +=========================+ src_top
  429. | src (cleared) | |
  430. |------------------------ | dst_top |
  431. | src (moved down) and dst| |
  432. +-------------------------+ src_bot |
  433. | dst (still in SR) | |
  434. |=========================| dst_bot |
  435. | (clipped below SR) | v
  436. +-------------------------+
  437. <
  438. ==============================================================================
  439. Detailed highlight state Extension *ui-hlstate*
  440. Activated by the `ext_hlstate` |ui-option|.
  441. Activates |ui-linegrid| implicitly.
  442. By default Nvim will only describe grid cells using the final calculated
  443. highlight attributes, as described by the dict keys in |ui-event-highlight_set|.
  444. The `ext_hlstate` extension allows to the UI to also receive a semantic
  445. description of the highlights active in a cell. In this mode highlights will be
  446. predefined in a table, see |ui-event-hl_attr_define| and |ui-event-grid_line|.
  447. The `info` parameter in `hl_attr_define` will contain a semantic description
  448. of the highlights. As highlight groups can be combined, this will be an array
  449. of items, with the item with highest priority last. Each item is a dictionary
  450. with the following possible keys:
  451. `kind`: always present. One of the following values:
  452. "ui": Builtin UI highlight. |highlight-groups|
  453. "syntax": Highlight applied to a buffer by a syntax declaration or
  454. other runtime/plugin functionality such as
  455. |nvim_buf_add_highlight()|
  456. "terminal": highlight from a process running in a |terminal-emulator|.
  457. Contains no further semantic information.
  458. `ui_name`: Highlight name from |highlight-groups|. Only for "ui" kind.
  459. `hi_name`: Name of the final |:highlight| group where the used
  460. attributes are defined.
  461. `id`: Unique numeric id representing this item.
  462. Note: "ui" items will have both `ui_name` and `hi_name` present. These can
  463. differ, because the builtin group was linked to another group |:hi-link| , or
  464. because 'winhighlight' was used. UI items will be transmitted, even if the
  465. highlight group is cleared, so `ui_name` can always be used to reliably identify
  466. screen elements, even if no attributes have been applied.
  467. ==============================================================================
  468. Multigrid Events *ui-multigrid*
  469. Activated by the `ext_multigrid` |ui-option|.
  470. Activates |ui-linegrid| implicitly.
  471. See |ui-linegrid| for grid events.
  472. See |nvim_ui_try_resize_grid()| to request changing the grid size.
  473. See |nvim_input_mouse()| for sending mouse events to Nvim.
  474. The multigrid extension gives UIs more control over how windows are displayed:
  475. - UIs receive updates on a separate grid for each window.
  476. - UIs can set the grid size independently of how much space the window
  477. occupies on the global layout. So the UI could use a different font size
  478. per-window. Or reserve space around the border of the window for its own
  479. elements, such as scrollbars from the UI toolkit.
  480. - A dedicated grid is used for messages, which may scroll over the window
  481. area. (Alternatively |ui-messages| can be used).
  482. By default, the grid size is handled by Nvim and set to the outer grid size
  483. (i.e. the size of the window frame in Nvim) whenever the split is created.
  484. Once a UI sets a grid size, Nvim does not handle the size for that grid and
  485. the UI must change the grid size whenever the outer size is changed. To
  486. delegate grid-size handling back to Nvim, request the size (0, 0).
  487. A window can be hidden and redisplayed without its grid being deallocated.
  488. This can happen multiple times for the same window, for instance when switching
  489. tabs.
  490. ["win_pos", grid, win, start_row, start_col, width, height] ~
  491. Set the position and size of the grid in Nvim (i.e. the outer grid
  492. size). If the window was previously hidden, it should now be shown
  493. again.
  494. ["win_float_pos", grid, win, anchor, anchor_grid, anchor_row, anchor_col, focusable] ~
  495. Display or reconfigure floating window `win`. The window should be
  496. displayed above another grid `anchor_grid` at the specified position
  497. `anchor_row` and `anchor_col`. For the meaning of `anchor` and more
  498. details of positioning, see |nvim_open_win()|.
  499. ["win_external_pos", grid, win] ~
  500. Display or reconfigure external window `win`. The window should be
  501. displayed as a separate top-level window in the desktop environment,
  502. or something similar.
  503. ["win_hide", grid] ~
  504. Stop displaying the window. The window can be shown again later.
  505. ["win_close", grid] ~
  506. Close the window.
  507. ["msg_set_pos", grid, row, scrolled, sep_char] ~
  508. Display messages on `grid`. The grid will be displayed at `row` on the
  509. default grid (grid=1), covering the full column width. `scrolled`
  510. indicates whether the message area has been scrolled to cover other
  511. grids. It can be useful to draw a separator then ('display' msgsep
  512. flag). The Builtin TUI draws a full line filled with `sep_char` and
  513. |hl-MsgSeparator| highlight.
  514. When |ui-messages| is active, no message grid is used, and this event
  515. will not be sent.
  516. ["win_viewport", grid, win, topline, botline, curline, curcol] ~
  517. Indicates the range of buffer text displayed in the window, as well
  518. as the cursor position in the buffer. All positions are zero-based.
  519. `botline` is set to one more than the line count of the buffer, if
  520. there are filler lines past the end.
  521. ["win_extmark", grid, win, ns_id, mark_id, row, col] ~
  522. Updates the position of an extmark which is currently visible in a
  523. window. Only emitted if the mark has the `ui_watched` attribute.
  524. ==============================================================================
  525. Popupmenu Events *ui-popupmenu*
  526. Activated by the `ext_popupmenu` |ui-option|.
  527. This UI extension delegates presentation of the |popupmenu-completion| and
  528. command-line 'wildmenu'.
  529. ["popupmenu_show", items, selected, row, col, grid] ~
  530. Show |popupmenu-completion|. `items` is an array of completion items
  531. to show; each item is an array of the form [word, kind, menu, info] as
  532. defined at |complete-items|, except that `word` is replaced by `abbr`
  533. if present. `selected` is the initially-selected item, a zero-based
  534. index into the array of items (-1 if no item is selected). `row` and
  535. `col` give the anchor position, where the first character of the
  536. completed word will be. When |ui-multigrid| is used, `grid` is the
  537. grid for the anchor position. When `ext_cmdline` is active, `grid` is
  538. set to -1 to indicate the popupmenu should be anchored to the external
  539. cmdline. Then `col` will be a byte position in the cmdline text.
  540. ["popupmenu_select", selected] ~
  541. Select an item in the current popupmenu. `selected` is a zero-based
  542. index into the array of items from the last popupmenu_show event, or
  543. -1 if no item is selected.
  544. ["popupmenu_hide"] ~
  545. Hide the popupmenu.
  546. ==============================================================================
  547. Tabline Events *ui-tabline*
  548. Activated by the `ext_tabline` |ui-option|.
  549. ["tabline_update", curtab, tabs, curbuf, buffers] ~
  550. Tabline was updated. UIs should present this data in a custom tabline
  551. widget. Note: options `curbuf` + `buffers` were added in API7.
  552. curtab: Current Tabpage
  553. tabs: List of Dicts [{ "tab": Tabpage, "name": String }, ...]
  554. curbuf: Current buffer handle.
  555. buffers: List of Dicts [{ "buffer": buffer handle, "name": String}, ...]
  556. ==============================================================================
  557. Cmdline Events *ui-cmdline*
  558. Activated by the `ext_cmdline` |ui-option|.
  559. This UI extension delegates presentation of the |cmdline| (except 'wildmenu').
  560. For command-line 'wildmenu' UI events, activate |ui-popupmenu|.
  561. ["cmdline_show", content, pos, firstc, prompt, indent, level] ~
  562. content: List of [attrs, string]
  563. [[{}, "t"], [attrs, "est"], ...]
  564. Triggered when the cmdline is displayed or changed.
  565. The `content` is the full content that should be displayed in the
  566. cmdline, and the `pos` is the position of the cursor that in the
  567. cmdline. The content is divided into chunks with different highlight
  568. attributes represented as a dict (see |ui-event-highlight_set|).
  569. `firstc` and `prompt` are text, that if non-empty should be
  570. displayed in front of the command line. `firstc` always indicates
  571. built-in command lines such as `:` (ex command) and `/` `?` (search),
  572. while `prompt` is an |input()| prompt. `indent` tells how many spaces
  573. the content should be indented.
  574. The Nvim command line can be invoked recursively, for instance by
  575. typing `<c-r>=` at the command line prompt. The `level` field is used
  576. to distinguish different command lines active at the same time. The
  577. first invoked command line has level 1, the next recursively-invoked
  578. prompt has level 2. A command line invoked from the |cmdline-window|
  579. has a higher level than than the edited command line.
  580. ["cmdline_pos", pos, level] ~
  581. Change the cursor position in the cmdline.
  582. ["cmdline_special_char", c, shift, level] ~
  583. Display a special char in the cmdline at the cursor position. This is
  584. typically used to indicate a pending state, e.g. after |c_CTRL-V|. If
  585. `shift` is true the text after the cursor should be shifted, otherwise
  586. it should overwrite the char at the cursor.
  587. Should be hidden at next cmdline_show.
  588. ["cmdline_hide"] ~
  589. Hide the cmdline.
  590. ["cmdline_block_show", lines] ~
  591. Show a block of context to the current command line. For example if
  592. the user defines a |:function| interactively: >
  593. :function Foo()
  594. : echo "foo"
  595. :
  596. <
  597. `lines` is a list of lines of highlighted chunks, in the same form as
  598. the "cmdline_show" `contents` parameter.
  599. ["cmdline_block_append", line] ~
  600. Append a line at the end of the currently shown block.
  601. ["cmdline_block_hide"] ~
  602. Hide the block.
  603. ==============================================================================
  604. Message/Dialog Events *ui-messages*
  605. Activated by the `ext_messages` |ui-option|.
  606. Activates |ui-linegrid| and |ui-cmdline| implicitly.
  607. This UI extension delegates presentation of messages and dialogs. Messages
  608. that would otherwise render in the message/cmdline screen space, are emitted
  609. as UI events.
  610. Nvim will not allocate screen space for the cmdline or messages, and
  611. 'cmdheight' will be forced zero. Cmdline state is emitted as |ui-cmdline|
  612. events, which the UI must handle.
  613. ["msg_show", kind, content, replace_last] ~
  614. Display a message to the user.
  615. kind
  616. Name indicating the message kind:
  617. "" (empty) Unknown (consider a feature-request: |bugs|)
  618. "confirm" |confirm()| or |:confirm| dialog
  619. "confirm_sub" |:substitute| confirm dialog |:s_c|
  620. "emsg" Error (|errors|, internal error, |:throw|, …)
  621. "echo" |:echo| message
  622. "echomsg" |:echomsg| message
  623. "echoerr" |:echoerr| message
  624. "lua_error" Error in |:lua| code
  625. "rpc_error" Error response from |rpcrequest()|
  626. "return_prompt" |press-enter| prompt after a multiple messages
  627. "quickfix" Quickfix navigation message
  628. "search_count" Search count message ("S" flag of 'shortmess')
  629. "wmsg" Warning ("search hit BOTTOM", |W10|, …)
  630. New kinds may be added in the future; clients should treat unknown
  631. kinds as the empty kind.
  632. content
  633. Array of `[attr_id, text_chunk]` tuples, building up the message
  634. text of chunks of different highlights. No extra spacing should be
  635. added between chunks, the `text_chunk` by itself contains any
  636. necessary whitespace. Messages can contain line breaks "\n".
  637. replace_last
  638. Decides how multiple messages should be displayed:
  639. false: Display the message together with all previous messages
  640. that are still visible.
  641. true: Replace the message in the most-recent `msg_show` call,
  642. but any other visible message should still remain.
  643. ["msg_clear"] ~
  644. Clear all messages currently displayed by "msg_show". (Messages sent
  645. by other "msg_" events below will not be affected).
  646. ["msg_showmode", content] ~
  647. Shows 'showmode' and |recording| messages. `content` has the same
  648. format as in "msg_show". This event is sent with empty `content` to
  649. hide the last message.
  650. ["msg_showcmd", content] ~
  651. Shows 'showcmd' messages. `content` has the same format as in "msg_show".
  652. This event is sent with empty `content` to hide the last message.
  653. ["msg_ruler", content] ~
  654. Used to display 'ruler' when there is no space for the ruler in a
  655. statusline. `content` has the same format as in "msg_show". This event is
  656. sent with empty `content` to hide the last message.
  657. ["msg_history_show", entries] ~
  658. Sent when |:messages| command is invoked. History is sent as a list of
  659. entries, where each entry is a `[kind, content]` tuple.
  660. ==============================================================================
  661. vim:tw=78:ts=8:noet:ft=help:norl: