From 69bc519b53ebf78fd95c8256468e7d538ebcb948 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 12 Dec 2023 15:40:21 +0100 Subject: [PATCH] refactor: move non-symbols to defs.h headers --- Makefile | 5 +- cmake.config/iwyu/mapping.imp | 1 - src/clint.py | 13 ++- src/nvim/api/options.c | 1 - src/nvim/api/private/dispatch.h | 2 +- src/nvim/api/private/helpers.c | 1 - src/nvim/api/private/helpers.h | 8 +- src/nvim/api/ui.c | 2 +- src/nvim/api/vim.c | 1 + src/nvim/arglist.c | 1 - src/nvim/arglist.h | 2 - src/nvim/autocmd.c | 2 +- src/nvim/buffer.c | 1 - src/nvim/bufwrite.c | 1 + src/nvim/channel.c | 3 + src/nvim/channel.h | 55 +---------- src/nvim/channel_defs.h | 74 ++++++++++++++ src/nvim/decoration.c | 2 +- src/nvim/drawscreen.c | 1 + src/nvim/eval.c | 1 + src/nvim/eval/funcs.c | 1 + src/nvim/eval/gc.h | 2 +- src/nvim/event/defs.h | 166 ++++++++++++++++++++++++++++++++ src/nvim/event/libuv_process.c | 2 +- src/nvim/event/loop.c | 1 + src/nvim/event/loop.h | 39 -------- src/nvim/event/multiqueue.h | 13 +-- src/nvim/event/process.c | 2 + src/nvim/event/rstream.c | 1 + src/nvim/event/signal.c | 1 + src/nvim/event/signal.h | 15 +-- src/nvim/event/socket.c | 1 + src/nvim/event/socket.h | 29 +----- src/nvim/event/stream.c | 1 + src/nvim/event/stream.h | 50 +--------- src/nvim/event/time.c | 3 + src/nvim/event/time.h | 14 +-- src/nvim/event/wstream.c | 2 + src/nvim/event/wstream.h | 12 +-- src/nvim/ex_cmds.c | 1 - src/nvim/ex_cmds.h | 29 ------ src/nvim/ex_cmds_defs.h | 25 +++++ src/nvim/ex_docmd.c | 2 +- src/nvim/extmark.h | 3 +- src/nvim/input.c | 2 +- src/nvim/log.h | 36 +------ src/nvim/log_defs.h | 36 +++++++ src/nvim/lua/executor.c | 1 - src/nvim/mark.c | 5 +- src/nvim/mark.h | 87 +---------------- src/nvim/mark_defs.h | 76 +++++++++++++++ src/nvim/mbyte.h | 2 +- src/nvim/message.c | 2 + src/nvim/message.h | 54 +---------- src/nvim/message_defs.h | 59 ++++++++++++ src/nvim/msgpack_rpc/channel.c | 3 +- src/nvim/msgpack_rpc/channel.h | 6 +- src/nvim/msgpack_rpc/server.c | 1 + src/nvim/option.c | 1 - src/nvim/option_defs.h | 3 +- src/nvim/os/input.c | 1 + src/nvim/os/pty_process_unix.c | 2 +- src/nvim/os/shell.c | 2 + src/nvim/os/signal.c | 1 + src/nvim/os/time.c | 2 +- src/nvim/os/tty.h | 2 +- src/nvim/popupmenu.h | 2 +- src/nvim/spell.c | 1 + src/nvim/spellsuggest.c | 1 + src/nvim/statusline.h | 2 +- src/nvim/tag.c | 1 + src/nvim/terminal.c | 1 + src/nvim/terminal.h | 1 + src/nvim/tui/input.c | 1 + src/nvim/tui/tui.c | 1 + src/nvim/ui.c | 1 + src/nvim/ui_client.c | 2 +- src/nvim/vim_defs.h | 1 - src/nvim/window.c | 1 + 79 files changed, 514 insertions(+), 478 deletions(-) create mode 100644 src/nvim/channel_defs.h create mode 100644 src/nvim/log_defs.h create mode 100644 src/nvim/message_defs.h diff --git a/Makefile b/Makefile index 0a807e65da..6176f3a7bf 100644 --- a/Makefile +++ b/Makefile @@ -142,12 +142,12 @@ 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/helpers.h\ |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/channel_defs.h\ |src/nvim/charset.h\ |src/nvim/drawline.h\ |src/nvim/eval.h\ @@ -158,7 +158,6 @@ iwyu: build/.ran-cmake |src/nvim/eval/window.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\ @@ -174,8 +173,6 @@ iwyu: build/.ran-cmake |src/nvim/keycodes.h\ |src/nvim/lua/executor.h\ |src/nvim/main.h\ - |src/nvim/mark.h\ - |src/nvim/msgpack_rpc/channel.h\ |src/nvim/msgpack_rpc/channel_defs.h\ |src/nvim/msgpack_rpc/helpers.h\ |src/nvim/msgpack_rpc/unpacker.h\ diff --git a/cmake.config/iwyu/mapping.imp b/cmake.config/iwyu/mapping.imp index 4056070958..f4559d9ea9 100644 --- a/cmake.config/iwyu/mapping.imp +++ b/cmake.config/iwyu/mapping.imp @@ -23,7 +23,6 @@ { symbol: [ "extern_proc", private, '', public ] }, { symbol: [ "iovec", private, '', public ] }, - { include: [ '"keysets_defs.generated.h"', private, '"nvim/api/private/dispatch.h"', public ] }, { include: [ '', private, '', public ] }, ] diff --git a/src/clint.py b/src/clint.py index 021d6b0a16..537406cd24 100755 --- a/src/clint.py +++ b/src/clint.py @@ -900,12 +900,12 @@ def CheckIncludes(filename, lines, error): # These should be synced with the ignored headers in the `iwyu` target in # the Makefile. check_includes_ignore = [ - "src/nvim/api/private/helpers.h", "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/channel_defs.h", "src/nvim/charset.h", "src/nvim/drawline.h", "src/nvim/eval.h", @@ -916,7 +916,6 @@ def CheckIncludes(filename, lines, error): "src/nvim/eval/window.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", @@ -932,8 +931,6 @@ 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.h", "src/nvim/msgpack_rpc/channel_defs.h", "src/nvim/msgpack_rpc/helpers.h", "src/nvim/msgpack_rpc/unpacker.h", @@ -949,10 +946,12 @@ def CheckIncludes(filename, lines, error): ] skip_headers = [ - "klib/kvec.h", - "klib/klist.h", "auto/config.h", - "nvim/func_attr.h" + "klib/klist.h", + "klib/kvec.h", + "nvim/func_attr.h", + "nvim/gettext.h", + "nvim/globals.h" ] for i in check_includes_ignore: diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c index a3ea7d9d47..ea617dffaf 100644 --- a/src/nvim/api/options.c +++ b/src/nvim/api/options.c @@ -15,7 +15,6 @@ #include "nvim/macros_defs.h" #include "nvim/memory.h" #include "nvim/option.h" -#include "nvim/option_vars.h" #include "nvim/vim_defs.h" #include "nvim/window.h" diff --git a/src/nvim/api/private/dispatch.h b/src/nvim/api/private/dispatch.h index 88f846f813..b627db6b00 100644 --- a/src/nvim/api/private/dispatch.h +++ b/src/nvim/api/private/dispatch.h @@ -27,5 +27,5 @@ extern const MsgpackRpcRequestHandler method_handlers[]; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "api/private/dispatch.h.generated.h" # include "api/private/dispatch_wrappers.h.generated.h" // IWYU pragma: export -# include "keysets_defs.generated.h" +# include "keysets_defs.generated.h" // IWYU pragma: export #endif diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 2772fa8b59..70e63d0ad5 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -17,7 +17,6 @@ #include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/eval/vars.h" #include "nvim/ex_eval.h" #include "nvim/garray.h" diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h index e61dd5f992..64558f0410 100644 --- a/src/nvim/api/private/helpers.h +++ b/src/nvim/api/private/helpers.h @@ -2,21 +2,15 @@ #include #include -#include #include "klib/kvec.h" #include "nvim/api/private/defs.h" -#include "nvim/api/private/dispatch.h" -#include "nvim/decoration.h" -#include "nvim/eval/typval_defs.h" #include "nvim/ex_eval_defs.h" -#include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/macros_defs.h" #include "nvim/map_defs.h" -#include "nvim/memory.h" -#include "nvim/message.h" +#include "nvim/message_defs.h" // IWYU pragma: keep #define OBJECT_OBJ(o) o diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index b73c026d57..678d23fbeb 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -15,7 +15,7 @@ #include "nvim/autocmd.h" #include "nvim/channel.h" #include "nvim/eval.h" -#include "nvim/event/loop.h" +#include "nvim/event/defs.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 91f908bb88..70e6b840de 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -54,6 +54,7 @@ #include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/input.h" +#include "nvim/os/os_defs.h" #include "nvim/os/process.h" #include "nvim/popupmenu.h" #include "nvim/pos_defs.h" diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c index 064543b430..8bc8edb572 100644 --- a/src/nvim/arglist.c +++ b/src/nvim/arglist.c @@ -13,7 +13,6 @@ #include "nvim/charset.h" #include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval.h" -#include "nvim/eval/typval_defs.h" #include "nvim/eval/window.h" #include "nvim/ex_cmds.h" #include "nvim/ex_cmds2.h" diff --git a/src/nvim/arglist.h b/src/nvim/arglist.h index 97729f466c..d117f6163b 100644 --- a/src/nvim/arglist.h +++ b/src/nvim/arglist.h @@ -2,9 +2,7 @@ #include "nvim/arglist_defs.h" // IWYU pragma: export #include "nvim/cmdexpand_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/types_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "arglist.h.generated.h" diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index 72b0852d8d..bfcf566fe3 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -19,7 +19,7 @@ #include "nvim/eval/typval.h" #include "nvim/eval/userfunc.h" #include "nvim/eval/vars.h" -#include "nvim/event/multiqueue.h" +#include "nvim/event/defs.h" #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" #include "nvim/fileio.h" diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 0392ff6ebd..75c6545c1d 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -39,7 +39,6 @@ #include "nvim/charset.h" #include "nvim/cmdexpand.h" #include "nvim/cursor.h" -#include "nvim/decoration.h" #include "nvim/diff.h" #include "nvim/digraph.h" #include "nvim/drawscreen.h" diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index 06bd05b11d..f8df273375 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -37,6 +37,7 @@ #include "nvim/option_vars.h" #include "nvim/os/fs.h" #include "nvim/os/input.h" +#include "nvim/os/os_defs.h" #include "nvim/path.h" #include "nvim/pos_defs.h" #include "nvim/sha256.h" diff --git a/src/nvim/channel.c b/src/nvim/channel.c index fb4711f7d9..42935933e0 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -15,8 +15,10 @@ #include "nvim/eval.h" #include "nvim/eval/encode.h" #include "nvim/eval/typval.h" +#include "nvim/event/multiqueue.h" #include "nvim/event/rstream.h" #include "nvim/event/socket.h" +#include "nvim/event/stream.h" #include "nvim/event/wstream.h" #include "nvim/garray.h" #include "nvim/gettext.h" @@ -32,6 +34,7 @@ #include "nvim/os/shell.h" #include "nvim/path.h" #include "nvim/rbuffer.h" +#include "nvim/types_defs.h" #ifdef MSWIN # include "nvim/os/fs.h" diff --git a/src/nvim/channel.h b/src/nvim/channel.h index 6deea08c83..2b6356b216 100644 --- a/src/nvim/channel.h +++ b/src/nvim/channel.h @@ -4,6 +4,7 @@ #include #include +#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" @@ -19,60 +20,6 @@ #include "nvim/terminal.h" #include "nvim/types_defs.h" -#define CHAN_STDIO 1 -#define CHAN_STDERR 2 - -typedef enum { - kChannelStreamProc, - kChannelStreamSocket, - kChannelStreamStdio, - kChannelStreamStderr, - kChannelStreamInternal, -} ChannelStreamType; - -typedef enum { - kChannelPartStdin, - kChannelPartStdout, - kChannelPartStderr, - kChannelPartRpc, - kChannelPartAll, -} ChannelPart; - -typedef enum { - kChannelStdinPipe, - kChannelStdinNull, -} ChannelStdinMode; - -typedef struct { - Stream in; - Stream out; -} StdioPair; - -typedef struct { - bool closed; -} StderrState; - -typedef struct { - LuaRef cb; - bool closed; -} InternalState; - -typedef struct { - Callback cb; - dict_T *self; - garray_T buffer; - bool eof; - bool buffered; - bool fwd_err; - const char *type; -} CallbackReader; - -#define CALLBACK_READER_INIT ((CallbackReader){ .cb = CALLBACK_NONE, \ - .self = NULL, \ - .buffer = GA_EMPTY_INIT_VALUE, \ - .buffered = false, \ - .fwd_err = false, \ - .type = NULL }) static inline bool callback_reader_set(CallbackReader reader) { return reader.cb.type != kCallbackNone || reader.self; diff --git a/src/nvim/channel_defs.h b/src/nvim/channel_defs.h new file mode 100644 index 0000000000..1af4c2de59 --- /dev/null +++ b/src/nvim/channel_defs.h @@ -0,0 +1,74 @@ +#pragma once +#include +#include +#include + +#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/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" +#include "nvim/terminal.h" +#include "nvim/types_defs.h" + +#define CHAN_STDIO 1 +#define CHAN_STDERR 2 + +typedef enum { + kChannelStreamProc, + kChannelStreamSocket, + kChannelStreamStdio, + kChannelStreamStderr, + kChannelStreamInternal, +} ChannelStreamType; + +typedef enum { + kChannelPartStdin, + kChannelPartStdout, + kChannelPartStderr, + kChannelPartRpc, + kChannelPartAll, +} ChannelPart; + +typedef enum { + kChannelStdinPipe, + kChannelStdinNull, +} ChannelStdinMode; + +typedef struct { + Stream in; + Stream out; +} StdioPair; + +typedef struct { + bool closed; +} StderrState; + +typedef struct { + LuaRef cb; + bool closed; +} InternalState; + +typedef struct { + Callback cb; + dict_T *self; + garray_T buffer; + bool eof; + bool buffered; + bool fwd_err; + const char *type; +} CallbackReader; + +#define CALLBACK_READER_INIT ((CallbackReader){ .cb = CALLBACK_NONE, \ + .self = NULL, \ + .buffer = GA_EMPTY_INIT_VALUE, \ + .buffered = false, \ + .fwd_err = false, \ + .type = NULL }) diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c index 74056b7c26..b3fad78f84 100644 --- a/src/nvim/decoration.c +++ b/src/nvim/decoration.c @@ -6,7 +6,6 @@ #include "nvim/api/extmark.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" -#include "nvim/buffer.h" #include "nvim/decoration.h" #include "nvim/drawscreen.h" #include "nvim/extmark.h" @@ -14,6 +13,7 @@ #include "nvim/grid.h" #include "nvim/highlight.h" #include "nvim/highlight_group.h" +#include "nvim/map_defs.h" #include "nvim/marktree.h" #include "nvim/memory.h" #include "nvim/move.h" diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index 314764d117..09a0a43e2f 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -91,6 +91,7 @@ #include "nvim/normal.h" #include "nvim/option.h" #include "nvim/option_vars.h" +#include "nvim/os/os_defs.h" #include "nvim/plines.h" #include "nvim/popupmenu.h" #include "nvim/pos_defs.h" diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 11c6034cc8..d8134c2360 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -32,6 +32,7 @@ #include "nvim/eval/vars.h" #include "nvim/event/multiqueue.h" #include "nvim/event/process.h" +#include "nvim/event/time.h" #include "nvim/ex_cmds.h" #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 1468c5564e..ea68c010d6 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -48,6 +48,7 @@ #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/gc.h b/src/nvim/eval/gc.h index 36149ec060..ea91952fff 100644 --- a/src/nvim/eval/gc.h +++ b/src/nvim/eval/gc.h @@ -6,5 +6,5 @@ extern dict_T *gc_first_dict; extern list_T *gc_first_list; #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "eval/gc.h.generated.h" // IWYU pragma: export +# include "eval/gc.h.generated.h" #endif diff --git a/src/nvim/event/defs.h b/src/nvim/event/defs.h index 56e00171e2..ffea388b9b 100644 --- a/src/nvim/event/defs.h +++ b/src/nvim/event/defs.h @@ -2,6 +2,10 @@ #include #include +#include +#include + +#include "nvim/rbuffer_defs.h" enum { EVENT_HANDLER_MAX_ARGC = 10, }; @@ -12,3 +16,165 @@ typedef struct { } Event; #define event_create(cb, ...) ((Event){ .handler = cb, .argv = { __VA_ARGS__ } }) + +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); + +struct signal_watcher { + uv_signal_t uv; + void *data; + signal_cb cb; + signal_close_cb close_cb; + MultiQueue *events; +}; + +struct time_watcher; + +typedef struct time_watcher TimeWatcher; +typedef void (*time_cb)(TimeWatcher *watcher, void *data); + +struct time_watcher { + uv_timer_t uv; + void *data; + time_cb cb, close_cb; + MultiQueue *events; + bool blockable; +}; + +struct wbuffer; + +typedef struct wbuffer WBuffer; +typedef void (*wbuffer_data_finalizer)(void *data); + +struct wbuffer { + size_t size, refcount; + char *data; + wbuffer_data_finalizer cb; +}; + +struct stream; + +typedef struct stream Stream; +/// Type of function called when the Stream buffer is filled with data +/// +/// @param stream The Stream instance +/// @param buf The associated RBuffer instance +/// @param count Number of bytes that was read. +/// @param data User-defined data +/// @param eof If the stream reached EOF. +typedef void (*stream_read_cb)(Stream *stream, RBuffer *buf, size_t count, void *data, bool eof); + +/// Type of function called when the Stream has information about a write +/// request. +/// +/// @param stream The Stream instance +/// @param data User-defined data +/// @param status 0 on success, anything else indicates failure +typedef void (*stream_write_cb)(Stream *stream, void *data, int status); +typedef void (*stream_close_cb)(Stream *stream, void *data); + +struct stream { + bool closed; + bool did_eof; + union { + uv_pipe_t pipe; + uv_tcp_t tcp; + uv_idle_t idle; +#ifdef MSWIN + uv_tty_t tty; +#endif + } uv; + uv_stream_t *uvstream; + uv_buf_t uvbuf; + RBuffer *buffer; + uv_file fd; + stream_read_cb read_cb; + stream_write_cb write_cb; + void *cb_data; + stream_close_cb close_cb, internal_close_cb; + void *close_cb_data, *internal_data; + size_t fpos; + size_t curmem; + size_t maxmem; + size_t pending_reqs; + size_t num_bytes; + MultiQueue *events; +}; + +struct socket_watcher; + +#define ADDRESS_MAX_SIZE 256 + +typedef struct socket_watcher SocketWatcher; +typedef void (*socket_cb)(SocketWatcher *watcher, int result, void *data); +typedef void (*socket_close_cb)(SocketWatcher *watcher, void *data); + +struct socket_watcher { + // Pipe/socket path, or TCP address string + char addr[ADDRESS_MAX_SIZE]; + // TCP server or unix socket (named pipe on Windows) + union { + struct { + uv_tcp_t handle; + struct addrinfo *addrinfo; + } tcp; + struct { + uv_pipe_t handle; + } pipe; + } uv; + uv_stream_t *stream; + void *data; + socket_cb cb; + socket_close_cb close_cb; + MultiQueue *events; +}; diff --git a/src/nvim/event/libuv_process.c b/src/nvim/event/libuv_process.c index 8264adb1fc..07c059423a 100644 --- a/src/nvim/event/libuv_process.c +++ b/src/nvim/event/libuv_process.c @@ -4,9 +4,9 @@ #include #include "nvim/eval/typval.h" +#include "nvim/event/defs.h" #include "nvim/event/libuv_process.h" #include "nvim/event/process.h" -#include "nvim/event/stream.h" #include "nvim/log.h" #include "nvim/os/os.h" #include "nvim/ui_client.h" diff --git a/src/nvim/event/loop.c b/src/nvim/event/loop.c index 697bdb7aa8..a2cb72771c 100644 --- a/src/nvim/event/loop.c +++ b/src/nvim/event/loop.c @@ -5,6 +5,7 @@ #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" diff --git a/src/nvim/event/loop.h b/src/nvim/event/loop.h index 442a159631..b567df5456 100644 --- a/src/nvim/event/loop.h +++ b/src/nvim/event/loop.h @@ -44,45 +44,6 @@ typedef struct loop { bool closing; ///< Set to true if loop_close() has been called } Loop; -#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) - #ifdef INCLUDE_GENERATED_DECLARATIONS # include "event/loop.h.generated.h" #endif diff --git a/src/nvim/event/multiqueue.h b/src/nvim/event/multiqueue.h index 7de307f77e..26e3bc1c30 100644 --- a/src/nvim/event/multiqueue.h +++ b/src/nvim/event/multiqueue.h @@ -1,17 +1,8 @@ #pragma once -#include +#include // IWYU pragma: keep -#include "nvim/event/defs.h" -#include "nvim/lib/queue.h" - -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) +#include "nvim/event/defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "event/multiqueue.h.generated.h" diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c index ac9c4973ce..3d9578936c 100644 --- a/src/nvim/event/process.c +++ b/src/nvim/event/process.c @@ -6,7 +6,9 @@ #include "klib/klist.h" #include "nvim/event/libuv_process.h" #include "nvim/event/loop.h" +#include "nvim/event/multiqueue.h" #include "nvim/event/process.h" +#include "nvim/event/stream.h" #include "nvim/globals.h" #include "nvim/log.h" #include "nvim/main.h" diff --git a/src/nvim/event/rstream.c b/src/nvim/event/rstream.c index 130c080db5..df97b592e4 100644 --- a/src/nvim/event/rstream.c +++ b/src/nvim/event/rstream.c @@ -5,6 +5,7 @@ #include #include +#include "nvim/event/defs.h" #include "nvim/event/loop.h" #include "nvim/event/rstream.h" #include "nvim/event/stream.h" diff --git a/src/nvim/event/signal.c b/src/nvim/event/signal.c index 2d6cccf53a..3a100812cf 100644 --- a/src/nvim/event/signal.c +++ b/src/nvim/event/signal.c @@ -1,6 +1,7 @@ #include #include +#include "nvim/event/defs.h" #include "nvim/event/loop.h" #include "nvim/event/signal.h" diff --git a/src/nvim/event/signal.h b/src/nvim/event/signal.h index 946de1b4f0..711797ca71 100644 --- a/src/nvim/event/signal.h +++ b/src/nvim/event/signal.h @@ -2,23 +2,10 @@ #include +#include "nvim/event/defs.h" #include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" -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); - -struct signal_watcher { - uv_signal_t uv; - void *data; - signal_cb cb; - signal_close_cb close_cb; - MultiQueue *events; -}; - #ifdef INCLUDE_GENERATED_DECLARATIONS # include "event/signal.h.generated.h" #endif diff --git a/src/nvim/event/socket.c b/src/nvim/event/socket.c index cde53a00e1..3c7b98bfe7 100644 --- a/src/nvim/event/socket.c +++ b/src/nvim/event/socket.c @@ -7,6 +7,7 @@ #include "nvim/ascii_defs.h" #include "nvim/charset.h" +#include "nvim/event/defs.h" #include "nvim/event/loop.h" #include "nvim/event/socket.h" #include "nvim/event/stream.h" diff --git a/src/nvim/event/socket.h b/src/nvim/event/socket.h index 504af3c7a8..24ba361efa 100644 --- a/src/nvim/event/socket.h +++ b/src/nvim/event/socket.h @@ -2,39 +2,12 @@ #include +#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" -struct socket_watcher; - -#define ADDRESS_MAX_SIZE 256 - -typedef struct socket_watcher SocketWatcher; -typedef void (*socket_cb)(SocketWatcher *watcher, int result, void *data); -typedef void (*socket_close_cb)(SocketWatcher *watcher, void *data); - -struct socket_watcher { - // Pipe/socket path, or TCP address string - char addr[ADDRESS_MAX_SIZE]; - // TCP server or unix socket (named pipe on Windows) - union { - struct { - uv_tcp_t handle; - struct addrinfo *addrinfo; - } tcp; - struct { - uv_pipe_t handle; - } pipe; - } uv; - uv_stream_t *stream; - void *data; - socket_cb cb; - socket_close_cb close_cb; - MultiQueue *events; -}; - #ifdef INCLUDE_GENERATED_DECLARATIONS # include "event/socket.h.generated.h" #endif diff --git a/src/nvim/event/stream.c b/src/nvim/event/stream.c index 8baecbbb31..886e93931b 100644 --- a/src/nvim/event/stream.c +++ b/src/nvim/event/stream.c @@ -4,6 +4,7 @@ #include #include +#include "nvim/event/defs.h" #include "nvim/event/loop.h" #include "nvim/event/stream.h" #include "nvim/log.h" diff --git a/src/nvim/event/stream.h b/src/nvim/event/stream.h index ab694e2247..588aab12b0 100644 --- a/src/nvim/event/stream.h +++ b/src/nvim/event/stream.h @@ -4,59 +4,11 @@ #include #include +#include "nvim/event/defs.h" #include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" #include "nvim/rbuffer_defs.h" -struct stream; - -typedef struct stream Stream; -/// Type of function called when the Stream buffer is filled with data -/// -/// @param stream The Stream instance -/// @param buf The associated RBuffer instance -/// @param count Number of bytes that was read. -/// @param data User-defined data -/// @param eof If the stream reached EOF. -typedef void (*stream_read_cb)(Stream *stream, RBuffer *buf, size_t count, void *data, bool eof); - -/// Type of function called when the Stream has information about a write -/// request. -/// -/// @param stream The Stream instance -/// @param data User-defined data -/// @param status 0 on success, anything else indicates failure -typedef void (*stream_write_cb)(Stream *stream, void *data, int status); -typedef void (*stream_close_cb)(Stream *stream, void *data); - -struct stream { - bool closed; - bool did_eof; - union { - uv_pipe_t pipe; - uv_tcp_t tcp; - uv_idle_t idle; -#ifdef MSWIN - uv_tty_t tty; -#endif - } uv; - uv_stream_t *uvstream; - uv_buf_t uvbuf; - RBuffer *buffer; - uv_file fd; - stream_read_cb read_cb; - stream_write_cb write_cb; - void *cb_data; - stream_close_cb close_cb, internal_close_cb; - void *close_cb_data, *internal_data; - size_t fpos; - size_t curmem; - size_t maxmem; - size_t pending_reqs; - size_t num_bytes; - MultiQueue *events; -}; - #ifdef INCLUDE_GENERATED_DECLARATIONS # include "event/stream.h.generated.h" #endif diff --git a/src/nvim/event/time.c b/src/nvim/event/time.c index 7206d74176..de837fd278 100644 --- a/src/nvim/event/time.c +++ b/src/nvim/event/time.c @@ -1,7 +1,10 @@ +#include #include #include +#include "nvim/event/defs.h" #include "nvim/event/loop.h" +#include "nvim/event/multiqueue.h" #include "nvim/event/time.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/event/time.h b/src/nvim/event/time.h index 3514566901..85171f315a 100644 --- a/src/nvim/event/time.h +++ b/src/nvim/event/time.h @@ -3,22 +3,10 @@ #include #include +#include "nvim/event/defs.h" #include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" -struct time_watcher; - -typedef struct time_watcher TimeWatcher; -typedef void (*time_cb)(TimeWatcher *watcher, void *data); - -struct time_watcher { - uv_timer_t uv; - void *data; - time_cb cb, close_cb; - MultiQueue *events; - bool blockable; -}; - #ifdef INCLUDE_GENERATED_DECLARATIONS # include "event/time.h.generated.h" #endif diff --git a/src/nvim/event/wstream.c b/src/nvim/event/wstream.c index 239f64c013..70cc5b6547 100644 --- a/src/nvim/event/wstream.c +++ b/src/nvim/event/wstream.c @@ -1,7 +1,9 @@ #include #include +#include #include +#include "nvim/event/defs.h" #include "nvim/event/loop.h" #include "nvim/event/stream.h" #include "nvim/event/wstream.h" diff --git a/src/nvim/event/wstream.h b/src/nvim/event/wstream.h index 4cba7bde8f..d61ab644f4 100644 --- a/src/nvim/event/wstream.h +++ b/src/nvim/event/wstream.h @@ -5,20 +5,10 @@ #include #include +#include "nvim/event/defs.h" #include "nvim/event/loop.h" #include "nvim/event/stream.h" -struct wbuffer; - -typedef struct wbuffer WBuffer; -typedef void (*wbuffer_data_finalizer)(void *data); - -struct wbuffer { - size_t size, refcount; - char *data; - wbuffer_data_finalizer cb; -}; - #ifdef INCLUDE_GENERATED_DECLARATIONS # include "event/wstream.h.generated.h" #endif diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 786612070e..96429c96f7 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.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/bufwrite.h" #include "nvim/change.h" diff --git a/src/nvim/ex_cmds.h b/src/nvim/ex_cmds.h index 011d42c6d9..2f576731f4 100644 --- a/src/nvim/ex_cmds.h +++ b/src/nvim/ex_cmds.h @@ -1,35 +1,6 @@ #pragma once -#include "nvim/buffer_defs.h" // IWYU pragma: keep -#include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" // IWYU pragma: export -#include "nvim/os/time_defs.h" -#include "nvim/pos_defs.h" // IWYU pragma: keep - -/// flags for do_ecmd() -enum { - ECMD_HIDE = 0x01, ///< don't free the current buffer - ECMD_SET_HELP = 0x02, ///< set b_help flag of (new) buffer before opening file - ECMD_OLDBUF = 0x04, ///< use existing buffer if it exists - ECMD_FORCEIT = 0x08, ///< ! used in Ex command - ECMD_ADDBUF = 0x10, ///< don't edit, just add to buffer list - ECMD_ALTBUF = 0x20, ///< like ECMD_ADDBUF and set the alternate file - ECMD_NOWINENTER = 0x40, ///< do not trigger BufWinEnter -}; - -/// for lnum argument in do_ecmd() -enum { - ECMD_LASTL = 0, ///< use last position in loaded file - ECMD_LAST = -1, ///< use last position in all files - ECMD_ONE = 1, ///< use first line -}; - -/// Previous :substitute replacement string definition -typedef struct { - char *sub; ///< Previous replacement string. - Timestamp timestamp; ///< Time when it was last set. - list_T *additional_elements; ///< Additional data left from ShaDa file. -} SubReplacementString; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "ex_cmds.h.generated.h" diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index 00363884ec..5ece6db8e9 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -229,3 +229,28 @@ typedef struct { bool bar; } magic; } CmdParseInfo; + +/// flags for do_ecmd() +enum { + ECMD_HIDE = 0x01, ///< don't free the current buffer + ECMD_SET_HELP = 0x02, ///< set b_help flag of (new) buffer before opening file + ECMD_OLDBUF = 0x04, ///< use existing buffer if it exists + ECMD_FORCEIT = 0x08, ///< ! used in Ex command + ECMD_ADDBUF = 0x10, ///< don't edit, just add to buffer list + ECMD_ALTBUF = 0x20, ///< like ECMD_ADDBUF and set the alternate file + ECMD_NOWINENTER = 0x40, ///< do not trigger BufWinEnter +}; + +/// for lnum argument in do_ecmd() +enum { + ECMD_LASTL = 0, ///< use last position in loaded file + ECMD_LAST = -1, ///< use last position in all files + ECMD_ONE = 1, ///< use first line +}; + +/// Previous :substitute replacement string definition +typedef struct { + char *sub; ///< Previous replacement string. + Timestamp timestamp; ///< Time when it was last set. + list_T *additional_elements; ///< Additional data left from ShaDa file. +} SubReplacementString; diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index ff80ee9e54..d8e2c54efa 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -29,7 +29,7 @@ #include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/eval/userfunc.h" -#include "nvim/event/loop.h" +#include "nvim/event/defs.h" #include "nvim/ex_cmds.h" #include "nvim/ex_cmds2.h" #include "nvim/ex_cmds_defs.h" diff --git a/src/nvim/extmark.h b/src/nvim/extmark.h index 5ba079bd12..e83c8d1257 100644 --- a/src/nvim/extmark.h +++ b/src/nvim/extmark.h @@ -5,10 +5,9 @@ #include "klib/kvec.h" #include "nvim/buffer_defs.h" // IWYU pragma: keep -#include "nvim/decoration_defs.h" // IWYU pragma: keep #include "nvim/extmark_defs.h" // IWYU pragma: export #include "nvim/macros_defs.h" -#include "nvim/marktree_defs.h" // IWYU pragma: keep +#include "nvim/marktree_defs.h" #include "nvim/pos_defs.h" EXTERN int curbuf_splice_pending INIT( = 0); diff --git a/src/nvim/input.c b/src/nvim/input.c index fb25968071..a2a9692cb4 100644 --- a/src/nvim/input.c +++ b/src/nvim/input.c @@ -7,7 +7,7 @@ #include #include "nvim/ascii_defs.h" -#include "nvim/event/multiqueue.h" +#include "nvim/event/defs.h" #include "nvim/getchar.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/log.h b/src/nvim/log.h index b277e09a0f..0a9a86c905 100644 --- a/src/nvim/log.h +++ b/src/nvim/log.h @@ -1,50 +1,18 @@ #pragma once -#include -#include - -#include "auto/config.h" +#include "nvim/log_defs.h" // IWYU pragma: export #include "nvim/macros_defs.h" // USDT probes. Example invocation: // NVIM_PROBE(nvim_foo_bar, 1, string.data); #if defined(HAVE_SYS_SDT_H) -# include // NOLINT +# include // IWYU pragma: keep # define NVIM_PROBE(name, n, ...) STAP_PROBE##n(neovim, name, __VA_ARGS__) #else # define NVIM_PROBE(name, n, ...) #endif -#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 - // uncrustify:off #if NVIM_HAS_INCLUDE() # include // IWYU pragma: keep diff --git a/src/nvim/log_defs.h b/src/nvim/log_defs.h new file mode 100644 index 0000000000..1b666720fc --- /dev/null +++ b/src/nvim/log_defs.h @@ -0,0 +1,36 @@ +#pragma once + +#include +#include + +#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 0763bbd329..77c3f22da8 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -27,7 +27,6 @@ #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/mark.c b/src/nvim/mark.c index 1e2462970f..54b1df99a2 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -2,13 +2,13 @@ #include #include +#include #include #include #include #include "nvim/ascii_defs.h" #include "nvim/buffer.h" -#include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cursor.h" #include "nvim/diff.h" @@ -16,7 +16,6 @@ #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" @@ -32,7 +31,9 @@ #include "nvim/os/fs.h" #include "nvim/os/input.h" #include "nvim/os/os.h" +#include "nvim/os/time.h" #include "nvim/path.h" +#include "nvim/pos_defs.h" #include "nvim/quickfix.h" #include "nvim/strings.h" #include "nvim/textobject.h" diff --git a/src/nvim/mark.h b/src/nvim/mark.h index 990be69028..b1a093bee0 100644 --- a/src/nvim/mark.h +++ b/src/nvim/mark.h @@ -1,54 +1,10 @@ #pragma once -#include -#include - #include "nvim/ascii_defs.h" -#include "nvim/buffer_defs.h" -#include "nvim/ex_cmds_defs.h" -#include "nvim/extmark_defs.h" +#include "nvim/ex_cmds_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/memory.h" -#include "nvim/os/time.h" -#include "nvim/pos_defs.h" - -/// 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 int mark_global_index(char name) REAL_FATTR_CONST; @@ -80,47 +36,6 @@ static inline int mark_local_index(const char name) : -1)))); } -static inline bool lt(pos_T a, pos_T b) - REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE; -static inline bool equalpos(pos_T a, pos_T b) - REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE; -static inline bool ltoreq(pos_T a, pos_T b) - REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE; -static inline void clearpos(pos_T *a) - REAL_FATTR_ALWAYS_INLINE; - -/// Return true if position a is before (less than) position b. -static inline bool lt(pos_T a, pos_T b) -{ - if (a.lnum != b.lnum) { - return a.lnum < b.lnum; - } else if (a.col != b.col) { - return a.col < b.col; - } else { - return a.coladd < b.coladd; - } -} - -/// Return true if position a and b are equal. -static inline bool equalpos(pos_T a, pos_T b) -{ - return (a.lnum == b.lnum) && (a.col == b.col) && (a.coladd == b.coladd); -} - -/// Return true if position a is less than or equal to b. -static inline bool ltoreq(pos_T a, pos_T b) -{ - return lt(a, b) || equalpos(a, b); -} - -/// Clear the pos_T structure pointed to by a. -static inline void clearpos(pos_T *a) -{ - a->lnum = 0; - a->col = 0; - a->coladd = 0; -} - /// Global marks (marks with file number or name) EXTERN xfmark_T namedfm[NGLOBALMARKS] INIT( = { 0 }); diff --git a/src/nvim/mark_defs.h b/src/nvim/mark_defs.h index 04672a5c52..a98a741363 100644 --- a/src/nvim/mark_defs.h +++ b/src/nvim/mark_defs.h @@ -84,3 +84,79 @@ typedef struct xfilemark { } xfmark_T; #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. +static inline bool lt(pos_T a, pos_T b) +{ + if (a.lnum != b.lnum) { + return a.lnum < b.lnum; + } else if (a.col != b.col) { + return a.col < b.col; + } else { + return a.coladd < b.coladd; + } +} + +static inline bool equalpos(pos_T a, pos_T b) + REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE; +/// Return true if position a and b are equal. +static inline bool equalpos(pos_T a, pos_T b) +{ + return (a.lnum == b.lnum) && (a.col == b.col) && (a.coladd == b.coladd); +} + +static inline bool ltoreq(pos_T a, pos_T b) + REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE; +/// Return true if position a is less than or equal to b. +static inline bool ltoreq(pos_T a, pos_T b) +{ + return lt(a, b) || equalpos(a, b); +} + +static inline void clearpos(pos_T *a) + REAL_FATTR_ALWAYS_INLINE; +/// Clear the pos_T structure pointed to by a. +static inline void clearpos(pos_T *a) +{ + a->lnum = 0; + a->col = 0; + a->coladd = 0; +} diff --git a/src/nvim/mbyte.h b/src/nvim/mbyte.h index 49c323282d..bae60185e2 100644 --- a/src/nvim/mbyte.h +++ b/src/nvim/mbyte.h @@ -3,12 +3,12 @@ #include #include #include +#include // IWYU pragma: keep #include "nvim/cmdexpand_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" // IWYU pragma: keep #include "nvim/func_attr.h" #include "nvim/mbyte_defs.h" // IWYU pragma: export -#include "nvim/os/os_defs.h" // IWYU pragma: export #include "nvim/types_defs.h" // IWYU pragma: keep // Return byte length of character that starts with byte "b". diff --git a/src/nvim/message.c b/src/nvim/message.c index b9935d5b5d..6aaa00cee9 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -10,6 +10,8 @@ #include #include +#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" diff --git a/src/nvim/message.h b/src/nvim/message.h index 904fb2d3ad..15a83fca2c 100644 --- a/src/nvim/message.h +++ b/src/nvim/message.h @@ -1,53 +1,12 @@ #pragma once -#include #include #include // IWYU pragma: keep -#include -#include "klib/kvec.h" -#include "nvim/api/private/defs.h" #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep #include "nvim/grid_defs.h" #include "nvim/macros_defs.h" - -/// Types of dialogs passed to do_dialog(). -enum { - VIM_GENERIC = 0, - VIM_ERROR = 1, - VIM_WARNING = 2, - VIM_INFO = 3, - VIM_QUESTION = 4, - VIM_LAST_TYPE = 4, ///< sentinel value -}; - -/// Return values for functions like vim_dialogyesno() -enum { - VIM_YES = 2, - VIM_NO = 3, - VIM_CANCEL = 4, - VIM_ALL = 5, - VIM_DISCARDALL = 6, -}; - -enum { MSG_HIST = 0x1000, }; ///< special attribute addition: Put message in history - -typedef struct { - String text; - int attr; -} HlMessageChunk; - -typedef kvec_t(HlMessageChunk) HlMessage; - -/// Message history for `:messages` -typedef struct msg_hist { - struct msg_hist *next; ///< Next message. - char *msg; ///< Message text. - const char *kind; ///< Message kind (for msg_ext) - int attr; ///< Message highlighting. - bool multiline; ///< Multiline message. - HlMessage multiattr; ///< multiattr message. -} MessageHistoryEntry; +#include "nvim/message_defs.h" // IWYU pragma: export /// First message extern MessageHistoryEntry *first_msg_hist; @@ -79,14 +38,3 @@ EXTERN int msg_listdo_overwrite INIT( = 0); #ifdef INCLUDE_GENERATED_DECLARATIONS # include "message.h.generated.h" #endif - -// Prefer using semsg(), because perror() may send the output to the wrong -// destination and mess up the screen. -#define PERROR(msg) (void)semsg("%s: %s", (msg), strerror(errno)) - -#ifndef MSWIN -/// Headless (no UI) error message handler. -# define os_errmsg(str) fprintf(stderr, "%s", (str)) -/// Headless (no UI) message handler. -# define os_msg(str) printf("%s", (str)) -#endif diff --git a/src/nvim/message_defs.h b/src/nvim/message_defs.h new file mode 100644 index 0000000000..a0237ea78f --- /dev/null +++ b/src/nvim/message_defs.h @@ -0,0 +1,59 @@ +#pragma once + +#include +#include +#include + +#include "klib/kvec.h" +#include "nvim/api/private/defs.h" +#include "nvim/grid_defs.h" +#include "nvim/macros_defs.h" + +/// Types of dialogs passed to do_dialog(). +enum { + VIM_GENERIC = 0, + VIM_ERROR = 1, + VIM_WARNING = 2, + VIM_INFO = 3, + VIM_QUESTION = 4, + VIM_LAST_TYPE = 4, ///< sentinel value +}; + +/// Return values for functions like vim_dialogyesno() +enum { + VIM_YES = 2, + VIM_NO = 3, + VIM_CANCEL = 4, + VIM_ALL = 5, + VIM_DISCARDALL = 6, +}; + +enum { MSG_HIST = 0x1000, }; ///< special attribute addition: Put message in history + +typedef struct { + String text; + int attr; +} HlMessageChunk; + +typedef kvec_t(HlMessageChunk) HlMessage; + +/// Message history for `:messages` +typedef struct msg_hist { + struct msg_hist *next; ///< Next message. + char *msg; ///< Message text. + const char *kind; ///< Message kind (for msg_ext) + int attr; ///< Message highlighting. + bool multiline; ///< Multiline message. + HlMessage multiattr; ///< multiattr message. +} MessageHistoryEntry; + +// Prefer using semsg(), because perror() may send the output to the wrong +// destination and mess up the screen. +#define PERROR(msg) (void)semsg("%s: %s", (msg), strerror(errno)) + +#ifndef MSWIN +/// Headless (no UI) error message handler. +# define os_errmsg(str) fprintf(stderr, "%s", (str)) +/// Headless (no UI) message handler. +# define os_msg(str) printf("%s", (str)) +#endif diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 2336853609..c9139f5f93 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -15,10 +15,9 @@ #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" -#include "nvim/event/stream.h" #include "nvim/event/wstream.h" #include "nvim/globals.h" #include "nvim/log.h" diff --git a/src/nvim/msgpack_rpc/channel.h b/src/nvim/msgpack_rpc/channel.h index 818bee8318..a33081eadc 100644 --- a/src/nvim/msgpack_rpc/channel.h +++ b/src/nvim/msgpack_rpc/channel.h @@ -3,11 +3,7 @@ #include // IWYU pragma: keep #include "nvim/api/private/defs.h" // IWYU pragma: keep -#include "nvim/channel.h" -#include "nvim/event/multiqueue.h" -#include "nvim/event/process.h" -#include "nvim/event/socket.h" -#include "nvim/event/wstream.h" +#include "nvim/event/defs.h" #include "nvim/macros_defs.h" #include "nvim/memory_defs.h" // IWYU pragma: keep #include "nvim/msgpack_rpc/channel_defs.h" // IWYU pragma: export diff --git a/src/nvim/msgpack_rpc/server.c b/src/nvim/msgpack_rpc/server.c index e60c1b88a5..0cc249b2b8 100644 --- a/src/nvim/msgpack_rpc/server.c +++ b/src/nvim/msgpack_rpc/server.c @@ -6,6 +6,7 @@ #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/option.c b/src/nvim/option.c index 0d0437d45f..6237b11de2 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -84,7 +84,6 @@ #include "nvim/regexp.h" #include "nvim/runtime.h" #include "nvim/search.h" -#include "nvim/sign_defs.h" #include "nvim/spell.h" #include "nvim/spellfile.h" #include "nvim/spellsuggest.h" diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 7ccf09b934..62c02989a2 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -131,6 +131,5 @@ typedef enum { } OptReqScope; #ifdef INCLUDE_GENERATED_DECLARATIONS -// Initialize the OptIndex enum. -# include "options_enum.generated.h" +# include "options_enum.generated.h" // IWYU pragma: export #endif diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 69d328754b..e096749ce3 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/event/defs.h" #include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" #include "nvim/event/rstream.h" diff --git a/src/nvim/os/pty_process_unix.c b/src/nvim/os/pty_process_unix.c index d4be3086ea..4478d9d7bd 100644 --- a/src/nvim/os/pty_process_unix.c +++ b/src/nvim/os/pty_process_unix.c @@ -32,9 +32,9 @@ #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/event/stream.h" #include "nvim/log.h" #include "nvim/os/fs.h" #include "nvim/os/os_defs.h" diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index cb8066a62d..a0401f3a24 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -11,6 +11,7 @@ #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" @@ -30,6 +31,7 @@ #include "nvim/message.h" #include "nvim/option_vars.h" #include "nvim/os/fs.h" +#include "nvim/os/os_defs.h" #include "nvim/os/shell.h" #include "nvim/os/signal.h" #include "nvim/os/time.h" diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c index 3a861b87b4..4960fa6a19 100644 --- a/src/nvim/os/signal.c +++ b/src/nvim/os/signal.c @@ -8,6 +8,7 @@ #include "nvim/autocmd.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 7f3e44f680..f842bb0ab8 100644 --- a/src/nvim/os/time.c +++ b/src/nvim/os/time.c @@ -7,7 +7,7 @@ #include #include "auto/config.h" -#include "nvim/event/loop.h" +#include "nvim/event/defs.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/log.h" diff --git a/src/nvim/os/tty.h b/src/nvim/os/tty.h index a24d875c05..3a78573189 100644 --- a/src/nvim/os/tty.h +++ b/src/nvim/os/tty.h @@ -1,5 +1,5 @@ #pragma once #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "os/tty.h.generated.h" // IWYU pragma: export +# include "os/tty.h.generated.h" #endif diff --git a/src/nvim/popupmenu.h b/src/nvim/popupmenu.h index dc741d1b77..1e4a1584ea 100644 --- a/src/nvim/popupmenu.h +++ b/src/nvim/popupmenu.h @@ -2,7 +2,7 @@ #include -#include "nvim/buffer_defs.h" +#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" diff --git a/src/nvim/spell.c b/src/nvim/spell.c index d20d113d9c..c322621038 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -90,6 +90,7 @@ #include "nvim/option_vars.h" #include "nvim/os/fs.h" #include "nvim/os/input.h" +#include "nvim/os/os_defs.h" #include "nvim/path.h" #include "nvim/pos_defs.h" #include "nvim/regexp.h" diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c index efd647a5c3..c4be6f2ec7 100644 --- a/src/nvim/spellsuggest.c +++ b/src/nvim/spellsuggest.c @@ -35,6 +35,7 @@ #include "nvim/option_vars.h" #include "nvim/os/fs.h" #include "nvim/os/input.h" +#include "nvim/os/os_defs.h" #include "nvim/pos_defs.h" #include "nvim/profile.h" #include "nvim/spell.h" diff --git a/src/nvim/statusline.h b/src/nvim/statusline.h index 59a900d566..e1038ef2ca 100644 --- a/src/nvim/statusline.h +++ b/src/nvim/statusline.h @@ -4,7 +4,7 @@ #include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/macros_defs.h" -#include "nvim/option_defs.h" +#include "nvim/option_defs.h" // IWYU pragma: keep #include "nvim/statusline_defs.h" // IWYU pragma: export /// Array defining what should be done when tabline is clicked diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 7fa02d2e0a..e67fa337b3 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -43,6 +43,7 @@ #include "nvim/optionstr.h" #include "nvim/os/fs.h" #include "nvim/os/input.h" +#include "nvim/os/os_defs.h" #include "nvim/os/time.h" #include "nvim/path.h" #include "nvim/pos_defs.h" diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 3b70ee922a..c26e2a2259 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -57,6 +57,7 @@ #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" +#include "nvim/event/defs.h" #include "nvim/event/multiqueue.h" #include "nvim/event/time.h" #include "nvim/ex_docmd.h" diff --git a/src/nvim/terminal.h b/src/nvim/terminal.h index ffa97f17b2..dd0ef3f47c 100644 --- a/src/nvim/terminal.h +++ b/src/nvim/terminal.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 6c47d1b5c7..9ba21a6afd 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -7,6 +7,7 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/event/defs.h" +#include "nvim/event/stream.h" #include "nvim/macros_defs.h" #include "nvim/main.h" #include "nvim/map_defs.h" diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index f084ab212b..496c192b95 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -15,6 +15,7 @@ #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/ui.c b/src/nvim/ui.c index 0fc0c5bf86..1f94e4da63 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -14,6 +14,7 @@ #include "nvim/buffer.h" #include "nvim/cursor_shape.h" #include "nvim/drawscreen.h" +#include "nvim/event/multiqueue.h" #include "nvim/ex_getln.h" #include "nvim/gettext.h" #include "nvim/globals.h" diff --git a/src/nvim/ui_client.c b/src/nvim/ui_client.c index d744560a86..5c9eeaabdf 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/loop.h" +#include "nvim/event/defs.h" #include "nvim/globals.h" #include "nvim/highlight.h" #include "nvim/log.h" diff --git a/src/nvim/vim_defs.h b/src/nvim/vim_defs.h index b408eb2fd7..b6cf402b02 100644 --- a/src/nvim/vim_defs.h +++ b/src/nvim/vim_defs.h @@ -56,7 +56,6 @@ typedef enum { kCdCauseAuto, ///< On 'autochdir'. } CdCause; -// bring lots of system header files #include "nvim/os/os_defs.h" // IWYU pragma: keep // return values for functions diff --git a/src/nvim/window.c b/src/nvim/window.c index 0a09d8e27d..fe9509548f 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -56,6 +56,7 @@ #include "nvim/option_defs.h" #include "nvim/option_vars.h" #include "nvim/os/fs.h" +#include "nvim/os/os_defs.h" #include "nvim/path.h" #include "nvim/plines.h" #include "nvim/pos_defs.h"