aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2023-12-20 14:32:22 +0100
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2023-12-20 19:52:02 +0100
commit0c120307ca1ab613e63865c634d7e10ad67fb0ba (patch)
treea9645d52815c7729bb43eccd11132b1cd8471307
parentcc6a257c8cad8051b6f7e9287249293ab0a929d9 (diff)
downloadrneovim-0c120307ca1ab613e63865c634d7e10ad67fb0ba.tar.gz
rneovim-0c120307ca1ab613e63865c634d7e10ad67fb0ba.tar.bz2
rneovim-0c120307ca1ab613e63865c634d7e10ad67fb0ba.zip
refactor: eliminate cyclic includes
-rw-r--r--.clang-tidy1
-rw-r--r--src/nvim/api/autocmd.c1
-rw-r--r--src/nvim/api/deprecated.c1
-rw-r--r--src/nvim/api/options.c1
-rw-r--r--src/nvim/api/vimscript.c1
-rw-r--r--src/nvim/api/win_config.c1
-rw-r--r--src/nvim/autocmd.h1
-rw-r--r--src/nvim/base64.c1
-rw-r--r--src/nvim/buffer_defs.h31
-rw-r--r--src/nvim/change.c1
-rw-r--r--src/nvim/channel.c1
-rw-r--r--src/nvim/charset.c1
-rw-r--r--src/nvim/cursor.c1
-rw-r--r--src/nvim/debugger.c2
-rw-r--r--src/nvim/decoration.c1
-rw-r--r--src/nvim/decoration.h2
-rw-r--r--src/nvim/eval/userfunc.c1
-rw-r--r--src/nvim/ex_cmds2.c1
-rw-r--r--src/nvim/ex_cmds_defs.h1
-rw-r--r--src/nvim/ex_session.c1
-rw-r--r--src/nvim/extmark.c1
-rw-r--r--src/nvim/file_search.c1
-rw-r--r--src/nvim/help.c1
-rw-r--r--src/nvim/highlight_group.c1
-rw-r--r--src/nvim/indent_c.c1
-rw-r--r--src/nvim/lua/executor.c1
-rw-r--r--src/nvim/mark.c2
-rw-r--r--src/nvim/mark.h1
-rw-r--r--src/nvim/memfile.c1
-rw-r--r--src/nvim/memory.c1
-rw-r--r--src/nvim/memory.h1
-rw-r--r--src/nvim/menu.c1
-rw-r--r--src/nvim/normal.c1
-rw-r--r--src/nvim/os/env.c1
-rw-r--r--src/nvim/os/input.c1
-rw-r--r--src/nvim/os/shell.c1
-rw-r--r--src/nvim/os/signal.c1
-rw-r--r--src/nvim/path.c1
-rw-r--r--src/nvim/plines.c1
-rw-r--r--src/nvim/plines.h2
-rw-r--r--src/nvim/popupmenu.c1
-rw-r--r--src/nvim/quickfix.c1
-rw-r--r--src/nvim/quickfix.h1
-rw-r--r--src/nvim/regexp_defs.h60
-rw-r--r--src/nvim/runtime.c1
-rw-r--r--src/nvim/shada.c1
-rw-r--r--src/nvim/spellfile.c1
-rw-r--r--src/nvim/state.c1
-rw-r--r--src/nvim/statusline.c1
-rw-r--r--src/nvim/syntax_defs.h8
-rw-r--r--src/nvim/tag.c1
-rw-r--r--src/nvim/terminal.c1
-rw-r--r--src/nvim/terminal.h5
-rw-r--r--src/nvim/textobject.c1
-rw-r--r--src/nvim/types_defs.h6
-rw-r--r--src/nvim/ui_compositor.c1
-rw-r--r--src/nvim/undo_defs.h2
-rw-r--r--src/nvim/usercmd.h1
-rw-r--r--src/nvim/version.h1
-rw-r--r--src/nvim/vim_defs.h7
-rw-r--r--src/nvim/winfloat.c1
61 files changed, 107 insertions, 70 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 927909cf8d..6776d86d21 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -46,7 +46,6 @@ Checks: >
-cppcoreguidelines-init-variables,
-llvm-header-guard, We use #pragma once,
-llvmlibc-restrict-system-libc-headers, We want to use glibc,
- -misc-header-include-cycle, Looks useful but redundant with IWYU. We may replace IWYU with this one day,
-misc-include-cleaner, Looks useful but redundant with IWYU. We may replace IWYU with this one day,
-misc-misplaced-const,
-misc-no-recursion,
diff --git a/src/nvim/api/autocmd.c b/src/nvim/api/autocmd.c
index 2ce08bdf40..88d7d985e8 100644
--- a/src/nvim/api/autocmd.c
+++ b/src/nvim/api/autocmd.c
@@ -20,6 +20,7 @@
#include "nvim/globals.h"
#include "nvim/lua/executor.h"
#include "nvim/memory.h"
+#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/api/deprecated.c b/src/nvim/api/deprecated.c
index 27af581ef4..f7bbd61cd3 100644
--- a/src/nvim/api/deprecated.c
+++ b/src/nvim/api/deprecated.c
@@ -21,6 +21,7 @@
#include "nvim/memory.h"
#include "nvim/option.h"
#include "nvim/pos_defs.h"
+#include "nvim/types_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "api/deprecated.c.generated.h"
diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c
index ea617dffaf..fb461152b4 100644
--- a/src/nvim/api/options.c
+++ b/src/nvim/api/options.c
@@ -15,6 +15,7 @@
#include "nvim/macros_defs.h"
#include "nvim/memory.h"
#include "nvim/option.h"
+#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
#include "nvim/window.h"
diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c
index 3bca988030..6f3f0127d1 100644
--- a/src/nvim/api/vimscript.c
+++ b/src/nvim/api/vimscript.c
@@ -11,6 +11,7 @@
#include "nvim/api/private/helpers.h"
#include "nvim/api/vimscript.h"
#include "nvim/ascii_defs.h"
+#include "nvim/buffer_defs.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
#include "nvim/eval/userfunc.h"
diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c
index 4ffe3478d7..be18dba315 100644
--- a/src/nvim/api/win_config.c
+++ b/src/nvim/api/win_config.c
@@ -23,6 +23,7 @@
#include "nvim/pos_defs.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
+#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/window.h"
#include "nvim/winfloat.h"
diff --git a/src/nvim/autocmd.h b/src/nvim/autocmd.h
index b0a5a13026..4aefe8e71b 100644
--- a/src/nvim/autocmd.h
+++ b/src/nvim/autocmd.h
@@ -13,6 +13,7 @@
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
#include "nvim/macros_defs.h"
#include "nvim/pos_defs.h"
+#include "nvim/types_defs.h"
// Set by the apply_autocmds_group function if the given event is equal to
// EVENT_FILETYPE. Used by the readfile function in order to determine if
diff --git a/src/nvim/base64.c b/src/nvim/base64.c
index 7f7d121442..a0ba219fa2 100644
--- a/src/nvim/base64.c
+++ b/src/nvim/base64.c
@@ -3,7 +3,6 @@
#include <stdint.h>
#include <string.h>
-#include "auto/config.h"
#include "nvim/base64.h"
#include "nvim/memory.h"
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index dc93243fad..49d2126801 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -4,16 +4,6 @@
#include <stdint.h>
#include <stdio.h>
-typedef struct file_buffer buf_T;
-
-/// Reference to a buffer that stores the value of buf_free_count.
-/// bufref_valid() only needs to check "buf" when the count differs.
-typedef struct {
- buf_T *br_buf;
- int br_fnum;
- int br_buf_free_count;
-} bufref_T;
-
#include "klib/kvec.h"
#include "nvim/api/private/defs.h"
#include "nvim/arglist_defs.h"
@@ -27,11 +17,24 @@ typedef struct {
#include "nvim/mapping_defs.h"
#include "nvim/mark_defs.h"
#include "nvim/marktree_defs.h"
+#include "nvim/memline_defs.h"
#include "nvim/option_vars.h"
+#include "nvim/os/fs_defs.h"
#include "nvim/pos_defs.h"
+#include "nvim/regexp_defs.h"
+#include "nvim/sign_defs.h"
#include "nvim/statusline_defs.h"
+#include "nvim/terminal.h"
#include "nvim/undo_defs.h"
+/// Reference to a buffer that stores the value of buf_free_count.
+/// bufref_valid() only needs to check "buf" when the count differs.
+typedef struct {
+ buf_T *br_buf;
+ int br_fnum;
+ int br_buf_free_count;
+} bufref_T;
+
#define GETFILE_SUCCESS(x) ((x) <= 0)
#define MODIFIABLE(buf) (buf->b_p_ma)
@@ -80,18 +83,10 @@ typedef struct {
// Mask to check for flags that prevent normal writing
#define BF_WRITE_MASK (BF_NOTEDITED + BF_NEW + BF_READERR)
-typedef struct window_S win_T;
typedef struct wininfo_S wininfo_T;
typedef struct frame_S frame_T;
typedef uint64_t disptick_T; // display tick type
-#include "nvim/memline_defs.h"
-#include "nvim/os/fs_defs.h"
-#include "nvim/regexp_defs.h"
-#include "nvim/sign_defs.h"
-#include "nvim/syntax_defs.h"
-#include "nvim/terminal.h"
-
// The taggy struct is used to store the information about a :tag command.
typedef struct taggy {
char *tagname; // tag name
diff --git a/src/nvim/change.c b/src/nvim/change.c
index 99698f2e5d..0154ead8fb 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -44,6 +44,7 @@
#include "nvim/state.h"
#include "nvim/strings.h"
#include "nvim/textformat.h"
+#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/vim_defs.h"
diff --git a/src/nvim/channel.c b/src/nvim/channel.c
index 42935933e0..8c4fa8f5ad 100644
--- a/src/nvim/channel.c
+++ b/src/nvim/channel.c
@@ -34,6 +34,7 @@
#include "nvim/os/shell.h"
#include "nvim/path.h"
#include "nvim/rbuffer.h"
+#include "nvim/terminal.h"
#include "nvim/types_defs.h"
#ifdef MSWIN
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index 48a9808b31..60a0c77cfa 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -27,6 +27,7 @@
#include "nvim/path.h"
#include "nvim/pos_defs.h"
#include "nvim/strings.h"
+#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c
index 1110fe1e64..bcb2810095 100644
--- a/src/nvim/cursor.c
+++ b/src/nvim/cursor.c
@@ -22,6 +22,7 @@
#include "nvim/plines.h"
#include "nvim/pos_defs.h"
#include "nvim/state.h"
+#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c
index 000fe13502..35333e4b12 100644
--- a/src/nvim/debugger.c
+++ b/src/nvim/debugger.c
@@ -8,6 +8,7 @@
#include <string.h>
#include "nvim/ascii_defs.h"
+#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cmdexpand_defs.h"
#include "nvim/debugger.h"
@@ -32,6 +33,7 @@
#include "nvim/regexp.h"
#include "nvim/runtime.h"
#include "nvim/state_defs.h"
+#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
/// batch mode debugging: don't save and restore typeahead.
diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c
index b3fad78f84..a18f30ed41 100644
--- a/src/nvim/decoration.c
+++ b/src/nvim/decoration.c
@@ -6,6 +6,7 @@
#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"
#include "nvim/drawscreen.h"
#include "nvim/extmark.h"
diff --git a/src/nvim/decoration.h b/src/nvim/decoration.h
index 92e0cbc76b..1c072eab20 100644
--- a/src/nvim/decoration.h
+++ b/src/nvim/decoration.h
@@ -5,7 +5,7 @@
#include <stdint.h>
#include "klib/kvec.h"
-#include "nvim/buffer_defs.h"
+#include "nvim/buffer_defs.h" // IWYU pragma: keep
#include "nvim/decoration_defs.h" // IWYU pragma: export
#include "nvim/macros_defs.h"
#include "nvim/marktree_defs.h"
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 5e943711d1..d0b3fe7993 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -10,6 +10,7 @@
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
+#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cmdexpand_defs.h"
#include "nvim/debugger.h"
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 1722b7902b..975335ba20 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -39,6 +39,7 @@
#include "nvim/pos_defs.h"
#include "nvim/quickfix.h"
#include "nvim/runtime.h"
+#include "nvim/types_defs.h"
#include "nvim/undo.h"
#include "nvim/vim_defs.h"
#include "nvim/window.h"
diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h
index cf6282ad06..4abc286a96 100644
--- a/src/nvim/ex_cmds_defs.h
+++ b/src/nvim/ex_cmds_defs.h
@@ -6,6 +6,7 @@
#include "nvim/eval/typval_defs.h"
#include "nvim/ex_eval_defs.h"
#include "nvim/normal_defs.h"
+#include "nvim/os/time_defs.h"
#include "nvim/pos_defs.h"
#include "nvim/regexp_defs.h"
diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c
index 6ae401a58c..47f92920eb 100644
--- a/src/nvim/ex_session.c
+++ b/src/nvim/ex_session.c
@@ -34,6 +34,7 @@
#include "nvim/path.h"
#include "nvim/pos_defs.h"
#include "nvim/runtime.h"
+#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
#include "nvim/window.h"
diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c
index f305b6d506..69b10dd674 100644
--- a/src/nvim/extmark.c
+++ b/src/nvim/extmark.c
@@ -39,6 +39,7 @@
#include "nvim/marktree.h"
#include "nvim/memline.h"
#include "nvim/pos_defs.h"
+#include "nvim/types_defs.h"
#include "nvim/undo.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c
index acbcaa16c2..76f7b7e1af 100644
--- a/src/nvim/file_search.c
+++ b/src/nvim/file_search.c
@@ -51,6 +51,7 @@
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
+#include "nvim/buffer_defs.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
#include "nvim/file_search.h"
diff --git a/src/nvim/help.c b/src/nvim/help.c
index b1b53bc0c3..92807039b3 100644
--- a/src/nvim/help.c
+++ b/src/nvim/help.c
@@ -36,7 +36,6 @@
#include "nvim/pos_defs.h"
#include "nvim/runtime.h"
#include "nvim/strings.h"
-#include "nvim/syntax.h"
#include "nvim/tag.h"
#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c
index 683ad0c8a3..1364d9373c 100644
--- a/src/nvim/highlight_group.c
+++ b/src/nvim/highlight_group.c
@@ -15,6 +15,7 @@
#include "nvim/api/private/validate.h"
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
+#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cmdexpand_defs.h"
#include "nvim/cursor_shape.h"
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index 6c133c1e99..377bd3bfec 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -23,6 +23,7 @@
#include "nvim/search.h"
#include "nvim/state_defs.h"
#include "nvim/strings.h"
+#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
// Find result cache for cpp_baseclass
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index 77c3f22da8..43a6a12fda 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -16,6 +16,7 @@
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii_defs.h"
+#include "nvim/buffer_defs.h"
#include "nvim/change.h"
#include "nvim/cmdexpand_defs.h"
#include "nvim/cursor.h"
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index 54b1df99a2..69042a6034 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -16,6 +16,7 @@
#include "nvim/eval/typval.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/extmark.h"
+#include "nvim/extmark_defs.h"
#include "nvim/fold.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
@@ -37,6 +38,7 @@
#include "nvim/quickfix.h"
#include "nvim/strings.h"
#include "nvim/textobject.h"
+#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
// This file contains routines to maintain and manipulate marks.
diff --git a/src/nvim/mark.h b/src/nvim/mark.h
index b1a093bee0..ec6862b38f 100644
--- a/src/nvim/mark.h
+++ b/src/nvim/mark.h
@@ -2,6 +2,7 @@
#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
diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c
index d989600d45..fc877d08a3 100644
--- a/src/nvim/memfile.c
+++ b/src/nvim/memfile.c
@@ -60,6 +60,7 @@
#include "nvim/os/os.h"
#include "nvim/path.h"
#include "nvim/pos_defs.h"
+#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
#define MEMFILE_PAGE_SIZE 4096 /// default page size
diff --git a/src/nvim/memory.c b/src/nvim/memory.c
index feb13384be..3e43771cdf 100644
--- a/src/nvim/memory.c
+++ b/src/nvim/memory.c
@@ -36,6 +36,7 @@
#include "nvim/sign.h"
#include "nvim/state_defs.h"
#include "nvim/statusline.h"
+#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/ui_client.h"
#include "nvim/ui_compositor.h"
diff --git a/src/nvim/memory.h b/src/nvim/memory.h
index ffdc4c7366..d425249ab6 100644
--- a/src/nvim/memory.h
+++ b/src/nvim/memory.h
@@ -2,6 +2,7 @@
#include <stdbool.h>
#include <stdint.h> // IWYU pragma: keep
+#include <string.h>
#include <time.h> // IWYU pragma: keep
#include "auto/config.h"
diff --git a/src/nvim/menu.c b/src/nvim/menu.c
index 68a8c9f873..383c9e7817 100644
--- a/src/nvim/menu.c
+++ b/src/nvim/menu.c
@@ -8,6 +8,7 @@
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
+#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cmdexpand_defs.h"
#include "nvim/cursor.h"
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index d9988cb94b..dbcec0721f 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -70,6 +70,7 @@
#include "nvim/tag.h"
#include "nvim/textformat.h"
#include "nvim/textobject.h"
+#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/vim_defs.h"
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c
index 6c14f3d593..5d3fa9f0e6 100644
--- a/src/nvim/os/env.c
+++ b/src/nvim/os/env.c
@@ -26,6 +26,7 @@
#include "nvim/os/os.h"
#include "nvim/path.h"
#include "nvim/strings.h"
+#include "nvim/types_defs.h"
#include "nvim/version.h"
#include "nvim/vim_defs.h"
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index ed4267dcbb..8765fdea4f 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -8,6 +8,7 @@
#include "nvim/api/private/defs.h"
#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"
diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c
index 26e3171c5b..26c202741a 100644
--- a/src/nvim/os/shell.c
+++ b/src/nvim/os/shell.c
@@ -8,6 +8,7 @@
#include "auto/config.h"
#include "klib/kvec.h"
#include "nvim/ascii_defs.h"
+#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/eval.h"
#include "nvim/eval/typval_defs.h"
diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c
index 4960fa6a19..0b0e59946c 100644
--- a/src/nvim/os/signal.c
+++ b/src/nvim/os/signal.c
@@ -7,6 +7,7 @@
#endif
#include "nvim/autocmd.h"
+#include "nvim/buffer_defs.h"
#include "nvim/eval.h"
#include "nvim/event/defs.h"
#include "nvim/event/signal.h"
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 1d34f5400e..be3a2dacb2 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -8,6 +8,7 @@
#include "auto/config.h"
#include "nvim/ascii_defs.h"
+#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cmdexpand.h"
#include "nvim/eval.h"
diff --git a/src/nvim/plines.c b/src/nvim/plines.c
index cbfaa4ace3..461f69ae6c 100644
--- a/src/nvim/plines.c
+++ b/src/nvim/plines.c
@@ -6,6 +6,7 @@
#include <string.h>
#include "nvim/ascii_defs.h"
+#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/decoration.h"
#include "nvim/diff.h"
diff --git a/src/nvim/plines.h b/src/nvim/plines.h
index 7227db4524..38024e622e 100644
--- a/src/nvim/plines.h
+++ b/src/nvim/plines.h
@@ -3,9 +3,9 @@
#include <stdbool.h>
#include <stdint.h> // IWYU pragma: keep
-#include "nvim/buffer_defs.h"
#include "nvim/marktree_defs.h"
#include "nvim/pos_defs.h" // IWYU pragma: keep
+#include "nvim/types_defs.h"
/// Argument for lbr_chartabsize().
typedef struct {
diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c
index c1f13c1115..386c13f630 100644
--- a/src/nvim/popupmenu.c
+++ b/src/nvim/popupmenu.c
@@ -38,6 +38,7 @@
#include "nvim/pos_defs.h"
#include "nvim/state_defs.h"
#include "nvim/strings.h"
+#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/ui_compositor.h"
#include "nvim/vim_defs.h"
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index e25f6b9b5e..59207dba17 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -14,6 +14,7 @@
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
#include "nvim/buffer.h"
+#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/drawscreen.h"
diff --git a/src/nvim/quickfix.h b/src/nvim/quickfix.h
index 9c49564d57..941aa2f991 100644
--- a/src/nvim/quickfix.h
+++ b/src/nvim/quickfix.h
@@ -1,5 +1,6 @@
#pragma once
+#include "nvim/buffer_defs.h" // IWYU pragma: keep
#include "nvim/eval/typval_defs.h" // IWYU pragma: keep
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
#include "nvim/option_defs.h" // IWYU pragma: keep
diff --git a/src/nvim/regexp_defs.h b/src/nvim/regexp_defs.h
index 31bc0e86e8..91d897ee7b 100644
--- a/src/nvim/regexp_defs.h
+++ b/src/nvim/regexp_defs.h
@@ -15,6 +15,32 @@
#include "nvim/pos_defs.h"
#include "nvim/types_defs.h"
+enum {
+ /// The number of sub-matches is limited to 10.
+ /// The first one (index 0) is the whole match, referenced with "\0".
+ /// The second one (index 1) is the first sub-match, referenced with "\1".
+ /// This goes up to the tenth (index 9), referenced with "\9".
+ NSUBEXP = 10,
+};
+
+typedef struct regengine regengine_T;
+
+/// Structure to be used for multi-line matching.
+/// Sub-match "no" starts in line "startpos[no].lnum" column "startpos[no].col"
+/// and ends in line "endpos[no].lnum" just before column "endpos[no].col".
+/// The line numbers are relative to the first line, thus startpos[0].lnum is
+/// always 0.
+/// When there is no match, the line number is -1.
+typedef struct {
+ regprog_T *regprog;
+ lpos_T startpos[NSUBEXP];
+ lpos_T endpos[NSUBEXP];
+
+ colnr_T rmm_matchcol; ///< match start without "\zs"
+ int rmm_ic;
+ colnr_T rmm_maxcol; ///< when not zero: maximum column
+} regmmatch_T;
+
/// Used for "magic_overruled".
typedef enum {
OPTION_MAGIC_NOT_SET, ///< p_magic not overruled
@@ -34,14 +60,6 @@ typedef enum {
} magic_T;
enum {
- /// The number of sub-matches is limited to 10.
- /// The first one (index 0) is the whole match, referenced with "\0".
- /// The second one (index 1) is the first sub-match, referenced with "\1".
- /// This goes up to the tenth (index 9), referenced with "\9".
- NSUBEXP = 10,
-};
-
-enum {
/// In the NFA engine: how many braces are allowed.
/// TODO(RE): Use dynamic memory allocation instead of static, like here
NFA_MAX_BRACES = 20,
@@ -61,28 +79,6 @@ enum {
NFA_ENGINE = 2,
};
-typedef struct regengine regengine_T;
-typedef struct regprog regprog_T;
-typedef struct reg_extmatch reg_extmatch_T;
-
-/// Structure to be used for multi-line matching.
-/// Sub-match "no" starts in line "startpos[no].lnum" column "startpos[no].col"
-/// and ends in line "endpos[no].lnum" just before column "endpos[no].col".
-/// The line numbers are relative to the first line, thus startpos[0].lnum is
-/// always 0.
-/// When there is no match, the line number is -1.
-typedef struct {
- regprog_T *regprog;
- lpos_T startpos[NSUBEXP];
- lpos_T endpos[NSUBEXP];
-
- colnr_T rmm_matchcol; ///< match start without "\zs"
- int rmm_ic;
- colnr_T rmm_maxcol; ///< when not zero: maximum column
-} regmmatch_T;
-
-#include "nvim/buffer_defs.h"
-
/// Structure returned by vim_regcomp() to pass on to vim_regexec().
/// This is the general structure. For the actual matcher, two specific
/// structures are used. See code below.
@@ -164,10 +160,10 @@ typedef struct {
/// Structure used to store external references: "\z\(\)" to "\z\1".
/// Use a reference count to avoid the need to copy this around. When it goes
/// from 1 to zero the matches need to be freed.
-struct reg_extmatch {
+typedef struct {
int16_t refcnt;
uint8_t *matches[NSUBEXP];
-};
+} reg_extmatch_T;
struct regengine {
/// bt_regcomp or nfa_regcomp
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c
index 7dfbdd888a..29b70e05ca 100644
--- a/src/nvim/runtime.c
+++ b/src/nvim/runtime.c
@@ -17,6 +17,7 @@
#include "nvim/api/private/helpers.h"
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
+#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cmdexpand.h"
#include "nvim/debugger.h"
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index 02e7c3cc68..5c479bb1c6 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -50,6 +50,7 @@
#include "nvim/search.h"
#include "nvim/shada.h"
#include "nvim/strings.h"
+#include "nvim/types_defs.h"
#include "nvim/version.h"
#include "nvim/vim_defs.h"
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index 027013c5f0..979495e810 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -264,6 +264,7 @@
#include "nvim/spell_defs.h"
#include "nvim/spellfile.h"
#include "nvim/strings.h"
+#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/vim_defs.h"
diff --git a/src/nvim/state.c b/src/nvim/state.c
index 199003b61c..518ceb8c88 100644
--- a/src/nvim/state.c
+++ b/src/nvim/state.c
@@ -3,6 +3,7 @@
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
+#include "nvim/buffer_defs.h"
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c
index 7fda93834d..d31b8ef0b1 100644
--- a/src/nvim/statusline.c
+++ b/src/nvim/statusline.c
@@ -40,6 +40,7 @@
#include "nvim/state_defs.h"
#include "nvim/statusline.h"
#include "nvim/strings.h"
+#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/window.h"
diff --git a/src/nvim/syntax_defs.h b/src/nvim/syntax_defs.h
index ae4997154e..8fd8b0638f 100644
--- a/src/nvim/syntax_defs.h
+++ b/src/nvim/syntax_defs.h
@@ -1,6 +1,9 @@
#pragma once
+#include "nvim/buffer_defs.h"
+#include "nvim/garray_defs.h"
#include "nvim/highlight_defs.h"
+#include "nvim/regexp_defs.h"
#define SST_MIN_ENTRIES 150 // minimal size for state stack array
#define SST_MAX_ENTRIES 1000 // maximal size for state stack array
@@ -8,11 +11,6 @@
#define SST_DIST 16 // normal distance between entries
#define SST_INVALID ((synstate_T *)-1) // invalid syn_state pointer
-typedef struct syn_state synstate_T;
-
-#include "nvim/buffer_defs.h"
-#include "nvim/regexp_defs.h"
-
// struct passed to in_id_list()
struct sp_syn {
int inc_tag; // ":syn include" unique tag
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index fb798a06fd..8c7b6171aa 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -54,6 +54,7 @@
#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/tag.h"
+#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/vim_defs.h"
#include "nvim/window.h"
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index da6bf134de..1586dd3d8e 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -49,7 +49,6 @@
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
#include "nvim/buffer.h"
-#include "nvim/buffer_defs.h"
#include "nvim/change.h"
#include "nvim/channel.h"
#include "nvim/cursor.h"
diff --git a/src/nvim/terminal.h b/src/nvim/terminal.h
index dd0ef3f47c..1bbc1abd4a 100644
--- a/src/nvim/terminal.h
+++ b/src/nvim/terminal.h
@@ -4,13 +4,12 @@
#include <stddef.h>
#include <stdint.h>
-typedef struct terminal Terminal;
+#include "nvim/api/private/defs.h" // IWYU pragma: keep
+
typedef void (*terminal_write_cb)(const char *buffer, size_t size, void *data);
typedef void (*terminal_resize_cb)(uint16_t width, uint16_t height, void *data);
typedef void (*terminal_close_cb)(void *data);
-#include "nvim/buffer_defs.h" // IWYU pragma: keep
-
typedef struct {
void *data; // PTY process channel
uint16_t width, height;
diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c
index 3a7cc2a633..9c601769c0 100644
--- a/src/nvim/textobject.c
+++ b/src/nvim/textobject.c
@@ -6,6 +6,7 @@
#include <string.h>
#include "nvim/ascii_defs.h"
+#include "nvim/buffer_defs.h"
#include "nvim/cursor.h"
#include "nvim/drawscreen.h"
#include "nvim/edit.h"
diff --git a/src/nvim/types_defs.h b/src/nvim/types_defs.h
index 27227685fa..cc9deb9630 100644
--- a/src/nvim/types_defs.h
+++ b/src/nvim/types_defs.h
@@ -55,3 +55,9 @@ typedef struct {
int add; // Number of signs added in the invalid range, negative for deleted signs.
} SignRange;
#define SIGNRANGE_INIT { 0, 0 }
+
+typedef struct file_buffer buf_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_compositor.c b/src/nvim/ui_compositor.c
index baad8f3c29..d8969b0061 100644
--- a/src/nvim/ui_compositor.c
+++ b/src/nvim/ui_compositor.c
@@ -14,6 +14,7 @@
#include "klib/kvec.h"
#include "nvim/api/private/defs.h"
#include "nvim/ascii_defs.h"
+#include "nvim/buffer_defs.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
#include "nvim/highlight.h"
diff --git a/src/nvim/undo_defs.h b/src/nvim/undo_defs.h
index 09a9689f67..e38b5e88fe 100644
--- a/src/nvim/undo_defs.h
+++ b/src/nvim/undo_defs.h
@@ -18,8 +18,6 @@ typedef struct {
colnr_T vi_curswant; ///< MAXCOL from w_curswant
} visualinfo_T;
-#include "nvim/buffer_defs.h"
-
typedef struct u_entry u_entry_T;
struct u_entry {
u_entry_T *ue_next; ///< pointer to next entry in list
diff --git a/src/nvim/usercmd.h b/src/nvim/usercmd.h
index bcabf9460b..4d6d154b79 100644
--- a/src/nvim/usercmd.h
+++ b/src/nvim/usercmd.h
@@ -3,6 +3,7 @@
#include <stddef.h> // IWYU pragma: keep
#include <stdint.h>
+#include "nvim/api/private/defs.h" // IWYU pragma: keep
#include "nvim/cmdexpand_defs.h" // IWYU pragma: keep
#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h"
diff --git a/src/nvim/version.h b/src/nvim/version.h
index 94219aaddc..cc355f2df5 100644
--- a/src/nvim/version.h
+++ b/src/nvim/version.h
@@ -1,5 +1,6 @@
#pragma once
+#include "nvim/api/private/defs.h" // IWYU pragma: keep
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
#include "nvim/macros_defs.h"
diff --git a/src/nvim/vim_defs.h b/src/nvim/vim_defs.h
index b6cf402b02..4cd0097cdf 100644
--- a/src/nvim/vim_defs.h
+++ b/src/nvim/vim_defs.h
@@ -1,13 +1,14 @@
#pragma once
+#include "auto/config.h"
+#include "nvim/os/os_defs.h" // IWYU pragma: keep
+
// Some defines from the old feature.h
#define SESSION_FILE "Session.vim"
#define MAX_MSG_HIST_LEN 200
#define SYS_OPTWIN_FILE "$VIMRUNTIME/optwin.vim"
#define RUNTIME_DIRNAME "runtime"
-#include "auto/config.h"
-
enum {
/// length of a buffer to store a number in ASCII (64 bits binary + NUL)
NUMBUFLEN = 65,
@@ -56,8 +57,6 @@ typedef enum {
kCdCauseAuto, ///< On 'autochdir'.
} CdCause;
-#include "nvim/os/os_defs.h" // IWYU pragma: keep
-
// return values for functions
#if !(defined(OK) && (OK == 1))
// OK already defined to 1 in MacOS X curses, skip this
diff --git a/src/nvim/winfloat.c b/src/nvim/winfloat.c
index 87069d5682..dc29c08c14 100644
--- a/src/nvim/winfloat.c
+++ b/src/nvim/winfloat.c
@@ -19,6 +19,7 @@
#include "nvim/optionstr.h"
#include "nvim/pos_defs.h"
#include "nvim/strings.h"
+#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/vim_defs.h"
#include "nvim/window.h"