aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2023-12-18 10:55:23 +0100
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2023-12-21 17:38:42 +0100
commitaf93a74a0f4afa9a3a4f55ffdf28141eaf776d22 (patch)
tree76068552bf3a74b4170ecd7b087905c96ddd6f8f
parentade42d531bcc9ca61facfb0524128a8a9f9b2444 (diff)
downloadrneovim-af93a74a0f4afa9a3a4f55ffdf28141eaf776d22.tar.gz
rneovim-af93a74a0f4afa9a3a4f55ffdf28141eaf776d22.tar.bz2
rneovim-af93a74a0f4afa9a3a4f55ffdf28141eaf776d22.zip
refactor: run IWYU on entire repo
Reference: https://github.com/neovim/neovim/issues/6371.
-rw-r--r--Makefile47
-rw-r--r--cmake.config/iwyu/mapping.imp1
-rw-r--r--cmake.config/iwyu/posix.imp2
-rwxr-xr-xsrc/clint.py4
-rw-r--r--src/nvim/api/private/converter.h2
-rw-r--r--src/nvim/api/private/dispatch.h2
-rw-r--r--src/nvim/api/private/helpers.h2
-rw-r--r--src/nvim/api/private/validate.h2
-rw-r--r--src/nvim/api/ui.c3
-rw-r--r--src/nvim/api/vim.c1
-rw-r--r--src/nvim/ascii_defs.h50
-rw-r--r--src/nvim/autocmd.c3
-rw-r--r--src/nvim/autocmd_defs.h1
-rw-r--r--src/nvim/base64.c2
-rw-r--r--src/nvim/buffer.c3
-rw-r--r--src/nvim/buffer.h5
-rw-r--r--src/nvim/buffer_updates.c1
-rw-r--r--src/nvim/bufwrite.c1
-rw-r--r--src/nvim/channel.c2
-rw-r--r--src/nvim/channel.h6
-rw-r--r--src/nvim/charset.c2
-rw-r--r--src/nvim/charset.h7
-rw-r--r--src/nvim/cmdexpand.c3
-rw-r--r--src/nvim/cursor.c1
-rw-r--r--src/nvim/decoration.c1
-rw-r--r--src/nvim/decoration_provider.c1
-rw-r--r--src/nvim/drawscreen.c1
-rw-r--r--src/nvim/edit.c3
-rw-r--r--src/nvim/eval.c4
-rw-r--r--src/nvim/eval.h3
-rw-r--r--src/nvim/eval/encode.h4
-rw-r--r--src/nvim/eval/funcs.c3
-rw-r--r--src/nvim/eval/typval.c3
-rw-r--r--src/nvim/eval/typval.h3
-rw-r--r--src/nvim/eval/userfunc.h2
-rw-r--r--src/nvim/eval/vars.c2
-rw-r--r--src/nvim/event/defs.h54
-rw-r--r--src/nvim/event/libuv_process.c2
-rw-r--r--src/nvim/event/libuv_process.h2
-rw-r--r--src/nvim/event/loop.c2
-rw-r--r--src/nvim/event/loop.h9
-rw-r--r--src/nvim/event/multiqueue.h47
-rw-r--r--src/nvim/event/process.h9
-rw-r--r--src/nvim/event/rstream.c5
-rw-r--r--src/nvim/event/rstream.h8
-rw-r--r--src/nvim/event/signal.c2
-rw-r--r--src/nvim/event/signal.h7
-rw-r--r--src/nvim/event/socket.c2
-rw-r--r--src/nvim/event/socket.h9
-rw-r--r--src/nvim/event/stream.c1
-rw-r--r--src/nvim/event/stream.h10
-rw-r--r--src/nvim/event/time.c1
-rw-r--r--src/nvim/event/time.h8
-rw-r--r--src/nvim/event/wstream.c2
-rw-r--r--src/nvim/event/wstream.h10
-rw-r--r--src/nvim/ex_docmd.c5
-rw-r--r--src/nvim/ex_getln.c1
-rw-r--r--src/nvim/ex_session.c1
-rw-r--r--src/nvim/fold.c1
-rw-r--r--src/nvim/garray.h1
-rw-r--r--src/nvim/getchar.c3
-rw-r--r--src/nvim/grid.h3
-rw-r--r--src/nvim/highlight.h2
-rw-r--r--src/nvim/input.c1
-rw-r--r--src/nvim/keycodes.c2
-rw-r--r--src/nvim/keycodes.h3
-rw-r--r--src/nvim/log.h33
-rw-r--r--src/nvim/log_defs.h36
-rw-r--r--src/nvim/lua/executor.c4
-rw-r--r--src/nvim/lua/executor.h11
-rw-r--r--src/nvim/lua/stdlib.c3
-rw-r--r--src/nvim/lua/xdiff.c1
-rw-r--r--src/nvim/macros_defs.h39
-rw-r--r--src/nvim/main.c1
-rw-r--r--src/nvim/main.h1
-rw-r--r--src/nvim/map_glyph_cache.c1
-rw-r--r--src/nvim/mapping.h27
-rw-r--r--src/nvim/mark.h46
-rw-r--r--src/nvim/mark_defs.h35
-rw-r--r--src/nvim/marktree.c2
-rw-r--r--src/nvim/mbyte.c2
-rw-r--r--src/nvim/mbyte.h31
-rw-r--r--src/nvim/memline.c1
-rw-r--r--src/nvim/memline.h4
-rw-r--r--src/nvim/message.c4
-rw-r--r--src/nvim/msgpack_rpc/channel.c1
-rw-r--r--src/nvim/msgpack_rpc/helpers.h5
-rw-r--r--src/nvim/msgpack_rpc/server.c1
-rw-r--r--src/nvim/msgpack_rpc/unpacker.h5
-rw-r--r--src/nvim/ops.c2
-rw-r--r--src/nvim/option.h3
-rw-r--r--src/nvim/os/input.c1
-rw-r--r--src/nvim/os/input.h2
-rw-r--r--src/nvim/os/pty_process_unix.c1
-rw-r--r--src/nvim/os/pty_process_unix.h2
-rw-r--r--src/nvim/os/pty_process_win.c1
-rw-r--r--src/nvim/os/shell.c1
-rw-r--r--src/nvim/os/signal.c1
-rw-r--r--src/nvim/os/time.c3
-rw-r--r--src/nvim/popupmenu.c1
-rw-r--r--src/nvim/regexp.c6
-rw-r--r--src/nvim/shada.c1
-rw-r--r--src/nvim/sign.c1
-rw-r--r--src/nvim/spell_defs.h12
-rw-r--r--src/nvim/spellfile.c2
-rw-r--r--src/nvim/state.c2
-rw-r--r--src/nvim/statusline.c17
-rw-r--r--src/nvim/terminal.c3
-rw-r--r--src/nvim/textformat.c1
-rw-r--r--src/nvim/textobject.c1
-rw-r--r--src/nvim/tui/input.c3
-rw-r--r--src/nvim/tui/input.h1
-rw-r--r--src/nvim/tui/tui.c1
-rw-r--r--src/nvim/types_defs.h3
-rw-r--r--src/nvim/ui.h2
-rw-r--r--src/nvim/ui_client.c2
-rw-r--r--src/nvim/ui_compositor.c2
-rw-r--r--src/nvim/undo.c2
-rw-r--r--src/nvim/usercmd.c1
-rw-r--r--src/nvim/usercmd.h2
-rw-r--r--src/nvim/version.c1
-rw-r--r--src/nvim/viml/parser/parser.h1
-rw-r--r--src/nvim/window.c1
123 files changed, 314 insertions, 462 deletions
diff --git a/Makefile b/Makefile
index 662c334c0c..5c33cdbfa9 100644
--- a/Makefile
+++ b/Makefile
@@ -136,52 +136,13 @@ generated-sources benchmark $(FORMAT) $(LINT) $(TEST) doc: | build/.ran-cmake
test: $(TEST)
-# The ignored header files should be synced with the `check_includes_ignore`
-# array in src/clint.py
iwyu: build/.ran-cmake
cmake --preset iwyu
cmake --build build > build/iwyu.log
- iwyu-fix-includes --only_re="src/nvim" --ignore_re="(src/nvim/eval/encode.c|src/nvim/auto/|src/nvim/os/lang.c|src/nvim/map.c\
- |src/nvim/api/private/validate.h\
- |src/nvim/assert_defs.h\
- |src/nvim/buffer.h\
- |src/nvim/buffer_defs.h\
- |src/nvim/channel.h\
- |src/nvim/charset.h\
- |src/nvim/eval.h\
- |src/nvim/eval/encode.h\
- |src/nvim/eval/typval.h\
- |src/nvim/eval/typval_defs.h\
- |src/nvim/eval/userfunc.h\
- |src/nvim/event/libuv_process.h\
- |src/nvim/event/loop.h\
- |src/nvim/event/process.h\
- |src/nvim/event/rstream.h\
- |src/nvim/event/signal.h\
- |src/nvim/event/socket.h\
- |src/nvim/event/stream.h\
- |src/nvim/event/time.h\
- |src/nvim/event/wstream.h\
- |src/nvim/garray.h\
- |src/nvim/globals.h\
- |src/nvim/grid.h\
- |src/nvim/highlight.h\
- |src/nvim/input.h\
- |src/nvim/keycodes.h\
- |src/nvim/lua/executor.h\
- |src/nvim/main.h\
- |src/nvim/msgpack_rpc/channel_defs.h\
- |src/nvim/msgpack_rpc/helpers.h\
- |src/nvim/msgpack_rpc/unpacker.h\
- |src/nvim/option.h\
- |src/nvim/os/input.h\
- |src/nvim/os/pty_conpty_win.h\
- |src/nvim/os/pty_process_unix.h\
- |src/nvim/os/pty_process_win.h\
- |src/nvim/tui/input.h\
- |src/nvim/ui.h\
- |src/nvim/viml/parser/expressions.h\
- |src/nvim/viml/parser/parser.h\
+ iwyu-fix-includes --only_re="src/nvim" --ignore_re="(src/nvim/eval/encode.c\
+ |src/nvim/auto/\
+ |src/nvim/os/lang.c\
+ |src/nvim/map.c\
)" --nosafe_headers < build/iwyu.log
cmake -B build -U ENABLE_IWYU
cmake --build build
diff --git a/cmake.config/iwyu/mapping.imp b/cmake.config/iwyu/mapping.imp
index f4559d9ea9..104fe7c4f9 100644
--- a/cmake.config/iwyu/mapping.imp
+++ b/cmake.config/iwyu/mapping.imp
@@ -22,6 +22,7 @@
{ symbol: [ "MIN", private, '"nvim/macros_defs.h"', public ] },
{ symbol: [ "extern_proc", private, '<uv.h>', public ] },
{ symbol: [ "iovec", private, '<sys/uio.h>', public ] },
+ { symbol: [ "ssize_t", private, '<uv.h>', public ] },
{ include: [ '<uv/unix.h>', private, '<uv.h>', public ] },
]
diff --git a/cmake.config/iwyu/posix.imp b/cmake.config/iwyu/posix.imp
index 2eabd3063b..ca96c984f2 100644
--- a/cmake.config/iwyu/posix.imp
+++ b/cmake.config/iwyu/posix.imp
@@ -13,6 +13,7 @@
{ include: [ '<bits/termios-c_cflag.h>', private, '<termios.h>', public ] },
{ include: [ '<bits/termios-c_iflag.h>', private, '<termios.h>', public ] },
{ include: [ '<bits/termios-c_oflag.h>', private, '<termios.h>', public ] },
+ { include: [ '<sys/ttycom.h>', private, '<sys/ioctl.h>', public ] },
{ include: [ '<sys/unistd.h>', private, '<unistd.h>', public ] },
{ symbol: ["SOCK_STREAM", private, "<sys/socket.h>", public ] },
@@ -26,7 +27,6 @@
{ symbol: ["ntohs", private, "<arpa/inet.h>", public ] },
{ symbol: ["pthread_sigmask", private, "<signal.h>", public ] },
{ symbol: ["sigset_t", private, "<signal.h>", public ] },
- { symbol: ["ssize_t", private, "<sys/types.h>", public ] },
{ symbol: ["uid_t", private, "<sys/types.h>", public ] },
]
diff --git a/src/clint.py b/src/clint.py
index 80ebf565a1..303c3df25d 100755
--- a/src/clint.py
+++ b/src/clint.py
@@ -897,8 +897,6 @@ def CheckIncludes(filename, lines, error):
}):
return
- # These should be synced with the ignored headers in the `iwyu` target in
- # the Makefile.
check_includes_ignore = [
"src/nvim/api/private/validate.h",
"src/nvim/assert_defs.h",
@@ -913,6 +911,7 @@ def CheckIncludes(filename, lines, error):
"src/nvim/eval/userfunc.h",
"src/nvim/event/libuv_process.h",
"src/nvim/event/loop.h",
+ "src/nvim/event/multiqueue.h",
"src/nvim/event/process.h",
"src/nvim/event/rstream.h",
"src/nvim/event/signal.h",
@@ -928,6 +927,7 @@ def CheckIncludes(filename, lines, error):
"src/nvim/keycodes.h",
"src/nvim/lua/executor.h",
"src/nvim/main.h",
+ "src/nvim/mark.h",
"src/nvim/msgpack_rpc/channel_defs.h",
"src/nvim/msgpack_rpc/helpers.h",
"src/nvim/msgpack_rpc/unpacker.h",
diff --git a/src/nvim/api/private/converter.h b/src/nvim/api/private/converter.h
index fc82abf332..a5acc56c7c 100644
--- a/src/nvim/api/private/converter.h
+++ b/src/nvim/api/private/converter.h
@@ -1,6 +1,6 @@
#pragma once
-#include "nvim/api/private/defs.h" // IWYU pragma: keep
+#include "nvim/api/private/defs.h" // IWYU pragma: export
#include "nvim/eval/typval_defs.h" // IWYU pragma: keep
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/api/private/dispatch.h b/src/nvim/api/private/dispatch.h
index b627db6b00..d322c1ceca 100644
--- a/src/nvim/api/private/dispatch.h
+++ b/src/nvim/api/private/dispatch.h
@@ -3,7 +3,7 @@
#include <stdbool.h>
#include <stdint.h>
-#include "nvim/api/private/defs.h"
+#include "nvim/api/private/defs.h" // IWYU pragma: export
#include "nvim/memory_defs.h"
#include "nvim/types_defs.h"
diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h
index 701ce91257..1ee66f906b 100644
--- a/src/nvim/api/private/helpers.h
+++ b/src/nvim/api/private/helpers.h
@@ -4,7 +4,7 @@
#include <stddef.h>
#include "klib/kvec.h"
-#include "nvim/api/private/defs.h"
+#include "nvim/api/private/defs.h" // IWYU pragma: export
#include "nvim/buffer_defs.h" // IWYU pragma: keep
#include "nvim/eval/typval_defs.h" // IWYU pragma: keep
#include "nvim/ex_eval_defs.h"
diff --git a/src/nvim/api/private/validate.h b/src/nvim/api/private/validate.h
index d1c977cd6e..692ea46176 100644
--- a/src/nvim/api/private/validate.h
+++ b/src/nvim/api/private/validate.h
@@ -3,7 +3,7 @@
#include <stdbool.h>
#include <stddef.h>
-#include "nvim/api/private/defs.h"
+#include "nvim/api/private/defs.h" // IWYU pragma: export
#include "nvim/api/private/helpers.h"
#include "nvim/assert_defs.h"
#include "nvim/macros_defs.h"
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c
index 678d23fbeb..82d42d652d 100644
--- a/src/nvim/api/ui.c
+++ b/src/nvim/api/ui.c
@@ -15,7 +15,8 @@
#include "nvim/autocmd.h"
#include "nvim/channel.h"
#include "nvim/eval.h"
-#include "nvim/event/defs.h"
+#include "nvim/event/loop.h"
+#include "nvim/event/multiqueue.h"
#include "nvim/event/wstream.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 9ae5244fa1..aed286165a 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -64,6 +64,7 @@
#include "nvim/statusline.h"
#include "nvim/strings.h"
#include "nvim/terminal.h"
+#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/vim_defs.h"
#include "nvim/window.h"
diff --git a/src/nvim/ascii_defs.h b/src/nvim/ascii_defs.h
index 3de04cd9fa..4215157654 100644
--- a/src/nvim/ascii_defs.h
+++ b/src/nvim/ascii_defs.h
@@ -86,35 +86,6 @@
static inline bool ascii_iswhite(int c)
REAL_FATTR_CONST
REAL_FATTR_ALWAYS_INLINE;
-
-static inline bool ascii_iswhite_or_nul(int c)
- REAL_FATTR_CONST
- REAL_FATTR_ALWAYS_INLINE;
-
-static inline bool ascii_isdigit(int c)
- REAL_FATTR_CONST
- REAL_FATTR_ALWAYS_INLINE;
-
-static inline bool ascii_isxdigit(int c)
- REAL_FATTR_CONST
- REAL_FATTR_ALWAYS_INLINE;
-
-static inline bool ascii_isident(int c)
- REAL_FATTR_CONST
- REAL_FATTR_ALWAYS_INLINE;
-
-static inline bool ascii_isbdigit(int c)
- REAL_FATTR_CONST
- REAL_FATTR_ALWAYS_INLINE;
-
-static inline bool ascii_isodigit(int c)
- REAL_FATTR_CONST
- REAL_FATTR_ALWAYS_INLINE;
-
-static inline bool ascii_isspace(int c)
- REAL_FATTR_CONST
- REAL_FATTR_ALWAYS_INLINE;
-
/// Checks if `c` is a space or tab character.
///
/// @see {ascii_isdigit}
@@ -123,6 +94,9 @@ static inline bool ascii_iswhite(int c)
return c == ' ' || c == '\t';
}
+static inline bool ascii_iswhite_or_nul(int c)
+ REAL_FATTR_CONST
+ REAL_FATTR_ALWAYS_INLINE;
/// Checks if `c` is a space or tab character or NUL.
///
/// @see {ascii_isdigit}
@@ -131,6 +105,9 @@ static inline bool ascii_iswhite_or_nul(int c)
return ascii_iswhite(c) || c == NUL;
}
+static inline bool ascii_isdigit(int c)
+ REAL_FATTR_CONST
+ REAL_FATTR_ALWAYS_INLINE;
/// Check whether character is a decimal digit.
///
/// Library isdigit() function is officially locale-dependent and, for
@@ -145,6 +122,9 @@ static inline bool ascii_isdigit(int c)
return c >= '0' && c <= '9';
}
+static inline bool ascii_isxdigit(int c)
+ REAL_FATTR_CONST
+ REAL_FATTR_ALWAYS_INLINE;
/// Checks if `c` is a hexadecimal digit, that is, one of 0-9, a-f, A-F.
///
/// @see {ascii_isdigit}
@@ -155,6 +135,9 @@ static inline bool ascii_isxdigit(int c)
|| (c >= 'A' && c <= 'F');
}
+static inline bool ascii_isident(int c)
+ REAL_FATTR_CONST
+ REAL_FATTR_ALWAYS_INLINE;
/// Checks if `c` is an “identifier” character
///
/// That is, whether it is alphanumeric character or underscore.
@@ -163,6 +146,9 @@ static inline bool ascii_isident(int c)
return ASCII_ISALNUM(c) || c == '_';
}
+static inline bool ascii_isbdigit(int c)
+ REAL_FATTR_CONST
+ REAL_FATTR_ALWAYS_INLINE;
/// Checks if `c` is a binary digit, that is, 0-1.
///
/// @see {ascii_isdigit}
@@ -171,6 +157,9 @@ static inline bool ascii_isbdigit(int c)
return (c == '0' || c == '1');
}
+static inline bool ascii_isodigit(int c)
+ REAL_FATTR_CONST
+ REAL_FATTR_ALWAYS_INLINE;
/// Checks if `c` is an octal digit, that is, 0-7.
///
/// @see {ascii_isdigit}
@@ -179,6 +168,9 @@ static inline bool ascii_isodigit(int c)
return (c >= '0' && c <= '7');
}
+static inline bool ascii_isspace(int c)
+ REAL_FATTR_CONST
+ REAL_FATTR_ALWAYS_INLINE;
/// Checks if `c` is a white-space character, that is,
/// one of \f, \n, \r, \t, \v.
///
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index 9605e3b4db..a7fe6667e8 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -19,7 +19,8 @@
#include "nvim/eval/typval.h"
#include "nvim/eval/userfunc.h"
#include "nvim/eval/vars.h"
-#include "nvim/event/defs.h"
+#include "nvim/event/loop.h"
+#include "nvim/event/multiqueue.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
#include "nvim/fileio.h"
diff --git a/src/nvim/autocmd_defs.h b/src/nvim/autocmd_defs.h
index 4639ec2731..ec81c2f1ed 100644
--- a/src/nvim/autocmd_defs.h
+++ b/src/nvim/autocmd_defs.h
@@ -12,7 +12,6 @@
#include "nvim/regexp_defs.h"
#include "nvim/types_defs.h"
-// event_T definition
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "auevents_enum.generated.h"
#endif
diff --git a/src/nvim/base64.c b/src/nvim/base64.c
index 7f7d121442..d461b7e3ff 100644
--- a/src/nvim/base64.c
+++ b/src/nvim/base64.c
@@ -3,7 +3,7 @@
#include <stdint.h>
#include <string.h>
-#include "auto/config.h"
+#include "auto/config.h" // IWYU pragma: keep
#include "nvim/base64.h"
#include "nvim/memory.h"
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index d62e73a191..24eab644a1 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -43,11 +43,9 @@
#include "nvim/digraph.h"
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/eval/vars.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds2.h"
-#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
#include "nvim/ex_getln.h"
@@ -69,7 +67,6 @@
#include "nvim/mark.h"
#include "nvim/mbyte.h"
#include "nvim/memfile_defs.h"
-#include "nvim/memline_defs.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/move.h"
diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h
index 36e70d1927..af30870776 100644
--- a/src/nvim/buffer.h
+++ b/src/nvim/buffer.h
@@ -6,13 +6,10 @@
#include "nvim/buffer_defs.h" // IWYU pragma: export
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
-#include "nvim/ex_cmds_defs.h"
#include "nvim/func_attr.h"
#include "nvim/macros_defs.h"
#include "nvim/memline.h"
-#include "nvim/memline_defs.h"
-#include "nvim/pos_defs.h"
+#include "nvim/types_defs.h"
/// Values for buflist_getfile()
enum getf_values {
diff --git a/src/nvim/buffer_updates.c b/src/nvim/buffer_updates.c
index a91a890d0e..7985d6931f 100644
--- a/src/nvim/buffer_updates.c
+++ b/src/nvim/buffer_updates.c
@@ -5,7 +5,6 @@
#include "klib/kvec.h"
#include "nvim/api/buffer.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/assert_defs.h"
#include "nvim/buffer.h"
diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c
index c506cfdfa3..7f44cdfb2c 100644
--- a/src/nvim/bufwrite.c
+++ b/src/nvim/bufwrite.c
@@ -17,6 +17,7 @@
#include "nvim/change.h"
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
+#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_eval.h"
diff --git a/src/nvim/channel.c b/src/nvim/channel.c
index e62c240636..d2b064ef3c 100644
--- a/src/nvim/channel.c
+++ b/src/nvim/channel.c
@@ -7,7 +7,6 @@
#include "klib/kvec.h"
#include "nvim/api/private/converter.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/autocmd.h"
#include "nvim/buffer_defs.h"
@@ -15,6 +14,7 @@
#include "nvim/eval.h"
#include "nvim/eval/encode.h"
#include "nvim/eval/typval.h"
+#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
#include "nvim/event/rstream.h"
#include "nvim/event/socket.h"
diff --git a/src/nvim/channel.h b/src/nvim/channel.h
index 7e3e84d918..e77f17d3e0 100644
--- a/src/nvim/channel.h
+++ b/src/nvim/channel.h
@@ -7,13 +7,9 @@
#include "nvim/channel_defs.h" // IWYU pragma: export
#include "nvim/eval/typval_defs.h"
#include "nvim/event/libuv_process.h"
-#include "nvim/event/multiqueue.h"
#include "nvim/event/process.h"
-#include "nvim/event/socket.h"
-#include "nvim/event/stream.h"
-#include "nvim/garray_defs.h"
+#include "nvim/func_attr.h"
#include "nvim/macros_defs.h"
-#include "nvim/main.h"
#include "nvim/map_defs.h"
#include "nvim/msgpack_rpc/channel_defs.h"
#include "nvim/os/pty_process.h"
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index 60a0c77cfa..fc900fd3a7 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -8,7 +8,7 @@
#include <limits.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
+#include <uv.h>
#include "auto/config.h"
#include "klib/kvec.h"
diff --git a/src/nvim/charset.h b/src/nvim/charset.h
index cfab0f8517..62a38660a8 100644
--- a/src/nvim/charset.h
+++ b/src/nvim/charset.h
@@ -3,12 +3,9 @@
#include <stdbool.h>
#include <stdint.h>
-#include "nvim/buffer_defs.h"
-#include "nvim/eval/typval_defs.h"
-#include "nvim/option_defs.h"
+#include "nvim/func_attr.h"
#include "nvim/option_vars.h"
-#include "nvim/pos_defs.h"
-#include "nvim/strings.h"
+#include "nvim/strings.h" // IWYU pragma: keep
/// Return the folded-case equivalent of the given character
///
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c
index 31b385c466..3198156409 100644
--- a/src/nvim/cmdexpand.c
+++ b/src/nvim/cmdexpand.c
@@ -6,9 +6,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
+#include <uv.h>
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/arglist.h"
#include "nvim/ascii_defs.h"
diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c
index bcb2810095..d25566213c 100644
--- a/src/nvim/cursor.c
+++ b/src/nvim/cursor.c
@@ -11,7 +11,6 @@
#include "nvim/drawscreen.h"
#include "nvim/fold.h"
#include "nvim/globals.h"
-#include "nvim/macros_defs.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c
index 7b3a32167e..ad2482c2e4 100644
--- a/src/nvim/decoration.c
+++ b/src/nvim/decoration.c
@@ -4,7 +4,6 @@
#include <stdlib.h>
#include "nvim/api/extmark.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/buffer_defs.h"
#include "nvim/decoration.h"
diff --git a/src/nvim/decoration_provider.c b/src/nvim/decoration_provider.c
index 39516ff541..e160a563f3 100644
--- a/src/nvim/decoration_provider.c
+++ b/src/nvim/decoration_provider.c
@@ -5,7 +5,6 @@
#include "klib/kvec.h"
#include "nvim/api/extmark.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/buffer_defs.h"
#include "nvim/decoration.h"
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c
index 3864177802..a6e483ab54 100644
--- a/src/nvim/drawscreen.c
+++ b/src/nvim/drawscreen.c
@@ -105,6 +105,7 @@
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/terminal.h"
+#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/ui_compositor.h"
#include "nvim/version.h"
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 613aa2a591..8984a959d3 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -5,7 +5,7 @@
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
-#include <sys/types.h>
+#include <uv.h>
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
@@ -18,6 +18,7 @@
#include "nvim/drawscreen.h"
#include "nvim/edit.h"
#include "nvim/eval.h"
+#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/extmark.h"
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index d12a49e7d4..68347fd582 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -7,11 +7,10 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
-#include <sys/types.h>
+#include <uv.h>
#include "auto/config.h"
#include "nvim/api/private/converter.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
@@ -29,6 +28,7 @@
#include "nvim/eval/typval.h"
#include "nvim/eval/userfunc.h"
#include "nvim/eval/vars.h"
+#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
#include "nvim/event/process.h"
#include "nvim/event/time.h"
diff --git a/src/nvim/eval.h b/src/nvim/eval.h
index b350b9a8d1..9ee5d99806 100644
--- a/src/nvim/eval.h
+++ b/src/nvim/eval.h
@@ -4,7 +4,7 @@
#include <stddef.h>
#include <stdint.h>
-#include "nvim/channel.h"
+#include "nvim/channel_defs.h" // IWYU pragma: keep
#include "nvim/cmdexpand_defs.h" // IWYU pragma: keep
#include "nvim/eval/typval_defs.h"
#include "nvim/event/time.h"
@@ -13,6 +13,7 @@
#include "nvim/hashtab_defs.h"
#include "nvim/macros_defs.h"
#include "nvim/mbyte_defs.h" // IWYU pragma: keep
+#include "nvim/msgpack_rpc/channel_defs.h" // IWYU pragma: keep
#include "nvim/option_defs.h" // IWYU pragma: keep
#include "nvim/os/fileio_defs.h" // IWYU pragma: keep
#include "nvim/os/stdpaths_defs.h" // IWYU pragma: keep
diff --git a/src/nvim/eval/encode.h b/src/nvim/eval/encode.h
index 11a0ce3932..fe1b951e3c 100644
--- a/src/nvim/eval/encode.h
+++ b/src/nvim/eval/encode.h
@@ -1,12 +1,10 @@
#pragma once
-#include <msgpack.h>
#include <msgpack/pack.h>
-#include <stddef.h>
#include <string.h>
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
+#include "nvim/func_attr.h"
#include "nvim/garray_defs.h"
/// Convert Vimscript value to msgpack string
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 5b6904269d..30a86b1917 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -14,13 +14,11 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
-#include <sys/types.h>
#include <time.h>
#include <uv.h>
#include "auto/config.h"
#include "nvim/api/private/converter.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/dispatch.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/vim.h"
@@ -47,7 +45,6 @@
#include "nvim/eval/userfunc.h"
#include "nvim/eval/vars.h"
#include "nvim/eval/window.h"
-#include "nvim/event/defs.h"
#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
#include "nvim/event/process.h"
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index 069cdced34..42b105b2a2 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -5,7 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
+#include <uv.h>
#include "nvim/ascii_defs.h"
#include "nvim/assert_defs.h"
@@ -19,7 +19,6 @@
#include "nvim/eval/userfunc.h"
#include "nvim/eval/vars.h"
#include "nvim/garray.h"
-#include "nvim/garray_defs.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/hashtab.h"
diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h
index efa6017f4b..0013c8ffe5 100644
--- a/src/nvim/eval/typval.h
+++ b/src/nvim/eval/typval.h
@@ -8,12 +8,11 @@
#include "nvim/eval/typval_defs.h" // IWYU pragma: export
#include "nvim/func_attr.h"
-#include "nvim/garray_defs.h"
#include "nvim/gettext.h"
#include "nvim/hashtab.h"
#include "nvim/lib/queue.h"
#include "nvim/macros_defs.h"
-#include "nvim/mbyte_defs.h"
+#include "nvim/mbyte_defs.h" // IWYU pragma: keep
#include "nvim/message.h"
#include "nvim/types_defs.h"
diff --git a/src/nvim/eval/userfunc.h b/src/nvim/eval/userfunc.h
index 8050caab2b..65a96a13c5 100644
--- a/src/nvim/eval/userfunc.h
+++ b/src/nvim/eval/userfunc.h
@@ -4,7 +4,7 @@
#include <stddef.h>
#include "nvim/cmdexpand_defs.h" // IWYU pragma: keep
-#include "nvim/eval.h"
+#include "nvim/eval.h" // IWYU pragma: keep
#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
#include "nvim/hashtab_defs.h" // IWYU pragma: keep
diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c
index de2fddb083..8ed76341b0 100644
--- a/src/nvim/eval/vars.c
+++ b/src/nvim/eval/vars.c
@@ -7,7 +7,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
+#include <uv.h>
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
diff --git a/src/nvim/event/defs.h b/src/nvim/event/defs.h
index ffea388b9b..e19ad4c970 100644
--- a/src/nvim/event/defs.h
+++ b/src/nvim/event/defs.h
@@ -20,52 +20,6 @@ typedef struct {
typedef struct multiqueue MultiQueue;
typedef void (*PutCallback)(MultiQueue *multiq, void *data);
-#define multiqueue_put(q, h, ...) \
- do { \
- multiqueue_put_event(q, event_create(h, __VA_ARGS__)); \
- } while (0)
-
-#define CREATE_EVENT(multiqueue, handler, ...) \
- do { \
- if (multiqueue) { \
- multiqueue_put((multiqueue), (handler), __VA_ARGS__); \
- } else { \
- void *argv[] = { __VA_ARGS__ }; \
- (handler)(argv); \
- } \
- } while (0)
-
-// Poll for events until a condition or timeout
-#define LOOP_PROCESS_EVENTS_UNTIL(loop, multiqueue, timeout, condition) \
- do { \
- int64_t remaining = timeout; \
- uint64_t before = (remaining > 0) ? os_hrtime() : 0; \
- while (!(condition)) { \
- LOOP_PROCESS_EVENTS(loop, multiqueue, remaining); \
- if (remaining == 0) { \
- break; \
- } else if (remaining > 0) { \
- uint64_t now = os_hrtime(); \
- remaining -= (int64_t)((now - before) / 1000000); \
- before = now; \
- if (remaining <= 0) { \
- break; \
- } \
- } \
- } \
- } while (0)
-
-#define LOOP_PROCESS_EVENTS(loop, multiqueue, timeout) \
- do { \
- if (multiqueue && !multiqueue_empty(multiqueue)) { \
- multiqueue_process_events(multiqueue); \
- } else { \
- loop_poll_events(loop, timeout); \
- } \
- } while (0)
-
-struct signal_watcher;
-
typedef struct signal_watcher SignalWatcher;
typedef void (*signal_cb)(SignalWatcher *watcher, int signum, void *data);
typedef void (*signal_close_cb)(SignalWatcher *watcher, void *data);
@@ -78,8 +32,6 @@ struct signal_watcher {
MultiQueue *events;
};
-struct time_watcher;
-
typedef struct time_watcher TimeWatcher;
typedef void (*time_cb)(TimeWatcher *watcher, void *data);
@@ -91,8 +43,6 @@ struct time_watcher {
bool blockable;
};
-struct wbuffer;
-
typedef struct wbuffer WBuffer;
typedef void (*wbuffer_data_finalizer)(void *data);
@@ -102,8 +52,6 @@ struct wbuffer {
wbuffer_data_finalizer cb;
};
-struct stream;
-
typedef struct stream Stream;
/// Type of function called when the Stream buffer is filled with data
///
@@ -151,8 +99,6 @@ struct stream {
MultiQueue *events;
};
-struct socket_watcher;
-
#define ADDRESS_MAX_SIZE 256
typedef struct socket_watcher SocketWatcher;
diff --git a/src/nvim/event/libuv_process.c b/src/nvim/event/libuv_process.c
index 07c059423a..65132ec2b1 100644
--- a/src/nvim/event/libuv_process.c
+++ b/src/nvim/event/libuv_process.c
@@ -4,8 +4,8 @@
#include <uv.h>
#include "nvim/eval/typval.h"
-#include "nvim/event/defs.h"
#include "nvim/event/libuv_process.h"
+#include "nvim/event/loop.h"
#include "nvim/event/process.h"
#include "nvim/log.h"
#include "nvim/os/os.h"
diff --git a/src/nvim/event/libuv_process.h b/src/nvim/event/libuv_process.h
index e3e2bfeb76..3951bb6802 100644
--- a/src/nvim/event/libuv_process.h
+++ b/src/nvim/event/libuv_process.h
@@ -2,8 +2,8 @@
#include <uv.h>
-#include "nvim/event/loop.h"
#include "nvim/event/process.h"
+#include "nvim/types_defs.h"
typedef struct libuv_process {
Process process;
diff --git a/src/nvim/event/loop.c b/src/nvim/event/loop.c
index a2cb72771c..93948d3eaa 100644
--- a/src/nvim/event/loop.c
+++ b/src/nvim/event/loop.c
@@ -3,12 +3,12 @@
#include <stdlib.h>
#include <uv.h>
-#include "nvim/event/defs.h"
#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
#include "nvim/log.h"
#include "nvim/memory.h"
#include "nvim/os/time.h"
+#include "nvim/types_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "event/loop.c.generated.h"
diff --git a/src/nvim/event/loop.h b/src/nvim/event/loop.h
index b567df5456..adcde4c909 100644
--- a/src/nvim/event/loop.h
+++ b/src/nvim/event/loop.h
@@ -1,19 +1,18 @@
#pragma once
#include <stdbool.h>
-#include <stdint.h>
#include <uv.h>
#include "klib/klist.h"
-#include "nvim/event/multiqueue.h"
-#include "nvim/os/time.h"
+#include "nvim/event/defs.h" // IWYU pragma: export
+#include "nvim/types_defs.h" // IWYU pragma: keep
typedef void *WatcherPtr;
#define _NOOP(x)
KLIST_INIT(WatcherPtr, WatcherPtr, _NOOP)
-typedef struct loop {
+struct loop {
uv_loop_t uv;
MultiQueue *events;
MultiQueue *thread_events;
@@ -42,7 +41,7 @@ typedef struct loop {
uv_mutex_t mutex;
int recursive;
bool closing; ///< Set to true if loop_close() has been called
-} Loop;
+};
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "event/loop.h.generated.h"
diff --git a/src/nvim/event/multiqueue.h b/src/nvim/event/multiqueue.h
index 26e3bc1c30..a0cebcea1d 100644
--- a/src/nvim/event/multiqueue.h
+++ b/src/nvim/event/multiqueue.h
@@ -2,8 +2,53 @@
#include <stddef.h> // IWYU pragma: keep
-#include "nvim/event/defs.h" // IWYU pragma: keep
+#include "nvim/event/defs.h" // IWYU pragma: export
+#include "nvim/os/time.h" // IWYU pragma: keep
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "event/multiqueue.h.generated.h"
#endif
+
+#define multiqueue_put(q, h, ...) \
+ do { \
+ multiqueue_put_event(q, event_create(h, __VA_ARGS__)); \
+ } while (0)
+
+#define CREATE_EVENT(multiqueue, handler, ...) \
+ do { \
+ if (multiqueue) { \
+ multiqueue_put((multiqueue), (handler), __VA_ARGS__); \
+ } else { \
+ void *argv[] = { __VA_ARGS__ }; \
+ (handler)(argv); \
+ } \
+ } while (0)
+
+// Poll for events until a condition or timeout
+#define LOOP_PROCESS_EVENTS_UNTIL(loop, multiqueue, timeout, condition) \
+ do { \
+ int64_t remaining = timeout; \
+ uint64_t before = (remaining > 0) ? os_hrtime() : 0; \
+ while (!(condition)) { \
+ LOOP_PROCESS_EVENTS(loop, multiqueue, remaining); \
+ if (remaining == 0) { \
+ break; \
+ } else if (remaining > 0) { \
+ uint64_t now = os_hrtime(); \
+ remaining -= (int64_t)((now - before) / 1000000); \
+ before = now; \
+ if (remaining <= 0) { \
+ break; \
+ } \
+ } \
+ } \
+ } while (0)
+
+#define LOOP_PROCESS_EVENTS(loop, multiqueue, timeout) \
+ do { \
+ if (multiqueue && !multiqueue_empty(multiqueue)) { \
+ multiqueue_process_events(multiqueue); \
+ } else { \
+ loop_poll_events(loop, timeout); \
+ } \
+ } while (0)
diff --git a/src/nvim/event/process.h b/src/nvim/event/process.h
index 234fc815af..a18414a86a 100644
--- a/src/nvim/event/process.h
+++ b/src/nvim/event/process.h
@@ -5,13 +5,8 @@
#include <stdint.h>
#include "nvim/eval/typval_defs.h"
-#include "nvim/event/loop.h"
-#include "nvim/event/multiqueue.h"
-#include "nvim/event/rstream.h"
-#include "nvim/event/stream.h"
-#include "nvim/event/wstream.h"
-
-struct process;
+#include "nvim/event/defs.h" // IWYU pragma: export
+#include "nvim/types_defs.h"
typedef enum {
kProcessTypeUv,
diff --git a/src/nvim/event/rstream.c b/src/nvim/event/rstream.c
index df97b592e4..c70ddeefb0 100644
--- a/src/nvim/event/rstream.c
+++ b/src/nvim/event/rstream.c
@@ -2,11 +2,9 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
-#include <sys/types.h>
#include <uv.h>
-#include "nvim/event/defs.h"
-#include "nvim/event/loop.h"
+#include "nvim/event/multiqueue.h"
#include "nvim/event/rstream.h"
#include "nvim/event/stream.h"
#include "nvim/log.h"
@@ -14,6 +12,7 @@
#include "nvim/main.h"
#include "nvim/os/os_defs.h"
#include "nvim/rbuffer.h"
+#include "nvim/types_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "event/rstream.c.generated.h"
diff --git a/src/nvim/event/rstream.h b/src/nvim/event/rstream.h
index b2a62acf83..3b04e5d435 100644
--- a/src/nvim/event/rstream.h
+++ b/src/nvim/event/rstream.h
@@ -1,11 +1,7 @@
#pragma once
-#include <stdbool.h>
-#include <stddef.h>
-#include <uv.h>
-
-#include "nvim/event/loop.h"
-#include "nvim/event/stream.h"
+#include "nvim/event/defs.h" // IWYU pragma: export
+#include "nvim/types_defs.h" // IWYU pragma: keep
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "event/rstream.h.generated.h"
diff --git a/src/nvim/event/signal.c b/src/nvim/event/signal.c
index 3a100812cf..57241e79b2 100644
--- a/src/nvim/event/signal.c
+++ b/src/nvim/event/signal.c
@@ -3,7 +3,9 @@
#include "nvim/event/defs.h"
#include "nvim/event/loop.h"
+#include "nvim/event/multiqueue.h"
#include "nvim/event/signal.h"
+#include "nvim/types_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "event/signal.c.generated.h"
diff --git a/src/nvim/event/signal.h b/src/nvim/event/signal.h
index 711797ca71..79784f1226 100644
--- a/src/nvim/event/signal.h
+++ b/src/nvim/event/signal.h
@@ -1,10 +1,7 @@
#pragma once
-#include <uv.h>
-
-#include "nvim/event/defs.h"
-#include "nvim/event/loop.h"
-#include "nvim/event/multiqueue.h"
+#include "nvim/event/defs.h" // IWYU pragma: export
+#include "nvim/types_defs.h" // IWYU pragma: keep
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "event/signal.h.generated.h"
diff --git a/src/nvim/event/socket.c b/src/nvim/event/socket.c
index 3c7b98bfe7..35db9150b3 100644
--- a/src/nvim/event/socket.c
+++ b/src/nvim/event/socket.c
@@ -9,6 +9,7 @@
#include "nvim/charset.h"
#include "nvim/event/defs.h"
#include "nvim/event/loop.h"
+#include "nvim/event/multiqueue.h"
#include "nvim/event/socket.h"
#include "nvim/event/stream.h"
#include "nvim/gettext.h"
@@ -18,6 +19,7 @@
#include "nvim/os/fs.h"
#include "nvim/os/os.h"
#include "nvim/path.h"
+#include "nvim/types_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "event/socket.c.generated.h"
diff --git a/src/nvim/event/socket.h b/src/nvim/event/socket.h
index 24ba361efa..8dd72234d2 100644
--- a/src/nvim/event/socket.h
+++ b/src/nvim/event/socket.h
@@ -1,12 +1,7 @@
#pragma once
-#include <uv.h>
-
-#include "nvim/event/defs.h"
-#include "nvim/event/loop.h"
-#include "nvim/event/multiqueue.h"
-#include "nvim/event/rstream.h"
-#include "nvim/event/wstream.h"
+#include "nvim/event/defs.h" // IWYU pragma: export
+#include "nvim/types_defs.h" // IWYU pragma: keep
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "event/socket.h.generated.h"
diff --git a/src/nvim/event/stream.c b/src/nvim/event/stream.c
index 886e93931b..0b9ed4f25b 100644
--- a/src/nvim/event/stream.c
+++ b/src/nvim/event/stream.c
@@ -9,6 +9,7 @@
#include "nvim/event/stream.h"
#include "nvim/log.h"
#include "nvim/rbuffer.h"
+#include "nvim/types_defs.h"
#ifdef MSWIN
# include "nvim/os/os_win_console.h"
#endif
diff --git a/src/nvim/event/stream.h b/src/nvim/event/stream.h
index 588aab12b0..f79c0ebaa3 100644
--- a/src/nvim/event/stream.h
+++ b/src/nvim/event/stream.h
@@ -1,13 +1,7 @@
#pragma once
-#include <stdbool.h>
-#include <stddef.h>
-#include <uv.h>
-
-#include "nvim/event/defs.h"
-#include "nvim/event/loop.h"
-#include "nvim/event/multiqueue.h"
-#include "nvim/rbuffer_defs.h"
+#include "nvim/event/defs.h" // IWYU pragma: export
+#include "nvim/types_defs.h" // IWYU pragma: keep
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "event/stream.h.generated.h"
diff --git a/src/nvim/event/time.c b/src/nvim/event/time.c
index de837fd278..861b15f6dd 100644
--- a/src/nvim/event/time.c
+++ b/src/nvim/event/time.c
@@ -6,6 +6,7 @@
#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
#include "nvim/event/time.h"
+#include "nvim/types_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "event/time.c.generated.h"
diff --git a/src/nvim/event/time.h b/src/nvim/event/time.h
index 85171f315a..0b684db897 100644
--- a/src/nvim/event/time.h
+++ b/src/nvim/event/time.h
@@ -1,11 +1,7 @@
#pragma once
-#include <stdbool.h>
-#include <uv.h>
-
-#include "nvim/event/defs.h"
-#include "nvim/event/loop.h"
-#include "nvim/event/multiqueue.h"
+#include "nvim/event/defs.h" // IWYU pragma: export
+#include "nvim/types_defs.h" // IWYU pragma: keep
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "event/time.h.generated.h"
diff --git a/src/nvim/event/wstream.c b/src/nvim/event/wstream.c
index 70cc5b6547..406ff1620d 100644
--- a/src/nvim/event/wstream.c
+++ b/src/nvim/event/wstream.c
@@ -4,11 +4,11 @@
#include <uv.h>
#include "nvim/event/defs.h"
-#include "nvim/event/loop.h"
#include "nvim/event/stream.h"
#include "nvim/event/wstream.h"
#include "nvim/macros_defs.h"
#include "nvim/memory.h"
+#include "nvim/types_defs.h"
#define DEFAULT_MAXMEM 1024 * 1024 * 2000
diff --git a/src/nvim/event/wstream.h b/src/nvim/event/wstream.h
index d61ab644f4..5994e6d700 100644
--- a/src/nvim/event/wstream.h
+++ b/src/nvim/event/wstream.h
@@ -1,13 +1,7 @@
#pragma once
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <uv.h>
-
-#include "nvim/event/defs.h"
-#include "nvim/event/loop.h"
-#include "nvim/event/stream.h"
+#include "nvim/event/defs.h" // IWYU pragma: export
+#include "nvim/types_defs.h" // IWYU pragma: keep
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "event/wstream.h.generated.h"
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index c268f47323..70c8dc9019 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -9,7 +9,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
+#include <uv.h>
#include "auto/config.h"
#include "nvim/arglist.h"
@@ -29,7 +29,8 @@
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
#include "nvim/eval/userfunc.h"
-#include "nvim/event/defs.h"
+#include "nvim/event/loop.h"
+#include "nvim/event/multiqueue.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds2.h"
#include "nvim/ex_cmds_defs.h"
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 974115d803..61e11636ae 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -11,7 +11,6 @@
#include "klib/kvec.h"
#include "nvim/api/extmark.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/vim.h"
#include "nvim/arabic.h"
diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c
index 47f92920eb..82e3fe09d2 100644
--- a/src/nvim/ex_session.c
+++ b/src/nvim/ex_session.c
@@ -25,6 +25,7 @@
#include "nvim/globals.h"
#include "nvim/macros_defs.h"
#include "nvim/mapping.h"
+#include "nvim/mbyte.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option.h"
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index a268070dec..b595bb0f87 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -11,7 +11,6 @@
#include "klib/kvec.h"
#include "nvim/api/extmark.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii_defs.h"
#include "nvim/buffer_defs.h"
diff --git a/src/nvim/garray.h b/src/nvim/garray.h
index a96deda759..dd355984b3 100644
--- a/src/nvim/garray.h
+++ b/src/nvim/garray.h
@@ -6,7 +6,6 @@
#include "nvim/garray_defs.h" // IWYU pragma: export
#include "nvim/log.h"
#include "nvim/memory.h"
-#include "nvim/types_defs.h"
#define GA_EMPTY(ga_ptr) ((ga_ptr)->ga_len <= 0)
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 305b18fc28..5d6a220ec7 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -11,7 +11,6 @@
#include <stdlib.h>
#include <string.h>
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii_defs.h"
#include "nvim/buffer_defs.h"
@@ -22,6 +21,7 @@
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
#include "nvim/eval/typval_defs.h"
+#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_docmd.h"
@@ -34,7 +34,6 @@
#include "nvim/insexpand.h"
#include "nvim/keycodes.h"
#include "nvim/lua/executor.h"
-#include "nvim/macros_defs.h"
#include "nvim/main.h"
#include "nvim/mapping.h"
#include "nvim/mbyte.h"
diff --git a/src/nvim/grid.h b/src/nvim/grid.h
index 9d8e395dae..7398ae7847 100644
--- a/src/nvim/grid.h
+++ b/src/nvim/grid.h
@@ -2,13 +2,12 @@
#include <stdbool.h>
#include <stddef.h> // IWYU pragma: keep
-#include <string.h>
-#include "nvim/buffer_defs.h"
#include "nvim/grid_defs.h" // IWYU pragma: export
#include "nvim/macros_defs.h"
#include "nvim/mbyte.h"
#include "nvim/pos_defs.h"
+#include "nvim/types_defs.h"
/// By default, all windows are drawn on a single rectangular grid, represented by
/// this ScreenGrid instance. In multigrid mode each window will have its own
diff --git a/src/nvim/highlight.h b/src/nvim/highlight.h
index ea8a663a9f..228d96ceb2 100644
--- a/src/nvim/highlight.h
+++ b/src/nvim/highlight.h
@@ -2,7 +2,7 @@
#include <stdbool.h>
-#include "nvim/api/keysets_defs.h"
+#include "nvim/api/keysets_defs.h" // IWYU pragma: keep
#include "nvim/api/private/defs.h" // IWYU pragma: keep
#include "nvim/buffer_defs.h" // IWYU pragma: keep
#include "nvim/highlight_defs.h" // IWYU pragma: export
diff --git a/src/nvim/input.c b/src/nvim/input.c
index a2a9692cb4..af66cfdcba 100644
--- a/src/nvim/input.c
+++ b/src/nvim/input.c
@@ -7,7 +7,6 @@
#include <string.h>
#include "nvim/ascii_defs.h"
-#include "nvim/event/defs.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
diff --git a/src/nvim/keycodes.c b/src/nvim/keycodes.c
index f8475b3e22..301c3846e7 100644
--- a/src/nvim/keycodes.c
+++ b/src/nvim/keycodes.c
@@ -4,7 +4,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
-#include <sys/types.h>
+#include <uv.h>
#include "nvim/ascii_defs.h"
#include "nvim/charset.h"
diff --git a/src/nvim/keycodes.h b/src/nvim/keycodes.h
index db9ef38cc3..fafe205f4d 100644
--- a/src/nvim/keycodes.h
+++ b/src/nvim/keycodes.h
@@ -3,9 +3,8 @@
#include <stddef.h>
#include "nvim/ascii_defs.h"
-#include "nvim/option_defs.h"
+#include "nvim/eval/typval_defs.h" // IWYU pragma: keep
#include "nvim/option_vars.h"
-#include "nvim/strings.h"
// Keycode definitions for special keys.
//
diff --git a/src/nvim/log.h b/src/nvim/log.h
index c6a033c634..1fb15e3503 100644
--- a/src/nvim/log.h
+++ b/src/nvim/log.h
@@ -1,7 +1,9 @@
#pragma once
+#include <stdbool.h>
+#include <stdio.h>
+
#include "auto/config.h"
-#include "nvim/log_defs.h" // IWYU pragma: export
#include "nvim/macros_defs.h"
// USDT probes. Example invocation:
@@ -20,6 +22,35 @@
#endif
// uncrustify:on
+#define LOGLVL_DBG 1
+#define LOGLVL_INF 2
+#define LOGLVL_WRN 3
+#define LOGLVL_ERR 4
+
+#define LOG(level, ...) logmsg((level), NULL, __func__, __LINE__, true, __VA_ARGS__)
+
+#ifdef NVIM_LOG_DEBUG
+# define DLOG(...) logmsg(LOGLVL_DBG, NULL, __func__, __LINE__, true, __VA_ARGS__)
+# define DLOGN(...) logmsg(LOGLVL_DBG, NULL, __func__, __LINE__, false, __VA_ARGS__)
+# define ILOG(...) logmsg(LOGLVL_INF, NULL, __func__, __LINE__, true, __VA_ARGS__)
+# define ILOGN(...) logmsg(LOGLVL_INF, NULL, __func__, __LINE__, false, __VA_ARGS__)
+#else
+# define DLOG(...)
+# define DLOGN(...)
+# define ILOG(...)
+# define ILOGN(...)
+#endif
+
+#define WLOG(...) logmsg(LOGLVL_WRN, NULL, __func__, __LINE__, true, __VA_ARGS__)
+#define WLOGN(...) logmsg(LOGLVL_WRN, NULL, __func__, __LINE__, false, __VA_ARGS__)
+#define ELOG(...) logmsg(LOGLVL_ERR, NULL, __func__, __LINE__, true, __VA_ARGS__)
+#define ELOGN(...) logmsg(LOGLVL_ERR, NULL, __func__, __LINE__, false, __VA_ARGS__)
+
+#ifdef HAVE_EXECINFO_BACKTRACE
+# define LOG_CALLSTACK() log_callstack(__func__, __LINE__)
+# define LOG_CALLSTACK_TO_FILE(fp) log_callstack_to_file(fp, __func__, __LINE__)
+#endif
+
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "log.h.generated.h"
#endif
diff --git a/src/nvim/log_defs.h b/src/nvim/log_defs.h
deleted file mode 100644
index 1b666720fc..0000000000
--- a/src/nvim/log_defs.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#pragma once
-
-#include <stdbool.h>
-#include <stdio.h>
-
-#include "auto/config.h"
-#include "nvim/macros_defs.h"
-
-#define LOGLVL_DBG 1
-#define LOGLVL_INF 2
-#define LOGLVL_WRN 3
-#define LOGLVL_ERR 4
-
-#define LOG(level, ...) logmsg((level), NULL, __func__, __LINE__, true, __VA_ARGS__)
-
-#ifdef NVIM_LOG_DEBUG
-# define DLOG(...) logmsg(LOGLVL_DBG, NULL, __func__, __LINE__, true, __VA_ARGS__)
-# define DLOGN(...) logmsg(LOGLVL_DBG, NULL, __func__, __LINE__, false, __VA_ARGS__)
-# define ILOG(...) logmsg(LOGLVL_INF, NULL, __func__, __LINE__, true, __VA_ARGS__)
-# define ILOGN(...) logmsg(LOGLVL_INF, NULL, __func__, __LINE__, false, __VA_ARGS__)
-#else
-# define DLOG(...)
-# define DLOGN(...)
-# define ILOG(...)
-# define ILOGN(...)
-#endif
-
-#define WLOG(...) logmsg(LOGLVL_WRN, NULL, __func__, __LINE__, true, __VA_ARGS__)
-#define WLOGN(...) logmsg(LOGLVL_WRN, NULL, __func__, __LINE__, false, __VA_ARGS__)
-#define ELOG(...) logmsg(LOGLVL_ERR, NULL, __func__, __LINE__, true, __VA_ARGS__)
-#define ELOGN(...) logmsg(LOGLVL_ERR, NULL, __func__, __LINE__, false, __VA_ARGS__)
-
-#ifdef HAVE_EXECINFO_BACKTRACE
-# define LOG_CALLSTACK() log_callstack(__func__, __LINE__)
-# define LOG_CALLSTACK_TO_FILE(fp) log_callstack_to_file(fp, __func__, __LINE__)
-#endif
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index 43a6a12fda..3e7cdd002e 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -13,7 +13,6 @@
#include "klib/kvec.h"
#include "luv/luv.h"
#include "nvim/api/extmark.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii_defs.h"
#include "nvim/buffer_defs.h"
@@ -24,10 +23,9 @@
#include "nvim/eval.h"
#include "nvim/eval/funcs.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/eval/userfunc.h"
-#include "nvim/event/defs.h"
#include "nvim/event/loop.h"
+#include "nvim/event/multiqueue.h"
#include "nvim/event/time.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds_defs.h"
diff --git a/src/nvim/lua/executor.h b/src/nvim/lua/executor.h
index b38faddbb3..0b4623cbd3 100644
--- a/src/nvim/lua/executor.h
+++ b/src/nvim/lua/executor.h
@@ -4,18 +4,13 @@
#include <lua.h>
#include <stdbool.h>
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
-#include "nvim/assert_defs.h"
-#include "nvim/cmdexpand_defs.h"
-#include "nvim/eval/typval_defs.h"
-#include "nvim/ex_cmds_defs.h"
+#include "nvim/cmdexpand_defs.h" // IWYU pragma: keep
+#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
#include "nvim/func_attr.h"
-#include "nvim/lua/converter.h"
#include "nvim/macros_defs.h"
-#include "nvim/map_defs.h"
#include "nvim/types_defs.h"
-#include "nvim/usercmd.h"
+#include "nvim/usercmd.h" // IWYU pragma: keep
// Generated by msgpack-gen.lua
void nlua_add_api_functions(lua_State *lstate) REAL_FATTR_NONNULL_ALL;
diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c
index 4b7d2dab21..db710457c3 100644
--- a/src/nvim/lua/stdlib.c
+++ b/src/nvim/lua/stdlib.c
@@ -6,7 +6,7 @@
#include <stddef.h>
#include <stdint.h>
#include <string.h>
-#include <sys/types.h>
+#include <uv.h>
#ifdef NVIM_VENDOR_BIT
# include "bit.h"
@@ -14,7 +14,6 @@
#include "cjson/lua_cjson.h"
#include "mpack/lmpack.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii_defs.h"
#include "nvim/buffer_defs.h"
diff --git a/src/nvim/lua/xdiff.c b/src/nvim/lua/xdiff.c
index 5285c1187d..e21bca170f 100644
--- a/src/nvim/lua/xdiff.c
+++ b/src/nvim/lua/xdiff.c
@@ -5,7 +5,6 @@
#include <string.h>
#include "luaconf.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/linematch.h"
#include "nvim/lua/converter.h"
diff --git a/src/nvim/macros_defs.h b/src/nvim/macros_defs.h
index a7af2f91c3..a0dcafab95 100644
--- a/src/nvim/macros_defs.h
+++ b/src/nvim/macros_defs.h
@@ -29,9 +29,6 @@
/// @return `s, sizeof(s) - 1`
#define S_LEN(s) (s), (sizeof(s) - 1)
-/// LINEEMPTY() - return true if the line is empty
-#define LINEEMPTY(p) (*ml_get(p) == NUL)
-
// toupper() and tolower() that use the current locale.
// Careful: Only call TOUPPER_LOC() and TOLOWER_LOC() with a character in the
// range 0 - 255. toupper()/tolower() on some systems can't handle others.
@@ -54,48 +51,12 @@
// Returns empty string if it is NULL.
#define EMPTY_IF_NULL(x) ((x) ? (x) : "")
-/// Adjust chars in a language according to 'langmap' option.
-/// NOTE that there is no noticeable overhead if 'langmap' is not set.
-/// When set the overhead for characters < 256 is small.
-/// Don't apply 'langmap' if the character comes from the Stuff buffer or from a
-/// mapping and the langnoremap option was set.
-/// The do-while is just to ignore a ';' after the macro.
-#define LANGMAP_ADJUST(c, condition) \
- do { \
- if (*p_langmap \
- && (condition) \
- && (p_lrm || (vgetc_busy ? typebuf_maplen() == 0 : KeyTyped)) \
- && !KeyStuffed \
- && (c) >= 0) \
- { \
- if ((c) < 256) \
- c = langmap_mapchar[c]; \
- else \
- c = langmap_adjust_mb(c); \
- } \
- } while (0)
-
#define WRITEBIN "wb" // no CR-LF translation
#define READBIN "rb"
#define APPENDBIN "ab"
#define REPLACE_NORMAL(s) (((s)& REPLACE_FLAG) && !((s)& VREPLACE_FLAG))
-// MB_PTR_ADV(): advance a pointer to the next character, taking care of
-// multi-byte characters if needed. Skip over composing chars.
-#define MB_PTR_ADV(p) (p += utfc_ptr2len((char *)p))
-
-// Advance multi-byte pointer, do not skip over composing chars.
-#define MB_CPTR_ADV(p) (p += utf_ptr2len((char *)p))
-
-// MB_PTR_BACK(): backup a pointer to the previous character, taking care of
-// multi-byte characters if needed. Only use with "p" > "s" !
-#define MB_PTR_BACK(s, p) \
- (p -= utf_head_off((char *)(s), (char *)(p) - 1) + 1)
-
-// MB_CHAR2BYTES(): convert character to bytes and advance pointer to bytes
-#define MB_CHAR2BYTES(c, b) ((b) += utf_char2bytes((c), ((char *)b)))
-
#define RESET_BINDING(wp) \
do { \
(wp)->w_p_scb = false; \
diff --git a/src/nvim/main.c b/src/nvim/main.c
index bf0b8d33b2..dfa7c685a0 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -19,7 +19,6 @@
#include "auto/config.h" // IWYU pragma: keep
#include "nvim/api/extmark.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/ui.h"
#include "nvim/arglist.h"
diff --git a/src/nvim/main.h b/src/nvim/main.h
index 6aeb62712a..dedfadf270 100644
--- a/src/nvim/main.h
+++ b/src/nvim/main.h
@@ -3,6 +3,7 @@
#include <stdbool.h>
#include "nvim/event/loop.h"
+#include "nvim/types_defs.h"
// Maximum number of commands from + or -c arguments.
#define MAX_ARG_CMDS 10
diff --git a/src/nvim/map_glyph_cache.c b/src/nvim/map_glyph_cache.c
index 5efa87b960..091b4f7990 100644
--- a/src/nvim/map_glyph_cache.c
+++ b/src/nvim/map_glyph_cache.c
@@ -11,7 +11,6 @@
#include <stdlib.h>
#include <string.h>
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii_defs.h"
#include "nvim/macros_defs.h"
diff --git a/src/nvim/mapping.h b/src/nvim/mapping.h
index ffe7ab4290..3baa52ee77 100644
--- a/src/nvim/mapping.h
+++ b/src/nvim/mapping.h
@@ -13,6 +13,10 @@
#include "nvim/regexp_defs.h" // IWYU pragma: keep
#include "nvim/types_defs.h" // IWYU pragma: keep
+#ifdef INCLUDE_GENERATED_DECLARATIONS
+# include "mapping.h.generated.h"
+#endif
+
/// Used for the first argument of do_map()
enum {
MAPTYPE_MAP = 0,
@@ -20,6 +24,23 @@ enum {
MAPTYPE_NOREMAP = 2,
};
-#ifdef INCLUDE_GENERATED_DECLARATIONS
-# include "mapping.h.generated.h"
-#endif
+/// Adjust chars in a language according to 'langmap' option.
+/// NOTE that there is no noticeable overhead if 'langmap' is not set.
+/// When set the overhead for characters < 256 is small.
+/// Don't apply 'langmap' if the character comes from the Stuff buffer or from a
+/// mapping and the langnoremap option was set.
+/// The do-while is just to ignore a ';' after the macro.
+#define LANGMAP_ADJUST(c, condition) \
+ do { \
+ if (*p_langmap \
+ && (condition) \
+ && (p_lrm || (vgetc_busy ? typebuf_maplen() == 0 : KeyTyped)) \
+ && !KeyStuffed \
+ && (c) >= 0) \
+ { \
+ if ((c) < 256) \
+ c = langmap_mapchar[c]; \
+ else \
+ c = langmap_adjust_mb(c); \
+ } \
+ } while (0)
diff --git a/src/nvim/mark.h b/src/nvim/mark.h
index ec6862b38f..2c1bf7c73c 100644
--- a/src/nvim/mark.h
+++ b/src/nvim/mark.h
@@ -1,15 +1,21 @@
#pragma once
+#include <locale.h>
+
#include "nvim/ascii_defs.h"
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
#include "nvim/extmark_defs.h" // IWYU pragma: keep
#include "nvim/func_attr.h"
#include "nvim/macros_defs.h"
#include "nvim/mark_defs.h" // IWYU pragma: export
+#include "nvim/os/time.h"
+
+#ifdef INCLUDE_GENERATED_DECLARATIONS
+# include "mark.h.generated.h"
+#endif
static inline int mark_global_index(char name)
REAL_FATTR_CONST;
-
/// Convert mark name to the offset
static inline int mark_global_index(const char name)
{
@@ -22,7 +28,6 @@ static inline int mark_global_index(const char name)
static inline int mark_local_index(char name)
REAL_FATTR_CONST;
-
/// Convert local mark name to the offset
static inline int mark_local_index(const char name)
{
@@ -40,6 +45,37 @@ static inline int mark_local_index(const char name)
/// Global marks (marks with file number or name)
EXTERN xfmark_T namedfm[NGLOBALMARKS] INIT( = { 0 });
-#ifdef INCLUDE_GENERATED_DECLARATIONS
-# include "mark.h.generated.h"
-#endif
+#define SET_FMARK(fmarkp_, mark_, fnum_, view_) \
+ do { \
+ fmark_T *const fmarkp__ = fmarkp_; \
+ fmarkp__->mark = mark_; \
+ fmarkp__->fnum = fnum_; \
+ fmarkp__->timestamp = os_time(); \
+ fmarkp__->view = view_; \
+ fmarkp__->additional_data = NULL; \
+ } while (0)
+
+/// Free and set fmark using given value
+#define RESET_FMARK(fmarkp_, mark_, fnum_, view_) \
+ do { \
+ fmark_T *const fmarkp___ = fmarkp_; \
+ free_fmark(*fmarkp___); \
+ SET_FMARK(fmarkp___, mark_, fnum_, view_); \
+ } while (0)
+
+/// Set given extended mark (regular mark + file name)
+#define SET_XFMARK(xfmarkp_, mark_, fnum_, view_, fname_) \
+ do { \
+ xfmark_T *const xfmarkp__ = xfmarkp_; \
+ xfmarkp__->fname = fname_; \
+ SET_FMARK(&(xfmarkp__->fmark), mark_, fnum_, view_); \
+ } while (0)
+
+/// Free and set given extended mark (regular mark + file name)
+#define RESET_XFMARK(xfmarkp_, mark_, fnum_, view_, fname_) \
+ do { \
+ xfmark_T *const xfmarkp__ = xfmarkp_; \
+ free_xfmark(*xfmarkp__); \
+ xfmarkp__->fname = fname_; \
+ SET_FMARK(&(xfmarkp__->fmark), mark_, fnum_, view_); \
+ } while (0)
diff --git a/src/nvim/mark_defs.h b/src/nvim/mark_defs.h
index a98a741363..5028781827 100644
--- a/src/nvim/mark_defs.h
+++ b/src/nvim/mark_defs.h
@@ -86,41 +86,6 @@ typedef struct xfilemark {
#define INIT_XFMARK { INIT_FMARK, NULL }
/// Set fmark using given value
-#define SET_FMARK(fmarkp_, mark_, fnum_, view_) \
- do { \
- fmark_T *const fmarkp__ = fmarkp_; \
- fmarkp__->mark = mark_; \
- fmarkp__->fnum = fnum_; \
- fmarkp__->timestamp = os_time(); \
- fmarkp__->view = view_; \
- fmarkp__->additional_data = NULL; \
- } while (0)
-
-/// Free and set fmark using given value
-#define RESET_FMARK(fmarkp_, mark_, fnum_, view_) \
- do { \
- fmark_T *const fmarkp___ = fmarkp_; \
- free_fmark(*fmarkp___); \
- SET_FMARK(fmarkp___, mark_, fnum_, view_); \
- } while (0)
-
-/// Set given extended mark (regular mark + file name)
-#define SET_XFMARK(xfmarkp_, mark_, fnum_, view_, fname_) \
- do { \
- xfmark_T *const xfmarkp__ = xfmarkp_; \
- xfmarkp__->fname = fname_; \
- SET_FMARK(&(xfmarkp__->fmark), mark_, fnum_, view_); \
- } while (0)
-
-/// Free and set given extended mark (regular mark + file name)
-#define RESET_XFMARK(xfmarkp_, mark_, fnum_, view_, fname_) \
- do { \
- xfmark_T *const xfmarkp__ = xfmarkp_; \
- free_xfmark(*xfmarkp__); \
- xfmarkp__->fname = fname_; \
- SET_FMARK(&(xfmarkp__->fmark), mark_, fnum_, view_); \
- } while (0)
-
static inline bool lt(pos_T a, pos_T b)
REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE;
/// Return true if position a is before (less than) position b.
diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c
index 958970bba1..fb0d0502ee 100644
--- a/src/nvim/marktree.c
+++ b/src/nvim/marktree.c
@@ -47,7 +47,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
+#include <uv.h>
#include "klib/kvec.h"
#include "nvim/macros_defs.h"
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index a992bf3cd8..b788d7aa6f 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -32,7 +32,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
+#include <uv.h>
#include <wctype.h>
#include "auto/config.h"
diff --git a/src/nvim/mbyte.h b/src/nvim/mbyte.h
index bae60185e2..96f8b24983 100644
--- a/src/nvim/mbyte.h
+++ b/src/nvim/mbyte.h
@@ -4,6 +4,7 @@
#include <stdint.h>
#include <string.h>
#include <sys/types.h> // IWYU pragma: keep
+#include <uv.h> // IWYU pragma: keep
#include "nvim/cmdexpand_defs.h" // IWYU pragma: keep
#include "nvim/eval/typval_defs.h" // IWYU pragma: keep
@@ -11,6 +12,10 @@
#include "nvim/mbyte_defs.h" // IWYU pragma: export
#include "nvim/types_defs.h" // IWYU pragma: keep
+#ifdef INCLUDE_GENERATED_DECLARATIONS
+# include "mbyte.h.generated.h"
+#endif
+
// Return byte length of character that starts with byte "b".
// Returns 1 for a single-byte character.
// MB_BYTE2LEN_CHECK() can be used to count a special key as one byte.
@@ -22,13 +27,8 @@ extern const uint8_t utf8len_tab_zero[256];
extern const uint8_t utf8len_tab[256];
-#ifdef INCLUDE_GENERATED_DECLARATIONS
-# include "mbyte.h.generated.h"
-#endif
-
static inline int mb_strcmp_ic(bool ic, const char *s1, const char *s2)
REAL_FATTR_NONNULL_ALL REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT;
-
/// Compare strings
///
/// @param[in] ic True if case is to be ignored.
@@ -38,3 +38,24 @@ static inline int mb_strcmp_ic(bool ic, const char *s1, const char *s2)
{
return (ic ? mb_stricmp(s1, s2) : strcmp(s1, s2));
}
+
+// Use our own character-case definitions, because the current locale may
+// differ from what the .spl file uses.
+// These must not be called with negative number!
+// Multi-byte implementation. For Unicode we can call utf_*(), but don't do
+// that for ASCII, because we don't want to use 'casemap' here. Otherwise use
+// the "w" library function for characters above 255.
+#define SPELL_TOFOLD(c) ((c) >= 128 ? utf_fold(c) : (int)spelltab.st_fold[c])
+
+#define SPELL_TOUPPER(c) ((c) >= 128 ? mb_toupper(c) : (int)spelltab.st_upper[c])
+
+#define SPELL_ISUPPER(c) ((c) >= 128 ? mb_isupper(c) : spelltab.st_isu[c])
+
+// MB_PTR_ADV(): advance a pointer to the next character, taking care of
+// multi-byte characters if needed. Skip over composing chars.
+#define MB_PTR_ADV(p) (p += utfc_ptr2len((char *)p))
+
+// MB_PTR_BACK(): backup a pointer to the previous character, taking care of
+// multi-byte characters if needed. Only use with "p" > "s" !
+#define MB_PTR_BACK(s, p) \
+ (p -= utf_head_off((char *)(s), (char *)(p) - 1) + 1)
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 63f3541b3c..8f6b78d2d5 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -39,7 +39,6 @@
#include <stddef.h>
#include <stdio.h>
#include <string.h>
-#include <sys/types.h>
#include <time.h>
#include <uv.h>
diff --git a/src/nvim/memline.h b/src/nvim/memline.h
index 808d97783e..8e7f3a565c 100644
--- a/src/nvim/memline.h
+++ b/src/nvim/memline.h
@@ -1,5 +1,6 @@
#pragma once
+#include "nvim/ascii_defs.h"
#include "nvim/eval/typval_defs.h" // IWYU pragma: keep
#include "nvim/memline_defs.h" // IWYU pragma: export
#include "nvim/pos_defs.h" // IWYU pragma: keep
@@ -8,3 +9,6 @@
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "memline.h.generated.h"
#endif
+
+/// LINEEMPTY() - return true if the line is empty
+#define LINEEMPTY(p) (*ml_get(p) == NUL)
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 38952d2cf6..895fba1372 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -8,10 +8,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
+#include <uv.h>
#include "klib/kvec.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii_defs.h"
#include "nvim/buffer_defs.h"
@@ -20,7 +19,6 @@
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/event/defs.h"
#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
#include "nvim/ex_cmds_defs.h"
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c
index c9139f5f93..f1b7f8026e 100644
--- a/src/nvim/msgpack_rpc/channel.c
+++ b/src/nvim/msgpack_rpc/channel.c
@@ -15,6 +15,7 @@
#include "nvim/api/ui.h"
#include "nvim/channel.h"
#include "nvim/event/defs.h"
+#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
#include "nvim/event/process.h"
#include "nvim/event/rstream.h"
diff --git a/src/nvim/msgpack_rpc/helpers.h b/src/nvim/msgpack_rpc/helpers.h
index dd2096f305..6344d8c567 100644
--- a/src/nvim/msgpack_rpc/helpers.h
+++ b/src/nvim/msgpack_rpc/helpers.h
@@ -1,11 +1,8 @@
#pragma once
-#include <msgpack.h>
-#include <stdbool.h>
-#include <stdint.h>
+#include <msgpack.h> // IWYU pragma: keep
#include "nvim/api/private/defs.h"
-#include "nvim/event/wstream.h"
/// Value by which objects represented as EXT type are shifted
///
diff --git a/src/nvim/msgpack_rpc/server.c b/src/nvim/msgpack_rpc/server.c
index 0cc249b2b8..e60c1b88a5 100644
--- a/src/nvim/msgpack_rpc/server.c
+++ b/src/nvim/msgpack_rpc/server.c
@@ -6,7 +6,6 @@
#include "nvim/channel.h"
#include "nvim/eval.h"
-#include "nvim/event/defs.h"
#include "nvim/event/socket.h"
#include "nvim/garray.h"
#include "nvim/log.h"
diff --git a/src/nvim/msgpack_rpc/unpacker.h b/src/nvim/msgpack_rpc/unpacker.h
index 53af29761e..d43dc2e997 100644
--- a/src/nvim/msgpack_rpc/unpacker.h
+++ b/src/nvim/msgpack_rpc/unpacker.h
@@ -1,17 +1,14 @@
#pragma once
#include <inttypes.h>
-#include <stdbool.h>
#include <string.h>
#include "mpack/mpack_core.h"
#include "mpack/object.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/dispatch.h"
-#include "nvim/api/private/helpers.h"
#include "nvim/grid_defs.h"
#include "nvim/memory_defs.h"
-#include "nvim/msgpack_rpc/channel_defs.h"
+#include "nvim/msgpack_rpc/channel_defs.h" // IWYU pragma: keep
#include "nvim/types_defs.h"
#include "nvim/ui_client.h"
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index ece7ccc960..d0a6b2c074 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -9,7 +9,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
+#include <uv.h>
#include "nvim/api/private/defs.h"
#include "nvim/ascii_defs.h"
diff --git a/src/nvim/option.h b/src/nvim/option.h
index 2e4186fe7f..9dbb176c94 100644
--- a/src/nvim/option.h
+++ b/src/nvim/option.h
@@ -1,14 +1,17 @@
#pragma once
#include <assert.h>
+#include <stdbool.h>
#include <stdint.h>
#include <stdio.h> // IWYU pragma: keep
#include "nvim/api/private/defs.h" // IWYU pragma: keep
#include "nvim/api/private/helpers.h"
+#include "nvim/assert_defs.h"
#include "nvim/cmdexpand_defs.h" // IWYU pragma: keep
#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
+#include "nvim/macros_defs.h"
#include "nvim/math.h"
#include "nvim/option_defs.h" // IWYU pragma: export
#include "nvim/types_defs.h" // IWYU pragma: keep
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index 8765fdea4f..0aa11beb6d 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -9,7 +9,6 @@
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
#include "nvim/buffer_defs.h"
-#include "nvim/event/defs.h"
#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
#include "nvim/event/rstream.h"
diff --git a/src/nvim/os/input.h b/src/nvim/os/input.h
index 4b104b0b50..abef46072b 100644
--- a/src/nvim/os/input.h
+++ b/src/nvim/os/input.h
@@ -4,7 +4,7 @@
#include <stdint.h> // IWYU pragma: keep
#include "nvim/api/private/defs.h" // IWYU pragma: keep
-#include "nvim/event/multiqueue.h"
+#include "nvim/event/defs.h" // IWYU pragma: keep
#include "nvim/macros_defs.h"
EXTERN bool used_stdin INIT( = false);
diff --git a/src/nvim/os/pty_process_unix.c b/src/nvim/os/pty_process_unix.c
index 4478d9d7bd..1bdbb094bd 100644
--- a/src/nvim/os/pty_process_unix.c
+++ b/src/nvim/os/pty_process_unix.c
@@ -32,7 +32,6 @@
#include "auto/config.h"
#include "klib/klist.h"
#include "nvim/eval/typval.h"
-#include "nvim/event/defs.h"
#include "nvim/event/loop.h"
#include "nvim/event/process.h"
#include "nvim/log.h"
diff --git a/src/nvim/os/pty_process_unix.h b/src/nvim/os/pty_process_unix.h
index 92cc582832..c04e4c7a20 100644
--- a/src/nvim/os/pty_process_unix.h
+++ b/src/nvim/os/pty_process_unix.h
@@ -4,8 +4,8 @@
#include <stdint.h>
#include <sys/ioctl.h>
-#include "nvim/event/loop.h"
#include "nvim/event/process.h"
+#include "nvim/types_defs.h"
typedef struct pty_process {
Process process;
diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c
index 563a79358c..e898879729 100644
--- a/src/nvim/os/pty_process_win.c
+++ b/src/nvim/os/pty_process_win.c
@@ -4,6 +4,7 @@
#include "nvim/ascii_defs.h"
#include "nvim/eval/typval.h"
+#include "nvim/event/loop.h"
#include "nvim/log.h"
#include "nvim/mbyte.h"
#include "nvim/memory.h"
diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c
index 26c202741a..aa5075a79b 100644
--- a/src/nvim/os/shell.c
+++ b/src/nvim/os/shell.c
@@ -12,7 +12,6 @@
#include "nvim/charset.h"
#include "nvim/eval.h"
#include "nvim/eval/typval_defs.h"
-#include "nvim/event/defs.h"
#include "nvim/event/libuv_process.h"
#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c
index 0b0e59946c..0cbedc7330 100644
--- a/src/nvim/os/signal.c
+++ b/src/nvim/os/signal.c
@@ -9,7 +9,6 @@
#include "nvim/autocmd.h"
#include "nvim/buffer_defs.h"
#include "nvim/eval.h"
-#include "nvim/event/defs.h"
#include "nvim/event/signal.h"
#include "nvim/globals.h"
#include "nvim/log.h"
diff --git a/src/nvim/os/time.c b/src/nvim/os/time.c
index f842bb0ab8..b2a402f559 100644
--- a/src/nvim/os/time.c
+++ b/src/nvim/os/time.c
@@ -7,7 +7,8 @@
#include <uv.h>
#include "auto/config.h"
-#include "nvim/event/defs.h"
+#include "nvim/event/loop.h"
+#include "nvim/event/multiqueue.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/log.h"
diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c
index df82cb259e..bb4cad0b54 100644
--- a/src/nvim/popupmenu.c
+++ b/src/nvim/popupmenu.c
@@ -6,7 +6,6 @@
#include <stdbool.h>
#include <string.h>
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/vim.h"
#include "nvim/ascii_defs.h"
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index 20c06340be..87f28a4379 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -13,7 +13,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
-#include <sys/types.h>
+#include <uv.h>
#include "nvim/ascii_defs.h"
#include "nvim/buffer_defs.h"
@@ -6379,7 +6379,7 @@ static bool regmatch(uint8_t *scan, const proftime_T *tm, int *timed_out)
case RE_COMPOSING:
// Skip composing characters.
while (utf_iscomposing(utf_ptr2char((char *)rex.input))) {
- MB_CPTR_ADV(rex.input);
+ rex.input += utf_ptr2len((char *)rex.input);
}
break;
@@ -9840,7 +9840,7 @@ static int nfa_regatom(void)
emsg(_(e_nopresub));
return FAIL;
}
- for (lp = (uint8_t *)reg_prev_sub; *lp != NUL; MB_CPTR_ADV(lp)) {
+ for (lp = (uint8_t *)reg_prev_sub; *lp != NUL; lp += utf_ptr2len((char *)lp)) {
EMIT(utf_ptr2char((char *)lp));
if (lp != (uint8_t *)reg_prev_sub) {
EMIT(NFA_CONCAT);
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index 5c479bb1c6..09142e55e0 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -13,7 +13,6 @@
#include <uv.h>
#include "auto/config.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii_defs.h"
#include "nvim/buffer.h"
diff --git a/src/nvim/sign.c b/src/nvim/sign.c
index b52142f721..0647d65e93 100644
--- a/src/nvim/sign.c
+++ b/src/nvim/sign.c
@@ -9,7 +9,6 @@
#include "klib/kvec.h"
#include "nvim/api/extmark.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii_defs.h"
#include "nvim/buffer.h"
diff --git a/src/nvim/spell_defs.h b/src/nvim/spell_defs.h
index 6293bc314b..37048451a2 100644
--- a/src/nvim/spell_defs.h
+++ b/src/nvim/spell_defs.h
@@ -216,18 +216,6 @@ typedef struct {
uint8_t st_upper[256]; ///< chars: upper case
} spelltab_T;
-// Use our own character-case definitions, because the current locale may
-// differ from what the .spl file uses.
-// These must not be called with negative number!
-// Multi-byte implementation. For Unicode we can call utf_*(), but don't do
-// that for ASCII, because we don't want to use 'casemap' here. Otherwise use
-// the "w" library function for characters above 255.
-#define SPELL_TOFOLD(c) ((c) >= 128 ? utf_fold(c) : (int)spelltab.st_fold[c])
-
-#define SPELL_TOUPPER(c) ((c) >= 128 ? mb_toupper(c) : (int)spelltab.st_upper[c])
-
-#define SPELL_ISUPPER(c) ((c) >= 128 ? mb_isupper(c) : spelltab.st_isu[c])
-
/// Values for "what" argument of spell_add_word()
typedef enum {
SPELL_ADD_GOOD = 0,
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index 979495e810..0cffd5741e 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -1536,7 +1536,7 @@ static int set_sofo(slang_T *lp, const char *from, const char *to)
// sl_sal_first[] for this.
for (p = from, s = to; *p != NUL && *s != NUL;) {
const int c = mb_cptr2char_adv(&p);
- MB_CPTR_ADV(s);
+ s += utf_ptr2len(s);
if (c >= 256) {
lp->sl_sal_first[c & 0xff]++;
}
diff --git a/src/nvim/state.c b/src/nvim/state.c
index 518ceb8c88..d04c131226 100644
--- a/src/nvim/state.c
+++ b/src/nvim/state.c
@@ -7,7 +7,7 @@
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/event/defs.h"
+#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
#include "nvim/ex_getln.h"
#include "nvim/getchar.h"
diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c
index 01729bc4de..112a433d9d 100644
--- a/src/nvim/statusline.c
+++ b/src/nvim/statusline.c
@@ -6,7 +6,6 @@
#include <stdlib.h>
#include <string.h>
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii_defs.h"
#include "nvim/buffer.h"
@@ -1178,7 +1177,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
out_p = out_p - n + 1;
// Fill up space left over by half a double-wide char.
while (++group_len < stl_items[stl_groupitems[groupdepth]].minwid) {
- MB_CHAR2BYTES(fillchar, out_p);
+ out_p += utf_char2bytes(fillchar, out_p);
}
// }
@@ -1201,7 +1200,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
if (min_group_width < 0) {
min_group_width = 0 - min_group_width;
while (group_len++ < min_group_width && out_p < out_end_p) {
- MB_CHAR2BYTES(fillchar, out_p);
+ out_p += utf_char2bytes(fillchar, out_p);
}
// If the group is right-aligned, shift everything to the right and
// prepend with filler characters.
@@ -1222,7 +1221,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
// Prepend the fill characters
for (; group_len > 0; group_len--) {
- MB_CHAR2BYTES(fillchar, t);
+ t += utf_char2bytes(fillchar, t);
}
}
}
@@ -1803,7 +1802,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
if (l + 1 == minwid && fillchar == '-' && ascii_isdigit(*t)) {
*out_p++ = ' ';
} else {
- MB_CHAR2BYTES(fillchar, out_p);
+ out_p += utf_char2bytes(fillchar, out_p);
}
}
minwid = 0;
@@ -1826,7 +1825,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
// digit follows.
if (fillable && *t == ' '
&& (!ascii_isdigit(*(t + 1)) || fillchar != '-')) {
- MB_CHAR2BYTES(fillchar, out_p);
+ out_p += utf_char2bytes(fillchar, out_p);
} else {
*out_p++ = *t;
}
@@ -1843,7 +1842,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
// For left-aligned items, fill any remaining space with the fillchar
for (; l < minwid && out_p < out_end_p; l++) {
- MB_CHAR2BYTES(fillchar, out_p);
+ out_p += utf_char2bytes(fillchar, out_p);
}
// Otherwise if the item is a number, copy that to the output buffer.
@@ -2064,7 +2063,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
// Fill up for half a double-wide character.
while (++width < maxwidth) {
- MB_CHAR2BYTES(fillchar, trunc_p);
+ trunc_p += utf_char2bytes(fillchar, trunc_p);
*trunc_p = NUL;
}
}
@@ -2099,7 +2098,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
char *seploc = start + dislocation;
STRMOVE(seploc, start);
for (char *s = start; s < seploc;) {
- MB_CHAR2BYTES(fillchar, s);
+ s += utf_char2bytes(fillchar, s);
}
for (int item_idx = stl_separator_locations[l] + 1;
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index 1586dd3d8e..80e5d5b126 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -44,7 +44,6 @@
#include <vterm_keycodes.h>
#include "klib/kvec.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
@@ -56,7 +55,7 @@
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/event/defs.h"
+#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
#include "nvim/event/time.h"
#include "nvim/ex_docmd.h"
diff --git a/src/nvim/textformat.c b/src/nvim/textformat.c
index 1b9732c5b2..7803322439 100644
--- a/src/nvim/textformat.c
+++ b/src/nvim/textformat.c
@@ -18,7 +18,6 @@
#include "nvim/globals.h"
#include "nvim/indent.h"
#include "nvim/indent_c.h"
-#include "nvim/macros_defs.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c
index 9c601769c0..0cfbb50684 100644
--- a/src/nvim/textobject.c
+++ b/src/nvim/textobject.c
@@ -14,7 +14,6 @@
#include "nvim/fold.h"
#include "nvim/globals.h"
#include "nvim/indent.h"
-#include "nvim/macros_defs.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c
index 9ba21a6afd..c7880b591d 100644
--- a/src/nvim/tui/input.c
+++ b/src/nvim/tui/input.c
@@ -4,9 +4,8 @@
#include <string.h>
#include "klib/kvec.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
-#include "nvim/event/defs.h"
+#include "nvim/event/loop.h"
#include "nvim/event/stream.h"
#include "nvim/macros_defs.h"
#include "nvim/main.h"
diff --git a/src/nvim/tui/input.h b/src/nvim/tui/input.h
index bc490754be..2da7f95338 100644
--- a/src/nvim/tui/input.h
+++ b/src/nvim/tui/input.h
@@ -4,7 +4,6 @@
#include <stdint.h>
#include <uv.h>
-#include "nvim/event/loop.h"
#include "nvim/event/stream.h"
#include "nvim/rbuffer_defs.h"
#include "nvim/tui/input_defs.h" // IWYU pragma: export
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 6c0b00f010..934b498df9 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -15,7 +15,6 @@
#include "nvim/api/private/helpers.h"
#include "nvim/ascii_defs.h"
#include "nvim/cursor_shape.h"
-#include "nvim/event/defs.h"
#include "nvim/event/loop.h"
#include "nvim/event/signal.h"
#include "nvim/event/stream.h"
diff --git a/src/nvim/types_defs.h b/src/nvim/types_defs.h
index cc9deb9630..b2c7101f60 100644
--- a/src/nvim/types_defs.h
+++ b/src/nvim/types_defs.h
@@ -57,7 +57,8 @@ typedef struct {
#define SIGNRANGE_INIT { 0, 0 }
typedef struct file_buffer buf_T;
+typedef struct loop Loop;
+typedef struct regprog regprog_T;
typedef struct syn_state synstate_T;
typedef struct terminal Terminal;
typedef struct window_S win_T;
-typedef struct regprog regprog_T;
diff --git a/src/nvim/ui.h b/src/nvim/ui.h
index f61398a7a0..8b00e4e917 100644
--- a/src/nvim/ui.h
+++ b/src/nvim/ui.h
@@ -3,7 +3,7 @@
#include <stdint.h> // IWYU pragma: keep
#include "nvim/api/private/defs.h" // IWYU pragma: keep
-#include "nvim/event/multiqueue.h"
+#include "nvim/event/defs.h"
#include "nvim/grid_defs.h" // IWYU pragma: keep
#include "nvim/highlight_defs.h" // IWYU pragma: keep
#include "nvim/macros_defs.h"
diff --git a/src/nvim/ui_client.c b/src/nvim/ui_client.c
index fdd859ba29..c7c0457fcd 100644
--- a/src/nvim/ui_client.c
+++ b/src/nvim/ui_client.c
@@ -10,7 +10,7 @@
#include "nvim/channel.h"
#include "nvim/eval.h"
#include "nvim/eval/typval_defs.h"
-#include "nvim/event/defs.h"
+#include "nvim/event/multiqueue.h"
#include "nvim/globals.h"
#include "nvim/highlight.h"
#include "nvim/log.h"
diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c
index d8969b0061..4cd11f3ccf 100644
--- a/src/nvim/ui_compositor.c
+++ b/src/nvim/ui_compositor.c
@@ -9,7 +9,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
+#include <uv.h>
#include "klib/kvec.h"
#include "nvim/api/private/defs.h"
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index 7c44f0de62..2d631f237f 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -77,7 +77,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
#include <time.h>
#include <uv.h>
@@ -106,6 +105,7 @@
#include "nvim/highlight.h"
#include "nvim/macros_defs.h"
#include "nvim/mark.h"
+#include "nvim/mbyte.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c
index 9872468ba9..86c0dc8367 100644
--- a/src/nvim/usercmd.c
+++ b/src/nvim/usercmd.c
@@ -8,7 +8,6 @@
#include <string.h>
#include "auto/config.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii_defs.h"
#include "nvim/buffer_defs.h"
diff --git a/src/nvim/usercmd.h b/src/nvim/usercmd.h
index 4d6d154b79..4ad9767e1f 100644
--- a/src/nvim/usercmd.h
+++ b/src/nvim/usercmd.h
@@ -10,7 +10,7 @@
#include "nvim/garray_defs.h"
#include "nvim/types_defs.h" // IWYU pragma: keep
-typedef struct ucmd {
+typedef struct {
char *uc_name; ///< The command name
uint32_t uc_argt; ///< The argument type
char *uc_rep; ///< The command's replacement string
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 2caf2c0cb8..814c8f5169 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -13,7 +13,6 @@
#include "auto/versiondef.h" // version info generated by the build system
#include "auto/versiondef_git.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii_defs.h"
#include "nvim/buffer.h"
diff --git a/src/nvim/viml/parser/parser.h b/src/nvim/viml/parser/parser.h
index cd5a493643..b29a77b5ef 100644
--- a/src/nvim/viml/parser/parser.h
+++ b/src/nvim/viml/parser/parser.h
@@ -7,7 +7,6 @@
#include "klib/kvec.h"
#include "nvim/func_attr.h"
#include "nvim/mbyte.h"
-#include "nvim/mbyte_defs.h"
#include "nvim/memory.h"
/// One parsed line
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 929a06350b..b140337fec 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -8,7 +8,6 @@
#include <string.h>
#include "klib/kvec.h"
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/arglist.h"
#include "nvim/ascii_defs.h"