diff --git a/Makefile b/Makefile index a28e4d1326..5fb5b9958d 100644 --- a/Makefile +++ b/Makefile @@ -142,20 +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/buffer.h\ - |src/nvim/api/command.h\ |src/nvim/api/extmark.h\ - |src/nvim/api/options.h\ |src/nvim/api/private/defs.h\ |src/nvim/api/private/dispatch.h\ |src/nvim/api/private/helpers.h\ |src/nvim/api/private/validate.h\ |src/nvim/api/ui.h\ - |src/nvim/api/vim.h\ - |src/nvim/api/vimscript.h\ - |src/nvim/api/win_config.h\ - |src/nvim/api/window.h\ - |src/nvim/arglist.h\ |src/nvim/ascii.h\ |src/nvim/assert.h\ |src/nvim/autocmd.h\ @@ -163,28 +155,19 @@ iwyu: build/.ran-cmake |src/nvim/buffer.h\ |src/nvim/buffer_defs.h\ |src/nvim/buffer_updates.h\ - |src/nvim/bufwrite.h\ - |src/nvim/change.h\ |src/nvim/channel.h\ |src/nvim/charset.h\ |src/nvim/cmdexpand.h\ - |src/nvim/cmdexpand_defs.h\ |src/nvim/cmdhist.h\ |src/nvim/context.h\ - |src/nvim/cursor.h\ |src/nvim/decoration.h\ |src/nvim/decoration_defs.h\ |src/nvim/decoration_provider.h\ |src/nvim/diff.h\ - |src/nvim/digraph.h\ |src/nvim/drawline.h\ |src/nvim/drawscreen.h\ - |src/nvim/edit.h\ |src/nvim/eval.h\ - |src/nvim/eval/buffer.h\ - |src/nvim/eval/decode.h\ |src/nvim/eval/encode.h\ - |src/nvim/eval/funcs.h\ |src/nvim/eval/typval.h\ |src/nvim/eval/typval_defs.h\ |src/nvim/eval/typval_encode.h\ @@ -204,46 +187,34 @@ iwyu: build/.ran-cmake |src/nvim/ex_cmds.h\ |src/nvim/ex_cmds_defs.h\ |src/nvim/ex_docmd.h\ - |src/nvim/ex_eval_defs.h\ |src/nvim/ex_getln.h\ |src/nvim/extmark.h\ |src/nvim/extmark_defs.h\ |src/nvim/file_search.h\ |src/nvim/fileio.h\ |src/nvim/fold.h\ - |src/nvim/fold_defs.h\ |src/nvim/garray.h\ |src/nvim/getchar.h\ |src/nvim/globals.h\ |src/nvim/grid.h\ - |src/nvim/grid_defs.h\ - |src/nvim/hashtab.h\ |src/nvim/highlight.h\ |src/nvim/highlight_defs.h\ |src/nvim/highlight_group.h\ - |src/nvim/indent.h\ - |src/nvim/indent_c.h\ |src/nvim/input.h\ |src/nvim/insexpand.h\ |src/nvim/keycodes.h\ - |src/nvim/linematch.h\ |src/nvim/log.h\ |src/nvim/lua/executor.h\ |src/nvim/macros.h\ |src/nvim/main.h\ |src/nvim/map.h\ - |src/nvim/mapping.h\ - |src/nvim/mapping_defs.h\ |src/nvim/mark.h\ |src/nvim/mark_defs.h\ |src/nvim/marktree.h\ - |src/nvim/match.h\ |src/nvim/mbyte.h\ |src/nvim/mbyte_defs.h\ |src/nvim/memfile_defs.h\ - |src/nvim/memline.h\ |src/nvim/memory.h\ - |src/nvim/menu.h\ |src/nvim/message.h\ |src/nvim/mouse.h\ |src/nvim/move.h\ @@ -254,31 +225,22 @@ iwyu: build/.ran-cmake |src/nvim/normal.h\ |src/nvim/ops.h\ |src/nvim/option.h\ - |src/nvim/option_defs.h\ |src/nvim/option_vars.h\ |src/nvim/os/fileio.h\ - |src/nvim/os/fs.h\ |src/nvim/os/input.h\ - |src/nvim/os/lang.h\ |src/nvim/os/pty_conpty_win.h\ |src/nvim/os/pty_process_unix.h\ |src/nvim/os/pty_process_win.h\ |src/nvim/path.h\ |src/nvim/plines.h\ |src/nvim/popupmenu.h\ - |src/nvim/profile.h\ - |src/nvim/quickfix.h\ - |src/nvim/regexp.h\ - |src/nvim/regexp_defs.h\ |src/nvim/search.h\ - |src/nvim/sign.h\ |src/nvim/spell.h\ |src/nvim/spell_defs.h\ |src/nvim/statusline.h\ |src/nvim/statusline_defs.h\ |src/nvim/strings.h\ |src/nvim/syntax.h\ - |src/nvim/testing.h\ |src/nvim/textformat.h\ |src/nvim/textobject.h\ |src/nvim/tui/input.h\ @@ -287,8 +249,6 @@ iwyu: build/.ran-cmake |src/nvim/ui.h\ |src/nvim/ui_client.h\ |src/nvim/ui_compositor.h\ - |src/nvim/undo.h\ - |src/nvim/usercmd.h\ |src/nvim/version.h\ |src/nvim/vim.h\ |src/nvim/viml/parser/expressions.h\ diff --git a/src/clint.py b/src/clint.py index c6d7d1e8a3..c9e6ca9973 100755 --- a/src/clint.py +++ b/src/clint.py @@ -897,20 +897,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/buffer.h", - "src/nvim/api/command.h", "src/nvim/api/extmark.h", - "src/nvim/api/options.h", "src/nvim/api/private/defs.h", "src/nvim/api/private/dispatch.h", "src/nvim/api/private/helpers.h", "src/nvim/api/private/validate.h", "src/nvim/api/ui.h", - "src/nvim/api/vim.h", - "src/nvim/api/vimscript.h", - "src/nvim/api/win_config.h", - "src/nvim/api/window.h", - "src/nvim/arglist.h", "src/nvim/ascii.h", "src/nvim/assert.h", "src/nvim/autocmd.h", @@ -918,28 +910,19 @@ def CheckIncludes(filename, lines, error): "src/nvim/buffer.h", "src/nvim/buffer_defs.h", "src/nvim/buffer_updates.h", - "src/nvim/bufwrite.h", - "src/nvim/change.h", "src/nvim/channel.h", "src/nvim/charset.h", "src/nvim/cmdexpand.h", - "src/nvim/cmdexpand_defs.h", "src/nvim/cmdhist.h", "src/nvim/context.h", - "src/nvim/cursor.h", "src/nvim/decoration.h", "src/nvim/decoration_defs.h", "src/nvim/decoration_provider.h", "src/nvim/diff.h", - "src/nvim/digraph.h", "src/nvim/drawline.h", "src/nvim/drawscreen.h", - "src/nvim/edit.h", "src/nvim/eval.h", - "src/nvim/eval/buffer.h", - "src/nvim/eval/decode.h", "src/nvim/eval/encode.h", - "src/nvim/eval/funcs.h", "src/nvim/eval/typval.h", "src/nvim/eval/typval_defs.h", "src/nvim/eval/typval_encode.h", @@ -959,46 +942,34 @@ def CheckIncludes(filename, lines, error): "src/nvim/ex_cmds.h", "src/nvim/ex_cmds_defs.h", "src/nvim/ex_docmd.h", - "src/nvim/ex_eval_defs.h", "src/nvim/ex_getln.h", "src/nvim/extmark.h", "src/nvim/extmark_defs.h", "src/nvim/file_search.h", "src/nvim/fileio.h", "src/nvim/fold.h", - "src/nvim/fold_defs.h", "src/nvim/garray.h", "src/nvim/getchar.h", "src/nvim/globals.h", "src/nvim/grid.h", - "src/nvim/grid_defs.h", - "src/nvim/hashtab.h", "src/nvim/highlight.h", "src/nvim/highlight_defs.h", "src/nvim/highlight_group.h", - "src/nvim/indent.h", - "src/nvim/indent_c.h", "src/nvim/input.h", "src/nvim/insexpand.h", "src/nvim/keycodes.h", - "src/nvim/linematch.h", "src/nvim/log.h", "src/nvim/lua/executor.h", "src/nvim/macros.h", "src/nvim/main.h", "src/nvim/map.h", - "src/nvim/mapping.h", - "src/nvim/mapping_defs.h", "src/nvim/mark.h", "src/nvim/mark_defs.h", "src/nvim/marktree.h", - "src/nvim/match.h", "src/nvim/mbyte.h", "src/nvim/mbyte_defs.h", "src/nvim/memfile_defs.h", - "src/nvim/memline.h", "src/nvim/memory.h", - "src/nvim/menu.h", "src/nvim/message.h", "src/nvim/mouse.h", "src/nvim/move.h", @@ -1009,31 +980,22 @@ def CheckIncludes(filename, lines, error): "src/nvim/normal.h", "src/nvim/ops.h", "src/nvim/option.h", - "src/nvim/option_defs.h", "src/nvim/option_vars.h", "src/nvim/os/fileio.h", - "src/nvim/os/fs.h", "src/nvim/os/input.h", - "src/nvim/os/lang.h", "src/nvim/os/pty_conpty_win.h", "src/nvim/os/pty_process_unix.h", "src/nvim/os/pty_process_win.h", "src/nvim/path.h", "src/nvim/plines.h", "src/nvim/popupmenu.h", - "src/nvim/profile.h", - "src/nvim/quickfix.h", - "src/nvim/regexp.h", - "src/nvim/regexp_defs.h", "src/nvim/search.h", - "src/nvim/sign.h", "src/nvim/spell.h", "src/nvim/spell_defs.h", "src/nvim/statusline.h", "src/nvim/statusline_defs.h", "src/nvim/strings.h", "src/nvim/syntax.h", - "src/nvim/testing.h", "src/nvim/textformat.h", "src/nvim/textobject.h", "src/nvim/tui/input.h", @@ -1042,8 +1004,6 @@ def CheckIncludes(filename, lines, error): "src/nvim/ui.h", "src/nvim/ui_client.h", "src/nvim/ui_compositor.h", - "src/nvim/undo.h", - "src/nvim/usercmd.h", "src/nvim/version.h", "src/nvim/vim.h", "src/nvim/viml/parser/expressions.h", diff --git a/src/nvim/api/buffer.h b/src/nvim/api/buffer.h index 557cf8db0c..f3971c1d30 100644 --- a/src/nvim/api/buffer.h +++ b/src/nvim/api/buffer.h @@ -3,9 +3,9 @@ #include // IWYU pragma: keep #include // IWYU pragma: keep -#include "nvim/api/keysets_defs.h" +#include "nvim/api/keysets_defs.h" // IWYU pragma: keep #include "nvim/api/private/defs.h" // IWYU pragma: keep -#include "nvim/buffer_defs.h" +#include "nvim/buffer_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "api/buffer.h.generated.h" diff --git a/src/nvim/api/command.h b/src/nvim/api/command.h index 95f0e05993..1cccbfb4c7 100644 --- a/src/nvim/api/command.h +++ b/src/nvim/api/command.h @@ -2,7 +2,7 @@ #include // IWYU pragma: keep -#include "nvim/api/keysets_defs.h" +#include "nvim/api/keysets_defs.h" // IWYU pragma: keep #include "nvim/api/private/defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/api/extmark.h b/src/nvim/api/extmark.h index 2989dee53d..491e468d95 100644 --- a/src/nvim/api/extmark.h +++ b/src/nvim/api/extmark.h @@ -2,7 +2,7 @@ #include // IWYU pragma: keep -#include "nvim/api/keysets_defs.h" +#include "nvim/api/keysets_defs.h" // IWYU pragma: keep #include "nvim/api/private/defs.h" // IWYU pragma: keep #include "nvim/decoration_defs.h" // IWYU pragma: keep #include "nvim/macros.h" diff --git a/src/nvim/api/options.h b/src/nvim/api/options.h index e44ed44c80..c16c6088b3 100644 --- a/src/nvim/api/options.h +++ b/src/nvim/api/options.h @@ -2,7 +2,7 @@ #include // IWYU pragma: keep -#include "nvim/api/keysets_defs.h" +#include "nvim/api/keysets_defs.h" // IWYU pragma: keep #include "nvim/api/private/defs.h" // IWYU pragma: keep #include "nvim/option_defs.h" // IWYU pragma: keep diff --git a/src/nvim/api/private/dispatch.h b/src/nvim/api/private/dispatch.h index 3d12b941f4..6a2c9eaf54 100644 --- a/src/nvim/api/private/dispatch.h +++ b/src/nvim/api/private/dispatch.h @@ -4,7 +4,7 @@ #include #include "nvim/api/private/defs.h" -#include "nvim/memory.h" +#include "nvim/memory_defs.h" #include "nvim/types_defs.h" typedef Object (*ApiDispatchWrapper)(uint64_t channel_id, Array args, Arena *arena, Error *error); diff --git a/src/nvim/api/vim.h b/src/nvim/api/vim.h index b2ebacb309..b620158751 100644 --- a/src/nvim/api/vim.h +++ b/src/nvim/api/vim.h @@ -2,7 +2,7 @@ #include // IWYU pragma: keep -#include "nvim/api/keysets_defs.h" +#include "nvim/api/keysets_defs.h" // IWYU pragma: keep #include "nvim/api/private/defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/api/vimscript.h b/src/nvim/api/vimscript.h index c068542311..c315e932e9 100644 --- a/src/nvim/api/vimscript.h +++ b/src/nvim/api/vimscript.h @@ -2,7 +2,7 @@ #include // IWYU pragma: keep -#include "nvim/api/keysets_defs.h" +#include "nvim/api/keysets_defs.h" // IWYU pragma: keep #include "nvim/api/private/defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/api/win_config.h b/src/nvim/api/win_config.h index 47e441a592..6df8ed13fa 100644 --- a/src/nvim/api/win_config.h +++ b/src/nvim/api/win_config.h @@ -2,7 +2,7 @@ #include // IWYU pragma: keep -#include "nvim/api/keysets_defs.h" +#include "nvim/api/keysets_defs.h" // IWYU pragma: keep #include "nvim/api/private/defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/api/window.h b/src/nvim/api/window.h index 600d6956b5..a5c9f86225 100644 --- a/src/nvim/api/window.h +++ b/src/nvim/api/window.h @@ -1,6 +1,6 @@ #pragma once -#include "nvim/api/keysets_defs.h" +#include "nvim/api/keysets_defs.h" // IWYU pragma: keep #include "nvim/api/private/defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/arglist.h b/src/nvim/arglist.h index bcb5c8f565..97729f466c 100644 --- a/src/nvim/arglist.h +++ b/src/nvim/arglist.h @@ -4,7 +4,7 @@ #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" +#include "nvim/types_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "arglist.h.generated.h" diff --git a/src/nvim/bufwrite.h b/src/nvim/bufwrite.h index 38d4d7745e..9ed6216847 100644 --- a/src/nvim/bufwrite.h +++ b/src/nvim/bufwrite.h @@ -2,7 +2,7 @@ #include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep -#include "nvim/pos_defs.h" +#include "nvim/pos_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "bufwrite.h.generated.h" diff --git a/src/nvim/change.h b/src/nvim/change.h index 1c90b67fe3..06155b6da6 100644 --- a/src/nvim/change.h +++ b/src/nvim/change.h @@ -1,15 +1,17 @@ #pragma once #include "nvim/buffer_defs.h" // IWYU pragma: keep -#include "nvim/pos_defs.h" +#include "nvim/pos_defs.h" // IWYU pragma: keep -// flags for open_line() -#define OPENLINE_DELSPACES 0x01 // delete spaces after cursor -#define OPENLINE_DO_COM 0x02 // format comments -#define OPENLINE_KEEPTRAIL 0x04 // keep trailing spaces -#define OPENLINE_MARKFIX 0x08 // fix mark positions -#define OPENLINE_COM_LIST 0x10 // format comments with list/2nd line indent -#define OPENLINE_FORMAT 0x20 // formatting long comment +/// flags for open_line() +enum { + OPENLINE_DELSPACES = 0x01, ///< delete spaces after cursor + OPENLINE_DO_COM = 0x02, ///< format comments + OPENLINE_KEEPTRAIL = 0x04, ///< keep trailing spaces + OPENLINE_MARKFIX = 0x08, ///< fix mark positions + OPENLINE_COM_LIST = 0x10, ///< format comments with list/2nd line indent + OPENLINE_FORMAT = 0x20, ///< formatting long comment +}; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "change.h.generated.h" diff --git a/src/nvim/cmdexpand.h b/src/nvim/cmdexpand.h index 4ae702f18d..b0772d26a3 100644 --- a/src/nvim/cmdexpand.h +++ b/src/nvim/cmdexpand.h @@ -4,7 +4,7 @@ #include "nvim/eval/typval_defs.h" // IWYU pragma: keep #include "nvim/ex_getln.h" #include "nvim/garray_defs.h" // IWYU pragma: keep -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep // Values for nextwild() and ExpandOne(). See ExpandOne() for meaning. diff --git a/src/nvim/cursor.h b/src/nvim/cursor.h index ea63f7c1e5..d50976b598 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" +#include "nvim/pos_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "cursor.h.generated.h" diff --git a/src/nvim/digraph.h b/src/nvim/digraph.h index 792e859991..267004124b 100644 --- a/src/nvim/digraph.h +++ b/src/nvim/digraph.h @@ -4,7 +4,7 @@ #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 -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "digraph.h.generated.h" diff --git a/src/nvim/edit.h b/src/nvim/edit.h index 7cf4141045..434b653f7b 100644 --- a/src/nvim/edit.h +++ b/src/nvim/edit.h @@ -2,29 +2,37 @@ #include "nvim/autocmd_defs.h" // IWYU pragma: keep #include "nvim/buffer_defs.h" // IWYU pragma: keep -#include "nvim/pos_defs.h" +#include "nvim/pos_defs.h" // IWYU pragma: keep -// Values for in_cinkeys() -#define KEY_OPEN_FORW 0x101 -#define KEY_OPEN_BACK 0x102 -#define KEY_COMPLETE 0x103 // end of completion +/// Values for in_cinkeys() +enum { + KEY_OPEN_FORW = 0x101, + KEY_OPEN_BACK = 0x102, + KEY_COMPLETE = 0x103, ///< end of completion +}; -// Values for change_indent() -#define INDENT_SET 1 // set indent -#define INDENT_INC 2 // increase indent -#define INDENT_DEC 3 // decrease indent +/// Values for change_indent() +enum { + INDENT_SET = 1, ///< set indent + INDENT_INC = 2, ///< increase indent + INDENT_DEC = 3, ///< decrease indent +}; -// flags for beginline() -#define BL_WHITE 1 // cursor on first non-white in the line -#define BL_SOL 2 // use 'sol' option -#define BL_FIX 4 // don't leave cursor on a NUL +/// flags for beginline() +enum { + BL_WHITE = 1, ///< cursor on first non-white in the line + BL_SOL = 2, ///< use 'sol' option + BL_FIX = 4, ///< don't leave cursor on a NUL +}; -// flags for insertchar() -#define INSCHAR_FORMAT 1 // force formatting -#define INSCHAR_DO_COM 2 // format comments -#define INSCHAR_CTRLV 4 // char typed just after CTRL-V -#define INSCHAR_NO_FEX 8 // don't use 'formatexpr' -#define INSCHAR_COM_LIST 16 // format comments with list/2nd line indent +/// flags for insertchar() +enum { + INSCHAR_FORMAT = 1, ///< force formatting + INSCHAR_DO_COM = 2, ///< format comments + INSCHAR_CTRLV = 4, ///< char typed just after CTRL-V + INSCHAR_NO_FEX = 8, ///< don't use 'formatexpr' + INSCHAR_COM_LIST = 16, ///< format comments with list/2nd line indent +}; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "edit.h.generated.h" diff --git a/src/nvim/eval/buffer.h b/src/nvim/eval/buffer.h index 106a499bad..1d346b99a5 100644 --- a/src/nvim/eval/buffer.h +++ b/src/nvim/eval/buffer.h @@ -2,7 +2,7 @@ #include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" // IWYU pragma: keep -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "eval/buffer.h.generated.h" diff --git a/src/nvim/eval/decode.h b/src/nvim/eval/decode.h index 1c0fd445f1..c0d10a469a 100644 --- a/src/nvim/eval/decode.h +++ b/src/nvim/eval/decode.h @@ -4,7 +4,7 @@ #include // IWYU pragma: keep #include "nvim/eval/typval_defs.h" // IWYU pragma: keep -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "eval/decode.h.generated.h" diff --git a/src/nvim/eval/funcs.h b/src/nvim/eval/funcs.h index 09f709be06..0c345dacb4 100644 --- a/src/nvim/eval/funcs.h +++ b/src/nvim/eval/funcs.h @@ -3,18 +3,20 @@ #include #include -#include "nvim/api/private/dispatch.h" -#include "nvim/buffer_defs.h" -#include "nvim/cmdexpand_defs.h" +#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 #include "nvim/types_defs.h" /// Prototype of C function that implements Vimscript function typedef void (*VimLFunc)(typval_T *args, typval_T *rvar, EvalFuncData data); /// Special flags for base_arg @see EvalFuncDef -#define BASE_NONE 0 ///< Not a method (no base argument). -#define BASE_LAST UINT8_MAX ///< Use the last argument as the method base. +enum { + BASE_NONE = 0, ///< Not a method (no base argument). + BASE_LAST = UINT8_MAX, ///< Use the last argument as the method base. +}; /// Structure holding Vimscript function definition typedef struct { diff --git a/src/nvim/eval/vars.h b/src/nvim/eval/vars.h index 849d0c4229..3512152184 100644 --- a/src/nvim/eval/vars.h +++ b/src/nvim/eval/vars.h @@ -6,7 +6,7 @@ #include "nvim/garray_defs.h" // IWYU pragma: keep #include "nvim/hashtab.h" #include "nvim/option_defs.h" // IWYU pragma: keep -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "eval/vars.h.generated.h" diff --git a/src/nvim/ex_cmds.h b/src/nvim/ex_cmds.h index 529009415b..de13f03197 100644 --- a/src/nvim/ex_cmds.h +++ b/src/nvim/ex_cmds.h @@ -6,7 +6,7 @@ #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" // IWYU pragma: export #include "nvim/os/time.h" -#include "nvim/pos_defs.h" +#include "nvim/pos_defs.h" // IWYU pragma: keep // flags for do_ecmd() #define ECMD_HIDE 0x01 // don't free the current buffer diff --git a/src/nvim/ex_docmd.h b/src/nvim/ex_docmd.h index 1ccd112e2a..3781ba1a34 100644 --- a/src/nvim/ex_docmd.h +++ b/src/nvim/ex_docmd.h @@ -2,29 +2,34 @@ #include -#include "nvim/buffer_defs.h" -#include "nvim/cmdexpand_defs.h" -#include "nvim/ex_cmds_defs.h" +#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/getchar_defs.h" #include "nvim/globals.h" +#include "nvim/types_defs.h" // IWYU pragma: keep -// flags for do_cmdline() -#define DOCMD_VERBOSE 0x01 // included command in error message -#define DOCMD_NOWAIT 0x02 // don't call wait_return() and friends -#define DOCMD_REPEAT 0x04 // repeat exec. until getline() returns NULL -#define DOCMD_KEYTYPED 0x08 // don't reset KeyTyped -#define DOCMD_EXCRESET 0x10 // reset exception environment (for debugging -#define DOCMD_KEEPLINE 0x20 // keep typed line for repeating with "." +/// flags for do_cmdline() +enum { + DOCMD_VERBOSE = 0x01, ///< included command in error message + DOCMD_NOWAIT = 0x02, ///< don't call wait_return() and friends + DOCMD_REPEAT = 0x04, ///< repeat exec. until getline() returns NULL + DOCMD_KEYTYPED = 0x08, ///< don't reset KeyTyped + DOCMD_EXCRESET = 0x10, ///< reset exception environment (for debugging + DOCMD_KEEPLINE = 0x20, ///< keep typed line for repeating with "." +}; -// defines for eval_vars() -#define VALID_PATH 1 -#define VALID_HEAD 2 +/// defines for eval_vars() +enum { + VALID_PATH = 1, + VALID_HEAD = 2, +}; // Whether a command index indicates a user command. #define IS_USER_CMDIDX(idx) ((int)(idx) < 0) -// Structure used to save the current state. Used when executing Normal mode -// commands while in any other mode. +/// Structure used to save the current state. Used when executing Normal mode +/// commands while in any other mode. typedef struct { int save_msg_scroll; int save_restart_edit; diff --git a/src/nvim/ex_getln.h b/src/nvim/ex_getln.h index 7e2a999b7d..967aab6138 100644 --- a/src/nvim/ex_getln.h +++ b/src/nvim/ex_getln.h @@ -5,9 +5,9 @@ #include "klib/kvec.h" #include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval_defs.h" -#include "nvim/ex_cmds_defs.h" -#include "nvim/option_defs.h" -#include "nvim/types_defs.h" +#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 struct cmdline_info; diff --git a/src/nvim/file_search.h b/src/nvim/file_search.h index ab47445a79..d4b5c5d352 100644 --- a/src/nvim/file_search.h +++ b/src/nvim/file_search.h @@ -3,7 +3,7 @@ #include #include "nvim/globals.h" -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep // Flags for find_file_*() functions. #define FINDFILE_FILE 0 // only files diff --git a/src/nvim/getchar.h b/src/nvim/getchar.h index 612a6d2a0c..177a021706 100644 --- a/src/nvim/getchar.h +++ b/src/nvim/getchar.h @@ -6,7 +6,7 @@ #include "nvim/eval/typval_defs.h" // IWYU pragma: keep #include "nvim/getchar_defs.h" // IWYU pragma: export #include "nvim/os/fileio.h" -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep /// Argument for flush_buffers(). typedef enum { diff --git a/src/nvim/hashtab.h b/src/nvim/hashtab.h index c1981a9160..bf109ecae8 100644 --- a/src/nvim/hashtab.h +++ b/src/nvim/hashtab.h @@ -2,8 +2,6 @@ #include -#include "nvim/types_defs.h" - /// Magic number used for hashitem "hi_key" value indicating a deleted item /// /// Only the address is used. diff --git a/src/nvim/highlight_group.h b/src/nvim/highlight_group.h index 03e1508539..ca7bd36271 100644 --- a/src/nvim/highlight_group.h +++ b/src/nvim/highlight_group.h @@ -5,7 +5,7 @@ #include "nvim/api/private/helpers.h" #include "nvim/cmdexpand_defs.h" // IWYU pragma: keep #include "nvim/highlight_defs.h" -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep #define MAX_HL_ID 20000 // maximum value for a highlight ID. diff --git a/src/nvim/indent.h b/src/nvim/indent.h index 13288584d9..b64015958c 100644 --- a/src/nvim/indent.h +++ b/src/nvim/indent.h @@ -2,16 +2,18 @@ #include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep -#include "nvim/pos_defs.h" -#include "nvim/types_defs.h" +#include "nvim/pos_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep typedef int (*IndentGetter)(void); -// flags for set_indent() -#define SIN_CHANGED 1 // call changed_bytes() when line changed -#define SIN_INSERT 2 // insert indent before existing text -#define SIN_UNDO 4 // save line for undo before changing it -#define SIN_NOMARK 8 // don't adjust extmarks +/// flags for set_indent() +enum { + SIN_CHANGED = 1, ///< call changed_bytes() when line changed + SIN_INSERT = 2, ///< insert indent before existing text + SIN_UNDO = 4, ///< save line for undo before changing it + SIN_NOMARK = 8, ///< don't adjust extmarks +}; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "indent.h.generated.h" diff --git a/src/nvim/indent_c.h b/src/nvim/indent_c.h index 82de7369b4..64ba67a42b 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" +#include "nvim/pos_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "indent_c.h.generated.h" diff --git a/src/nvim/insexpand.h b/src/nvim/insexpand.h index 3ad0ac05de..39584321ef 100644 --- a/src/nvim/insexpand.h +++ b/src/nvim/insexpand.h @@ -2,8 +2,8 @@ #include "nvim/macros.h" #include "nvim/option_defs.h" // IWYU pragma: keep -#include "nvim/pos_defs.h" -#include "nvim/types_defs.h" +#include "nvim/pos_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep #include "nvim/vim.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/linematch.h b/src/nvim/linematch.h index 3f3cdae171..eaf0d54bec 100644 --- a/src/nvim/linematch.h +++ b/src/nvim/linematch.h @@ -2,7 +2,7 @@ #include // IWYU pragma: keep -#include "nvim/pos_defs.h" +#include "nvim/pos_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "linematch.h.generated.h" diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index cac0031ff4..7a39838c7e 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include diff --git a/src/nvim/mapping.h b/src/nvim/mapping.h index af614c0276..ffe7ab4290 100644 --- a/src/nvim/mapping.h +++ b/src/nvim/mapping.h @@ -1,10 +1,9 @@ #pragma once -#include -#include -#include +#include // IWYU pragma: keep +#include // IWYU pragma: keep -#include "nvim/api/keysets_defs.h" +#include "nvim/api/keysets_defs.h" // IWYU pragma: keep #include "nvim/api/private/defs.h" // IWYU pragma: keep #include "nvim/cmdexpand_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" // IWYU pragma: keep @@ -12,7 +11,7 @@ #include "nvim/mapping_defs.h" // IWYU pragma: export #include "nvim/option_defs.h" // IWYU pragma: keep #include "nvim/regexp_defs.h" // IWYU pragma: keep -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep /// Used for the first argument of do_map() enum { diff --git a/src/nvim/match.h b/src/nvim/match.h index e27b6128cd..8dcf4fa470 100644 --- a/src/nvim/match.h +++ b/src/nvim/match.h @@ -3,7 +3,7 @@ #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/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "match.h.generated.h" diff --git a/src/nvim/mbyte.h b/src/nvim/mbyte.h index daeee15fd2..5623d0c106 100644 --- a/src/nvim/mbyte.h +++ b/src/nvim/mbyte.h @@ -10,7 +10,7 @@ #include "nvim/grid_defs.h" #include "nvim/mbyte_defs.h" // IWYU pragma: export #include "nvim/os/os_defs.h" -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep // Return byte length of character that starts with byte "b". // Returns 1 for a single-byte character. diff --git a/src/nvim/memline.h b/src/nvim/memline.h index 77e2abfb6d..e70a8e423e 100644 --- a/src/nvim/memline.h +++ b/src/nvim/memline.h @@ -2,8 +2,8 @@ #include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/memline_defs.h" // IWYU pragma: export -#include "nvim/pos_defs.h" -#include "nvim/types_defs.h" +#include "nvim/pos_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "memline.h.generated.h" diff --git a/src/nvim/menu.h b/src/nvim/menu.h index 0a9fbf35c4..9644386003 100644 --- a/src/nvim/menu.h +++ b/src/nvim/menu.h @@ -1,11 +1,9 @@ #pragma once -#include - #include "nvim/cmdexpand_defs.h" // IWYU pragma: keep #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep #include "nvim/menu_defs.h" // IWYU pragma: export -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "menu.h.generated.h" diff --git a/src/nvim/move.h b/src/nvim/move.h index 3904b6ffa3..137940f87e 100644 --- a/src/nvim/move.h +++ b/src/nvim/move.h @@ -4,7 +4,7 @@ #include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" // IWYU pragma: keep -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep #include "nvim/vim.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/option.h b/src/nvim/option.h index 94aa1d8cec..f5cd484fd6 100644 --- a/src/nvim/option.h +++ b/src/nvim/option.h @@ -9,7 +9,7 @@ #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep #include "nvim/option_defs.h" // IWYU pragma: export #include "nvim/search.h" -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep /// The options that are local to a window or buffer have "indir" set to one of /// these values. Special values: diff --git a/src/nvim/os/fs.h b/src/nvim/os/fs.h index 8ba0177909..56dd657f70 100644 --- a/src/nvim/os/fs.h +++ b/src/nvim/os/fs.h @@ -6,7 +6,7 @@ #include // IWYU pragma: keep #include "nvim/os/fs_defs.h" // IWYU pragma: export -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "os/fs.h.generated.h" diff --git a/src/nvim/os/lang.h b/src/nvim/os/lang.h index 87013ccec9..4e7bf82195 100644 --- a/src/nvim/os/lang.h +++ b/src/nvim/os/lang.h @@ -1,8 +1,8 @@ #pragma once -#include "nvim/cmdexpand_defs.h" -#include "nvim/ex_cmds_defs.h" -#include "nvim/types_defs.h" +#include "nvim/cmdexpand_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 "os/lang.h.generated.h" diff --git a/src/nvim/path.h b/src/nvim/path.h index 19b6081b42..89f939dd02 100644 --- a/src/nvim/path.h +++ b/src/nvim/path.h @@ -4,7 +4,7 @@ #include "nvim/func_attr.h" #include "nvim/garray_defs.h" // IWYU pragma: keep -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep // Flags for expand_wildcards() #define EW_DIR 0x01 // include directory names diff --git a/src/nvim/plines.h b/src/nvim/plines.h index 0d3dd9f059..6aede88c8b 100644 --- a/src/nvim/plines.h +++ b/src/nvim/plines.h @@ -5,7 +5,7 @@ #include "nvim/buffer_defs.h" #include "nvim/marktree.h" -#include "nvim/pos_defs.h" +#include "nvim/pos_defs.h" // IWYU pragma: keep /// Argument for lbr_chartabsize(). typedef struct { diff --git a/src/nvim/profile.h b/src/nvim/profile.h index 839c435b3e..1a1800c279 100644 --- a/src/nvim/profile.h +++ b/src/nvim/profile.h @@ -5,7 +5,7 @@ #include "nvim/cmdexpand_defs.h" // IWYU pragma: keep #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep -#include "nvim/runtime.h" +#include "nvim/runtime_defs.h" // IWYU pragma: keep #define TIME_MSG(s) do { \ if (time_fd != NULL) time_msg(s, NULL); \ diff --git a/src/nvim/quickfix.h b/src/nvim/quickfix.h index 2ad92ab6fe..9c49564d57 100644 --- a/src/nvim/quickfix.h +++ b/src/nvim/quickfix.h @@ -3,13 +3,15 @@ #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/pos_defs.h" -#include "nvim/types_defs.h" +#include "nvim/pos_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep -// flags for skip_vimgrep_pat() -#define VGR_GLOBAL 1 -#define VGR_NOJUMP 2 -#define VGR_FUZZY 4 +/// flags for skip_vimgrep_pat() +enum { + VGR_GLOBAL = 1, + VGR_NOJUMP = 2, + VGR_FUZZY = 4, +}; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "quickfix.h.generated.h" diff --git a/src/nvim/regexp.h b/src/nvim/regexp.h index b618f01e59..447f4860a9 100644 --- a/src/nvim/regexp.h +++ b/src/nvim/regexp.h @@ -1,9 +1,9 @@ #pragma once #include "nvim/buffer_defs.h" // IWYU pragma: keep -#include "nvim/pos_defs.h" +#include "nvim/pos_defs.h" // IWYU pragma: keep #include "nvim/regexp_defs.h" // IWYU pragma: export -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep // Second argument for vim_regcomp(). #define RE_MAGIC 1 ///< 'magic' option diff --git a/src/nvim/regexp_defs.h b/src/nvim/regexp_defs.h index f18bceb486..079f3b6929 100644 --- a/src/nvim/regexp_defs.h +++ b/src/nvim/regexp_defs.h @@ -10,6 +10,7 @@ #pragma once #include +#include #include "nvim/pos_defs.h" #include "nvim/types_defs.h" @@ -32,25 +33,29 @@ typedef enum { MAGIC_ALL = 4, ///< "\v" very magic } magic_T; -// 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". -#define NSUBEXP 10 +/// 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". +enum { NSUBEXP = 10, }; -// In the NFA engine: how many braces are allowed. -// TODO(RE): Use dynamic memory allocation instead of static, like here -#define NFA_MAX_BRACES 20 +/// In the NFA engine: how many braces are allowed. +/// TODO(RE): Use dynamic memory allocation instead of static, like here +enum { NFA_MAX_BRACES = 20, }; -// In the NFA engine: how many states are allowed. -#define NFA_MAX_STATES 100000 -#define NFA_TOO_EXPENSIVE (-1) +/// In the NFA engine: how many states are allowed. +enum { + NFA_MAX_STATES = 100000, + NFA_TOO_EXPENSIVE = -1, +}; -// Which regexp engine to use? Needed for vim_regcomp(). -// Must match with 'regexpengine'. -#define AUTOMATIC_ENGINE 0 -#define BACKTRACKING_ENGINE 1 -#define NFA_ENGINE 2 +/// Which regexp engine to use? Needed for vim_regcomp(). +/// Must match with 'regexpengine'. +enum { + AUTOMATIC_ENGINE = 0, + BACKTRACKING_ENGINE = 1, + NFA_ENGINE = 2, +}; typedef struct regengine regengine_T; typedef struct regprog regprog_T; @@ -69,14 +74,14 @@ typedef struct { colnr_T rmm_matchcol; ///< match start without "\zs" int rmm_ic; - colnr_T rmm_maxcol; /// when not zero: maximum column + 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. +/// 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. struct regprog { regengine_T *engine; unsigned regflags; @@ -85,9 +90,9 @@ struct regprog { bool re_in_use; ///< prog is being executed }; -// Structure used by the back track matcher. -// These fields are only to be used in regexp.c! -// See regexp.c for an explanation. +/// Structure used by the back track matcher. +/// These fields are only to be used in regexp.c! +/// See regexp.c for an explanation. typedef struct { // These four members implement regprog_T. regengine_T *engine; @@ -104,19 +109,19 @@ typedef struct { uint8_t program[]; } bt_regprog_T; -// Structure representing a NFA state. -// An NFA state may have no outgoing edge, when it is a NFA_MATCH state. +/// Structure representing a NFA state. +/// An NFA state may have no outgoing edge, when it is a NFA_MATCH state. typedef struct nfa_state nfa_state_T; struct nfa_state { int c; nfa_state_T *out; nfa_state_T *out1; int id; - int lastlist[2]; // 0: normal, 1: recursive + int lastlist[2]; ///< 0: normal, 1: recursive int val; }; -// Structure used by the NFA matcher. +/// Structure used by the NFA matcher. typedef struct { // These four members implement regprog_T. regengine_T *engine; @@ -125,24 +130,24 @@ typedef struct { unsigned re_flags; bool re_in_use; - nfa_state_T *start; // points into state[] + nfa_state_T *start; ///< points into state[] - int reganch; // pattern starts with ^ - int regstart; // char at start of pattern - uint8_t *match_text; // plain text to match with + int reganch; ///< pattern starts with ^ + int regstart; ///< char at start of pattern + uint8_t *match_text; ///< plain text to match with - int has_zend; // pattern contains \ze - int has_backref; // pattern contains \1 .. \9 + int has_zend; ///< pattern contains \ze + int has_backref; ///< pattern contains \1 .. \9 int reghasz; char *pattern; - int nsubexp; // number of () + int nsubexp; ///< number of () int nstate; nfa_state_T state[]; } nfa_regprog_T; -// Structure to be used for single-line matching. -// Sub-match "no" starts at "startp[no]" and ends just before "endp[no]". -// When there is no match, the pointer is NULL. +/// Structure to be used for single-line matching. +/// Sub-match "no" starts at "startp[no]" and ends just before "endp[no]". +/// When there is no match, the pointer is NULL. typedef struct { regprog_T *regprog; char *startp[NSUBEXP]; @@ -152,9 +157,9 @@ typedef struct { bool rm_ic; } regmatch_T; -// 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. +/// 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 { int16_t refcnt; uint8_t *matches[NSUBEXP]; @@ -172,7 +177,9 @@ struct regengine { // uint8_t *expr; }; -// Flags used by vim_regsub() and vim_regsub_both() -#define REGSUB_COPY 1 -#define REGSUB_MAGIC 2 -#define REGSUB_BACKSLASH 4 +/// Flags used by vim_regsub() and vim_regsub_both() +enum { + REGSUB_COPY = 1, + REGSUB_MAGIC = 2, + REGSUB_BACKSLASH = 4, +}; diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index 30de776bff..d5c076d914 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -76,6 +76,15 @@ struct source_cookie { vimconv_T conv; ///< type of conversion }; +typedef struct { + char *path; + bool after; + TriState has_lua; +} SearchPathItem; + +typedef kvec_t(SearchPathItem) RuntimeSearchPath; +typedef kvec_t(char *) CharVec; + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "runtime.c.generated.h" #endif @@ -432,7 +441,7 @@ int do_in_path(const char *path, const char *prefix, char *name, int flags, return did_one ? OK : FAIL; } -RuntimeSearchPath runtime_search_path_get_cached(int *ref) +static RuntimeSearchPath runtime_search_path_get_cached(int *ref) FUNC_ATTR_NONNULL_ALL { runtime_search_path_validate(); @@ -447,7 +456,7 @@ RuntimeSearchPath runtime_search_path_get_cached(int *ref) return runtime_search_path; } -RuntimeSearchPath copy_runtime_search_path(const RuntimeSearchPath src) +static RuntimeSearchPath copy_runtime_search_path(const RuntimeSearchPath src) { RuntimeSearchPath dst = KV_INITIAL_VALUE; for (size_t j = 0; j < kv_size(src); j++) { @@ -458,7 +467,7 @@ RuntimeSearchPath copy_runtime_search_path(const RuntimeSearchPath src) return dst; } -void runtime_search_path_unref(RuntimeSearchPath path, const int *ref) +static void runtime_search_path_unref(RuntimeSearchPath path, const int *ref) FUNC_ATTR_NONNULL_ALL { if (*ref) { @@ -478,7 +487,7 @@ void runtime_search_path_unref(RuntimeSearchPath path, const int *ref) /// When "flags" has DIP_ERR: give an error message if there is no match. /// /// return FAIL when no file could be sourced, OK otherwise. -int do_in_cached_path(char *name, int flags, DoInRuntimepathCB callback, void *cookie) +static int do_in_cached_path(char *name, int flags, DoInRuntimepathCB callback, void *cookie) { char *tail; bool did_one = false; @@ -597,8 +606,8 @@ ArrayOf(String) runtime_get_named_thread(bool lua, Array pat, bool all) return rv; } -ArrayOf(String) runtime_get_named_common(bool lua, Array pat, bool all, - RuntimeSearchPath path, char *buf, size_t buf_len) +static ArrayOf(String) runtime_get_named_common(bool lua, Array pat, bool all, + RuntimeSearchPath path, char *buf, size_t buf_len) { ArrayOf(String) rv = ARRAY_DICT_INIT; for (size_t i = 0; i < kv_size(path); i++) { @@ -734,7 +743,7 @@ static bool path_is_after(char *buf, size_t buflen) && strcmp(buf + buflen - 5, "after") == 0; } -RuntimeSearchPath runtime_search_path_build(void) +static RuntimeSearchPath runtime_search_path_build(void) { kvec_t(String) pack_entries = KV_INITIAL_VALUE; Map(String, int) pack_used = MAP_INIT; @@ -809,7 +818,7 @@ const char *did_set_runtimepackpath(optset_T *args) return NULL; } -void runtime_search_path_free(RuntimeSearchPath path) +static void runtime_search_path_free(RuntimeSearchPath path) { for (size_t j = 0; j < kv_size(path); j++) { SearchPathItem item = kv_A(path, j); diff --git a/src/nvim/runtime.h b/src/nvim/runtime.h index 9ca7088cfc..87e4436618 100644 --- a/src/nvim/runtime.h +++ b/src/nvim/runtime.h @@ -1,7 +1,48 @@ #pragma once -#include "nvim/option_defs.h" // IWYU pragma: export +#include // IWYU pragma: keep + +#include "nvim/api/private/defs.h" // IWYU pragma: keep +#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/garray_defs.h" +#include "nvim/option_defs.h" // IWYU pragma: keep +#include "nvim/pos_defs.h" // IWYU pragma: keep #include "nvim/runtime_defs.h" // IWYU pragma: export +#include "nvim/types_defs.h" // IWYU pragma: keep + +/// Stack of execution contexts. Each entry is an estack_T. +/// Current context is at ga_len - 1. +extern garray_T exestack; +/// name of error message source +#define SOURCING_NAME (((estack_T *)exestack.ga_data)[exestack.ga_len - 1].es_name) +/// line number in the message source or zero +#define SOURCING_LNUM (((estack_T *)exestack.ga_data)[exestack.ga_len - 1].es_lnum) + +/// Growarray to store info about already sourced scripts. +extern garray_T script_items; +#define SCRIPT_ITEM(id) (((scriptitem_T **)script_items.ga_data)[(id) - 1]) +#define SCRIPT_ID_VALID(id) ((id) > 0 && (id) <= script_items.ga_len) + +/// last argument for do_source() +enum { + DOSO_NONE = 0, + DOSO_VIMRC = 1, ///< loading vimrc file +}; + +/// Used for flags in do_in_path() +enum { + DIP_ALL = 0x01, ///< all matches, not just the first one + DIP_DIR = 0x02, ///< find directories instead of files + DIP_ERR = 0x04, ///< give an error message when none found + DIP_START = 0x08, ///< also use "start" directory in 'packpath' + DIP_OPT = 0x10, ///< also use "opt" directory in 'packpath' + DIP_NORTP = 0x20, ///< do not use 'runtimepath' + DIP_NOAFTER = 0x40, ///< skip "after" directories + DIP_AFTER = 0x80, ///< only use "after" directories + DIP_DIRFILE = 0x200, ///< find both files and directories +}; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "runtime.h.generated.h" diff --git a/src/nvim/runtime_defs.h b/src/nvim/runtime_defs.h index 235c002962..169cadfb94 100644 --- a/src/nvim/runtime_defs.h +++ b/src/nvim/runtime_defs.h @@ -1,8 +1,13 @@ #pragma once +#include + #include "nvim/autocmd_defs.h" #include "nvim/eval/typval_defs.h" +#include "nvim/ex_eval_defs.h" +#include "nvim/garray_defs.h" #include "nvim/pos_defs.h" +#include "nvim/types_defs.h" typedef enum { ETYPE_TOP, ///< toplevel @@ -30,14 +35,6 @@ typedef struct { } es_info; } estack_T; -/// Stack of execution contexts. Each entry is an estack_T. -/// Current context is at ga_len - 1. -extern garray_T exestack; -/// name of error message source -#define SOURCING_NAME (((estack_T *)exestack.ga_data)[exestack.ga_len - 1].es_name) -/// line number in the message source or zero -#define SOURCING_LNUM (((estack_T *)exestack.ga_data)[exestack.ga_len - 1].es_lnum) - /// Argument for estack_sfile(). typedef enum { ESTACK_NONE, @@ -76,37 +73,4 @@ typedef struct { int sn_prl_execed; ///< line being timed was executed } scriptitem_T; -/// Growarray to store info about already sourced scripts. -extern garray_T script_items; -#define SCRIPT_ITEM(id) (((scriptitem_T **)script_items.ga_data)[(id) - 1]) -#define SCRIPT_ID_VALID(id) ((id) > 0 && (id) <= script_items.ga_len) - typedef bool (*DoInRuntimepathCB)(int, char **, bool, void *); - -typedef struct { - char *path; - bool after; - TriState has_lua; -} SearchPathItem; - -typedef kvec_t(SearchPathItem) RuntimeSearchPath; -typedef kvec_t(char *) CharVec; - -// last argument for do_source() -enum { - DOSO_NONE = 0, - DOSO_VIMRC = 1, // loading vimrc file -}; - -// Used for flags in do_in_path() -enum { - DIP_ALL = 0x01, // all matches, not just the first one - DIP_DIR = 0x02, // find directories instead of files - DIP_ERR = 0x04, // give an error message when none found - DIP_START = 0x08, // also use "start" directory in 'packpath' - DIP_OPT = 0x10, // also use "opt" directory in 'packpath' - DIP_NORTP = 0x20, // do not use 'runtimepath' - DIP_NOAFTER = 0x40, // skip "after" directories - DIP_AFTER = 0x80, // only use "after" directories - DIP_DIRFILE = 0x200, // find both files and directories -}; diff --git a/src/nvim/sign.h b/src/nvim/sign.h index 388b447b61..1c607bc7de 100644 --- a/src/nvim/sign.h +++ b/src/nvim/sign.h @@ -4,7 +4,7 @@ #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 -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "sign.h.generated.h" diff --git a/src/nvim/strings.h b/src/nvim/strings.h index 0b2dc334f9..4e6c37d585 100644 --- a/src/nvim/strings.h +++ b/src/nvim/strings.h @@ -1,12 +1,12 @@ #pragma once -#include -#include +#include // IWYU pragma: keep +#include #include #include "klib/kvec.h" -#include "nvim/eval/typval_defs.h" -#include "nvim/types_defs.h" +#include "nvim/eval/typval_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep /// Append string to string and return pointer to the next byte /// diff --git a/src/nvim/testing.h b/src/nvim/testing.h index 2e1c74fb22..a34ed209c1 100644 --- a/src/nvim/testing.h +++ b/src/nvim/testing.h @@ -1,7 +1,7 @@ #pragma once #include "nvim/eval/typval_defs.h" // IWYU pragma: keep -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "testing.h.generated.h" diff --git a/src/nvim/textformat.h b/src/nvim/textformat.h index 4beafeb7ec..b86df20f13 100644 --- a/src/nvim/textformat.h +++ b/src/nvim/textformat.h @@ -1,7 +1,7 @@ #pragma once #include "nvim/normal.h" -#include "nvim/pos_defs.h" +#include "nvim/pos_defs.h" // IWYU pragma: keep #ifdef INCLUDE_GENERATED_DECLARATIONS # include "textformat.h.generated.h" diff --git a/src/nvim/undo.h b/src/nvim/undo.h index 13b6486a17..f3a8a60d45 100644 --- a/src/nvim/undo.h +++ b/src/nvim/undo.h @@ -2,8 +2,8 @@ #include "nvim/buffer_defs.h" // IWYU pragma: keep #include "nvim/ex_cmds_defs.h" // IWYU pragma: keep -#include "nvim/pos_defs.h" -#include "nvim/types_defs.h" +#include "nvim/pos_defs.h" // IWYU pragma: keep +#include "nvim/types_defs.h" // IWYU pragma: keep #include "nvim/undo_defs.h" // IWYU pragma: export #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/usercmd.h b/src/nvim/usercmd.h index 73bb5b9279..bcabf9460b 100644 --- a/src/nvim/usercmd.h +++ b/src/nvim/usercmd.h @@ -1,28 +1,29 @@ #pragma once +#include // IWYU pragma: keep #include #include "nvim/cmdexpand_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" -#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep +#include "nvim/ex_cmds_defs.h" #include "nvim/garray_defs.h" -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep typedef struct ucmd { - char *uc_name; // The command name - uint32_t uc_argt; // The argument type - char *uc_rep; // The command's replacement string - int64_t uc_def; // The default value for a range/count - int uc_compl; // completion type - cmd_addr_T uc_addr_type; // The command's address type - sctx_T uc_script_ctx; // SCTX where the command was defined - char *uc_compl_arg; // completion argument if any - LuaRef uc_compl_luaref; // Reference to Lua completion function - LuaRef uc_preview_luaref; // Reference to Lua preview function - LuaRef uc_luaref; // Reference to Lua function + char *uc_name; ///< The command name + uint32_t uc_argt; ///< The argument type + char *uc_rep; ///< The command's replacement string + int64_t uc_def; ///< The default value for a range/count + int uc_compl; ///< completion type + cmd_addr_T uc_addr_type; ///< The command's address type + sctx_T uc_script_ctx; ///< SCTX where the command was defined + char *uc_compl_arg; ///< completion argument if any + LuaRef uc_compl_luaref; ///< Reference to Lua completion function + LuaRef uc_preview_luaref; ///< Reference to Lua preview function + LuaRef uc_luaref; ///< Reference to Lua function } ucmd_T; -#define UC_BUFFER 1 // -buffer: local to current buffer +enum { UC_BUFFER = 1, }; ///< -buffer: local to current buffer extern garray_T ucmds; diff --git a/src/nvim/window.h b/src/nvim/window.h index bc3ec6adb9..9f82f3c4a8 100644 --- a/src/nvim/window.h +++ b/src/nvim/window.h @@ -6,34 +6,41 @@ #include "nvim/garray_defs.h" // IWYU pragma: keep #include "nvim/macros.h" #include "nvim/option_defs.h" // IWYU pragma: keep -#include "nvim/types_defs.h" +#include "nvim/types_defs.h" // IWYU pragma: keep -// Values for file_name_in_line() -#define FNAME_MESS 1 // give error message -#define FNAME_EXP 2 // expand to path -#define FNAME_HYP 4 // check for hypertext link -#define FNAME_INCL 8 // apply 'includeexpr' -#define FNAME_REL 16 // ".." and "./" are relative to the (current) - // file instead of the current directory -#define FNAME_UNESC 32 // remove backslashes used for escaping +/// Values for file_name_in_line() +enum { + FNAME_MESS = 1, ///< give error message + FNAME_EXP = 2, ///< expand to path + FNAME_HYP = 4, ///< check for hypertext link + FNAME_INCL = 8, ///< apply 'includeexpr' + FNAME_REL = 16, ///< ".." and "./" are relative to the (current) + ///< file instead of the current directory + FNAME_UNESC = 32, ///< remove backslashes used for escaping +}; -// arguments for win_split() -#define WSP_ROOM 0x01 // require enough room -#define WSP_VERT 0x02 // split/equalize vertically -#define WSP_HOR 0x04 // equalize horizontally -#define WSP_TOP 0x08 // window at top-left of shell -#define WSP_BOT 0x10 // window at bottom-right of shell -#define WSP_HELP 0x20 // creating the help window -#define WSP_BELOW 0x40 // put new window below/right -#define WSP_ABOVE 0x80 // put new window above/left -#define WSP_NEWLOC 0x100 // don't copy location list +/// arguments for win_split() +enum { + WSP_ROOM = 0x01, ///< require enough room + WSP_VERT = 0x02, ///< split/equalize vertically + WSP_HOR = 0x04, ///< equalize horizontally + WSP_TOP = 0x08, ///< window at top-left of shell + WSP_BOT = 0x10, ///< window at bottom-right of shell + WSP_HELP = 0x20, ///< creating the help window + WSP_BELOW = 0x40, ///< put new window below/right + WSP_ABOVE = 0x80, ///< put new window above/left + WSP_NEWLOC = 0x100, ///< don't copy location list +}; -// Minimum screen size -#define MIN_COLUMNS 12 // minimal columns for screen -#define MIN_LINES 2 // minimal lines for screen +/// Minimum screen size +enum { + MIN_COLUMNS = 12, ///< minimal columns for screen + MIN_LINES = 2, ///< minimal lines for screen +}; -// Set to true if 'cmdheight' was explicitly set to 0. +/// Set to true if 'cmdheight' was explicitly set to 0. EXTERN bool p_ch_was_zero INIT( = false); + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "window.h.generated.h" #endif