aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/clint.py43
-rw-r--r--src/nvim/api/buffer.h4
-rw-r--r--src/nvim/api/command.h2
-rw-r--r--src/nvim/api/extmark.h2
-rw-r--r--src/nvim/api/options.h2
-rw-r--r--src/nvim/api/private/dispatch.h2
-rw-r--r--src/nvim/api/vim.h2
-rw-r--r--src/nvim/api/vimscript.h2
-rw-r--r--src/nvim/api/win_config.h2
-rw-r--r--src/nvim/api/window.h2
-rw-r--r--src/nvim/arglist.h2
-rw-r--r--src/nvim/buffer_defs.h2
-rw-r--r--src/nvim/bufwrite.h2
-rw-r--r--src/nvim/change.h18
-rw-r--r--src/nvim/cmdexpand.h2
-rw-r--r--src/nvim/cursor.h2
-rw-r--r--src/nvim/digraph.h2
-rw-r--r--src/nvim/edit.h46
-rw-r--r--src/nvim/eval.c1
-rw-r--r--src/nvim/eval.h2
-rw-r--r--src/nvim/eval.lua2
-rw-r--r--src/nvim/eval/buffer.h2
-rw-r--r--src/nvim/eval/decode.h2
-rw-r--r--src/nvim/eval/funcs.h12
-rw-r--r--src/nvim/eval/typval_defs.h2
-rw-r--r--src/nvim/eval/userfunc.c1
-rw-r--r--src/nvim/eval/userfunc.h9
-rw-r--r--src/nvim/eval/vars.h4
-rw-r--r--src/nvim/ex_cmds.h2
-rw-r--r--src/nvim/ex_docmd.h35
-rw-r--r--src/nvim/ex_getln.c4
-rw-r--r--src/nvim/ex_getln.h6
-rw-r--r--src/nvim/file_search.h2
-rw-r--r--src/nvim/generators/gen_options.lua4
-rw-r--r--src/nvim/getchar.h2
-rw-r--r--src/nvim/hashtab.h61
-rw-r--r--src/nvim/hashtab_defs.h59
-rw-r--r--src/nvim/highlight_group.h2
-rw-r--r--src/nvim/indent.h16
-rw-r--r--src/nvim/indent_c.h2
-rw-r--r--src/nvim/insexpand.h4
-rw-r--r--src/nvim/linematch.h2
-rw-r--r--src/nvim/mapping.c1
-rw-r--r--src/nvim/mapping.h9
-rw-r--r--src/nvim/match.h2
-rw-r--r--src/nvim/mbyte.h2
-rw-r--r--src/nvim/memline.h4
-rw-r--r--src/nvim/menu.h4
-rw-r--r--src/nvim/move.h2
-rw-r--r--src/nvim/option.c75
-rw-r--r--src/nvim/option.h3
-rw-r--r--src/nvim/option_vars.h4
-rw-r--r--src/nvim/options.lua19
-rw-r--r--src/nvim/os/fs.h2
-rw-r--r--src/nvim/os/lang.h6
-rw-r--r--src/nvim/path.h2
-rw-r--r--src/nvim/plines.h2
-rw-r--r--src/nvim/profile.h2
-rw-r--r--src/nvim/quickfix.h14
-rw-r--r--src/nvim/regexp.h4
-rw-r--r--src/nvim/regexp_defs.h95
-rw-r--r--src/nvim/runtime.c25
-rw-r--r--src/nvim/runtime.h43
-rw-r--r--src/nvim/runtime_defs.h46
-rw-r--r--src/nvim/sign.h2
-rw-r--r--src/nvim/spell_defs.h340
-rw-r--r--src/nvim/spellsuggest.c3
-rw-r--r--src/nvim/state.c4
-rw-r--r--src/nvim/strings.h8
-rw-r--r--src/nvim/testing.h2
-rw-r--r--src/nvim/textformat.h2
-rw-r--r--src/nvim/ugrid.h16
-rw-r--r--src/nvim/undo.h4
-rw-r--r--src/nvim/usercmd.h29
-rw-r--r--src/nvim/window.h53
75 files changed, 609 insertions, 597 deletions
diff --git a/src/clint.py b/src/clint.py
index c6d7d1e8a3..9daa1ad21f 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,33 +910,23 @@ 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",
"src/nvim/eval/userfunc.h",
- "src/nvim/eval/vars.h",
"src/nvim/eval/window.h",
"src/nvim/event/libuv_process.h",
"src/nvim/event/loop.h",
@@ -959,46 +941,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,41 +979,28 @@ 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",
"src/nvim/tui/tui.h",
- "src/nvim/ugrid.h",
"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 <lua.h> // IWYU pragma: keep
#include <stdint.h> // 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 <stdint.h> // 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 <stdint.h> // 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 <stdint.h> // 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 <stdint.h>
#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 <stdint.h> // 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 <stdint.h> // 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 <stdint.h> // 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/buffer_defs.h b/src/nvim/buffer_defs.h
index d3b80c8891..0269060c2f 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -21,7 +21,7 @@ typedef struct {
#include "nvim/extmark_defs.h"
#include "nvim/garray_defs.h"
#include "nvim/grid_defs.h"
-#include "nvim/hashtab.h"
+#include "nvim/hashtab_defs.h"
#include "nvim/highlight_defs.h"
#include "nvim/map.h"
#include "nvim/mapping_defs.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.c b/src/nvim/eval.c
index 02e0be9a94..e7fe7e17bc 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -42,6 +42,7 @@
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/grid_defs.h"
+#include "nvim/hashtab.h"
#include "nvim/highlight_group.h"
#include "nvim/insexpand.h"
#include "nvim/keycodes.h"
diff --git a/src/nvim/eval.h b/src/nvim/eval.h
index 8d2e34b842..b4d6c34405 100644
--- a/src/nvim/eval.h
+++ b/src/nvim/eval.h
@@ -11,7 +11,7 @@
#include "nvim/event/time.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/globals.h"
-#include "nvim/hashtab.h"
+#include "nvim/hashtab_defs.h"
#include "nvim/macros.h"
#include "nvim/os/fileio.h"
#include "nvim/os/stdpaths_defs.h"
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index 79ebc728fe..32a5fac4a0 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -7038,7 +7038,9 @@ M.funcs = {
Rvc Virtual Replace mode completion |compl-generic|
Rvx Virtual Replace mode |i_CTRL-X| completion
c Command-line editing
+ cr Command-line while in overstrike mode |c_<Insert>|
cv Vim Ex mode |gQ|
+ cvr Vim Ex while in overstrike mode |c_<Insert>|
r Hit-enter prompt
rm The -- more -- prompt
r? A |:confirm| query of some sort
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 <stddef.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/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 <stdbool.h>
#include <stdint.h>
-#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/typval_defs.h b/src/nvim/eval/typval_defs.h
index ea5d70bf19..c6bd11ccdb 100644
--- a/src/nvim/eval/typval_defs.h
+++ b/src/nvim/eval/typval_defs.h
@@ -4,7 +4,7 @@
#include <limits.h>
#include "nvim/garray_defs.h"
-#include "nvim/hashtab.h"
+#include "nvim/hashtab_defs.h"
#include "nvim/lib/queue.h"
#include "nvim/pos_defs.h"
#include "nvim/types_defs.h"
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index c095dace92..a859b8a94d 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -25,7 +25,6 @@
#include "nvim/ex_getln.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
-#include "nvim/garray_defs.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
diff --git a/src/nvim/eval/userfunc.h b/src/nvim/eval/userfunc.h
index 5ad5db80b7..8050caab2b 100644
--- a/src/nvim/eval/userfunc.h
+++ b/src/nvim/eval/userfunc.h
@@ -3,14 +3,13 @@
#include <stdbool.h>
#include <stddef.h>
-#include "nvim/cmdexpand_defs.h"
+#include "nvim/cmdexpand_defs.h" // IWYU pragma: keep
#include "nvim/eval.h"
#include "nvim/eval/typval_defs.h"
-#include "nvim/ex_cmds_defs.h"
-#include "nvim/garray_defs.h"
-#include "nvim/hashtab.h"
+#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
+#include "nvim/hashtab_defs.h" // IWYU pragma: keep
#include "nvim/pos_defs.h"
-#include "nvim/types_defs.h"
+#include "nvim/types_defs.h" // IWYU pragma: keep
struct funccal_entry;
diff --git a/src/nvim/eval/vars.h b/src/nvim/eval/vars.h
index 849d0c4229..6ddf449ff1 100644
--- a/src/nvim/eval/vars.h
+++ b/src/nvim/eval/vars.h
@@ -4,9 +4,9 @@
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
#include "nvim/garray_defs.h" // IWYU pragma: keep
-#include "nvim/hashtab.h"
+#include "nvim/hashtab_defs.h" // IWYU pragma: keep
#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 <stdbool.h>
-#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.c b/src/nvim/ex_getln.c
index f302f44dad..37af6b6a44 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -1835,8 +1835,10 @@ static int command_line_handle_key(CommandLineState *s)
case K_INS:
case K_KINS:
ccline.overstrike = !ccline.overstrike;
-
ui_cursor_shape(); // may show different cursor shape
+ may_trigger_modechanged();
+ status_redraw_curbuf();
+ redraw_statuslines();
return command_line_not_changed(s);
case Ctrl_HAT:
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 <stdlib.h>
#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/generators/gen_options.lua b/src/nvim/generators/gen_options.lua
index c9878bf3b0..26ade2745d 100644
--- a/src/nvim/generators/gen_options.lua
+++ b/src/nvim/generators/gen_options.lua
@@ -143,9 +143,13 @@ local function dump_option(i, o)
end
if o.varname then
w(' .var=&' .. o.varname)
+ -- Immutable options should directly point to the default value
+ elseif o.immutable then
+ w((' .var=&options[%u].def_val'):format(i - 1))
elseif #o.scope == 1 and o.scope[1] == 'window' then
w(' .var=VAR_WIN')
end
+ w(' .immutable=' .. (o.immutable and 'true' or 'false'))
if #o.scope == 1 and o.scope[1] == 'global' then
w(' .indir=PV_NONE')
else
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..d14eb6944e 100644
--- a/src/nvim/hashtab.h
+++ b/src/nvim/hashtab.h
@@ -2,74 +2,17 @@
#include <stddef.h>
-#include "nvim/types_defs.h"
+#include "nvim/hashtab_defs.h" // IWYU pragma: export
/// Magic number used for hashitem "hi_key" value indicating a deleted item
///
/// Only the address is used.
extern char hash_removed;
-/// Type for hash number (hash calculation result).
-typedef size_t hash_T;
-
/// The address of "hash_removed" is used as a magic number
/// for hi_key to indicate a removed item.
#define HI_KEY_REMOVED (&hash_removed)
-#define HASHITEM_EMPTY(hi) ((hi)->hi_key == NULL \
- || (hi)->hi_key == &hash_removed)
-
-/// Hashtable item.
-///
-/// Each item has a NUL terminated string key.
-/// A key can appear only once in the table.
-///
-/// A hash number is computed from the key for quick lookup. When the hashes
-/// of two different keys point to the same entry an algorithm is used to
-/// iterate over other entries in the table until the right one is found.
-/// To make the iteration work removed keys are different from entries where a
-/// key was never present.
-///
-/// Note that this does not contain a pointer to the key and another pointer to
-/// the value. Instead, it is assumed that the key is contained within the
-/// value, so that you can get a pointer to the value subtracting an offset from
-/// the pointer to the key.
-/// This reduces the size of this item by 1/3.
-typedef struct hashitem_S {
- /// Cached hash number for hi_key.
- hash_T hi_hash;
-
- /// Item key.
- ///
- /// Possible values mean the following:
- /// NULL : Item was never used.
- /// HI_KEY_REMOVED : Item was removed.
- /// (Any other pointer value) : Item is currently being used.
- char *hi_key;
-} hashitem_T;
-
-/// Initial size for a hashtable.
-/// Our items are relatively small and growing is expensive, thus start with 16.
-/// Must be a power of 2.
-/// This allows for storing 10 items (2/3 of 16) before a resize is needed.
-#define HT_INIT_SIZE 16
-
-/// An array-based hashtable.
-///
-/// Keys are NUL terminated strings. They cannot be repeated within a table.
-/// Values are of any type.
-///
-/// The hashtable grows to accommodate more entries when needed.
-typedef struct hashtable_S {
- hash_T ht_mask; ///< mask used for hash value
- ///< (nr of items in array is "ht_mask" + 1)
- size_t ht_used; ///< number of items used
- size_t ht_filled; ///< number of items used or removed
- int ht_changed; ///< incremented when adding or removing an item
- int ht_locked; ///< counter for hash_lock()
- hashitem_T *ht_array; ///< points to the array, allocated when it's
- ///< not "ht_smallarray"
- hashitem_T ht_smallarray[HT_INIT_SIZE]; ///< initial array
-} hashtab_T;
+#define HASHITEM_EMPTY(hi) ((hi)->hi_key == NULL || (hi)->hi_key == &hash_removed)
/// Iterate over a hashtab
///
diff --git a/src/nvim/hashtab_defs.h b/src/nvim/hashtab_defs.h
new file mode 100644
index 0000000000..089838fcae
--- /dev/null
+++ b/src/nvim/hashtab_defs.h
@@ -0,0 +1,59 @@
+#pragma once
+
+#include <stddef.h>
+
+/// Type for hash number (hash calculation result).
+typedef size_t hash_T;
+
+/// Hashtable item.
+///
+/// Each item has a NUL terminated string key.
+/// A key can appear only once in the table.
+///
+/// A hash number is computed from the key for quick lookup. When the hashes
+/// of two different keys point to the same entry an algorithm is used to
+/// iterate over other entries in the table until the right one is found.
+/// To make the iteration work removed keys are different from entries where a
+/// key was never present.
+///
+/// Note that this does not contain a pointer to the key and another pointer to
+/// the value. Instead, it is assumed that the key is contained within the
+/// value, so that you can get a pointer to the value subtracting an offset from
+/// the pointer to the key.
+/// This reduces the size of this item by 1/3.
+typedef struct hashitem_S {
+ /// Cached hash number for hi_key.
+ hash_T hi_hash;
+
+ /// Item key.
+ ///
+ /// Possible values mean the following:
+ /// NULL : Item was never used.
+ /// HI_KEY_REMOVED : Item was removed.
+ /// (Any other pointer value) : Item is currently being used.
+ char *hi_key;
+} hashitem_T;
+
+/// Initial size for a hashtable.
+/// Our items are relatively small and growing is expensive, thus start with 16.
+/// Must be a power of 2.
+/// This allows for storing 10 items (2/3 of 16) before a resize is needed.
+enum { HT_INIT_SIZE = 16, };
+
+/// An array-based hashtable.
+///
+/// Keys are NUL terminated strings. They cannot be repeated within a table.
+/// Values are of any type.
+///
+/// The hashtable grows to accommodate more entries when needed.
+typedef struct hashtable_S {
+ hash_T ht_mask; ///< mask used for hash value
+ ///< (nr of items in array is "ht_mask" + 1)
+ size_t ht_used; ///< number of items used
+ size_t ht_filled; ///< number of items used or removed
+ int ht_changed; ///< incremented when adding or removing an item
+ int ht_locked; ///< counter for hash_lock()
+ hashitem_T *ht_array; ///< points to the array, allocated when it's
+ ///< not "ht_smallarray"
+ hashitem_T ht_smallarray[HT_INIT_SIZE]; ///< initial array
+} hashtab_T;
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 <stddef.h> // 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 <lauxlib.h>
#include <limits.h>
#include <stdbool.h>
-#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
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 <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
+#include <stdint.h> // IWYU pragma: keep
+#include <stdio.h> // 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 <stdbool.h>
-
#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.c b/src/nvim/option.c
index 972002585e..eda8ccbfb7 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -1913,26 +1913,6 @@ static void apply_optionset_autocmd(int opt_idx, int opt_flags, OptVal oldval, O
reset_v_option_vars();
}
-/// Ensure that options set to p_force_on cannot be disabled.
-static const char *did_set_force_on(optset_T *args FUNC_ATTR_UNUSED)
-{
- if (p_force_on == false) {
- p_force_on = true;
- return e_unsupportedoption;
- }
- return NULL;
-}
-
-/// Ensure that options set to p_force_off cannot be enabled.
-static const char *did_set_force_off(optset_T *args FUNC_ATTR_UNUSED)
-{
- if (p_force_off == true) {
- p_force_off = false;
- return e_unsupportedoption;
- }
- return NULL;
-}
-
/// Process the updated 'arabic' option value.
static const char *did_set_arabic(optset_T *args)
{
@@ -3195,6 +3175,7 @@ int findoption(const char *const arg)
return findoption_len(arg, strlen(arg));
}
+/// Free an allocated OptVal.
void optval_free(OptVal o)
{
switch (o.type) {
@@ -3211,6 +3192,7 @@ void optval_free(OptVal o)
}
}
+/// Copy an OptVal.
OptVal optval_copy(OptVal o)
{
switch (o.type) {
@@ -3224,6 +3206,27 @@ OptVal optval_copy(OptVal o)
UNREACHABLE;
}
+/// Check if two option values are equal.
+bool optval_equal(OptVal o1, OptVal o2)
+{
+ if (o1.type != o2.type) {
+ return false;
+ }
+
+ switch (o1.type) {
+ case kOptValTypeNil:
+ return true;
+ case kOptValTypeBoolean:
+ return o1.data.boolean == o2.data.boolean;
+ case kOptValTypeNumber:
+ return o1.data.number == o2.data.number;
+ case kOptValTypeString:
+ return o1.data.string.size == o2.data.string.size
+ && strequal(o1.data.string.data, o2.data.string.data);
+ }
+ UNREACHABLE;
+}
+
/// Match type of OptVal with the type of the target option. Returns true if the types match and
/// false otherwise.
static bool optval_match_type(OptVal o, int opt_idx)
@@ -3480,14 +3483,16 @@ OptVal get_option_value(const char *name, uint32_t *flagsp, int scope, bool *hid
return NIL_OPTVAL;
}
- void *varp = get_varp_scope(&(options[opt_idx]), scope);
+ vimoption_T *opt = &options[opt_idx];
+ void *varp = get_varp_scope(opt, scope);
+
if (hidden != NULL) {
*hidden = varp == NULL;
}
if (flagsp != NULL) {
// Return the P_xxxx option flags.
- *flagsp = options[opt_idx].flags;
+ *flagsp = opt->flags;
}
return optval_copy(optval_from_varp(opt_idx, varp));
@@ -3542,7 +3547,6 @@ static const char *did_set_option(int opt_idx, void *varp, OptVal old_value, Opt
bool free_oldval = (opt->flags & P_ALLOCED);
bool value_changed = false;
- opt_did_set_cb_T did_set_cb;
optset_T did_set_cb_args = {
.os_varp = varp,
.os_idx = opt_idx,
@@ -3558,24 +3562,21 @@ static const char *did_set_option(int opt_idx, void *varp, OptVal old_value, Opt
.os_win = curwin
};
- if ((int *)varp == &p_force_on) {
- did_set_cb = did_set_force_on;
- } else if ((int *)varp == &p_force_off) {
- did_set_cb = did_set_force_off;
- } else {
- did_set_cb = opt->opt_did_set_cb;
+ // Disallow changing immutable options.
+ if (opt->immutable && !optval_equal(old_value, new_value)) {
+ errmsg = e_unsupportedoption;
}
-
- // Disallow changing some options from secure mode
- if ((secure || sandbox != 0) && (opt->flags & P_SECURE)) {
+ // Disallow changing some options from secure mode.
+ else if ((secure || sandbox != 0) && (opt->flags & P_SECURE)) {
errmsg = e_secure;
- // Check for a "normal" directory or file name in some string options.
- } else if (new_value.type == kOptValTypeString
- && check_illegal_path_names(*(char **)varp, opt->flags)) {
+ }
+ // Check for a "normal" directory or file name in some string options.
+ else if (new_value.type == kOptValTypeString
+ && check_illegal_path_names(*(char **)varp, opt->flags)) {
errmsg = e_invarg;
- } else if (did_set_cb != NULL) {
+ } else if (opt->opt_did_set_cb != NULL) {
// Invoke the option specific callback function to validate and apply the new value.
- errmsg = did_set_cb(&did_set_cb_args);
+ errmsg = opt->opt_did_set_cb(&did_set_cb_args);
// The 'filetype' and 'syntax' option callback functions may change the os_value_changed field.
value_changed = did_set_cb_args.os_value_changed;
// The 'keymap', 'filetype' and 'syntax' option callback functions may change the
diff --git a/src/nvim/option.h b/src/nvim/option.h
index 94aa1d8cec..4d89d354f9 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:
@@ -48,6 +48,7 @@ typedef struct vimoption {
///< local option: indirect option index
///< callback function to invoke after an option is modified to validate and
///< apply the new value.
+ bool immutable; ///< option value cannot be changed from the default value.
/// callback function to invoke after an option is modified to validate and
/// apply the new value.
diff --git a/src/nvim/option_vars.h b/src/nvim/option_vars.h
index 45d9e0c31b..bffdfb25ef 100644
--- a/src/nvim/option_vars.h
+++ b/src/nvim/option_vars.h
@@ -456,7 +456,6 @@ EXTERN unsigned dy_flags;
#define DY_UHEX 0x004
// legacy flag, not used
#define DY_MSGSEP 0x008
-EXTERN int p_ed; ///< 'edcompatible'
EXTERN char *p_ead; ///< 'eadirection'
EXTERN int p_emoji; ///< 'emoji'
EXTERN int p_ea; ///< 'equalalways'
@@ -786,9 +785,6 @@ EXTERN int p_wb; ///< 'writebackup'
EXTERN OptInt p_wd; ///< 'writedelay'
EXTERN int p_cdh; ///< 'cdhome'
-EXTERN int p_force_on; ///< options that cannot be turned off.
-EXTERN int p_force_off; ///< options that cannot be turned on.
-
/// "indir" values for buffer-local options.
/// These need to be defined globally, so that the BV_COUNT can be used with
/// b_p_script_stx[].
diff --git a/src/nvim/options.lua b/src/nvim/options.lua
index c5dfa91f27..daaf73d241 100644
--- a/src/nvim/options.lua
+++ b/src/nvim/options.lua
@@ -6,6 +6,7 @@
--- @field varname? string
--- @field pv_name? string
--- @field type 'bool'|'number'|'string'
+--- @field immutable? boolean
--- @field list? 'comma'|'onecomma'|'commacolon'|'onecommacolon'|'flags'|'flagscomma'
--- @field scope vim.option_scope[]
--- @field deny_duplicates? boolean
@@ -1341,7 +1342,7 @@ return {
scope = { 'global' },
short_desc = N_('No description'),
type = 'bool',
- varname = 'p_force_off',
+ immutable = true,
},
{
abbreviation = 'cpt',
@@ -2299,7 +2300,7 @@ return {
scope = { 'global' },
short_desc = N_('No description'),
type = 'bool',
- varname = 'p_force_off',
+ immutable = true,
},
{
abbreviation = 'emo',
@@ -3885,7 +3886,7 @@ return {
scope = { 'global' },
short_desc = N_('No description'),
type = 'bool',
- varname = 'p_force_off',
+ immutable = true,
},
{
abbreviation = 'hkp',
@@ -3894,7 +3895,7 @@ return {
scope = { 'global' },
short_desc = N_('No description'),
type = 'bool',
- varname = 'p_force_off',
+ immutable = true,
},
{
abbreviation = 'hls',
@@ -4292,7 +4293,7 @@ return {
scope = { 'global' },
short_desc = N_('No description'),
type = 'bool',
- varname = 'p_force_off',
+ immutable = true,
},
{
abbreviation = 'isf',
@@ -6042,7 +6043,7 @@ return {
scope = { 'global' },
short_desc = N_('enable prompt in Ex mode'),
type = 'bool',
- varname = 'p_force_on',
+ immutable = true,
},
{
abbreviation = 'pb',
@@ -6299,7 +6300,7 @@ return {
scope = { 'global' },
short_desc = N_('No description'),
type = 'bool',
- varname = 'p_force_on',
+ immutable = true,
},
{
defaults = { if_true = 2 },
@@ -8824,7 +8825,7 @@ return {
scope = { 'global' },
short_desc = N_('No description'),
type = 'bool',
- varname = 'p_force_off',
+ immutable = true,
},
{
abbreviation = 'tw',
@@ -9069,7 +9070,7 @@ return {
scope = { 'global' },
short_desc = N_('No description'),
type = 'bool',
- varname = 'p_force_on',
+ immutable = true,
},
{
abbreviation = 'udir',
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 <uv.h> // 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 <stdbool.h>
+#include <stdint.h>
#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 <stddef.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
+#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 <stdbool.h>
+
#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/spell_defs.h b/src/nvim/spell_defs.h
index bb5ebb8ec4..dfa399750f 100644
--- a/src/nvim/spell_defs.h
+++ b/src/nvim/spell_defs.h
@@ -5,191 +5,197 @@
#include "nvim/buffer_defs.h"
#include "nvim/garray_defs.h"
-#include "nvim/hashtab.h"
+#include "nvim/hashtab_defs.h"
#include "nvim/regexp_defs.h"
-#define MAXWLEN 254 // Assume max. word len is this many bytes.
- // Some places assume a word length fits in a
- // byte, thus it can't be above 255.
+/// Assume max. word len is this many bytes.
+/// Some places assume a word length fits in a byte, thus it can't be above 255.
+enum { MAXWLEN = 254, };
-// Number of regions supported.
-#define MAXREGIONS 8
+/// Number of regions supported.
+enum { MAXREGIONS = 8, };
-// Type used for indexes in the word tree need to be at least 4 bytes. If int
-// is 8 bytes we could use something smaller, but what?
+/// Type used for indexes in the word tree need to be at least 4 bytes. If int
+/// is 8 bytes we could use something smaller, but what?
typedef int idx_T;
#define SPL_FNAME_TMPL "%s.%s.spl"
#define SPL_FNAME_ADD ".add."
#define SPL_FNAME_ASCII ".ascii."
-// Flags used for a word. Only the lowest byte can be used, the region byte
-// comes above it.
-#define WF_REGION 0x01 // region byte follows
-#define WF_ONECAP 0x02 // word with one capital (or all capitals)
-#define WF_ALLCAP 0x04 // word must be all capitals
-#define WF_RARE 0x08 // rare word
-#define WF_BANNED 0x10 // bad word
-#define WF_AFX 0x20 // affix ID follows
-#define WF_FIXCAP 0x40 // keep-case word, allcap not allowed
-#define WF_KEEPCAP 0x80 // keep-case word
-
-#define WF_CAPMASK (WF_ONECAP | WF_ALLCAP | WF_KEEPCAP | WF_FIXCAP)
-
-// for <flags2>, shifted up one byte to be used in wn_flags
-#define WF_HAS_AFF 0x0100 // word includes affix
-#define WF_NEEDCOMP 0x0200 // word only valid in compound
-#define WF_NOSUGGEST 0x0400 // word not to be suggested
-#define WF_COMPROOT 0x0800 // already compounded word, COMPOUNDROOT
-#define WF_NOCOMPBEF 0x1000 // no compounding before this word
-#define WF_NOCOMPAFT 0x2000 // no compounding after this word
-
-// flags for <pflags>
-#define WFP_RARE 0x01 // rare prefix
-#define WFP_NC 0x02 // prefix is not combining
-#define WFP_UP 0x04 // to-upper prefix
-#define WFP_COMPPERMIT 0x08 // prefix with COMPOUNDPERMITFLAG
-#define WFP_COMPFORBID 0x10 // prefix with COMPOUNDFORBIDFLAG
-
-// Flags for postponed prefixes in "sl_pidxs". Must be above affixID (one
-// byte) and prefcondnr (two bytes).
-#define WF_RAREPFX (WFP_RARE << 24) // rare postponed prefix
-#define WF_PFX_NC (WFP_NC << 24) // non-combining postponed prefix
-#define WF_PFX_UP (WFP_UP << 24) // to-upper postponed prefix
-#define WF_PFX_COMPPERMIT (WFP_COMPPERMIT << 24) // postponed prefix with
- // COMPOUNDPERMITFLAG
-#define WF_PFX_COMPFORBID (WFP_COMPFORBID << 24) // postponed prefix with
- // COMPOUNDFORBIDFLAG
-
-// flags for <compoptions>
-#define COMP_CHECKDUP 1 // CHECKCOMPOUNDDUP
-#define COMP_CHECKREP 2 // CHECKCOMPOUNDREP
-#define COMP_CHECKCASE 4 // CHECKCOMPOUNDCASE
-#define COMP_CHECKTRIPLE 8 // CHECKCOMPOUNDTRIPLE
-
-// Info from "REP", "REPSAL" and "SAL" entries in ".aff" file used in si_rep,
-// si_repsal, sl_rep, and si_sal. Not for sl_sal!
-// One replacement: from "ft_from" to "ft_to".
+/// Flags used for a word. Only the lowest byte can be used, the region byte
+/// comes above it.
+enum {
+ WF_REGION = 0x01, ///< region byte follows
+ WF_ONECAP = 0x02, ///< word with one capital (or all capitals)
+ WF_ALLCAP = 0x04, ///< word must be all capitals
+ WF_RARE = 0x08, ///< rare word
+ WF_BANNED = 0x10, ///< bad word
+ WF_AFX = 0x20, ///< affix ID follows
+ WF_FIXCAP = 0x40, ///< keep-case word, allcap not allowed
+ WF_KEEPCAP = 0x80, ///< keep-case word
+ WF_CAPMASK = (WF_ONECAP | WF_ALLCAP | WF_KEEPCAP | WF_FIXCAP),
+};
+
+/// for <flags2>, shifted up one byte to be used in wn_flags
+enum {
+ WF_HAS_AFF = 0x0100, ///< word includes affix
+ WF_NEEDCOMP = 0x0200, ///< word only valid in compound
+ WF_NOSUGGEST = 0x0400, ///< word not to be suggested
+ WF_COMPROOT = 0x0800, ///< already compounded word, COMPOUNDROOT
+ WF_NOCOMPBEF = 0x1000, ///< no compounding before this word
+ WF_NOCOMPAFT = 0x2000, ///< no compounding after this word
+};
+
+/// flags for <pflags>
+enum {
+ WFP_RARE = 0x01, ///< rare prefix
+ WFP_NC = 0x02, ///< prefix is not combining
+ WFP_UP = 0x04, ///< to-upper prefix
+ WFP_COMPPERMIT = 0x08, ///< prefix with COMPOUNDPERMITFLAG
+ WFP_COMPFORBID = 0x10, ///< prefix with COMPOUNDFORBIDFLAG
+};
+
+/// Flags for postponed prefixes in "sl_pidxs". Must be above affixID (one
+/// byte) and prefcondnr (two bytes).
+enum {
+ WF_RAREPFX = WFP_RARE << 24, ///< rare postponed prefix
+ WF_PFX_NC = WFP_NC << 24, ///< non-combining postponed prefix
+ WF_PFX_UP = WFP_UP << 24, ///< to-upper postponed prefix
+ WF_PFX_COMPPERMIT = WFP_COMPPERMIT << 24, ///< postponed prefix with COMPOUNDPERMITFLAG
+ WF_PFX_COMPFORBID = WFP_COMPFORBID << 24, ///< postponed prefix with COMPOUNDFORBIDFLAG
+};
+
+/// flags for <compoptions>
+enum {
+ COMP_CHECKDUP = 1, ///< CHECKCOMPOUNDDUP
+ COMP_CHECKREP = 2, ///< CHECKCOMPOUNDREP
+ COMP_CHECKCASE = 4, ///< CHECKCOMPOUNDCASE
+ COMP_CHECKTRIPLE = 8, ///< CHECKCOMPOUNDTRIPLE
+};
+
+/// Info from "REP", "REPSAL" and "SAL" entries in ".aff" file used in si_rep,
+/// si_repsal, sl_rep, and si_sal. Not for sl_sal!
+/// One replacement: from "ft_from" to "ft_to".
typedef struct fromto_S {
char *ft_from;
char *ft_to;
} fromto_T;
-// Info from "SAL" entries in ".aff" file used in sl_sal.
-// The info is split for quick processing by spell_soundfold().
-// Note that "sm_oneof" and "sm_rules" point into sm_lead.
+/// Info from "SAL" entries in ".aff" file used in sl_sal.
+/// The info is split for quick processing by spell_soundfold().
+/// Note that "sm_oneof" and "sm_rules" point into sm_lead.
typedef struct salitem_S {
- char *sm_lead; // leading letters
- int sm_leadlen; // length of "sm_lead"
- char *sm_oneof; // letters from () or NULL
- char *sm_rules; // rules like ^, $, priority
- char *sm_to; // replacement.
- int *sm_lead_w; // wide character copy of "sm_lead"
- int *sm_oneof_w; // wide character copy of "sm_oneof"
- int *sm_to_w; // wide character copy of "sm_to"
+ char *sm_lead; ///< leading letters
+ int sm_leadlen; ///< length of "sm_lead"
+ char *sm_oneof; ///< letters from () or NULL
+ char *sm_rules; ///< rules like ^, $, priority
+ char *sm_to; ///< replacement.
+ int *sm_lead_w; ///< wide character copy of "sm_lead"
+ int *sm_oneof_w; ///< wide character copy of "sm_oneof"
+ int *sm_to_w; ///< wide character copy of "sm_to"
} salitem_T;
typedef int salfirst_T;
-// Values for SP_*ERROR are negative, positive values are used by
-// read_cnt_string().
-#define SP_TRUNCERROR (-1) // spell file truncated error
-#define SP_FORMERROR (-2) // format error in spell file
-#define SP_OTHERERROR (-3) // other error while reading spell file
-
-// Structure used to store words and other info for one language, loaded from
-// a .spl file.
-// The main access is through the tree in "sl_fbyts/sl_fidxs", storing the
-// case-folded words. "sl_kbyts/sl_kidxs" is for keep-case words.
-//
-// The "byts" array stores the possible bytes in each tree node, preceded by
-// the number of possible bytes, sorted on byte value:
-// <len> <byte1> <byte2> ...
-// The "idxs" array stores the index of the child node corresponding to the
-// byte in "byts".
-// Exception: when the byte is zero, the word may end here and "idxs" holds
-// the flags, region mask and affixID for the word. There may be several
-// zeros in sequence for alternative flag/region/affixID combinations.
+/// Values for SP_*ERROR are negative, positive values are used by
+/// read_cnt_string().
+enum {
+ SP_TRUNCERROR = -1, ///< spell file truncated error
+ SP_FORMERROR = -2, ///< format error in spell file
+ SP_OTHERERROR = -3, ///< other error while reading spell file
+};
+
+/// Structure used to store words and other info for one language, loaded from
+/// a .spl file.
+/// The main access is through the tree in "sl_fbyts/sl_fidxs", storing the
+/// case-folded words. "sl_kbyts/sl_kidxs" is for keep-case words.
+///
+/// The "byts" array stores the possible bytes in each tree node, preceded by
+/// the number of possible bytes, sorted on byte value:
+/// <len> <byte1> <byte2> ...
+/// The "idxs" array stores the index of the child node corresponding to the
+/// byte in "byts".
+/// Exception: when the byte is zero, the word may end here and "idxs" holds
+/// the flags, region mask and affixID for the word. There may be several
+/// zeros in sequence for alternative flag/region/affixID combinations.
typedef struct slang_S slang_T;
struct slang_S {
- slang_T *sl_next; // next language
- char *sl_name; // language name "en", "en.rare", "nl", etc.
- char *sl_fname; // name of .spl file
- bool sl_add; // true if it's a .add file.
-
- uint8_t *sl_fbyts; // case-folded word bytes
- int sl_fbyts_len; // length of sl_fbyts
- idx_T *sl_fidxs; // case-folded word indexes
- uint8_t *sl_kbyts; // keep-case word bytes
- idx_T *sl_kidxs; // keep-case word indexes
- uint8_t *sl_pbyts; // prefix tree word bytes
- idx_T *sl_pidxs; // prefix tree word indexes
-
- char *sl_info; // infotext string or NULL
-
+ slang_T *sl_next; ///< next language
+ char *sl_name; ///< language name "en", "en.rare", "nl", etc.
+ char *sl_fname; ///< name of .spl file
+ bool sl_add; ///< true if it's a .add file.
+
+ uint8_t *sl_fbyts; ///< case-folded word bytes
+ int sl_fbyts_len; ///< length of sl_fbyts
+ idx_T *sl_fidxs; ///< case-folded word indexes
+ uint8_t *sl_kbyts; ///< keep-case word bytes
+ idx_T *sl_kidxs; ///< keep-case word indexes
+ uint8_t *sl_pbyts; ///< prefix tree word bytes
+ idx_T *sl_pidxs; ///< prefix tree word indexes
+
+ char *sl_info; ///< infotext string or NULL
+
+ /// table with up to 8 region names plus NUL
char sl_regions[MAXREGIONS * 2 + 1];
- // table with up to 8 region names plus NUL
-
- char *sl_midword; // MIDWORD string or NULL
-
- hashtab_T sl_wordcount; // hashtable with word count, wordcount_T
-
- int sl_compmax; // COMPOUNDWORDMAX (default: MAXWLEN)
- int sl_compminlen; // COMPOUNDMIN (default: 0)
- int sl_compsylmax; // COMPOUNDSYLMAX (default: MAXWLEN)
- int sl_compoptions; // COMP_* flags
- garray_T sl_comppat; // CHECKCOMPOUNDPATTERN items
- regprog_T *sl_compprog; // COMPOUNDRULE turned into a regexp progrm
- // (NULL when no compounding)
- uint8_t *sl_comprules; // all COMPOUNDRULE concatenated (or NULL)
- uint8_t *sl_compstartflags; // flags for first compound word
- uint8_t *sl_compallflags; // all flags for compound words
- bool sl_nobreak; // When true: no spaces between words
- char *sl_syllable; // SYLLABLE repeatable chars or NULL
- garray_T sl_syl_items; // syllable items
-
- int sl_prefixcnt; // number of items in "sl_prefprog"
- regprog_T **sl_prefprog; // table with regprogs for prefixes
-
- garray_T sl_rep; // list of fromto_T entries from REP lines
- int16_t sl_rep_first[256]; // indexes where byte first appears, -1 if
- // there is none
- garray_T sl_sal; // list of salitem_T entries from SAL lines
- salfirst_T sl_sal_first[256]; // indexes where byte first appears, -1 if
- // there is none
- bool sl_followup; // SAL followup
- bool sl_collapse; // SAL collapse_result
- bool sl_rem_accents; // SAL remove_accents
- bool sl_sofo; // SOFOFROM and SOFOTO instead of SAL items:
- // "sl_sal_first" maps chars
- // "sl_sal" is a list of wide char lists.
- garray_T sl_repsal; // list of fromto_T entries from REPSAL lines
- int16_t sl_repsal_first[256]; // sl_rep_first for REPSAL lines
- bool sl_nosplitsugs; // don't suggest splitting a word
- bool sl_nocompoundsugs; // don't suggest compounding
+
+ char *sl_midword; ///< MIDWORD string or NULL
+
+ hashtab_T sl_wordcount; ///< hashtable with word count, wordcount_T
+
+ int sl_compmax; ///< COMPOUNDWORDMAX (default: MAXWLEN)
+ int sl_compminlen; ///< COMPOUNDMIN (default: 0)
+ int sl_compsylmax; ///< COMPOUNDSYLMAX (default: MAXWLEN)
+ int sl_compoptions; ///< COMP_* flags
+ garray_T sl_comppat; ///< CHECKCOMPOUNDPATTERN items
+ regprog_T *sl_compprog; ///< COMPOUNDRULE turned into a regexp progrm
+ ///< (NULL when no compounding)
+ uint8_t *sl_comprules; ///< all COMPOUNDRULE concatenated (or NULL)
+ uint8_t *sl_compstartflags; ///< flags for first compound word
+ uint8_t *sl_compallflags; ///< all flags for compound words
+ bool sl_nobreak; ///< When true: no spaces between words
+ char *sl_syllable; ///< SYLLABLE repeatable chars or NULL
+ garray_T sl_syl_items; ///< syllable items
+
+ int sl_prefixcnt; ///< number of items in "sl_prefprog"
+ regprog_T **sl_prefprog; ///< table with regprogs for prefixes
+
+ garray_T sl_rep; ///< list of fromto_T entries from REP lines
+ int16_t sl_rep_first[256]; ///< indexes where byte first appears, -1 if there is none
+ garray_T sl_sal; ///< list of salitem_T entries from SAL lines
+ salfirst_T sl_sal_first[256]; ///< indexes where byte first appears, -1 if there is none
+ bool sl_followup; ///< SAL followup
+ bool sl_collapse; ///< SAL collapse_result
+ bool sl_rem_accents; ///< SAL remove_accents
+ bool sl_sofo; ///< SOFOFROM and SOFOTO instead of SAL items:
+ ///< "sl_sal_first" maps chars
+ ///< "sl_sal" is a list of wide char lists.
+ garray_T sl_repsal; ///< list of fromto_T entries from REPSAL lines
+ int16_t sl_repsal_first[256]; ///< sl_rep_first for REPSAL lines
+ bool sl_nosplitsugs; ///< don't suggest splitting a word
+ bool sl_nocompoundsugs; ///< don't suggest compounding
// Info from the .sug file. Loaded on demand.
- time_t sl_sugtime; // timestamp for .sug file
- uint8_t *sl_sbyts; // soundfolded word bytes
- idx_T *sl_sidxs; // soundfolded word indexes
- buf_T *sl_sugbuf; // buffer with word number table
- bool sl_sugloaded; // true when .sug file was loaded or failed to
- // load
-
- bool sl_has_map; // true, if there is a MAP line
- hashtab_T sl_map_hash; // MAP for multi-byte chars
- int sl_map_array[256]; // MAP for first 256 chars
- hashtab_T sl_sounddone; // table with soundfolded words that have
- // handled, see add_sound_suggest()
+ time_t sl_sugtime; ///< timestamp for .sug file
+ uint8_t *sl_sbyts; ///< soundfolded word bytes
+ idx_T *sl_sidxs; ///< soundfolded word indexes
+ buf_T *sl_sugbuf; ///< buffer with word number table
+ bool sl_sugloaded; ///< true when .sug file was loaded or failed to load
+
+ bool sl_has_map; ///< true, if there is a MAP line
+ hashtab_T sl_map_hash; ///< MAP for multi-byte chars
+ int sl_map_array[256]; ///< MAP for first 256 chars
+ hashtab_T sl_sounddone; ///< table with soundfolded words that have
+ ///< handled, see add_sound_suggest()
};
-// Structure used in "b_langp", filled from 'spelllang'.
+/// Structure used in "b_langp", filled from 'spelllang'.
typedef struct langp_S {
- slang_T *lp_slang; // info for this language
- slang_T *lp_sallang; // language used for sound folding or NULL
- slang_T *lp_replang; // language used for REP items or NULL
- int lp_region; // bitmask for region or REGION_ALL
+ slang_T *lp_slang; ///< info for this language
+ slang_T *lp_sallang; ///< language used for sound folding or NULL
+ slang_T *lp_replang; ///< language used for REP items or NULL
+ int lp_region; ///< bitmask for region or REGION_ALL
} langp_T;
#define LANGP_ENTRY(ga, i) (((langp_T *)(ga).ga_data) + (i))
@@ -198,15 +204,15 @@ typedef struct langp_S {
#define VIMSUGMAGICL 6
#define VIMSUGVERSION 1
-#define REGION_ALL 0xff // word valid in all regions
+enum { REGION_ALL = 0xff, }; ///< word valid in all regions
-// The tables used for recognizing word characters according to spelling.
-// These are only used for the first 256 characters of 'encoding'.
+/// The tables used for recognizing word characters according to spelling.
+/// These are only used for the first 256 characters of 'encoding'.
typedef struct {
- bool st_isw[256]; // flags: is word char
- bool st_isu[256]; // flags: is uppercase char
- uint8_t st_fold[256]; // chars: folded case
- uint8_t st_upper[256]; // chars: upper case
+ bool st_isw[256]; ///< flags: is word char
+ bool st_isu[256]; ///< flags: is uppercase char
+ uint8_t st_fold[256]; ///< chars: folded case
+ uint8_t st_upper[256]; ///< chars: upper case
} spelltab_T;
// Use our own character-case definitions, because the current locale may
@@ -221,7 +227,7 @@ typedef struct {
#define SPELL_ISUPPER(c) ((c) >= 128 ? mb_isupper(c) : spelltab.st_isu[c])
-// Values for "what" argument of spell_add_word()
+/// Values for "what" argument of spell_add_word()
typedef enum {
SPELL_ADD_GOOD = 0,
SPELL_ADD_BAD = 1,
@@ -229,10 +235,10 @@ typedef enum {
} SpellAddType;
typedef struct wordcount_S {
- uint16_t wc_count; ///< nr of times word was seen
- char wc_word[]; ///< word
+ uint16_t wc_count; ///< nr of times word was seen
+ char wc_word[]; ///< word
} wordcount_T;
#define WC_KEY_OFF offsetof(wordcount_T, wc_word)
#define HI2WC(hi) ((wordcount_T *)((hi)->hi_key - WC_KEY_OFF))
-#define MAXWORDCOUNT 0xffff
+enum { MAXWORDCOUNT = 0xffff, };
diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c
index 1852f75432..af9f4db45a 100644
--- a/src/nvim/spellsuggest.c
+++ b/src/nvim/spellsuggest.c
@@ -3141,8 +3141,7 @@ static void check_suggestions(suginfo_T *su, garray_T *gap)
// Need to append what follows to check for "the the".
xstrlcpy(longword, stp[i].st_word, MAXWLEN + 1);
int len = stp[i].st_wordlen;
- xstrlcpy(longword + len, su->su_badptr + stp[i].st_orglen,
- (size_t)(MAXWLEN - len + 1));
+ xstrlcpy(longword + len, su->su_badptr + stp[i].st_orglen, MAXWLEN + 1 - (size_t)len);
hlf_T attr = HLF_COUNT;
(void)spell_check(curwin, longword, &attr, NULL, false);
if (attr != HLF_COUNT) {
diff --git a/src/nvim/state.c b/src/nvim/state.c
index 1402bff425..76d75cf1fb 100644
--- a/src/nvim/state.c
+++ b/src/nvim/state.c
@@ -8,6 +8,7 @@
#include "nvim/eval/typval.h"
#include "nvim/event/defs.h"
#include "nvim/event/multiqueue.h"
+#include "nvim/ex_getln.h"
#include "nvim/getchar.h"
#include "nvim/globals.h"
#include "nvim/insexpand.h"
@@ -210,6 +211,9 @@ void get_mode(char *buf)
if (exmode_active) {
buf[i++] = 'v';
}
+ if ((State & MODE_CMDLINE) && cmdline_overstrike()) {
+ buf[i++] = 'r';
+ }
} else if (State & MODE_TERMINAL) {
buf[i++] = 't';
} else {
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 <stdarg.h>
-#include <stdbool.h>
+#include <stdarg.h> // IWYU pragma: keep
+#include <stddef.h>
#include <string.h>
#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/ugrid.h b/src/nvim/ugrid.h
index 53278dbf7a..a82b0e1c9d 100644
--- a/src/nvim/ugrid.h
+++ b/src/nvim/ugrid.h
@@ -1,25 +1,17 @@
#pragma once
-#include "nvim/globals.h"
#include "nvim/grid_defs.h"
-#include "nvim/ui.h"
-struct ucell;
-struct ugrid;
-
-typedef struct ucell UCell;
-typedef struct ugrid UGrid;
-
-struct ucell {
+typedef struct ucell {
schar_T data;
sattr_T attr;
-};
+} UCell;
-struct ugrid {
+typedef struct ugrid {
int row, col;
int width, height;
UCell **cells;
-};
+} UGrid;
#define UGRID_FOREACH_CELL(grid, row, startcol, endcol, code) \
do { \
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 <stddef.h> // IWYU pragma: keep
#include <stdint.h>
#include "nvim/cmdexpand_defs.h" // IWYU pragma: keep
#include "nvim/eval/typval_defs.h"
-#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
+#include "nvim/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