From 8533adb4844b771b84dac2141fa2fa60e0487b47 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 21 Dec 2023 16:50:05 +0800 Subject: [PATCH] refactor(IWYU): move decor provider types to decoration_defs.h (#26692) --- Makefile | 1 - src/clint.py | 1 - src/nvim/api/buffer.c | 1 - src/nvim/api/buffer.h | 3 +- src/nvim/api/vim.c | 1 - src/nvim/base64.c | 1 + src/nvim/buffer.c | 1 - src/nvim/buffer_defs.h | 2 +- src/nvim/bufwrite.c | 2 -- src/nvim/bufwrite.h | 2 +- src/nvim/change.c | 1 - src/nvim/change.h | 4 ++- src/nvim/channel.h | 1 - src/nvim/cursor.h | 2 +- src/nvim/decoration.c | 1 - src/nvim/decoration.h | 2 +- src/nvim/decoration_defs.h | 18 ++++++++++++ src/nvim/decoration_provider.c | 8 ++++++ src/nvim/decoration_provider.h | 26 ++--------------- src/nvim/digraph.h | 1 - src/nvim/drawline.c | 1 + src/nvim/drawline.h | 9 +++--- src/nvim/drawscreen.c | 1 - src/nvim/edit.c | 1 - src/nvim/edit.h | 2 +- src/nvim/eval.c | 1 - src/nvim/eval.h | 3 +- src/nvim/eval/funcs.c | 1 - src/nvim/eval/funcs.h | 1 - src/nvim/ex_cmds2.h | 2 +- src/nvim/extmark.h | 2 +- src/nvim/fileio.c | 1 - src/nvim/fileio.h | 3 +- src/nvim/fold.h | 3 +- src/nvim/highlight.c | 1 + src/nvim/indent.h | 1 - src/nvim/indent_c.h | 2 +- src/nvim/memfile.h | 2 +- src/nvim/memline.c | 1 - src/nvim/memline.h | 2 +- src/nvim/memory.h | 2 +- src/nvim/mouse.c | 1 - src/nvim/mouse.h | 1 - src/nvim/move.h | 1 - src/nvim/normal.c | 1 - src/nvim/normal.h | 4 ++- src/nvim/option.c | 1 + src/nvim/optionstr.h | 2 +- src/nvim/os/os.h | 2 +- src/nvim/os/os_win_console.c | 38 +++++++++++++++++++++++++ src/nvim/os/pty_conpty_win.c | 1 + src/nvim/os/pty_process_win.c | 1 + src/nvim/os/tty.c | 52 ---------------------------------- src/nvim/os/tty.h | 5 ---- src/nvim/popupmenu.c | 1 - src/nvim/popupmenu.h | 2 +- src/nvim/regexp.h | 2 +- src/nvim/search.c | 1 - src/nvim/search.h | 1 - src/nvim/sign.c | 1 - src/nvim/sign.h | 1 - src/nvim/statusline.c | 1 - src/nvim/statusline.h | 2 +- src/nvim/syntax.c | 1 - src/nvim/syntax.h | 2 +- src/nvim/tag.h | 2 +- src/nvim/terminal.h | 1 + src/nvim/tui/tui.c | 1 - src/nvim/undo.h | 2 +- 69 files changed, 110 insertions(+), 142 deletions(-) delete mode 100644 src/nvim/os/tty.c delete mode 100644 src/nvim/os/tty.h diff --git a/Makefile b/Makefile index c0262033cf..662c334c0c 100644 --- a/Makefile +++ b/Makefile @@ -148,7 +148,6 @@ iwyu: build/.ran-cmake |src/nvim/buffer_defs.h\ |src/nvim/channel.h\ |src/nvim/charset.h\ - |src/nvim/drawline.h\ |src/nvim/eval.h\ |src/nvim/eval/encode.h\ |src/nvim/eval/typval.h\ diff --git a/src/clint.py b/src/clint.py index 51155f0038..80ebf565a1 100755 --- a/src/clint.py +++ b/src/clint.py @@ -906,7 +906,6 @@ def CheckIncludes(filename, lines, error): "src/nvim/buffer_defs.h", "src/nvim/channel.h", "src/nvim/charset.h", - "src/nvim/drawline.h", "src/nvim/eval.h", "src/nvim/eval/encode.h", "src/nvim/eval/typval.h", diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 99d261e73d..bbb6b92986 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -18,7 +18,6 @@ #include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" -#include "nvim/buffer_defs.h" #include "nvim/buffer_updates.h" #include "nvim/change.h" #include "nvim/cursor.h" diff --git a/src/nvim/api/buffer.h b/src/nvim/api/buffer.h index f3971c1d30..fe2d104058 100644 --- a/src/nvim/api/buffer.h +++ b/src/nvim/api/buffer.h @@ -5,7 +5,8 @@ #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/pos_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "api/buffer.h.generated.h" diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index aed286165a..9ae5244fa1 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -64,7 +64,6 @@ #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/base64.c b/src/nvim/base64.c index a0ba219fa2..7f7d121442 100644 --- a/src/nvim/base64.c +++ b/src/nvim/base64.c @@ -3,6 +3,7 @@ #include #include +#include "auto/config.h" #include "nvim/base64.h" #include "nvim/memory.h" diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index c9ae4c3ed3..d62e73a191 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -94,7 +94,6 @@ #include "nvim/strings.h" #include "nvim/syntax.h" #include "nvim/terminal.h" -#include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/usercmd.h" diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 49d2126801..3a6b5e2c6b 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -24,7 +24,7 @@ #include "nvim/regexp_defs.h" #include "nvim/sign_defs.h" #include "nvim/statusline_defs.h" -#include "nvim/terminal.h" +#include "nvim/types_defs.h" #include "nvim/undo_defs.h" /// Reference to a buffer that stores the value of buf_free_count. diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index 67e5fb3b6f..c506cfdfa3 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -13,12 +13,10 @@ #include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" -#include "nvim/buffer_defs.h" #include "nvim/bufwrite.h" #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/bufwrite.h b/src/nvim/bufwrite.h index 9ed6216847..ce9e04d2b1 100644 --- a/src/nvim/bufwrite.h +++ b/src/nvim/bufwrite.h @@ -1,8 +1,8 @@ #pragma once -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep #include "nvim/pos_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "bufwrite.h.generated.h" diff --git a/src/nvim/change.c b/src/nvim/change.c index 0154ead8fb..290f527946 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -9,7 +9,6 @@ #include "nvim/assert_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" -#include "nvim/buffer_defs.h" #include "nvim/buffer_updates.h" #include "nvim/change.h" #include "nvim/charset.h" diff --git a/src/nvim/change.h b/src/nvim/change.h index 06155b6da6..bd1094d57e 100644 --- a/src/nvim/change.h +++ b/src/nvim/change.h @@ -1,7 +1,9 @@ #pragma once -#include "nvim/buffer_defs.h" // IWYU pragma: keep +#include // IWYU pragma: keep + #include "nvim/pos_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep /// flags for open_line() enum { diff --git a/src/nvim/channel.h b/src/nvim/channel.h index 2b6356b216..7e3e84d918 100644 --- a/src/nvim/channel.h +++ b/src/nvim/channel.h @@ -17,7 +17,6 @@ #include "nvim/map_defs.h" #include "nvim/msgpack_rpc/channel_defs.h" #include "nvim/os/pty_process.h" -#include "nvim/terminal.h" #include "nvim/types_defs.h" static inline bool callback_reader_set(CallbackReader reader) diff --git a/src/nvim/cursor.h b/src/nvim/cursor.h index d50976b598..19107dfec9 100644 --- a/src/nvim/cursor.h +++ b/src/nvim/cursor.h @@ -1,7 +1,7 @@ #pragma once -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/pos_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "cursor.h.generated.h" diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c index a18f30ed41..7b3a32167e 100644 --- a/src/nvim/decoration.c +++ b/src/nvim/decoration.c @@ -20,7 +20,6 @@ #include "nvim/move.h" #include "nvim/option_vars.h" #include "nvim/pos_defs.h" -#include "nvim/sign.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "decoration.c.generated.h" diff --git a/src/nvim/decoration.h b/src/nvim/decoration.h index 1c072eab20..d8fd432880 100644 --- a/src/nvim/decoration.h +++ b/src/nvim/decoration.h @@ -5,11 +5,11 @@ #include #include "klib/kvec.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" #include "nvim/pos_defs.h" // IWYU pragma: keep +#include "nvim/sign_defs.h" // IWYU pragma: keep #include "nvim/types_defs.h" // actual Decor* data is in decoration_defs.h diff --git a/src/nvim/decoration_defs.h b/src/nvim/decoration_defs.h index 6e7dc08f80..f272753f46 100644 --- a/src/nvim/decoration_defs.h +++ b/src/nvim/decoration_defs.h @@ -125,3 +125,21 @@ typedef struct { // initializes in a valid state for the DecorHighlightInline branch #define DECOR_INLINE_INIT { .ext = false, .data.hl = DECOR_HIGHLIGHT_INLINE_INIT } + +typedef struct { + NS ns_id; + bool active; + LuaRef redraw_start; + LuaRef redraw_buf; + LuaRef redraw_win; + LuaRef redraw_line; + LuaRef redraw_end; + LuaRef hl_def; + LuaRef spell_nav; + int hl_valid; + bool hl_cached; + + uint8_t error_count; +} DecorProvider; + +typedef kvec_withinit_t(DecorProvider *, 4) DecorProviders; diff --git a/src/nvim/decoration_provider.c b/src/nvim/decoration_provider.c index 172eb569c9..39516ff541 100644 --- a/src/nvim/decoration_provider.c +++ b/src/nvim/decoration_provider.c @@ -1,5 +1,6 @@ #include #include +#include #include #include "klib/kvec.h" @@ -8,6 +9,7 @@ #include "nvim/api/private/helpers.h" #include "nvim/buffer_defs.h" #include "nvim/decoration.h" +#include "nvim/decoration_defs.h" #include "nvim/decoration_provider.h" #include "nvim/globals.h" #include "nvim/highlight.h" @@ -16,6 +18,12 @@ #include "nvim/message.h" #include "nvim/pos_defs.h" +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "decoration_provider.c.generated.h" +#endif + +enum { DP_MAX_ERROR = 3, }; + static kvec_t(DecorProvider) decor_providers = KV_INITIAL_VALUE; #define DECORATION_PROVIDER_INIT(ns_id) (DecorProvider) \ diff --git a/src/nvim/decoration_provider.h b/src/nvim/decoration_provider.h index e0dd67a6f7..ad6fb7ac19 100644 --- a/src/nvim/decoration_provider.h +++ b/src/nvim/decoration_provider.h @@ -1,32 +1,10 @@ #pragma once #include -#include -#include "klib/kvec.h" -#include "nvim/buffer_defs.h" // IWYU pragma: keep +#include "nvim/decoration_defs.h" // IWYU pragma: keep #include "nvim/macros_defs.h" -#include "nvim/types_defs.h" - -#define DP_MAX_ERROR 3 - -typedef struct { - NS ns_id; - bool active; - LuaRef redraw_start; - LuaRef redraw_buf; - LuaRef redraw_win; - LuaRef redraw_line; - LuaRef redraw_end; - LuaRef hl_def; - LuaRef spell_nav; - int hl_valid; - bool hl_cached; - - uint8_t error_count; -} DecorProvider; - -typedef kvec_withinit_t(DecorProvider *, 4) DecorProviders; +#include "nvim/types_defs.h" // IWYU pragma: keep EXTERN bool provider_active INIT( = false); diff --git a/src/nvim/digraph.h b/src/nvim/digraph.h index 267004124b..a3782cdd58 100644 --- a/src/nvim/digraph.h +++ b/src/nvim/digraph.h @@ -1,6 +1,5 @@ #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/garray_defs.h" // IWYU pragma: keep diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index ee1cd0a3ce..4f62fda2c5 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -15,6 +15,7 @@ #include "nvim/cursor.h" #include "nvim/cursor_shape.h" #include "nvim/decoration.h" +#include "nvim/decoration_defs.h" #include "nvim/decoration_provider.h" #include "nvim/diff.h" #include "nvim/drawline.h" diff --git a/src/nvim/drawline.h b/src/nvim/drawline.h index 5a7f220a13..97a6ca2eee 100644 --- a/src/nvim/drawline.h +++ b/src/nvim/drawline.h @@ -4,14 +4,13 @@ #include #include "klib/kvec.h" -#include "nvim/decoration_provider.h" -#include "nvim/fold_defs.h" +#include "nvim/decoration_defs.h" // IWYU pragma: keep +#include "nvim/fold_defs.h" // IWYU pragma: keep #include "nvim/macros_defs.h" #include "nvim/pos_defs.h" #include "nvim/types_defs.h" -// Maximum columns for terminal highlight attributes -#define TERM_ATTRS_MAX 1024 +enum { TERM_ATTRS_MAX = 1024, }; ///< Maximum columns for terminal highlight attributes typedef struct { NS ns_id; @@ -23,7 +22,7 @@ EXTERN kvec_t(WinExtmark) win_extmark_arr INIT( = KV_INITIAL_VALUE); EXTERN bool conceal_cursor_used INIT( = false); -// Spell checking variables passed from win_update() to win_line(). +/// Spell checking variables passed from win_update() to win_line(). typedef struct { bool spv_has_spell; ///< drawn window has spell checking bool spv_unchanged; ///< not updating for changed text diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index 9a5cfc7d07..8a441901d9 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -105,7 +105,6 @@ #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 0fcb665f0f..613aa2a591 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -18,7 +18,6 @@ #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/edit.h b/src/nvim/edit.h index 434b653f7b..2f15e737be 100644 --- a/src/nvim/edit.h +++ b/src/nvim/edit.h @@ -1,8 +1,8 @@ #pragma once #include "nvim/autocmd_defs.h" // IWYU pragma: keep -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/pos_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep /// Values for in_cinkeys() enum { diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 21bb325e37..d12a49e7d4 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -16,7 +16,6 @@ #include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" -#include "nvim/buffer_defs.h" #include "nvim/channel.h" #include "nvim/charset.h" #include "nvim/cmdexpand_defs.h" diff --git a/src/nvim/eval.h b/src/nvim/eval.h index 65f7020295..b350b9a8d1 100644 --- a/src/nvim/eval.h +++ b/src/nvim/eval.h @@ -4,18 +4,19 @@ #include #include -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/channel.h" #include "nvim/cmdexpand_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" #include "nvim/event/time.h" #include "nvim/ex_cmds_defs.h" +#include "nvim/grid_defs.h" // IWYU pragma: keep #include "nvim/hashtab_defs.h" #include "nvim/macros_defs.h" #include "nvim/mbyte_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 +#include "nvim/types_defs.h" // IWYU pragma: keep #include "nvim/vim_defs.h" // IWYU pragma: keep #define COPYID_INC 2 diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index f13235c3e9..5b6904269d 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -28,7 +28,6 @@ #include "nvim/assert_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" -#include "nvim/buffer_defs.h" #include "nvim/channel.h" #include "nvim/charset.h" #include "nvim/cmdexpand.h" diff --git a/src/nvim/eval/funcs.h b/src/nvim/eval/funcs.h index 0c345dacb4..e3a574b233 100644 --- a/src/nvim/eval/funcs.h +++ b/src/nvim/eval/funcs.h @@ -3,7 +3,6 @@ #include #include -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/cmdexpand_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" #include "nvim/pos_defs.h" // IWYU pragma: keep diff --git a/src/nvim/ex_cmds2.h b/src/nvim/ex_cmds2.h index 4f41f2cc41..a35a27758c 100644 --- a/src/nvim/ex_cmds2.h +++ b/src/nvim/ex_cmds2.h @@ -1,7 +1,7 @@ #pragma once -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep /// flags for check_changed() enum { diff --git a/src/nvim/extmark.h b/src/nvim/extmark.h index e83c8d1257..2f2491f8a4 100644 --- a/src/nvim/extmark.h +++ b/src/nvim/extmark.h @@ -4,11 +4,11 @@ #include #include "klib/kvec.h" -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/extmark_defs.h" // IWYU pragma: export #include "nvim/macros_defs.h" #include "nvim/marktree_defs.h" #include "nvim/pos_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep EXTERN int curbuf_splice_pending INIT( = 0); diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 066a150f5a..3e8c4f694c 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -19,7 +19,6 @@ #include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" -#include "nvim/buffer_defs.h" #include "nvim/buffer_updates.h" #include "nvim/change.h" #include "nvim/cursor.h" diff --git a/src/nvim/fileio.h b/src/nvim/fileio.h index 32a5ec3002..26161c03ba 100644 --- a/src/nvim/fileio.h +++ b/src/nvim/fileio.h @@ -4,12 +4,13 @@ #include // IWYU pragma: keep #include // IWYU pragma: keep -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep #include "nvim/garray_defs.h" // IWYU pragma: keep #include "nvim/os/fs_defs.h" // IWYU pragma: keep +#include "nvim/os/os_defs.h" // IWYU pragma: keep #include "nvim/pos_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep /// Values for readfile() flags enum { diff --git a/src/nvim/fold.h b/src/nvim/fold.h index efa239daa5..887787578e 100644 --- a/src/nvim/fold.h +++ b/src/nvim/fold.h @@ -2,7 +2,8 @@ #include // IWYU pragma: keep -#include "nvim/buffer_defs.h" // IWYU pragma: keep +#include "nvim/decoration_defs.h" // IWYU pragma: keep +#include "nvim/eval/typval_defs.h" // IWYU pragma: keep #include "nvim/fold_defs.h" // IWYU pragma: export #include "nvim/garray_defs.h" // IWYU pragma: keep #include "nvim/macros_defs.h" diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c index 6684a20607..cffa362d6a 100644 --- a/src/nvim/highlight.c +++ b/src/nvim/highlight.c @@ -11,6 +11,7 @@ #include "nvim/api/private/helpers.h" #include "nvim/api/private/validate.h" #include "nvim/api/ui.h" +#include "nvim/decoration_defs.h" #include "nvim/decoration_provider.h" #include "nvim/drawscreen.h" #include "nvim/gettext.h" diff --git a/src/nvim/indent.h b/src/nvim/indent.h index b64015958c..54d27e6243 100644 --- a/src/nvim/indent.h +++ b/src/nvim/indent.h @@ -1,6 +1,5 @@ #pragma once -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep #include "nvim/pos_defs.h" // IWYU pragma: keep #include "nvim/types_defs.h" // IWYU pragma: keep diff --git a/src/nvim/indent_c.h b/src/nvim/indent_c.h index 64ba67a42b..65a402f02c 100644 --- a/src/nvim/indent_c.h +++ b/src/nvim/indent_c.h @@ -1,7 +1,7 @@ #pragma once -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/pos_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "indent_c.h.generated.h" diff --git a/src/nvim/memfile.h b/src/nvim/memfile.h index 687ac042a4..6e7b575e5b 100644 --- a/src/nvim/memfile.h +++ b/src/nvim/memfile.h @@ -1,7 +1,7 @@ #pragma once -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/memfile_defs.h" // IWYU pragma: export +#include "nvim/types_defs.h" // IWYU pragma: keep /// flags for mf_sync() enum { diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 25c2de89e0..63f3541b3c 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -48,7 +48,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/cursor.h" #include "nvim/drawscreen.h" diff --git a/src/nvim/memline.h b/src/nvim/memline.h index e70a8e423e..808d97783e 100644 --- a/src/nvim/memline.h +++ b/src/nvim/memline.h @@ -1,6 +1,6 @@ #pragma once -#include "nvim/buffer_defs.h" // IWYU pragma: keep +#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 #include "nvim/types_defs.h" // IWYU pragma: keep diff --git a/src/nvim/memory.h b/src/nvim/memory.h index d425249ab6..1511876c81 100644 --- a/src/nvim/memory.h +++ b/src/nvim/memory.h @@ -2,7 +2,7 @@ #include #include // IWYU pragma: keep -#include +#include // IWYU pragma: keep #include // IWYU pragma: keep #include "auto/config.h" diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index 35db717058..a026859a7e 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -6,7 +6,6 @@ #include "nvim/ascii_defs.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/mouse.h b/src/nvim/mouse.h index d787b8ff57..2dcb3469da 100644 --- a/src/nvim/mouse.h +++ b/src/nvim/mouse.h @@ -1,6 +1,5 @@ #pragma once -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" // IWYU pragma: keep #include "nvim/normal_defs.h" // IWYU pragma: keep #include "nvim/types_defs.h" // IWYU pragma: keep diff --git a/src/nvim/move.h b/src/nvim/move.h index f48de6987b..afeaeba235 100644 --- a/src/nvim/move.h +++ b/src/nvim/move.h @@ -1,6 +1,5 @@ #pragma once -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" // IWYU pragma: keep #include "nvim/types_defs.h" // IWYU pragma: keep #include "nvim/vim_defs.h" // IWYU pragma: keep diff --git a/src/nvim/normal.c b/src/nvim/normal.c index dbcec0721f..3937533d36 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -18,7 +18,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/charset.h" #include "nvim/cmdhist.h" diff --git a/src/nvim/normal.h b/src/nvim/normal.h index dbe74712fc..93e3e09c2e 100644 --- a/src/nvim/normal.h +++ b/src/nvim/normal.h @@ -1,9 +1,11 @@ #pragma once -#include "nvim/buffer_defs.h" // IWYU pragma: keep +#include // IWYU pragma: keep + #include "nvim/macros_defs.h" #include "nvim/normal_defs.h" // IWYU pragma: export #include "nvim/pos_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep /// Values for find_ident_under_cursor() enum { diff --git a/src/nvim/option.c b/src/nvim/option.c index b1bc34744c..49a8c468d6 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -38,6 +38,7 @@ #include "nvim/cmdexpand.h" #include "nvim/cmdexpand_defs.h" #include "nvim/cursor_shape.h" +#include "nvim/decoration_defs.h" #include "nvim/decoration_provider.h" #include "nvim/diff.h" #include "nvim/drawscreen.h" diff --git a/src/nvim/optionstr.h b/src/nvim/optionstr.h index b317e55b7e..ae35d706aa 100644 --- a/src/nvim/optionstr.h +++ b/src/nvim/optionstr.h @@ -2,9 +2,9 @@ #include // IWYU pragma: keep -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/cmdexpand_defs.h" // IWYU pragma: keep #include "nvim/option_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "optionstr.h.generated.h" diff --git a/src/nvim/os/os.h b/src/nvim/os/os.h index 302d84d066..7ba5f05448 100644 --- a/src/nvim/os/os.h +++ b/src/nvim/os/os.h @@ -4,11 +4,11 @@ #include // IWYU pragma: keep #include // IWYU pragma: keep -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/cmdexpand_defs.h" // IWYU pragma: keep #include "nvim/garray_defs.h" // IWYU pragma: keep #include "nvim/os/os_defs.h" // IWYU pragma: export #include "nvim/os/stdpaths_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep #define HAVE_PATHDEF diff --git a/src/nvim/os/os_win_console.c b/src/nvim/os/os_win_console.c index 816e81e997..953d291290 100644 --- a/src/nvim/os/os_win_console.c +++ b/src/nvim/os/os_win_console.c @@ -1,6 +1,7 @@ #include #include "nvim/globals.h" +#include "nvim/memory.h" #include "nvim/os/fs.h" #include "nvim/os/input.h" #include "nvim/os/os.h" @@ -105,3 +106,40 @@ void os_title_reset(void) { SetConsoleTitle(origTitle); } + +#if !defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING) +# define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 +#endif +/// Guesses the terminal-type. Calls SetConsoleMode() and uv_set_vterm_state() +/// if appropriate. +/// +/// @param[in,out] term Name of the guessed terminal, statically-allocated +/// @param out_fd stdout file descriptor +void os_tty_guess_term(const char **term, int out_fd) +{ + bool conemu_ansi = strequal(os_getenv("ConEmuANSI"), "ON"); + bool vtp = false; + + HANDLE handle = (HANDLE)_get_osfhandle(out_fd); + DWORD dwMode; + if (handle != INVALID_HANDLE_VALUE && GetConsoleMode(handle, &dwMode)) { + dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; + if (SetConsoleMode(handle, dwMode)) { + vtp = true; + } + } + + if (*term == NULL) { + if (vtp) { + *term = "vtpcon"; + } else if (conemu_ansi) { + *term = "conemu"; + } else { + *term = "win32con"; + } + } + + if (conemu_ansi) { + uv_tty_set_vterm_state(UV_TTY_SUPPORTED); + } +} diff --git a/src/nvim/os/pty_conpty_win.c b/src/nvim/os/pty_conpty_win.c index 53169c0ef8..e7697880af 100644 --- a/src/nvim/os/pty_conpty_win.c +++ b/src/nvim/os/pty_conpty_win.c @@ -1,5 +1,6 @@ #include +#include "nvim/log.h" #include "nvim/os/os.h" #include "nvim/os/pty_conpty_win.h" #include "nvim/vim_defs.h" diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index ca2dce36ea..563a79358c 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/log.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/os/os.h" diff --git a/src/nvim/os/tty.c b/src/nvim/os/tty.c deleted file mode 100644 index 57325c312f..0000000000 --- a/src/nvim/os/tty.c +++ /dev/null @@ -1,52 +0,0 @@ -// -// Terminal/console utils -// - -#ifdef MSWIN -# include "nvim/memory.h" -# include "nvim/os/os.h" -#endif -#include "nvim/os/tty.h" - -#ifdef INCLUDE_GENERATED_DECLARATIONS -# include "os/tty.c.generated.h" // IWYU pragma: export -#endif - -#ifdef MSWIN -# if !defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING) -# define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 -# endif -/// Guesses the terminal-type. Calls SetConsoleMode() and uv_set_vterm_state() -/// if appropriate. -/// -/// @param[in,out] term Name of the guessed terminal, statically-allocated -/// @param out_fd stdout file descriptor -void os_tty_guess_term(const char **term, int out_fd) -{ - bool conemu_ansi = strequal(os_getenv("ConEmuANSI"), "ON"); - bool vtp = false; - - HANDLE handle = (HANDLE)_get_osfhandle(out_fd); - DWORD dwMode; - if (handle != INVALID_HANDLE_VALUE && GetConsoleMode(handle, &dwMode)) { - dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; - if (SetConsoleMode(handle, dwMode)) { - vtp = true; - } - } - - if (*term == NULL) { - if (vtp) { - *term = "vtpcon"; - } else if (conemu_ansi) { - *term = "conemu"; - } else { - *term = "win32con"; - } - } - - if (conemu_ansi) { - uv_tty_set_vterm_state(UV_TTY_SUPPORTED); - } -} -#endif diff --git a/src/nvim/os/tty.h b/src/nvim/os/tty.h deleted file mode 100644 index 3a78573189..0000000000 --- a/src/nvim/os/tty.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#ifdef INCLUDE_GENERATED_DECLARATIONS -# include "os/tty.h.generated.h" -#endif diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c index 386c13f630..df82cb259e 100644 --- a/src/nvim/popupmenu.c +++ b/src/nvim/popupmenu.c @@ -12,7 +12,6 @@ #include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" -#include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/drawscreen.h" #include "nvim/eval/typval.h" diff --git a/src/nvim/popupmenu.h b/src/nvim/popupmenu.h index 1e4a1584ea..20a342b841 100644 --- a/src/nvim/popupmenu.h +++ b/src/nvim/popupmenu.h @@ -2,11 +2,11 @@ #include -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" // IWYU pragma: keep #include "nvim/grid_defs.h" #include "nvim/macros_defs.h" #include "nvim/menu_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep /// Used for popup menu items. typedef struct { diff --git a/src/nvim/regexp.h b/src/nvim/regexp.h index 447f4860a9..1414749c2f 100644 --- a/src/nvim/regexp.h +++ b/src/nvim/regexp.h @@ -1,6 +1,6 @@ #pragma once -#include "nvim/buffer_defs.h" // IWYU pragma: keep +#include "nvim/eval/typval_defs.h" // IWYU pragma: keep #include "nvim/pos_defs.h" // IWYU pragma: keep #include "nvim/regexp_defs.h" // IWYU pragma: export #include "nvim/types_defs.h" // IWYU pragma: keep diff --git a/src/nvim/search.c b/src/nvim/search.c index a23d27635f..8279b4857c 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -11,7 +11,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/charset.h" #include "nvim/cmdhist.h" diff --git a/src/nvim/search.h b/src/nvim/search.h index 12553c8e74..04a06f75a2 100644 --- a/src/nvim/search.h +++ b/src/nvim/search.h @@ -3,7 +3,6 @@ #include #include -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" #include "nvim/normal_defs.h" // IWYU pragma: keep #include "nvim/os/time_defs.h" diff --git a/src/nvim/sign.c b/src/nvim/sign.c index 2bf328bf75..b52142f721 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -13,7 +13,6 @@ #include "nvim/api/private/helpers.h" #include "nvim/ascii_defs.h" #include "nvim/buffer.h" -#include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cmdexpand_defs.h" #include "nvim/cursor.h" diff --git a/src/nvim/sign.h b/src/nvim/sign.h index 1c607bc7de..2b6497c255 100644 --- a/src/nvim/sign.h +++ b/src/nvim/sign.h @@ -1,6 +1,5 @@ #pragma once -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/cmdexpand_defs.h" // IWYU pragma: keep #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep #include "nvim/sign_defs.h" // IWYU pragma: export diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index d31b8ef0b1..01729bc4de 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -10,7 +10,6 @@ #include "nvim/api/private/helpers.h" #include "nvim/ascii_defs.h" #include "nvim/buffer.h" -#include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/digraph.h" #include "nvim/drawline.h" diff --git a/src/nvim/statusline.h b/src/nvim/statusline.h index e1038ef2ca..36fc5be68e 100644 --- a/src/nvim/statusline.h +++ b/src/nvim/statusline.h @@ -2,10 +2,10 @@ #include -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/macros_defs.h" #include "nvim/option_defs.h" // IWYU pragma: keep #include "nvim/statusline_defs.h" // IWYU pragma: export +#include "nvim/types_defs.h" // IWYU pragma: keep /// Array defining what should be done when tabline is clicked EXTERN StlClickDefinition *tab_page_click_defs INIT( = NULL); diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index d5ee93914a..41c9703f3b 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -10,7 +10,6 @@ #include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" -#include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cmdexpand_defs.h" #include "nvim/drawscreen.h" diff --git a/src/nvim/syntax.h b/src/nvim/syntax.h index b9065acf7d..f07ad238d3 100644 --- a/src/nvim/syntax.h +++ b/src/nvim/syntax.h @@ -1,10 +1,10 @@ #pragma once -#include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/cmdexpand_defs.h" // IWYU pragma: keep #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep #include "nvim/macros_defs.h" #include "nvim/syntax_defs.h" // IWYU pragma: export +#include "nvim/types_defs.h" // IWYU pragma: keep enum { HL_CONTAINED = 0x01, ///< not used on toplevel diff --git a/src/nvim/tag.h b/src/nvim/tag.h index 87e71c8bef..42196b44b7 100644 --- a/src/nvim/tag.h +++ b/src/nvim/tag.h @@ -1,9 +1,9 @@ #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 +#include "nvim/types_defs.h" // IWYU pragma: keep enum { LSIZE = 512, }; ///< max. size of a line in the tags file diff --git a/src/nvim/terminal.h b/src/nvim/terminal.h index 1bbc1abd4a..317003c0d2 100644 --- a/src/nvim/terminal.h +++ b/src/nvim/terminal.h @@ -5,6 +5,7 @@ #include #include "nvim/api/private/defs.h" // IWYU pragma: keep +#include "nvim/types_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); diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index ba4069ecf4..6c0b00f010 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -40,7 +40,6 @@ #ifdef MSWIN # include "nvim/os/os_win_console.h" -# include "nvim/os/tty.h" #endif #define OUTBUF_SIZE 0xffff diff --git a/src/nvim/undo.h b/src/nvim/undo.h index f3a8a60d45..a70b1fe486 100644 --- a/src/nvim/undo.h +++ b/src/nvim/undo.h @@ -1,6 +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/pos_defs.h" // IWYU pragma: keep #include "nvim/types_defs.h" // IWYU pragma: keep