neovim/src/nvim
Luuk van Baal de48fbbd5f fix(messages)!: vim.ui_attach message callbacks are unsafe
Problem:  Lua callbacks for "msg_show" events with vim.ui_attach() are
          executed when it is not safe.
Solution: Disallow non-fast API calls for "msg_show" event callbacks.
          Automatically detach callback after excessive errors.
          Make sure fast APIs do not modify Nvim state.
2024-11-14 13:23:11 +01:00
..
api fix(messages)!: vim.ui_attach message callbacks are unsafe 2024-11-14 13:23:11 +01:00
eval refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
event refactor(event): change last use of klist to kvec 2024-09-28 20:23:22 +02:00
generators fix(messages)!: vim.ui_attach message callbacks are unsafe 2024-11-14 13:23:11 +01:00
lib refactor(declarations): also generate prototypes for functions in headers 2024-07-13 12:30:49 +02:00
lua fix(messages)!: vim.ui_attach message callbacks are unsafe 2024-11-14 13:23:11 +01:00
msgpack_rpc refactor(api)!: rename Dictionary => Dict 2024-09-23 14:42:57 +02:00
os refactor(message): propagate highlight id instead of attrs 2024-11-08 13:21:35 +01:00
po build: silence "po" noise #30469 2024-09-23 02:18:30 -07:00
tui fix(tui): avoid flushing buffer halfway an OSC 2 sequence (#30793) 2024-10-15 07:34:13 +08:00
viml/parser refactor(api)!: rename Dictionary => Dict 2024-09-23 14:42:57 +02:00
arabic.c perf: don't decode utf8 character multiple times in getvcol() 2024-01-22 09:04:42 +08:00
arabic.h build(IWYU): remove arabic_defs.h (#26235) 2023-11-27 07:41:43 +08:00
arglist_defs.h refactor: remove redundant struct names 2024-01-02 21:59:12 +01:00
arglist.c vim-patch:9.1.0678: [security]: use-after-free in alist_add() 2024-08-17 06:04:52 +08:00
arglist.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
ascii_defs.h refactor(declarations): also generate prototypes for functions in headers 2024-07-13 12:30:49 +02:00
assert_defs.h refactor: remove redundant NOLINT comments 2024-01-01 19:57:44 +01:00
auevents.lua refactor: sort various Lua tables in src/ alphabetically (#30977) 2024-10-29 07:57:25 +08:00
autocmd_defs.h vim-patch:9.1.0272: autocmd may change cwd after :tcd and :lcd (#28223) 2024-04-08 06:25:22 +08:00
autocmd.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
autocmd.h vim-patch:9.1.0231: Filetype may be undetected when SwapExists sets ft in other buf (#28136) 2024-04-01 06:12:11 +08:00
base64.c feat(terminal): add support for copying with OSC 52 in embedded terminal (#29117) 2024-06-11 13:18:06 -05:00
base64.h refactor: move Arena and ArenaMem to memory_defs.h (#26240) 2023-11-27 17:21:58 +08:00
buffer_defs.h vim-patch:9.1.0831: 'findexpr' can't be used as lambad or Funcref (#31058) 2024-11-03 10:06:41 +08:00
buffer_updates.c refactor(lua): use Arena when converting from lua stack to API args 2024-02-13 11:54:44 +01:00
buffer_updates.h refactor: move some constants out of vim_defs.h (#26298) 2023-11-29 20:32:40 +08:00
buffer.c refactor(message): propagate highlight id instead of attrs 2024-11-08 13:21:35 +01:00
buffer.h refactor(declarations): also generate prototypes for functions in headers 2024-07-13 12:30:49 +02:00
bufwrite.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
bufwrite.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
change.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
change.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
channel_defs.h refactor(io): separate types for read and write streams 2024-05-31 15:01:13 +02:00
channel.c refactor(api)!: rename Dictionary => Dict 2024-09-23 14:42:57 +02:00
channel.h refactor: rename "process" => "proc" #30387 2024-09-15 12:20:58 -07:00
charset.c vim-patch:9.1.0803: tests: no error check when setting global 'isk' 2024-10-24 06:56:12 +08:00
charset.h refactor(declarations): also generate prototypes for functions in headers 2024-07-13 12:30:49 +02:00
CMakeLists.txt build: specify POST_BUILD when using add_custom_command 2024-11-09 13:07:16 +01:00
cmdexpand_defs.h vim-patch:9.1.0831: 'findexpr' can't be used as lambad or Funcref (#31058) 2024-11-03 10:06:41 +08:00
cmdexpand.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
cmdexpand.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
cmdhist.c refactor(message): propagate highlight id instead of attrs 2024-11-08 13:21:35 +01:00
cmdhist.h vim-patch:9.1.0798: too many strlen() calls in cmdhist.c (#30895) 2024-10-22 13:03:02 +08:00
context.c refactor(api)!: rename Dictionary => Dict 2024-09-23 14:42:57 +02:00
context.h refactor(shada): rework msgpack decoding without msgpack-c 2024-08-05 11:12:44 +02:00
cursor_shape.c refactor(api)!: rename Dictionary => Dict 2024-09-23 14:42:57 +02:00
cursor_shape.h refactor: remove redundant struct names 2024-01-02 21:59:12 +01:00
cursor.c refactor: collapse statements in single assignments 2024-07-30 22:43:29 +01:00
cursor.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
debugger.c revert: "refactor: use S_LEN macro" (#29319) 2024-06-14 05:20:06 +08:00
debugger.h refactor: move Arena and ArenaMem to memory_defs.h (#26240) 2023-11-27 17:21:58 +08:00
decoration_defs.h refactor(message): propagate highlight id instead of attrs 2024-11-08 13:21:35 +01:00
decoration_provider.c test: silence expected errors 2024-04-02 17:07:44 +02:00
decoration_provider.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
decoration.c refactor(api)!: rename Dictionary => Dict 2024-09-23 14:42:57 +02:00
decoration.h fix(column): modifying a sign should update placed signs (#29750) 2024-07-17 08:53:10 +08:00
diff.c refactor(options): remove fileformat macros 2024-11-05 02:36:51 +06:00
diff.h refactor(IWYU): fix includes for cmdhist.h (#26324) 2023-11-30 22:48:15 +08:00
digraph.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
digraph.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
drawline.c fix(drawline): correct highlight priority with Visual selection (#30706) 2024-10-08 06:24:36 +08:00
drawline.h refactor: remove CPO_TO_CPO_FLAGS() (#26718) 2023-12-23 15:53:28 +08:00
drawscreen.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
drawscreen.h vim-patch:8.2.5047: CurSearch highlight is often wrong 2024-06-19 08:02:29 +08:00
edit.c fix(paste): improve repeating of pasted text (#30438) 2024-09-22 06:02:48 +08:00
edit.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
errors.h fix(messages)!: vim.ui_attach message callbacks are unsafe 2024-11-14 13:23:11 +01:00
eval_defs.h refactor(typval)!: remove distinction of binary and nonbinary strings 2024-06-27 11:04:04 +02:00
eval.c fix(messages)!: vim.ui_attach message callbacks are unsafe 2024-11-14 13:23:11 +01:00
eval.h vim-patch:9.1.0831: 'findexpr' can't be used as lambad or Funcref (#31058) 2024-11-03 10:06:41 +08:00
eval.lua docs: misc (#30914) 2024-11-09 08:10:56 +08:00
ex_cmds2.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
ex_cmds2.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
ex_cmds_defs.h refactor(shada): rework msgpack decoding without msgpack-c 2024-08-05 11:12:44 +02:00
ex_cmds.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
ex_cmds.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
ex_cmds.lua vim-patch:9.1.0381: cbuffer and similar commands don't accept a range (#28571) 2024-04-30 06:02:38 +08:00
ex_docmd.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
ex_docmd.h refactor(IWYU): move typedefs out of globals.h (#26322) 2023-11-30 19:52:23 +08:00
ex_eval_defs.h refactor(IWYU): move typedefs out of globals.h (#26322) 2023-11-30 19:52:23 +08:00
ex_eval.c vim-patch:9.0.0634: evaluating "expr" options has more overhead than needed 2024-08-02 11:56:51 +08:00
ex_eval.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
ex_getln_defs.h refactor(message): propagate highlight id instead of attrs 2024-11-08 13:21:35 +01:00
ex_getln.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
ex_getln.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
ex_session.c refactor: move shared messages to errors.h #26214 2024-06-01 08:19:41 -07:00
ex_session.h refactor: move Arena and ArenaMem to memory_defs.h (#26240) 2023-11-27 17:21:58 +08:00
extmark_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
extmark.c fix(decor): exclude invalid marks from meta total 2024-09-04 15:13:12 +02:00
extmark.h refactor(extmarks): remove unused new pos from ExtmarkSavePos 2024-01-18 19:54:45 +01:00
file_search.c vim-patch:9.1.0810: cannot easily adjust the |:find| command 2024-10-29 08:20:00 +08:00
file_search.h vim-patch:partial:8.1.0914: code related to findfile() is spread out (#30000) 2024-08-07 01:12:33 +00:00
fileio.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
fileio.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
fold_defs.h refactor: remove redundant struct names 2024-01-02 21:59:12 +01:00
fold.c vim-patch:9.1.0672: marker folds may get corrupted on undo (#30026) 2024-08-11 22:52:31 +00:00
fold.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
func_attr.h refactor(api): make freeing of return-value opt-in instead of opt out 2024-02-21 11:58:28 +01:00
garray_defs.h refactor: remove redundant struct names 2024-01-02 21:59:12 +01:00
garray.c refactor: collapse statements in single assignments 2024-07-30 22:43:29 +01:00
garray.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
getchar_defs.h refactor: remove redundant struct names 2024-01-02 21:59:12 +01:00
getchar.c feat(lua): allow vim.on_key() callback to consume the key (#30939) 2024-11-01 09:11:15 +08:00
getchar.h refactor(fileio): remove API shell layer encouraging unnecessary allocations 2024-02-25 11:20:06 +01:00
gettext_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
globals.h refactor(message): propagate highlight id instead of attrs 2024-11-08 13:21:35 +01:00
grid_defs.h feat(editor): handle new multibyte sequences in normal mode replacement 2024-11-04 13:12:33 +01:00
grid.c feat(mbyte): support extended grapheme clusters including more emoji 2024-08-30 11:49:09 +02:00
grid.h vim-patch:9.1.0184: Cursor pos wrong when clicking with conceal and wrap (#27890) 2024-03-17 07:26:39 +08:00
hashtab_defs.h refactor: remove redundant struct names 2024-01-02 21:59:12 +01:00
hashtab.c refactor: collapse statements in single assignments 2024-07-30 22:43:29 +01:00
hashtab.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
help.c revert: "refactor: use S_LEN macro" (#29319) 2024-06-14 05:20:06 +08:00
help.h refactor: move Arena and ArenaMem to memory_defs.h (#26240) 2023-11-27 17:21:58 +08:00
highlight_defs.h refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
highlight_group.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
highlight_group.h fix(highlight): add Nvim{Light,Dark}Gray{1,2,3,4} colors 2024-03-30 14:31:46 +02:00
highlight.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
highlight.h refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
iconv_defs.h refactor: fix headers with IWYU 2023-11-28 22:23:56 +01:00
indent_c.c docs: misc (#29622) 2024-07-15 06:54:45 +08:00
indent_c.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
indent.c vim-patch:9.1.0806: tests: no error check when setting global 'briopt' 2024-10-24 06:56:12 +08:00
indent.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
input.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
input.h refactor(options): generate BV_ and WV_ constants (#26705) 2023-12-22 12:24:23 +08:00
insexpand.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
insexpand.h vim-patch:9.1.0754: fixed order of items in insert-mode completion menu (#30619) 2024-10-03 06:45:01 +08:00
keycodes.c revert: "refactor: use S_LEN macro" (#29319) 2024-06-14 05:20:06 +08:00
keycodes.h fix(paste): improve repeating of pasted text (#30438) 2024-09-22 06:02:48 +08:00
linematch.c fix(coverity/510275): linematch out of bounds access (#30687) 2024-10-07 23:22:09 +00:00
linematch.h fix(diff): use mmfile_t in linematch 2024-09-30 11:51:33 +01:00
log.c docs: dev-arch, focusable windows #30510 2024-10-07 08:27:38 -07:00
log.h refactor: run IWYU on entire repo 2023-12-21 17:38:42 +01:00
macros_defs.h perf: don't decode utf8 character multiple times in getvcol() 2024-01-22 09:04:42 +08:00
main.c vim-patch:9.1.0797: testing of options can be further improved (#30893) 2024-10-22 09:05:14 +08:00
main.h refactor: run IWYU on entire repo 2023-12-21 17:38:42 +01:00
map_defs.h feat(ui): add support for OSC 8 hyperlinks (#27109) 2024-01-24 16:36:25 -06:00
map_glyph_cache.c refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
map_key_impl.c.h refactor: fix headers with IWYU 2023-11-28 22:23:56 +01:00
map_value_impl.c.h refactor: fix headers with IWYU 2023-11-28 22:23:56 +01:00
map.c fix(column): keep track of number of lines with number of signs 2024-01-15 09:37:53 +00:00
mapping_defs.h vim-patch:9.1.0642: Check that mapping rhs starts with lhs fails if not simplified (#29909) 2024-07-30 07:35:25 +08:00
mapping.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
mapping.h vim-patch:9.1.0814: mapset() may remove unrelated mapping (#30941) 2024-10-24 23:16:54 +00:00
mark_defs.h refactor(shada): rework msgpack decoding without msgpack-c 2024-08-05 11:12:44 +02:00
mark.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
mark.h refactor(declarations): also generate prototypes for functions in headers 2024-07-13 12:30:49 +02:00
marktree_defs.h perf(extmarks): add metadata for efficient filtering of special decorations 2024-01-22 19:03:32 +01:00
marktree.c fix(decor): exclude invalid marks from meta total 2024-09-04 15:13:12 +02:00
marktree.h feat: get/set namespace properties #28728 2024-06-07 08:33:40 -07:00
match.c vim-patch:8.2.5047: CurSearch highlight is often wrong 2024-06-19 08:02:29 +08:00
match.h refactor: fix runtime_defs.h (#26259) 2023-11-28 07:47:36 +08:00
math.c build: "popcount" name conflict on NetBSD #28983 2024-05-27 04:14:57 -07:00
math.h refactor(options): remove option type macros 2023-12-14 16:46:42 +06:00
mbyte_defs.h docs: fix typos (#27868) 2024-03-28 09:32:32 +08:00
mbyte.c feat(editor): handle new multibyte sequences in normal mode replacement 2024-11-04 13:12:33 +01:00
mbyte.h feat(mbyte): support extended grapheme clusters including more emoji 2024-08-30 11:49:09 +02:00
memfile_defs.h vim-patch:8.1.1413: error when the drive of the swap file was disconnected (#30009) 2024-08-08 08:11:53 +00:00
memfile.c vim-patch:8.1.1413: error when the drive of the swap file was disconnected (#30009) 2024-08-08 08:11:53 +00:00
memfile.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
memline_defs.h vim-patch:9.1.0138: too many STRLEN calls when getting a memline (#27799) 2024-03-10 17:08:00 +08:00
memline.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
memline.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
memory_defs.h refactor(shada): use msgpack_sbuffer less 2024-06-11 11:11:38 +02:00
memory.c docs: misc (#29719) 2024-08-29 06:11:32 +08:00
memory.h Merge pull request #29241 from bfredl/shadapack 2024-06-14 11:33:27 +02:00
menu_defs.h refactor: replace manual header guards with #pragma once 2023-11-12 22:01:28 +01:00
menu.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
menu.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
message_defs.h refactor(message): propagate highlight id instead of attrs 2024-11-08 13:21:35 +01:00
message.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
message.h refactor(message): propagate highlight id instead of attrs 2024-11-08 13:21:35 +01:00
mouse.c feat(float): allow enabling mouse for non-focusable window (#30844) 2024-10-20 22:18:26 +08:00
mouse.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
move.c refactor: collapse statements in single assignments 2024-07-30 22:43:29 +01:00
move.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
normal_defs.h feat(editor): handle new multibyte sequences in normal mode replacement 2024-11-04 13:12:33 +01:00
normal.c feat(ext_messages): add hl_id to ext_messages chunks 2024-11-09 14:28:17 +01:00
normal.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
ops.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
ops.h vim-patch:9.1.0824: too many strlen() calls in register.c (#31022) 2024-11-01 09:34:19 +00:00
option_defs.h refactor(options): option flags enum #30961 2024-10-28 06:49:16 -07:00
option_vars.h refactor(options): remove fileformat macros 2024-11-05 02:36:51 +06:00
option.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
option.h feat(options)!: disallow setting hidden options #28400 2024-11-04 05:00:12 -08:00
options.lua refactor(options): remove fileformat macros 2024-11-05 02:36:51 +06:00
optionstr.c refactor(options): use os_win/os_buf for local options (#31060) 2024-11-08 06:54:28 +00:00
optionstr.h refactor(options): use schar_T representation for fillchars and listchars 2024-01-08 14:37:55 +01:00
path.c vim-patch:8.2.0985: simplify() does not remove slashes from "///path" 2024-10-13 18:52:46 +08:00
path.h vim-patch:9.1.0568: Cannot expand paths from 'cdpath' setting 2024-07-12 07:39:36 +08:00
plines.c vim-patch:9.1.0707: [security]: invalid cursor position may cause a crash (#30204) 2024-09-01 05:07:17 +08:00
plines.h feat(mbyte): support extended grapheme clusters including more emoji 2024-08-30 11:49:09 +02:00
popupmenu.c vim-patch:9.1.0830: using wrong highlight group for spaces for popupmenu (#31054) 2024-11-03 08:27:15 +08:00
popupmenu.h vim-patch:9.1.0772: some missing changes from v9.1.0771 2024-10-10 07:21:02 +08:00
pos_defs.h refactor(IWYU): move typedefs out of globals.h (#26322) 2023-11-30 19:52:23 +08:00
profile.c fix(startup): report --startuptime error to stderr (#31131) 2024-11-13 13:22:40 +08:00
profile.h refactor: fix runtime_defs.h (#26259) 2023-11-28 07:47:36 +08:00
quickfix.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
quickfix.h refactor: eliminate cyclic includes 2023-12-20 19:52:02 +01:00
README.md docs: various #25289 2024-01-18 00:14:48 -08:00
regexp_defs.h refactor: move structs from regexp_defs.h to regexp.c (#26899) 2024-01-05 22:26:07 +08:00
regexp.c feat(mbyte): support extended grapheme clusters including more emoji 2024-08-30 11:49:09 +02:00
regexp.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
runtime_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
runtime.c refactor(message): propagate highlight id instead of attrs 2024-11-08 13:21:35 +01:00
runtime.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
search.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
search.h refactor(shada): rework msgpack decoding without msgpack-c 2024-08-05 11:12:44 +02:00
sha256.c refactor: collapse statements in single assignments 2024-07-30 22:43:29 +01:00
sha256.h refactor: move Arena and ArenaMem to memory_defs.h (#26240) 2023-11-27 17:21:58 +08:00
shada.c vim-patch:9.1.0824: too many strlen() calls in register.c (#31022) 2024-11-01 09:34:19 +00:00
shada.h refactor(shada): rework msgpack decoding without msgpack-c 2024-08-05 11:12:44 +02:00
sign_defs.h vim-patch:9.1.0538: not possible to assign priority when defining a sign (#29592) 2024-07-07 07:21:14 +08:00
sign.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
sign.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
spell_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
spell.c vim-patch:9.1.0783: 'spell' option setting has problems (#30818) 2024-10-15 09:40:54 +08:00
spell.h vim-patch:9.1.0418: Cannot move to previous/next rare word (#28822) 2024-05-18 07:09:05 +08:00
spellfile.c vim-patch:8.2.1651: spellfile code not completely tested 2024-07-16 15:25:10 +08:00
spellfile.h refactor: move Arena and ArenaMem to memory_defs.h (#26240) 2023-11-27 17:21:58 +08:00
spellsuggest.c feat(mbyte): support extended grapheme clusters including more emoji 2024-08-30 11:49:09 +02:00
spellsuggest.h build(clint): more precise check for "defs" headers (#26236) 2023-11-27 08:34:06 +08:00
state_defs.h refactor: move some constants out of vim_defs.h (#26298) 2023-11-29 20:32:40 +08:00
state.c fix(ui): ensure screen update before waiting for input #30576 2024-10-03 02:31:17 -07:00
state.h fix(api/buffer): fix handling of viewport of non-current buffer 2024-03-13 07:19:59 +01:00
statusline_defs.h refactor(column): define and use maximum 'statuscolumn' width 2024-01-04 11:52:37 +00:00
statusline.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
statusline.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
strings.c fix(coverity/497375): f_strpart cast overflow (#30773) 2024-10-12 07:43:07 +08:00
strings.h refactor(declarations): also generate prototypes for functions in headers 2024-07-13 12:30:49 +02:00
syntax_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
syntax.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
syntax.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
tag.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
tag.h vim-patch:9.1.0554: :bw leaves jumplist and tagstack data around (#29639) 2024-07-10 10:35:12 +08:00
terminal.c vim-patch:9.1.0824: too many strlen() calls in register.c (#31022) 2024-11-01 09:34:19 +00:00
terminal.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
testing.c vim-patch:9.1.0666: assert_equal() doesn't show multibyte string correctly (#30018) 2024-08-10 06:35:51 +08:00
testing.h refactor: fix runtime_defs.h (#26259) 2023-11-28 07:47:36 +08:00
textformat.c fix(multibyte): handle backspace of wide clusters in replace mode 2024-09-06 10:22:29 +02:00
textformat.h refactor(IWYU): create normal_defs.h (#26293) 2023-11-29 12:10:42 +08:00
textobject.c refactor: collapse statements in single assignments 2024-07-30 22:43:29 +01:00
textobject.h refactor(IWYU): move typedefs out of globals.h (#26322) 2023-11-30 19:52:23 +08:00
types_defs.h feat(editor): handle new multibyte sequences in normal mode replacement 2024-11-04 13:12:33 +01:00
ugrid.c refactor: follow style guide 2023-11-13 23:39:56 +01:00
ugrid.h refactor: remove redundant struct names 2024-01-02 21:59:12 +01:00
ui_client.c refactor(api)!: rename Dictionary => Dict 2024-09-23 14:42:57 +02:00
ui_client.h feat(log): use "ui" as default name for TUI client #30345 2024-09-11 17:25:00 -07:00
ui_compositor.c feat(float): allow enabling mouse for non-focusable window (#30844) 2024-10-20 22:18:26 +08:00
ui_compositor.h refactor(IWYU): move UI and LineFlags to ui_defs.h (#26318) 2023-11-30 17:16:57 +08:00
ui_defs.h fix(ui): avoid recursiveness and invalid memory access #28578 2024-05-01 13:51:06 -07:00
ui.c fix(messages)!: vim.ui_attach message callbacks are unsafe 2024-11-14 13:23:11 +01:00
ui.h fix(messages)!: vim.ui_attach message callbacks are unsafe 2024-11-14 13:23:11 +01:00
undo_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
undo.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
undo.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
usercmd.c refactor(highlight): make enum of builtin highlights start with 1 2024-11-13 11:20:10 +01:00
usercmd.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
version.c docs: update version.c (#30016) 2024-08-09 11:36:03 +08:00
version.h refactor: eliminate cyclic includes 2023-12-20 19:52:02 +01:00
vim_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
vvars.lua docs: misc (#30914) 2024-11-09 08:10:56 +08:00
window.c vim-patch:9.1.0812: Coverity warns about dereferencing NULL ptr 2024-10-24 06:56:12 +08:00
window.h vim-patch:partial:8.1.0914: code related to findfile() is spread out (#30000) 2024-08-07 01:12:33 +00:00
winfloat.c fix(options): missing error check for global 'scl' and 'winhl' (#30919) 2024-10-24 10:03:38 +08:00
winfloat.h refactor: move float_relative_str[] to nvim_win_get_config() (#26344) 2023-12-01 16:37:09 +08:00

Nvim core

Module-specific details are documented at the top of each module (terminal.c, undo.c, …).

See :help dev for guidelines.

Filename conventions

The source files use extensions to hint about their purpose.

  • *.c, *.generated.c - full C files, with all includes, etc.
  • *.c.h - parametrized C files, contain all necessary includes, but require defining macros before actually using. Example: typval_encode.c.h
  • *.h - full headers, with all includes. Does not apply to *.generated.h.
  • *.h.generated.h - exported functions declarations.
  • *.c.generated.h - static functions declarations.

Common structures

  • StringBuilder
  • kvec or garray.c for dynamic lists / vectors (use StringBuilder for strings)

Logs

Low-level log messages sink to $NVIM_LOG_FILE.

UI events are logged at DEBUG level.

rm -rf build/
make CMAKE_EXTRA_FLAGS="-DLOG_DEBUG"

Use LOG_CALLSTACK() (Linux only) to log the current stacktrace. To log to an alternate file (e.g. stderr) use LOG_CALLSTACK_TO_FILE(FILE*). Requires -no-pie (ref):

rm -rf build/
make CMAKE_EXTRA_FLAGS="-DLOG_DEBUG -DCMAKE_C_FLAGS=-no-pie"

Many log messages have a shared prefix, such as "UI" or "RPC". Use the shell to filter the log, e.g. at DEBUG level you might want to exclude UI messages:

tail -F ~/.local/state/nvim/log | cat -v | stdbuf -o0 grep -v UI | stdbuf -o0 tee -a log

Build with ASAN

Building Nvim with Clang sanitizers (Address Sanitizer: ASan, Undefined Behavior Sanitizer: UBSan, Memory Sanitizer: MSan, Thread Sanitizer: TSan) is a good way to catch undefined behavior, leaks and other errors as soon as they happen. It's significantly faster than Valgrind.

Requires clang 3.4 or later, and llvm-symbolizer must be in $PATH:

clang --version

Build Nvim with sanitizer instrumentation (choose one):

CC=clang make CMAKE_EXTRA_FLAGS="-DENABLE_ASAN_UBSAN=ON"
CC=clang make CMAKE_EXTRA_FLAGS="-DENABLE_MSAN=ON"
CC=clang make CMAKE_EXTRA_FLAGS="-DENABLE_TSAN=ON"

Create a directory to store logs:

mkdir -p "$HOME/logs"

Configure the sanitizer(s) via these environment variables:

# Change to detect_leaks=1 to detect memory leaks (slower, noisier).
export ASAN_OPTIONS="detect_leaks=0:log_path=$HOME/logs/asan"
# Show backtraces in the logs.
export MSAN_OPTIONS="log_path=${HOME}/logs/msan"
export TSAN_OPTIONS="log_path=${HOME}/logs/tsan"

Logs will be written to ${HOME}/logs/*san.PID then.

For more information: https://github.com/google/sanitizers/wiki/SanitizerCommonFlags

Reproducible build

To make a reproducible build of Nvim, set cmake variable LUA_GEN_PRG to a LuaJIT binary built with LUAJIT_SECURITY_PRN=0. See commit cb757f2663.

Debug: Performance

Profiling (easy)

For debugging performance bottlenecks in any code, there is a simple (and very effective) approach:

  1. Run the slow code in a loop.
  2. Break execution ~5 times and save the stacktrace.
  3. The cause of the bottleneck will (almost always) appear in most of the stacktraces.

Profiling (fancy)

For more advanced profiling, consider perf + flamegraph.

USDT profiling (powerful)

Or you can use USDT probes via NVIM_PROBE (#12036).

USDT is basically a way to define stable probe points in userland binaries. The benefit of bcc is the ability to define logic to go along with the probe points.

Tools:

  • bpftrace provides an awk-like language to the kernel bytecode, BPF.
  • BCC provides a subset of C. Provides more complex logic than bpftrace, but takes a bit more effort.

Example using bpftrace to track slow vim functions, and print out any files that were opened during the trace. At the end, it prints a histogram of function timing:

#!/usr/bin/env bpftrace

BEGIN {
  @depth = -1;
}

tracepoint:sched:sched_process_fork /@pidmap[args->parent_pid]/ {
  @pidmap[args->child_pid] = 1;
}

tracepoint:sched:sched_process_exit /@pidmap[args->pid]/ {
  delete(@pidmap[args->pid]);
}

usdt:build/bin/nvim:neovim:eval__call_func__entry {
    @pidmap[pid] = 1;
    @depth++;
    @funcentry[@depth] = nsecs;
}

usdt:build/bin/nvim:neovim:eval__call_func__return {
    $func = str(arg0);
    $msecs = (nsecs - @funcentry[@depth]) / 1000000;

    @time_histo = hist($msecs);

    if ($msecs >= 1000) {
      printf("%u ms for %s\n", $msecs, $func);
      print(@files);
    }

    clear(@files);
    delete(@funcentry[@depth]);
    @depth--;
}

tracepoint:syscalls:sys_enter_open,
tracepoint:syscalls:sys_enter_openat {
  if (@pidmap[pid] == 1 && @depth >= 0) {
    @files[str(args->filename)] = count();
  }
}

END {
  clear(@depth);
}

$ sudo bpftrace funcslower.bt
1527 ms for Slower
@files[/usr/lib/libstdc++.so.6]: 2
@files[/etc/fish/config.fish]: 2
<snip>

^C
@time_histo:
[0]                71430 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
[1]                  346 |                                                    |
[2, 4)               208 |                                                    |
[4, 8)                91 |                                                    |
[8, 16)               22 |                                                    |
[16, 32)              85 |                                                    |
[32, 64)               7 |                                                    |
[64, 128)              0 |                                                    |
[128, 256)             0 |                                                    |
[256, 512)             6 |                                                    |
[512, 1K)              1 |                                                    |
[1K, 2K)               5 |                                                    |

Debug: TUI

TUI troubleshoot

Nvim logs its internal terminfo state at 'verbose' level 3. This makes it possible to see exactly what terminfo values Nvim is using on any system.

nvim -V3log

TUI Debugging with gdb/lldb

Launching the nvim TUI involves two processes, one for main editor state and one for rendering the TUI. Both of these processes use the nvim binary, so somewhat confusingly setting a breakpoint in either will generally succeed but may not be hit depending on which process the breakpoints were set in.

To debug the main process, you can debug the nvim binary with the --headless flag which does not launch the TUI and will allow you to set breakpoints in code not related to TUI rendering like so:

lldb -- ./build/bin/nvim --headless --listen ~/.cache/nvim/debug-server.pipe

While in lldb, enter run. You can then attach to the headless process in a new terminal window to interact with the editor like so:

./build/bin/nvim --remote-ui --server ~/.cache/nvim/debug-server.pipe

Conversely for debugging TUI rendering, you can start a headless process and debug the remote-ui process multiple times without losing editor state.

For details on using nvim-dap and automatically debugging the child (main) process, see here

TUI trace

The ancient script command is still the "state of the art" for tracing terminal behavior. The libvterm vterm-dump utility formats the result for human-readability.

Record a Nvim terminal session and format it with vterm-dump:

script foo
./build/bin/nvim -u NONE
# Exit the script session with CTRL-d

# Use `vterm-dump` utility to format the result.
./.deps/usr/bin/vterm-dump foo > bar

Then you can compare bar with another session, to debug TUI behavior.

TUI redraw

Set the 'writedelay' and 'redrawdebug' options to see where and when the UI is painted.

:set writedelay=50 rdb=compositor

Note: neovim uses an internal screenbuffer to only send minimal updates even if a large region is repainted internally. To also highlight excess internal redraws, use

:set writedelay=50 rdb=compositor,nodelta

Terminal reference

Data structures

Buffer text is stored as a tree of line segments, defined in memline.c. The central idea is found in ml_find_line.

Nvim lifecycle

Following describes how Nvim processes input.

Consider a typical Vim-like editing session:

  1. Vim displays the welcome screen
  2. User types: :
  3. Vim enters command-line mode
  4. User types: edit README.txt<CR>
  5. Vim opens the file and returns to normal mode
  6. User types: G
  7. Vim navigates to the end of the file
  8. User types: 5
  9. Vim enters count-pending mode
  10. User types: d
  11. Vim enters operator-pending mode
  12. User types: w
  13. Vim deletes 5 words
  14. User types: g
  15. Vim enters the "g command mode"
  16. User types: g
  17. Vim goes to the beginning of the file
  18. User types: i
  19. Vim enters insert mode
  20. User types: word<ESC>
  21. Vim inserts "word" at the beginning and returns to normal mode

Note that we split user actions into sequences of inputs that change the state of the editor. While there's no documentation about a "g command mode" (step 16), internally it is implemented similarly to "operator-pending mode".

From this we can see that Vim has the behavior of an input-driven state machine (more specifically, a pushdown automaton since it requires a stack for transitioning back from states). Assuming each state has a callback responsible for handling keys, this pseudocode represents the main program loop:

def state_enter(state_callback, data):
  do
    key = readkey()                 # read a key from the user
  while state_callback(data, key)   # invoke the callback for the current state

That is, each state is entered by calling state_enter and passing a state-specific callback and data. Here is a high-level pseudocode for a program that implements something like the workflow described above:

def main()
  state_enter(normal_state, {}):

def normal_state(data, key):
  if key == ':':
    state_enter(command_line_state, {})
  elif key == 'i':
    state_enter(insert_state, {})
  elif key == 'd':
    state_enter(delete_operator_state, {})
  elif key == 'g':
    state_enter(g_command_state, {})
  elif is_number(key):
    state_enter(get_operator_count_state, {'count': key})
  elif key == 'G'
    jump_to_eof()
  return true

def command_line_state(data, key):
  if key == '<cr>':
    if data['input']:
      execute_ex_command(data['input'])
    return false
  elif key == '<esc>'
    return false

  if not data['input']:
    data['input'] = ''

  data['input'] += key
  return true

def delete_operator_state(data, key):
  count = data['count'] or 1
  if key == 'w':
    delete_word(count)
  elif key == '$':
    delete_to_eol(count)
  return false  # return to normal mode

def g_command_state(data, key):
  if key == 'g':
    go_top()
  elif key == 'v':
    reselect()
  return false  # return to normal mode

def get_operator_count_state(data, key):
  if is_number(key):
    data['count'] += key
    return true
  unshift_key(key)  # return key to the input buffer
  state_enter(delete_operator_state, data)
  return false

def insert_state(data, key):
  if key == '<esc>':
    return false  # exit insert mode
  self_insert(key)
  return true

The above gives an idea of how Nvim is organized internally. Some states like the g_command_state or get_operator_count_state do not have a dedicated state_enter callback, but are implicitly embedded into other states (this will change later as we continue the refactoring effort). To start reading the actual code, here's the recommended order:

  1. state_enter() function (state.c). This is the actual program loop, note that a VimState structure is used, which contains function pointers for the callback and state data.
  2. main() function (main.c). After all startup, normal_enter is called at the end of function to enter normal mode.
  3. normal_enter() function (normal.c) is a small wrapper for setting up the NormalState structure and calling state_enter.
  4. normal_check() function (normal.c) is called before each iteration of normal mode.
  5. normal_execute() function (normal.c) is called when a key is read in normal mode.

The basic structure described for normal mode in 3, 4 and 5 is used for other modes managed by the state_enter loop:

  • command-line mode: command_line_{enter,check,execute}()(ex_getln.c)
  • insert mode: insert_{enter,check,execute}()(edit.c)
  • terminal mode: terminal_{enter,execute}()(terminal.c)

Important variables

The current mode is stored in State. The values it can have are MODE_NORMAL, MODE_INSERT, MODE_CMDLINE, and a few others.

The current window is curwin. The current buffer is curbuf. These point to structures with the cursor position in the window, option values, the file name, etc.

All the global variables are declared in globals.h.

The main loop

The main loop is implemented in state_enter. The basic idea is that Vim waits for the user to type a character and processes it until another character is needed. Thus there are several places where Vim waits for a character to be typed. The vgetc() function is used for this. It also handles mapping.

Updating the screen is mostly postponed until a command or a sequence of commands has finished. The work is done by update_screen(), which calls win_update() for every window, which calls win_line() for every line. See the start of drawscreen.c for more explanations.

Command-line mode

When typing a :, normal_cmd() will call getcmdline() to obtain a line with an Ex command. getcmdline() calls a loop that will handle each typed character. It returns when hitting <CR> or <Esc> or some other character that ends the command line mode.

Ex commands

Ex commands are handled by the function do_cmdline(). It does the generic parsing of the : command line and calls do_one_cmd() for each separate command. It also takes care of while loops.

do_one_cmd() parses the range and generic arguments and puts them in the exarg_t and passes it to the function that handles the command.

The : commands are listed in ex_cmds.lua.

Normal mode commands

The Normal mode commands are handled by the normal_cmd() function. It also handles the optional count and an extra character for some commands. These are passed in a cmdarg_T to the function that handles the command.

There is a table nv_cmds in normal.c which lists the first character of every command. The second entry of each item is the name of the function that handles the command.

Insert mode commands

When doing an i or a command, normal_cmd() will call the edit() function. It contains a loop that waits for the next character and handles it. It returns when leaving Insert mode.

Options

There is a list with all option names in options.lua.

Async event support

One of the features Nvim added is the support for handling arbitrary asynchronous events, which can include:

  • RPC requests
  • job control callbacks
  • timers

Nvim implements this functionality by entering another event loop while waiting for characters, so instead of:

def state_enter(state_callback, data):
  do
    key = readkey()                 # read a key from the user
  while state_callback(data, key)   # invoke the callback for the current state

Nvim program loop is more like:

def state_enter(state_callback, data):
  do
    event = read_next_event()       # read an event from the operating system
  while state_callback(data, event) # invoke the callback for the current state

where event is something the operating system delivers to us, including (but not limited to) user input. The read_next_event() part is internally implemented by libuv, the platform layer used by Nvim.

Since Nvim inherited its code from Vim, the states are not prepared to receive "arbitrary events", so we use a special key to represent those (When a state receives an "arbitrary event", it normally doesn't do anything other than update the screen).

Main loop

The Loop structure (which describes main_loop) abstracts multiple queues into one loop:

uv_loop_t uv;
MultiQueue *events;
MultiQueue *thread_events;
MultiQueue *fast_events;

loop_poll_events checks Loop.uv and Loop.fast_events whenever Nvim is idle, and also at os_breakcheck intervals.

MultiQueue is cool because you can attach throw-away "child queues" trivially. For example do_os_system() does this (for every spawned process!) to automatically route events onto the main_loop:

Process *proc = &uvproc.process;
MultiQueue *events = multiqueue_new_child(main_loop.events);
proc->events = events;