aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile9
-rw-r--r--runtime/doc/builtin.txt8
-rw-r--r--runtime/lua/vim/_meta/vimfn.lua8
-rwxr-xr-xsrc/clint.py9
-rw-r--r--src/nvim/api/buffer.c1
-rw-r--r--src/nvim/autocmd.c2
-rw-r--r--src/nvim/buffer.c2
-rw-r--r--src/nvim/buffer_updates.c1
-rw-r--r--src/nvim/buffer_updates.h4
-rw-r--r--src/nvim/bufwrite.c2
-rw-r--r--src/nvim/change.c2
-rw-r--r--src/nvim/cmdexpand.c2
-rw-r--r--src/nvim/context.h1
-rw-r--r--src/nvim/cursor_shape.c1
-rw-r--r--src/nvim/debugger.c1
-rw-r--r--src/nvim/decoration.h5
-rw-r--r--src/nvim/decoration_provider.h2
-rw-r--r--src/nvim/digraph.c3
-rw-r--r--src/nvim/drawline.c4
-rw-r--r--src/nvim/drawline.h2
-rw-r--r--src/nvim/edit.c2
-rw-r--r--src/nvim/eval.h3
-rw-r--r--src/nvim/eval.lua8
-rw-r--r--src/nvim/ex_cmds.c3
-rw-r--r--src/nvim/ex_cmds2.c2
-rw-r--r--src/nvim/ex_docmd.c2
-rw-r--r--src/nvim/ex_docmd.h2
-rw-r--r--src/nvim/ex_getln.c2
-rw-r--r--src/nvim/ex_getln.h2
-rw-r--r--src/nvim/extmark.c1
-rw-r--r--src/nvim/extmark.h3
-rw-r--r--src/nvim/extmark_defs.h3
-rw-r--r--src/nvim/fileio.c3
-rw-r--r--src/nvim/fold.c1
-rw-r--r--src/nvim/fold_defs.h15
-rw-r--r--src/nvim/globals.h1
-rw-r--r--src/nvim/grid.c1
-rw-r--r--src/nvim/highlight.h3
-rw-r--r--src/nvim/indent.c5
-rw-r--r--src/nvim/indent_c.c1
-rw-r--r--src/nvim/input.c4
-rw-r--r--src/nvim/insexpand.c2
-rw-r--r--src/nvim/lua/converter.c6
-rw-r--r--src/nvim/main.c5
-rw-r--r--src/nvim/mapping.c3
-rw-r--r--src/nvim/mapping_defs.h3
-rw-r--r--src/nvim/mark.c2
-rw-r--r--src/nvim/marktree.h11
-rw-r--r--src/nvim/mbyte_defs.h5
-rw-r--r--src/nvim/memfile.h9
-rw-r--r--src/nvim/memline.c44
-rw-r--r--src/nvim/memory.c1
-rw-r--r--src/nvim/menu.c2
-rw-r--r--src/nvim/message.c1
-rw-r--r--src/nvim/message.h22
-rw-r--r--src/nvim/normal.c2
-rw-r--r--src/nvim/normal_defs.h6
-rw-r--r--src/nvim/ops.c8
-rw-r--r--src/nvim/ops.h124
-rw-r--r--src/nvim/option.c1
-rw-r--r--src/nvim/os/input.c1
-rw-r--r--src/nvim/os/os_defs.h2
-rw-r--r--src/nvim/os/os_win_console.c4
-rw-r--r--src/nvim/os/shell.c1
-rw-r--r--src/nvim/os/users.c3
-rw-r--r--src/nvim/plines.c1
-rw-r--r--src/nvim/popupmenu.c1
-rw-r--r--src/nvim/quickfix.c4
-rw-r--r--src/nvim/runtime.c5
-rw-r--r--src/nvim/search.c4
-rw-r--r--src/nvim/sign.c2
-rw-r--r--src/nvim/state.h10
-rw-r--r--src/nvim/state_defs.h45
-rw-r--r--src/nvim/statusline.c1
-rw-r--r--src/nvim/syntax.c2
-rw-r--r--src/nvim/tag.c3
-rw-r--r--src/nvim/tag.h2
-rw-r--r--src/nvim/textformat.c1
-rw-r--r--src/nvim/ui.c2
-rw-r--r--src/nvim/ui_compositor.c1
-rw-r--r--src/nvim/undo.c2
-rw-r--r--src/nvim/undo_defs.h71
-rw-r--r--src/nvim/usercmd.c2
-rw-r--r--src/nvim/version.c2
-rw-r--r--src/nvim/vim_defs.h111
-rw-r--r--src/nvim/viml/parser/expressions.c2
-rw-r--r--src/nvim/window.h9
-rw-r--r--test/functional/api/keymap_spec.lua2
-rw-r--r--test/functional/api/server_requests_spec.lua2
89 files changed, 339 insertions, 352 deletions
diff --git a/Makefile b/Makefile
index b1c39d5816..c6a0c053ea 100644
--- a/Makefile
+++ b/Makefile
@@ -143,7 +143,6 @@ iwyu: build/.ran-cmake
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/extmark.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\
@@ -154,14 +153,11 @@ iwyu: build/.ran-cmake
|src/nvim/autocmd_defs.h\
|src/nvim/buffer.h\
|src/nvim/buffer_defs.h\
- |src/nvim/buffer_updates.h\
|src/nvim/channel.h\
|src/nvim/charset.h\
|src/nvim/cmdexpand.h\
|src/nvim/cmdhist.h\
- |src/nvim/context.h\
|src/nvim/decoration.h\
- |src/nvim/decoration_provider.h\
|src/nvim/diff.h\
|src/nvim/drawline.h\
|src/nvim/drawscreen.h\
@@ -169,7 +165,6 @@ iwyu: build/.ran-cmake
|src/nvim/eval/encode.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/window.h\
|src/nvim/event/libuv_process.h\
@@ -185,7 +180,6 @@ iwyu: build/.ran-cmake
|src/nvim/ex_cmds.h\
|src/nvim/ex_cmds_defs.h\
|src/nvim/ex_docmd.h\
- |src/nvim/ex_getln.h\
|src/nvim/extmark.h\
|src/nvim/file_search.h\
|src/nvim/fileio.h\
@@ -203,15 +197,12 @@ iwyu: build/.ran-cmake
|src/nvim/lua/executor.h\
|src/nvim/main.h\
|src/nvim/mark.h\
- |src/nvim/marktree.h\
- |src/nvim/message.h\
|src/nvim/mouse.h\
|src/nvim/move.h\
|src/nvim/msgpack_rpc/channel.h\
|src/nvim/msgpack_rpc/channel_defs.h\
|src/nvim/msgpack_rpc/helpers.h\
|src/nvim/msgpack_rpc/unpacker.h\
- |src/nvim/ops.h\
|src/nvim/option.h\
|src/nvim/os/fileio.h\
|src/nvim/os/input.h\
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 349bb93133..6ffb514487 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -4189,8 +4189,8 @@ maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()*
"mode_bits" Nvim's internal binary representation of "mode".
|mapset()| ignores this; only "mode" is used.
See |maplist()| for usage examples. The values
- are from src/nvim/vim.h and may change in the
- future.
+ are from src/nvim/state_defs.h and may change in
+ the future.
The dictionary can be used to restore a mapping with
|mapset()|.
@@ -4257,8 +4257,8 @@ maplist([{abbr}]) *maplist()*
endfor
echo saved_maps->mapnew({_, m -> m.lhs})
< The values of the mode_bits are defined in Nvim's
- src/nvim/vim.h file and they can be discovered at runtime
- using |:map-commands| and "maplist()". Example: >vim
+ src/nvim/state_defs.h file and they can be discovered at
+ runtime using |:map-commands| and "maplist()". Example: >vim
omap xyzzy <Nop>
let op_bit = maplist()->filter(
\ {_, m -> m.lhs == 'xyzzy'})[0].mode_bits
diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua
index 947424c4ad..05e5b2b871 100644
--- a/runtime/lua/vim/_meta/vimfn.lua
+++ b/runtime/lua/vim/_meta/vimfn.lua
@@ -5050,8 +5050,8 @@ function vim.fn.map(expr1, expr2) end
--- "mode_bits" Nvim's internal binary representation of "mode".
--- |mapset()| ignores this; only "mode" is used.
--- See |maplist()| for usage examples. The values
---- are from src/nvim/vim.h and may change in the
---- future.
+--- are from src/nvim/state_defs.h and may change in
+--- the future.
---
--- The dictionary can be used to restore a mapping with
--- |mapset()|.
@@ -5129,8 +5129,8 @@ function vim.fn.mapcheck(name, mode, abbr) end
--- endfor
--- echo saved_maps->mapnew({_, m -> m.lhs})
--- <The values of the mode_bits are defined in Nvim's
---- src/nvim/vim.h file and they can be discovered at runtime
---- using |:map-commands| and "maplist()". Example: >vim
+--- src/nvim/state_defs.h file and they can be discovered at
+--- runtime using |:map-commands| and "maplist()". Example: >vim
--- omap xyzzy <Nop>
--- let op_bit = maplist()->filter(
--- \ {_, m -> m.lhs == 'xyzzy'})[0].mode_bits
diff --git a/src/clint.py b/src/clint.py
index ef2ac57a87..e730b9276b 100755
--- a/src/clint.py
+++ b/src/clint.py
@@ -898,7 +898,6 @@ def CheckIncludes(filename, lines, error):
# the Makefile.
check_includes_ignore = [
"src/nvim/api/extmark.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",
@@ -909,14 +908,11 @@ def CheckIncludes(filename, lines, error):
"src/nvim/autocmd_defs.h",
"src/nvim/buffer.h",
"src/nvim/buffer_defs.h",
- "src/nvim/buffer_updates.h",
"src/nvim/channel.h",
"src/nvim/charset.h",
"src/nvim/cmdexpand.h",
"src/nvim/cmdhist.h",
- "src/nvim/context.h",
"src/nvim/decoration.h",
- "src/nvim/decoration_provider.h",
"src/nvim/diff.h",
"src/nvim/drawline.h",
"src/nvim/drawscreen.h",
@@ -924,7 +920,6 @@ def CheckIncludes(filename, lines, error):
"src/nvim/eval/encode.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/window.h",
"src/nvim/event/libuv_process.h",
@@ -940,7 +935,6 @@ def CheckIncludes(filename, lines, error):
"src/nvim/ex_cmds.h",
"src/nvim/ex_cmds_defs.h",
"src/nvim/ex_docmd.h",
- "src/nvim/ex_getln.h",
"src/nvim/extmark.h",
"src/nvim/file_search.h",
"src/nvim/fileio.h",
@@ -958,15 +952,12 @@ def CheckIncludes(filename, lines, error):
"src/nvim/lua/executor.h",
"src/nvim/main.h",
"src/nvim/mark.h",
- "src/nvim/marktree.h",
- "src/nvim/message.h",
"src/nvim/mouse.h",
"src/nvim/move.h",
"src/nvim/msgpack_rpc/channel.h",
"src/nvim/msgpack_rpc/channel_defs.h",
"src/nvim/msgpack_rpc/helpers.h",
"src/nvim/msgpack_rpc/unpacker.h",
- "src/nvim/ops.h",
"src/nvim/option.h",
"src/nvim/os/fileio.h",
"src/nvim/os/input.h",
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 96e0e240f2..0df231868d 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -34,6 +34,7 @@
#include "nvim/move.h"
#include "nvim/ops.h"
#include "nvim/pos_defs.h"
+#include "nvim/state_defs.h"
#include "nvim/types_defs.h"
#include "nvim/undo.h"
#include "nvim/vim_defs.h"
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index 585fac1228..74a1dbdbc3 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -29,7 +29,7 @@
#include "nvim/globals.h"
#include "nvim/grid.h"
#include "nvim/hashtab.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/insexpand.h"
#include "nvim/lua/executor.h"
#include "nvim/main.h"
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index e6bedca232..8a594dea92 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -89,8 +89,8 @@
#include "nvim/regexp.h"
#include "nvim/runtime.h"
#include "nvim/search.h"
-#include "nvim/sign.h"
#include "nvim/spell.h"
+#include "nvim/state_defs.h"
#include "nvim/statusline.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
diff --git a/src/nvim/buffer_updates.c b/src/nvim/buffer_updates.c
index 6a96f715af..01bcb9d7be 100644
--- a/src/nvim/buffer_updates.c
+++ b/src/nvim/buffer_updates.c
@@ -11,7 +11,6 @@
#include "nvim/buffer.h"
#include "nvim/buffer_defs.h"
#include "nvim/buffer_updates.h"
-#include "nvim/extmark.h"
#include "nvim/func_attr.h"
#include "nvim/globals.h"
#include "nvim/log.h"
diff --git a/src/nvim/buffer_updates.h b/src/nvim/buffer_updates.h
index ca5246c571..e844f3b2a8 100644
--- a/src/nvim/buffer_updates.h
+++ b/src/nvim/buffer_updates.h
@@ -3,8 +3,8 @@
#include <stdint.h> // IWYU pragma: keep
#include "nvim/buffer_defs.h" // IWYU pragma: keep
-#include "nvim/extmark.h"
-#include "nvim/pos_defs.h"
+#include "nvim/extmark_defs.h" // IWYU pragma: keep
+#include "nvim/pos_defs.h" // IWYU pragma: keep
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "buffer_updates.h.generated.h"
diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c
index 178218729a..f774fcb057 100644
--- a/src/nvim/bufwrite.c
+++ b/src/nvim/bufwrite.c
@@ -26,7 +26,7 @@
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/iconv_defs.h"
#include "nvim/input.h"
#include "nvim/macros_defs.h"
diff --git a/src/nvim/change.c b/src/nvim/change.c
index 20cc034638..81a55b92ee 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -24,7 +24,7 @@
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/indent.h"
#include "nvim/indent_c.h"
#include "nvim/insexpand.h"
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c
index 275b284392..367b86ec55 100644
--- a/src/nvim/cmdexpand.c
+++ b/src/nvim/cmdexpand.c
@@ -35,7 +35,7 @@
#include "nvim/grid.h"
#include "nvim/hashtab.h"
#include "nvim/help.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/highlight_group.h"
#include "nvim/keycodes.h"
#include "nvim/log.h"
diff --git a/src/nvim/context.h b/src/nvim/context.h
index f39399e806..1c18a1af7c 100644
--- a/src/nvim/context.h
+++ b/src/nvim/context.h
@@ -1,6 +1,5 @@
#pragma once
-#include <msgpack.h>
#include <msgpack/sbuffer.h>
#include <stddef.h>
diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c
index 82068ce9c5..745c0cc6ed 100644
--- a/src/nvim/cursor_shape.c
+++ b/src/nvim/cursor_shape.c
@@ -15,6 +15,7 @@
#include "nvim/log.h"
#include "nvim/macros_defs.h"
#include "nvim/option_vars.h"
+#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/ui.h"
#include "nvim/vim_defs.h"
diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c
index dd248ca58e..a343c1ad6b 100644
--- a/src/nvim/debugger.c
+++ b/src/nvim/debugger.c
@@ -32,6 +32,7 @@
#include "nvim/pos_defs.h"
#include "nvim/regexp.h"
#include "nvim/runtime.h"
+#include "nvim/state_defs.h"
#include "nvim/vim_defs.h"
/// batch mode debugging: don't save and restore typeahead.
diff --git a/src/nvim/decoration.h b/src/nvim/decoration.h
index 829046f1b9..f5448c051b 100644
--- a/src/nvim/decoration.h
+++ b/src/nvim/decoration.h
@@ -1,16 +1,15 @@
#pragma once
#include <stdbool.h>
-#include <stddef.h>
+#include <stddef.h> // IWYU pragma: keep
#include <stdint.h>
#include "klib/kvec.h"
#include "nvim/buffer_defs.h"
#include "nvim/decoration_defs.h" // IWYU pragma: export
-#include "nvim/extmark_defs.h"
#include "nvim/macros_defs.h"
#include "nvim/marktree.h"
-#include "nvim/pos_defs.h"
+#include "nvim/pos_defs.h" // IWYU pragma: keep
#include "nvim/types_defs.h"
// actual Decor* data is in decoration_defs.h
diff --git a/src/nvim/decoration_provider.h b/src/nvim/decoration_provider.h
index 90bd9e6a41..e0dd67a6f7 100644
--- a/src/nvim/decoration_provider.h
+++ b/src/nvim/decoration_provider.h
@@ -4,7 +4,7 @@
#include <stdint.h>
#include "klib/kvec.h"
-#include "nvim/buffer_defs.h"
+#include "nvim/buffer_defs.h" // IWYU pragma: keep
#include "nvim/macros_defs.h"
#include "nvim/types_defs.h"
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c
index 647ab26441..99d5cf1035 100644
--- a/src/nvim/digraph.c
+++ b/src/nvim/digraph.c
@@ -22,7 +22,7 @@
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/keycodes.h"
#include "nvim/mapping.h"
#include "nvim/mbyte.h"
@@ -32,6 +32,7 @@
#include "nvim/option_vars.h"
#include "nvim/os/input.h"
#include "nvim/runtime.h"
+#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 5b90231a62..e0887ed1d0 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -21,6 +21,7 @@
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/fold.h"
+#include "nvim/fold_defs.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
#include "nvim/highlight.h"
@@ -48,8 +49,7 @@
#include "nvim/ui.h"
#include "nvim/vim_defs.h"
-#define MB_FILLER_CHAR '<' // character used when a double-width character
- // doesn't fit.
+#define MB_FILLER_CHAR '<' // character used when a double-width character doesn't fit.
/// possible draw states in win_line(), drawn in sequence.
typedef enum {
diff --git a/src/nvim/drawline.h b/src/nvim/drawline.h
index 6a9c6d5597..5a7f220a13 100644
--- a/src/nvim/drawline.h
+++ b/src/nvim/drawline.h
@@ -5,7 +5,7 @@
#include "klib/kvec.h"
#include "nvim/decoration_provider.h"
-#include "nvim/fold.h"
+#include "nvim/fold_defs.h"
#include "nvim/macros_defs.h"
#include "nvim/pos_defs.h"
#include "nvim/types_defs.h"
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 77065f95e9..71a12ea1b0 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -29,7 +29,7 @@
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/highlight_group.h"
#include "nvim/indent.h"
#include "nvim/indent_c.h"
diff --git a/src/nvim/eval.h b/src/nvim/eval.h
index b8104cf82a..1fc2891917 100644
--- a/src/nvim/eval.h
+++ b/src/nvim/eval.h
@@ -277,6 +277,9 @@ enum {
EVAL_EVALUATE = 1, ///< when missing don't actually evaluate
};
+// Character used as separated in autoload function/variable names.
+#define AUTOLOAD_CHAR '#'
+
/// Passed to an eval() function to enable evaluation.
EXTERN evalarg_T EVALARG_EVALUATE INIT( = { EVAL_EVALUATE, NULL, NULL, NULL });
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index 6355dd6b93..55f4721c3a 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -6198,8 +6198,8 @@ M.funcs = {
"mode_bits" Nvim's internal binary representation of "mode".
|mapset()| ignores this; only "mode" is used.
See |maplist()| for usage examples. The values
- are from src/nvim/vim.h and may change in the
- future.
+ are from src/nvim/state_defs.h and may change in
+ the future.
The dictionary can be used to restore a mapping with
|mapset()|.
@@ -6287,8 +6287,8 @@ M.funcs = {
endfor
echo saved_maps->mapnew({_, m -> m.lhs})
<The values of the mode_bits are defined in Nvim's
- src/nvim/vim.h file and they can be discovered at runtime
- using |:map-commands| and "maplist()". Example: >vim
+ src/nvim/state_defs.h file and they can be discovered at
+ runtime using |:map-commands| and "maplist()". Example: >vim
omap xyzzy <Nop>
let op_bit = maplist()->filter(
\ {_, m -> m.lhs == 'xyzzy'})[0].mode_bits
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 974631d61f..e369397047 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -48,7 +48,7 @@
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/help.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/highlight_group.h"
#include "nvim/indent.h"
#include "nvim/input.h"
@@ -79,6 +79,7 @@
#include "nvim/regexp.h"
#include "nvim/search.h"
#include "nvim/spell.h"
+#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/terminal.h"
#include "nvim/types_defs.h"
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index a00124ea30..1722b7902b 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -26,7 +26,7 @@
#include "nvim/fileio.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/macros_defs.h"
#include "nvim/mark.h"
#include "nvim/memory.h"
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 381e23b27d..0b466bbe4e 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -44,7 +44,7 @@
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/highlight_group.h"
#include "nvim/input.h"
#include "nvim/keycodes.h"
diff --git a/src/nvim/ex_docmd.h b/src/nvim/ex_docmd.h
index 3781ba1a34..698153e8df 100644
--- a/src/nvim/ex_docmd.h
+++ b/src/nvim/ex_docmd.h
@@ -28,6 +28,8 @@ enum {
// Whether a command index indicates a user command.
#define IS_USER_CMDIDX(idx) ((int)(idx) < 0)
+enum { DIALOG_MSG_SIZE = 1000, }; ///< buffer size for dialog_msg()
+
/// Structure used to save the current state. Used when executing Normal mode
/// commands while in any other mode.
typedef struct {
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index b078f77b98..64ef17b157 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -39,7 +39,7 @@
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/highlight_group.h"
#include "nvim/keycodes.h"
#include "nvim/macros_defs.h"
diff --git a/src/nvim/ex_getln.h b/src/nvim/ex_getln.h
index 967aab6138..93bdd2299f 100644
--- a/src/nvim/ex_getln.h
+++ b/src/nvim/ex_getln.h
@@ -9,8 +9,6 @@
#include "nvim/option_defs.h" // IWYU pragma: keep
#include "nvim/types_defs.h" // IWYU pragma: keep
-struct cmdline_info;
-
/// Command-line colors: one chunk
///
/// Defines a region which has the same highlighting.
diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c
index 794a76907c..d9c1993f32 100644
--- a/src/nvim/extmark.c
+++ b/src/nvim/extmark.c
@@ -26,6 +26,7 @@
// code for redrawing the line with the deleted decoration.
#include <assert.h>
+#include <stddef.h>
#include "nvim/api/private/defs.h"
#include "nvim/buffer_defs.h"
diff --git a/src/nvim/extmark.h b/src/nvim/extmark.h
index 53a8215882..061cd0ed5f 100644
--- a/src/nvim/extmark.h
+++ b/src/nvim/extmark.h
@@ -17,9 +17,6 @@ EXTERN int extmark_splice_pending INIT( = 0);
typedef kvec_t(MTPair) ExtmarkInfoArray;
-// TODO(bfredl): good enough name for now.
-typedef ptrdiff_t bcount_t;
-
// delete the columns between mincol and endcol
typedef struct {
int start_row;
diff --git a/src/nvim/extmark_defs.h b/src/nvim/extmark_defs.h
index 458c80b16b..c5a8684545 100644
--- a/src/nvim/extmark_defs.h
+++ b/src/nvim/extmark_defs.h
@@ -3,6 +3,9 @@
#include "klib/kvec.h"
#include "nvim/types_defs.h"
+// TODO(bfredl): good enough name for now.
+typedef ptrdiff_t bcount_t;
+
typedef struct undo_object ExtmarkUndoObject;
typedef kvec_t(ExtmarkUndoObject) extmark_undo_vec_t;
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 303776b2eb..0bb664bcf5 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -37,7 +37,7 @@
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/iconv_defs.h"
#include "nvim/log.h"
#include "nvim/macros_defs.h"
@@ -60,6 +60,7 @@
#include "nvim/regexp.h"
#include "nvim/sha256.h"
#include "nvim/shada.h"
+#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/types_defs.h"
#include "nvim/ui.h"
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index 69857d2628..c905b2d3ed 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -45,6 +45,7 @@
#include "nvim/plines.h"
#include "nvim/pos_defs.h"
#include "nvim/search.h"
+#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/types_defs.h"
diff --git a/src/nvim/fold_defs.h b/src/nvim/fold_defs.h
index 20a5805769..68ecd9cc7e 100644
--- a/src/nvim/fold_defs.h
+++ b/src/nvim/fold_defs.h
@@ -2,13 +2,14 @@
#include "nvim/pos_defs.h"
-// Info used to pass info about a fold from the fold-detection code to the
-// code that displays the foldcolumn.
+/// Info used to pass info about a fold from the fold-detection code to the
+/// code that displays the foldcolumn.
typedef struct foldinfo {
- linenr_T fi_lnum; // line number where fold starts
- int fi_level; // level of the fold; when this is zero the
- // other fields are invalid
- int fi_low_level; // lowest fold level that starts in the same
- // line
+ linenr_T fi_lnum; ///< line number where fold starts
+ int fi_level; ///< level of the fold; when this is zero the
+ ///< other fields are invalid
+ int fi_low_level; ///< lowest fold level that starts in the same line
linenr_T fi_lines;
} foldinfo_T;
+
+enum { FOLD_TEXT_LEN = 51, }; ///< buffer size for get_foldtext()
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 080be8a1d4..270ffe4fa0 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -15,6 +15,7 @@
#include "nvim/menu_defs.h"
#include "nvim/os/os_defs.h"
#include "nvim/runtime.h"
+#include "nvim/state_defs.h"
#include "nvim/syntax_defs.h"
#include "nvim/types_defs.h"
diff --git a/src/nvim/grid.c b/src/nvim/grid.c
index e5b870e6b0..2ef89b778e 100644
--- a/src/nvim/grid.c
+++ b/src/nvim/grid.c
@@ -29,7 +29,6 @@
#include "nvim/option_vars.h"
#include "nvim/types_defs.h"
#include "nvim/ui.h"
-#include "nvim/vim_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "grid.c.generated.h"
diff --git a/src/nvim/highlight.h b/src/nvim/highlight.h
index 8c8657ae77..e5d3f3d1ca 100644
--- a/src/nvim/highlight.h
+++ b/src/nvim/highlight.h
@@ -29,3 +29,6 @@ static inline int win_hl_attr(win_T *wp, int hlf)
rgb_bg = rgb_bg != -1 ? rgb_bg : (dark_ ? 0x000000 : 0xFFFFFF); \
rgb_sp = rgb_sp != -1 ? rgb_sp : 0xFF0000; \
} while (0);
+
+// Enums need a typecast to be used as array index.
+#define HL_ATTR(n) hl_attr_active[(int)(n)]
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index e3ba395164..348f3a6528 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -36,6 +36,7 @@
#include "nvim/pos_defs.h"
#include "nvim/regexp.h"
#include "nvim/search.h"
+#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/textformat.h"
#include "nvim/types_defs.h"
@@ -1369,11 +1370,11 @@ int get_lisp_indent(void)
static int lisp_match(char *p)
{
- char buf[LSIZE];
+ char buf[512];
char *word = *curbuf->b_p_lw != NUL ? curbuf->b_p_lw : p_lispwords;
while (*word != NUL) {
- (void)copy_option_part(&word, buf, LSIZE, ",");
+ (void)copy_option_part(&word, buf, sizeof(buf), ",");
int len = (int)strlen(buf);
if ((strncmp(buf, p, (size_t)len) == 0) && ascii_iswhite_or_nul(p[len])) {
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index 77851bfaac..c140d468d8 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -22,6 +22,7 @@
#include "nvim/plines.h"
#include "nvim/pos_defs.h"
#include "nvim/search.h"
+#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/vim_defs.h"
diff --git a/src/nvim/input.c b/src/nvim/input.c
index e3fe17fcf9..fb25968071 100644
--- a/src/nvim/input.c
+++ b/src/nvim/input.c
@@ -11,7 +11,7 @@
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/input.h"
#include "nvim/keycodes.h"
#include "nvim/mbyte.h"
@@ -19,8 +19,8 @@
#include "nvim/message.h"
#include "nvim/mouse.h"
#include "nvim/os/input.h"
+#include "nvim/state_defs.h"
#include "nvim/ui.h"
-#include "nvim/vim_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "input.c.generated.h" // IWYU pragma: export
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index e1a6b1fbf3..12543a2d42 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -29,7 +29,7 @@
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/indent.h"
#include "nvim/indent_c.h"
#include "nvim/insexpand.h"
diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c
index 4c6e38ca57..4598d48c4a 100644
--- a/src/nvim/lua/converter.c
+++ b/src/nvim/lua/converter.c
@@ -7,12 +7,9 @@
#include <stdlib.h>
#include <string.h>
+#include "klib/kvec.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
-#include "nvim/memory.h"
-// FIXME: vim.h is not actually needed, but otherwise it states MAXPATHL is
-// redefined
-#include "klib/kvec.h"
#include "nvim/ascii_defs.h"
#include "nvim/eval/decode.h"
#include "nvim/eval/typval.h"
@@ -24,6 +21,7 @@
#include "nvim/lua/converter.h"
#include "nvim/lua/executor.h"
#include "nvim/macros_defs.h"
+#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/types_defs.h"
#include "nvim/vim_defs.h"
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 3d8f33628f..6585bd1df7 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -17,10 +17,6 @@
# include <sanitizer/ubsan_interface.h>
#endif
-// uncrustify:off
-#include "nvim/vim_defs.h"
-// uncrustify:on
-
#include "auto/config.h" // IWYU pragma: keep
#include "nvim/api/extmark.h"
#include "nvim/api/private/defs.h"
@@ -99,6 +95,7 @@
#include "nvim/ui_client.h"
#include "nvim/ui_compositor.h"
#include "nvim/version.h"
+#include "nvim/vim_defs.h"
#include "nvim/window.h"
#ifdef MSWIN
# include "nvim/os/os_win_console.h"
diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c
index 6fc9c04194..17593a9121 100644
--- a/src/nvim/mapping.c
+++ b/src/nvim/mapping.c
@@ -29,7 +29,7 @@
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/keycodes.h"
#include "nvim/lua/executor.h"
#include "nvim/macros_defs.h"
@@ -44,6 +44,7 @@
#include "nvim/regexp_defs.h"
#include "nvim/runtime.h"
#include "nvim/search.h"
+#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/types_defs.h"
#include "nvim/ui.h"
diff --git a/src/nvim/mapping_defs.h b/src/nvim/mapping_defs.h
index 8056273a09..6691c5ac3b 100644
--- a/src/nvim/mapping_defs.h
+++ b/src/nvim/mapping_defs.h
@@ -5,6 +5,9 @@
#include "nvim/eval/typval_defs.h"
#include "nvim/types_defs.h"
+/// Maximum length of key sequence to be mapped.
+enum { MAXMAPLEN = 50, };
+
/// Structure used for mappings and abbreviations.
typedef struct mapblock mapblock_T;
struct mapblock {
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index 8bc9965b50..5839cf7a2e 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -20,7 +20,7 @@
#include "nvim/fold.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
diff --git a/src/nvim/marktree.h b/src/nvim/marktree.h
index 37119048ae..c76359d3f9 100644
--- a/src/nvim/marktree.h
+++ b/src/nvim/marktree.h
@@ -1,21 +1,16 @@
#pragma once
-#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "klib/kvec.h"
-#include "nvim/assert_defs.h"
#include "nvim/decoration_defs.h"
-#include "nvim/garray_defs.h"
+#include "nvim/garray_defs.h" // IWYU pragma: keep
#include "nvim/map_defs.h"
-#include "nvim/pos_defs.h"
-#include "nvim/types_defs.h"
+#include "nvim/pos_defs.h" // IWYU pragma: keep
// only for debug functions:
-#include "nvim/api/private/defs.h"
-
-struct mtnode_s;
+#include "nvim/api/private/defs.h" // IWYU pragma: keep
#define MT_MAX_DEPTH 20
#define MT_BRANCH_FACTOR 10
diff --git a/src/nvim/mbyte_defs.h b/src/nvim/mbyte_defs.h
index c5c973c71a..2904047223 100644
--- a/src/nvim/mbyte_defs.h
+++ b/src/nvim/mbyte_defs.h
@@ -4,6 +4,11 @@
#include "nvim/iconv_defs.h"
+/// Maximum number of bytes in a multi-byte character. It can be one 32-bit
+/// character of up to 6 bytes, or one 16-bit character of up to three bytes
+/// plus six following composing characters of three bytes each.
+enum { MB_MAXBYTES = 21, };
+
/// max length of an unicode char
enum { MB_MAXCHAR = 6, };
diff --git a/src/nvim/memfile.h b/src/nvim/memfile.h
index 2d1930e95c..687ac042a4 100644
--- a/src/nvim/memfile.h
+++ b/src/nvim/memfile.h
@@ -11,6 +11,15 @@ enum {
MFS_ZERO = 8, ///< only write block 0
};
+enum {
+ /// Minimal size for block 0 of a swap file.
+ /// NOTE: This depends on size of struct block0! It's not done with a sizeof(),
+ /// because struct block0 is defined in memline.c (Sorry).
+ /// The maximal block size is arbitrary.
+ MIN_SWAP_PAGE_SIZE = 1048,
+ MAX_SWAP_PAGE_SIZE = 50000,
+};
+
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "memfile.h.generated.h"
#endif
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 3ecbcaad1e..3c671121b7 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -60,7 +60,7 @@
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/input.h"
#include "nvim/macros_defs.h"
#include "nvim/main.h"
@@ -167,29 +167,29 @@ enum {
B0_MAGIC_CHAR = 0x55,
};
-// Block zero holds all info about the swapfile. This is the first block in the file.
-//
-// NOTE: DEFINITION OF BLOCK 0 SHOULD NOT CHANGE! It would make all existing swapfiles unusable!
-//
-// If size of block0 changes anyway, adjust MIN_SWAP_PAGE_SIZE in vim.h!!
-//
-// This block is built up of single bytes, to make it portable across
-// different machines. b0_magic_* is used to check the byte order and size of
-// variables, because the rest of the swapfile is not portable.
+/// Block zero holds all info about the swapfile. This is the first block in the file.
+///
+/// NOTE: DEFINITION OF BLOCK 0 SHOULD NOT CHANGE! It would make all existing swapfiles unusable!
+///
+/// If size of block0 changes anyway, adjust MIN_SWAP_PAGE_SIZE in memfile.h!!
+///
+/// This block is built up of single bytes, to make it portable across
+/// different machines. b0_magic_* is used to check the byte order and size of
+/// variables, because the rest of the swapfile is not portable.
typedef struct {
char b0_id[2]; ///< ID for block 0: BLOCK0_ID0 and BLOCK0_ID1.
- char b0_version[10]; // Vim version string
- char b0_page_size[4]; // number of bytes per page
- char b0_mtime[4]; // last modification time of file
- char b0_ino[4]; // inode of b0_fname
- char b0_pid[4]; // process id of creator (or 0)
- char b0_uname[B0_UNAME_SIZE]; // name of user (uid if no name)
- char b0_hname[B0_HNAME_SIZE]; // host name (if it has a name)
- char b0_fname[B0_FNAME_SIZE_ORG]; // name of file being edited
- long b0_magic_long; // check for byte order of long
- int b0_magic_int; // check for byte order of int
- int16_t b0_magic_short; // check for byte order of short
- char b0_magic_char; // check for last char
+ char b0_version[10]; ///< Vim version string
+ char b0_page_size[4]; ///< number of bytes per page
+ char b0_mtime[4]; ///< last modification time of file
+ char b0_ino[4]; ///< inode of b0_fname
+ char b0_pid[4]; ///< process id of creator (or 0)
+ char b0_uname[B0_UNAME_SIZE]; ///< name of user (uid if no name)
+ char b0_hname[B0_HNAME_SIZE]; ///< host name (if it has a name)
+ char b0_fname[B0_FNAME_SIZE_ORG]; ///< name of file being edited
+ long b0_magic_long; ///< check for byte order of long
+ int b0_magic_int; ///< check for byte order of int
+ int16_t b0_magic_short; ///< check for byte order of short
+ char b0_magic_char; ///< check for last char
} ZeroBlock;
// Note: b0_dirty and b0_flags are put at the end of the file name. For very
diff --git a/src/nvim/memory.c b/src/nvim/memory.c
index 5eb4a548fb..a13091793c 100644
--- a/src/nvim/memory.c
+++ b/src/nvim/memory.c
@@ -30,6 +30,7 @@
#include "nvim/message.h"
#include "nvim/option_vars.h"
#include "nvim/sign.h"
+#include "nvim/state_defs.h"
#include "nvim/ui.h"
#include "nvim/usercmd.h"
#include "nvim/vim_defs.h"
diff --git a/src/nvim/menu.c b/src/nvim/menu.c
index fb42913bfe..3252a73970 100644
--- a/src/nvim/menu.c
+++ b/src/nvim/menu.c
@@ -20,7 +20,7 @@
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/keycodes.h"
#include "nvim/macros_defs.h"
#include "nvim/mbyte.h"
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 4bf099d1fa..3268ff389a 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -50,6 +50,7 @@
#include "nvim/pos_defs.h"
#include "nvim/regexp.h"
#include "nvim/runtime.h"
+#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/types_defs.h"
#include "nvim/ui.h"
diff --git a/src/nvim/message.h b/src/nvim/message.h
index 04ea1a76ff..adbb40277b 100644
--- a/src/nvim/message.h
+++ b/src/nvim/message.h
@@ -1,15 +1,15 @@
#pragma once
-#include <stdarg.h>
+#include <errno.h>
#include <stdbool.h>
-#include <stddef.h>
+#include <stddef.h> // IWYU pragma: keep
+#include <stdio.h>
#include "klib/kvec.h"
#include "nvim/api/private/defs.h"
-#include "nvim/ex_cmds_defs.h"
+#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
#include "nvim/grid_defs.h"
#include "nvim/macros_defs.h"
-#include "nvim/types_defs.h"
/// Types of dialogs passed to do_dialog().
enum {
@@ -30,6 +30,9 @@ enum {
VIM_DISCARDALL = 6,
};
+/// special attribute addition: Put message in history
+enum { MSG_HIST = 0x1000, };
+
typedef struct {
String text;
int attr;
@@ -77,3 +80,14 @@ EXTERN int msg_listdo_overwrite INIT( = 0);
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "message.h.generated.h"
#endif
+
+// Prefer using semsg(), because perror() may send the output to the wrong
+// destination and mess up the screen.
+#define PERROR(msg) (void)semsg("%s: %s", (msg), strerror(errno))
+
+#ifndef MSWIN
+/// Headless (no UI) error message handler.
+# define os_errmsg(str) fprintf(stderr, "%s", (str))
+/// Headless (no UI) message handler.
+# define os_msg(str) printf("%s", (str))
+#endif
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 503b3671fa..1f789dc153 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -40,7 +40,7 @@
#include "nvim/globals.h"
#include "nvim/grid.h"
#include "nvim/help.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/keycodes.h"
#include "nvim/macros_defs.h"
#include "nvim/mapping.h"
diff --git a/src/nvim/normal_defs.h b/src/nvim/normal_defs.h
index dcb7aa6186..060c1057f9 100644
--- a/src/nvim/normal_defs.h
+++ b/src/nvim/normal_defs.h
@@ -64,6 +64,12 @@ enum {
CA_NO_ADJ_OP_END = 2, ///< don't adjust operator end
};
+/// Replacement for nchar used by nv_replace().
+enum {
+ REPLACE_CR_NCHAR = -1,
+ REPLACE_NL_NCHAR = -2,
+};
+
/// columns needed by shown command
enum { SHOWCMD_COLS = 10, };
enum { SHOWCMD_BUFLEN = SHOWCMD_COLS + 1 + 30, };
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index e66f46945e..3a4e87edf7 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -32,7 +32,7 @@
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/indent.h"
#include "nvim/indent_c.h"
#include "nvim/keycodes.h"
@@ -103,9 +103,9 @@ static const char e_search_pattern_and_expression_register_may_not_contain_two_o
#define OPF_LINES 1 // operator always works on lines
#define OPF_CHANGE 2 // operator changes text
-// The names of operators.
-// IMPORTANT: Index must correspond with defines in vim.h!!!
-// The third field indicates whether the operator always works on lines.
+/// The names of operators.
+/// IMPORTANT: Index must correspond with defines in ops.h!!!
+/// The third field indicates whether the operator always works on lines.
static char opchars[][3] = {
{ NUL, NUL, 0 }, // OP_NOP
{ 'd', NUL, OPF_CHANGE }, // OP_DELETE
diff --git a/src/nvim/ops.h b/src/nvim/ops.h
index 106e59f383..67a613cbca 100644
--- a/src/nvim/ops.h
+++ b/src/nvim/ops.h
@@ -1,78 +1,82 @@
#pragma once
-#include <lauxlib.h>
#include <stdbool.h>
#include <stddef.h>
#include "nvim/ascii_defs.h"
#include "nvim/eval/typval_defs.h"
-#include "nvim/ex_cmds_defs.h"
-#include "nvim/extmark.h"
+#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
+#include "nvim/extmark_defs.h" // IWYU pragma: keep
+#include "nvim/func_attr.h"
#include "nvim/macros_defs.h"
-#include "nvim/normal.h"
-#include "nvim/option_defs.h"
-#include "nvim/os/time.h"
+#include "nvim/normal_defs.h"
+#include "nvim/option_defs.h" // IWYU pragma: keep
+#include "nvim/os/time_defs.h"
#include "nvim/pos_defs.h"
#include "nvim/types_defs.h"
typedef int (*Indenter)(void);
-// flags for do_put()
-#define PUT_FIXINDENT 1 // make indent look nice
-#define PUT_CURSEND 2 // leave cursor after end of new text
-#define PUT_CURSLINE 4 // leave cursor on last line of new text
-#define PUT_LINE 8 // put register as lines
-#define PUT_LINE_SPLIT 16 // split line for linewise register
-#define PUT_LINE_FORWARD 32 // put linewise register below Visual sel.
-#define PUT_BLOCK_INNER 64 // in block mode, do not add trailing spaces
+/// flags for do_put()
+enum {
+ PUT_FIXINDENT = 1, ///< make indent look nice
+ PUT_CURSEND = 2, ///< leave cursor after end of new text
+ PUT_CURSLINE = 4, ///< leave cursor on last line of new text
+ PUT_LINE = 8, ///< put register as lines
+ PUT_LINE_SPLIT = 16, ///< split line for linewise register
+ PUT_LINE_FORWARD = 32, ///< put linewise register below Visual sel.
+ PUT_BLOCK_INNER = 64, ///< in block mode, do not add trailing spaces
+};
-// Registers:
-// 0 = register for latest (unnamed) yank
-// 1..9 = registers '1' to '9', for deletes
-// 10..35 = registers 'a' to 'z'
-// 36 = delete register '-'
-// 37 = selection register '*'
-// 38 = clipboard register '+'
-#define DELETION_REGISTER 36
-#define NUM_SAVED_REGISTERS 37
-// The following registers should not be saved in ShaDa file:
-#define STAR_REGISTER 37
-#define PLUS_REGISTER 38
-#define NUM_REGISTERS 39
+/// Registers:
+/// 0 = register for latest (unnamed) yank
+/// 1..9 = registers '1' to '9', for deletes
+/// 10..35 = registers 'a' to 'z'
+/// 36 = delete register '-'
+/// 37 = selection register '*'
+/// 38 = clipboard register '+'
+enum {
+ DELETION_REGISTER = 36,
+ NUM_SAVED_REGISTERS = 37,
+ // The following registers should not be saved in ShaDa file:
+ STAR_REGISTER = 37,
+ PLUS_REGISTER = 38,
+ NUM_REGISTERS = 39,
+};
-// Operator IDs; The order must correspond to opchars[] in ops.c!
-#define OP_NOP 0 // no pending operation
-#define OP_DELETE 1 // "d" delete operator
-#define OP_YANK 2 // "y" yank operator
-#define OP_CHANGE 3 // "c" change operator
-#define OP_LSHIFT 4 // "<" left shift operator
-#define OP_RSHIFT 5 // ">" right shift operator
-#define OP_FILTER 6 // "!" filter operator
-#define OP_TILDE 7 // "g~" switch case operator
-#define OP_INDENT 8 // "=" indent operator
-#define OP_FORMAT 9 // "gq" format operator
-#define OP_COLON 10 // ":" colon operator
-#define OP_UPPER 11 // "gU" make upper case operator
-#define OP_LOWER 12 // "gu" make lower case operator
-#define OP_JOIN 13 // "J" join operator, only for Visual mode
-#define OP_JOIN_NS 14 // "gJ" join operator, only for Visual mode
-#define OP_ROT13 15 // "g?" rot-13 encoding
-#define OP_REPLACE 16 // "r" replace chars, only for Visual mode
-#define OP_INSERT 17 // "I" Insert column, only for Visual mode
-#define OP_APPEND 18 // "A" Append column, only for Visual mode
-#define OP_FOLD 19 // "zf" define a fold
-#define OP_FOLDOPEN 20 // "zo" open folds
-#define OP_FOLDOPENREC 21 // "zO" open folds recursively
-#define OP_FOLDCLOSE 22 // "zc" close folds
-#define OP_FOLDCLOSEREC 23 // "zC" close folds recursively
-#define OP_FOLDDEL 24 // "zd" delete folds
-#define OP_FOLDDELREC 25 // "zD" delete folds recursively
-#define OP_FORMAT2 26 // "gw" format operator, keeps cursor pos
-#define OP_FUNCTION 27 // "g@" call 'operatorfunc'
-#define OP_NR_ADD 28 // "<C-A>" Add to the number or alphabetic
- // character (OP_ADD conflicts with Perl)
-#define OP_NR_SUB 29 // "<C-X>" Subtract from the number or
- // alphabetic character
+/// Operator IDs; The order must correspond to opchars[] in ops.c!
+enum {
+ OP_NOP = 0, ///< no pending operation
+ OP_DELETE = 1, ///< "d" delete operator
+ OP_YANK = 2, ///< "y" yank operator
+ OP_CHANGE = 3, ///< "c" change operator
+ OP_LSHIFT = 4, ///< "<" left shift operator
+ OP_RSHIFT = 5, ///< ">" right shift operator
+ OP_FILTER = 6, ///< "!" filter operator
+ OP_TILDE = 7, ///< "g~" switch case operator
+ OP_INDENT = 8, ///< "=" indent operator
+ OP_FORMAT = 9, ///< "gq" format operator
+ OP_COLON = 10, ///< ":" colon operator
+ OP_UPPER = 11, ///< "gU" make upper case operator
+ OP_LOWER = 12, ///< "gu" make lower case operator
+ OP_JOIN = 13, ///< "J" join operator, only for Visual mode
+ OP_JOIN_NS = 14, ///< "gJ" join operator, only for Visual mode
+ OP_ROT13 = 15, ///< "g?" rot-13 encoding
+ OP_REPLACE = 16, ///< "r" replace chars, only for Visual mode
+ OP_INSERT = 17, ///< "I" Insert column, only for Visual mode
+ OP_APPEND = 18, ///< "A" Append column, only for Visual mode
+ OP_FOLD = 19, ///< "zf" define a fold
+ OP_FOLDOPEN = 20, ///< "zo" open folds
+ OP_FOLDOPENREC = 21, ///< "zO" open folds recursively
+ OP_FOLDCLOSE = 22, ///< "zc" close folds
+ OP_FOLDCLOSEREC = 23, ///< "zC" close folds recursively
+ OP_FOLDDEL = 24, ///< "zd" delete folds
+ OP_FOLDDELREC = 25, ///< "zD" delete folds recursively
+ OP_FORMAT2 = 26, ///< "gw" format operator, keeps cursor pos
+ OP_FUNCTION = 27, ///< "g@" call 'operatorfunc'
+ OP_NR_ADD = 28, ///< "<C-A>" Add to the number or alphabetic character
+ OP_NR_SUB = 29, ///< "<C-X>" Subtract from the number or alphabetic character
+};
/// Flags for get_reg_contents().
enum GRegFlags {
diff --git a/src/nvim/option.c b/src/nvim/option.c
index ec974aaa7a..96d6d8e01e 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -89,6 +89,7 @@
#include "nvim/spell.h"
#include "nvim/spellfile.h"
#include "nvim/spellsuggest.h"
+#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/tag.h"
#include "nvim/terminal.h"
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index 5ae24c89ab..f3bd1c7ed9 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -28,7 +28,6 @@
#include "nvim/profile.h"
#include "nvim/rbuffer.h"
#include "nvim/state.h"
-#include "nvim/vim_defs.h"
#define READ_BUFFER_SIZE 0xfff
#define INPUT_BUFFER_SIZE (READ_BUFFER_SIZE * 4)
diff --git a/src/nvim/os/os_defs.h b/src/nvim/os/os_defs.h
index e5060a5e6a..9db559e7a5 100644
--- a/src/nvim/os/os_defs.h
+++ b/src/nvim/os/os_defs.h
@@ -41,6 +41,8 @@
// Command-processing buffer. Use large buffers for all platforms.
#define CMDBUFFSIZE 1024
+#define ROOT_UID 0
+
/// Converts libuv error (negative int) to error description string.
#define os_strerror uv_strerror
diff --git a/src/nvim/os/os_win_console.c b/src/nvim/os/os_win_console.c
index 1a5ecefaa9..816e81e997 100644
--- a/src/nvim/os/os_win_console.c
+++ b/src/nvim/os/os_win_console.c
@@ -1,8 +1,10 @@
+#include <string.h>
+
+#include "nvim/globals.h"
#include "nvim/os/fs.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/os/os_win_console.h"
-#include "nvim/vim_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "os/os_win_console.c.generated.h"
diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c
index 994c67ae4c..191be784e8 100644
--- a/src/nvim/os/shell.c
+++ b/src/nvim/os/shell.c
@@ -38,6 +38,7 @@
#include "nvim/pos_defs.h"
#include "nvim/profile.h"
#include "nvim/rbuffer.h"
+#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/tag.h"
#include "nvim/types_defs.h"
diff --git a/src/nvim/os/users.c b/src/nvim/os/users.c
index 5f77b5a6ee..ae0994a73f 100644
--- a/src/nvim/os/users.c
+++ b/src/nvim/os/users.c
@@ -17,6 +17,9 @@
#endif
#ifdef MSWIN
# include <lm.h>
+
+# include "nvim/mbyte.h"
+# include "nvim/message.h"
#endif
// All user names (for ~user completion as done by shell).
diff --git a/src/nvim/plines.c b/src/nvim/plines.c
index 5ad453043b..6e9f92c193 100644
--- a/src/nvim/plines.c
+++ b/src/nvim/plines.c
@@ -24,7 +24,6 @@
#include "nvim/pos_defs.h"
#include "nvim/state.h"
#include "nvim/types_defs.h"
-#include "nvim/vim_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "plines.c.generated.h"
diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c
index 5f2faf01b7..f009722357 100644
--- a/src/nvim/popupmenu.c
+++ b/src/nvim/popupmenu.c
@@ -31,6 +31,7 @@
#include "nvim/option_vars.h"
#include "nvim/popupmenu.h"
#include "nvim/pos_defs.h"
+#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/ui.h"
#include "nvim/ui_compositor.h"
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index eee0296ad6..4e20eb8925 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -34,7 +34,7 @@
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/help.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/highlight_group.h"
#include "nvim/macros_defs.h"
#include "nvim/mark.h"
@@ -252,6 +252,8 @@ static const char *e_current_quickfix_list_was_changed =
static const char *e_current_location_list_was_changed =
N_("E926: Current location list was changed");
+enum { QF_WINHEIGHT = 10, }; ///< default height for quickfix window
+
// Quickfix window check helper macro
#define IS_QF_WINDOW(wp) (bt_quickfix((wp)->w_buffer) && (wp)->w_llist_ref == NULL)
// Location list window check helper macro
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c
index a0926865e6..38d3942126 100644
--- a/src/nvim/runtime.c
+++ b/src/nvim/runtime.c
@@ -55,6 +55,9 @@
#include "nvim/types_defs.h"
#include "nvim/usercmd.h"
#include "nvim/vim_defs.h"
+#ifdef USE_CRNL
+# include "nvim/highlight.h"
+#endif
/// Structure used to store info for each sourced file.
/// It is shared between do_source() and getsourceline().
@@ -65,7 +68,7 @@ struct source_cookie {
char *nextline; ///< if not NULL: line that was read ahead
linenr_T sourcing_lnum; ///< line number of the source file
int finished; ///< ":finish" used
-#if defined(USE_CRNL)
+#ifdef USE_CRNL
int fileformat; ///< EOL_UNKNOWN, EOL_UNIX or EOL_DOS
bool error; ///< true if LF found after CR-LF
#endif
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 4c790a50a1..642219c1e0 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -28,7 +28,7 @@
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/indent_c.h"
#include "nvim/insexpand.h"
#include "nvim/macros_defs.h"
@@ -50,7 +50,9 @@
#include "nvim/profile.h"
#include "nvim/regexp.h"
#include "nvim/search.h"
+#include "nvim/state_defs.h"
#include "nvim/strings.h"
+#include "nvim/tag.h"
#include "nvim/ui.h"
#include "nvim/vim_defs.h"
#include "nvim/window.h"
diff --git a/src/nvim/sign.c b/src/nvim/sign.c
index 62dc450ff5..d05c708d2c 100644
--- a/src/nvim/sign.c
+++ b/src/nvim/sign.c
@@ -29,7 +29,7 @@
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/highlight_group.h"
#include "nvim/macros_defs.h"
#include "nvim/map_defs.h"
diff --git a/src/nvim/state.h b/src/nvim/state.h
index 6617b77fa0..8c5957bf9a 100644
--- a/src/nvim/state.h
+++ b/src/nvim/state.h
@@ -1,14 +1,6 @@
#pragma once
-typedef struct vim_state VimState;
-
-typedef int (*state_check_callback)(VimState *state);
-typedef int (*state_execute_callback)(VimState *state, int key);
-
-struct vim_state {
- state_check_callback check;
- state_execute_callback execute;
-};
+#include "nvim/state_defs.h" // IWYU pragma: export
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "state.h.generated.h"
diff --git a/src/nvim/state_defs.h b/src/nvim/state_defs.h
new file mode 100644
index 0000000000..0b32412f5a
--- /dev/null
+++ b/src/nvim/state_defs.h
@@ -0,0 +1,45 @@
+#pragma once
+
+typedef struct vim_state VimState;
+
+typedef int (*state_check_callback)(VimState *state);
+typedef int (*state_execute_callback)(VimState *state, int key);
+
+struct vim_state {
+ state_check_callback check;
+ state_execute_callback execute;
+};
+
+/// Values for State
+///
+/// The lower bits up to 0x80 are used to distinguish normal/visual/op_pending
+/// /cmdline/insert/replace/terminal mode. This is used for mapping. If none
+/// of these bits are set, no mapping is done. See the comment above do_map().
+/// The upper bits are used to distinguish between other states and variants of
+/// the base modes.
+enum {
+ MODE_NORMAL = 0x01, ///< Normal mode, command expected
+ MODE_VISUAL = 0x02, ///< Visual mode - use get_real_state()
+ MODE_OP_PENDING = 0x04, ///< Normal mode, operator is pending - use get_real_state()
+ MODE_CMDLINE = 0x08, ///< Editing the command line
+ MODE_INSERT = 0x10, ///< Insert mode, also for Replace mode
+ MODE_LANGMAP = 0x20, ///< Language mapping, can be combined with MODE_INSERT and MODE_CMDLINE
+ MODE_SELECT = 0x40, ///< Select mode, use get_real_state()
+ MODE_TERMINAL = 0x80, ///< Terminal mode
+
+ MAP_ALL_MODES = 0xff, ///< all mode bits used for mapping
+
+ REPLACE_FLAG = 0x100, ///< Replace mode flag
+ MODE_REPLACE = REPLACE_FLAG | MODE_INSERT,
+ VREPLACE_FLAG = 0x200, ///< Virtual-replace mode flag
+ MODE_VREPLACE = REPLACE_FLAG | VREPLACE_FLAG | MODE_INSERT,
+ MODE_LREPLACE = REPLACE_FLAG | MODE_LANGMAP,
+
+ MODE_NORMAL_BUSY = 0x1000 | MODE_NORMAL, ///< Normal mode, busy with a command
+ MODE_HITRETURN = 0x2000 | MODE_NORMAL, ///< waiting for return or command
+ MODE_ASKMORE = 0x3000, ///< Asking if you want --more--
+ MODE_SETWSIZE = 0x4000, ///< window size has changed
+ MODE_EXTERNCMD = 0x5000, ///< executing an external command
+ MODE_SHOWMATCH = 0x6000 | MODE_INSERT, ///< show matching paren
+ MODE_CONFIRM = 0x7000, ///< ":confirm" prompt
+};
diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c
index d42a180948..604ec3dfae 100644
--- a/src/nvim/statusline.c
+++ b/src/nvim/statusline.c
@@ -37,6 +37,7 @@
#include "nvim/plines.h"
#include "nvim/pos_defs.h"
#include "nvim/sign.h"
+#include "nvim/state_defs.h"
#include "nvim/statusline.h"
#include "nvim/strings.h"
#include "nvim/ui.h"
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 33d0d46d94..11282ea170 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -25,7 +25,7 @@
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/hashtab.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/highlight_group.h"
#include "nvim/indent_c.h"
#include "nvim/macros_defs.h"
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index f99f0dc612..c6a1a13606 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -29,7 +29,7 @@
#include "nvim/globals.h"
#include "nvim/hashtab.h"
#include "nvim/help.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/input.h"
#include "nvim/insexpand.h"
#include "nvim/macros_defs.h"
@@ -51,6 +51,7 @@
#include "nvim/regexp.h"
#include "nvim/runtime.h"
#include "nvim/search.h"
+#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/tag.h"
#include "nvim/ui.h"
diff --git a/src/nvim/tag.h b/src/nvim/tag.h
index f628d23fbe..87e71c8bef 100644
--- a/src/nvim/tag.h
+++ b/src/nvim/tag.h
@@ -5,6 +5,8 @@
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
#include "nvim/option_defs.h" // IWYU pragma: keep
+enum { LSIZE = 512, }; ///< max. size of a line in the tags file
+
/// Values for do_tag().
enum {
DT_TAG = 1, ///< jump to newer position or same tag again
diff --git a/src/nvim/textformat.c b/src/nvim/textformat.c
index 64c698f48f..b69d438a59 100644
--- a/src/nvim/textformat.c
+++ b/src/nvim/textformat.c
@@ -32,6 +32,7 @@
#include "nvim/os/input.h"
#include "nvim/pos_defs.h"
#include "nvim/search.h"
+#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/textformat.h"
#include "nvim/textobject.h"
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index 3cc07b835e..36f34bc75a 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -29,11 +29,11 @@
#include "nvim/option.h"
#include "nvim/option_vars.h"
#include "nvim/os/time.h"
+#include "nvim/state_defs.h"
#include "nvim/strings.h"
#include "nvim/ui.h"
#include "nvim/ui_client.h"
#include "nvim/ui_compositor.h"
-#include "nvim/vim_defs.h"
#include "nvim/window.h"
#include "nvim/winfloat.h"
diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c
index 9b6dafae98..b698e017dc 100644
--- a/src/nvim/ui_compositor.c
+++ b/src/nvim/ui_compositor.c
@@ -27,7 +27,6 @@
#include "nvim/types_defs.h"
#include "nvim/ui.h"
#include "nvim/ui_compositor.h"
-#include "nvim/vim_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "ui_compositor.c.generated.h"
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index b60211941f..93a973c33d 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -104,7 +104,7 @@
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/macros_defs.h"
#include "nvim/mark.h"
#include "nvim/memline.h"
diff --git a/src/nvim/undo_defs.h b/src/nvim/undo_defs.h
index 3e745ab4dc..0b78ea543f 100644
--- a/src/nvim/undo_defs.h
+++ b/src/nvim/undo_defs.h
@@ -6,28 +6,31 @@
#include "nvim/mark_defs.h"
#include "nvim/pos_defs.h"
+/// Size in bytes of the hash used in the undo file.
+enum { UNDO_HASH_SIZE = 32, };
+
typedef struct u_header u_header_T;
-// Structure to store info about the Visual area.
+/// Structure to store info about the Visual area.
typedef struct {
- pos_T vi_start; // start pos of last VIsual
- pos_T vi_end; // end position of last VIsual
- int vi_mode; // VIsual_mode of last VIsual
- colnr_T vi_curswant; // MAXCOL from w_curswant
+ pos_T vi_start; ///< start pos of last VIsual
+ pos_T vi_end; ///< end position of last VIsual
+ int vi_mode; ///< VIsual_mode of last VIsual
+ colnr_T vi_curswant; ///< MAXCOL from w_curswant
} visualinfo_T;
#include "nvim/buffer_defs.h"
typedef struct u_entry u_entry_T;
struct u_entry {
- u_entry_T *ue_next; // pointer to next entry in list
- linenr_T ue_top; // number of line above undo block
- linenr_T ue_bot; // number of line below undo block
- linenr_T ue_lcount; // linecount when u_save called
- char **ue_array; // array of lines in undo block
- linenr_T ue_size; // number of lines in ue_array
+ u_entry_T *ue_next; ///< pointer to next entry in list
+ linenr_T ue_top; ///< number of line above undo block
+ linenr_T ue_bot; ///< number of line below undo block
+ linenr_T ue_lcount; ///< linecount when u_save called
+ char **ue_array; ///< array of lines in undo block
+ linenr_T ue_size; ///< number of lines in ue_array
#ifdef U_DEBUG
- int ue_magic; // magic number to check allocation
+ int ue_magic; ///< magic number to check allocation
#endif
};
@@ -35,40 +38,42 @@ struct u_header {
// The following have a pointer and a number. The number is used when reading
// the undo file in u_read_undo()
union {
- u_header_T *ptr; // pointer to next undo header in list
+ u_header_T *ptr; ///< pointer to next undo header in list
int seq;
} uh_next;
union {
- u_header_T *ptr; // pointer to previous header in list
+ u_header_T *ptr; ///< pointer to previous header in list
int seq;
} uh_prev;
union {
- u_header_T *ptr; // pointer to next header for alt. redo
+ u_header_T *ptr; ///< pointer to next header for alt. redo
int seq;
} uh_alt_next;
union {
- u_header_T *ptr; // pointer to previous header for alt. redo
+ u_header_T *ptr; ///< pointer to previous header for alt. redo
int seq;
} uh_alt_prev;
- int uh_seq; // sequence number, higher == newer undo
- int uh_walk; // used by undo_time()
- u_entry_T *uh_entry; // pointer to first entry
- u_entry_T *uh_getbot_entry; // pointer to where ue_bot must be set
- pos_T uh_cursor; // cursor position before saving
+ int uh_seq; ///< sequence number, higher == newer undo
+ int uh_walk; ///< used by undo_time()
+ u_entry_T *uh_entry; ///< pointer to first entry
+ u_entry_T *uh_getbot_entry; ///< pointer to where ue_bot must be set
+ pos_T uh_cursor; ///< cursor position before saving
colnr_T uh_cursor_vcol;
- int uh_flags; // see below
- fmark_T uh_namedm[NMARKS]; // marks before undo/after redo
- extmark_undo_vec_t uh_extmark; // info to move extmarks
- visualinfo_T uh_visual; // Visual areas before undo/after redo
- time_t uh_time; // timestamp when the change was made
- int uh_save_nr; // set when the file was saved after the
- // changes in this block
+ int uh_flags; ///< see below
+ fmark_T uh_namedm[NMARKS]; ///< marks before undo/after redo
+ extmark_undo_vec_t uh_extmark; ///< info to move extmarks
+ visualinfo_T uh_visual; ///< Visual areas before undo/after redo
+ time_t uh_time; ///< timestamp when the change was made
+ int uh_save_nr; ///< set when the file was saved after the
+ ///< changes in this block
#ifdef U_DEBUG
- int uh_magic; // magic number to check allocation
+ int uh_magic; ///< magic number to check allocation
#endif
};
-// values for uh_flags
-#define UH_CHANGED 0x01 // b_changed flag before undo/after redo
-#define UH_EMPTYBUF 0x02 // buffer was empty
-#define UH_RELOAD 0x04 // buffer was reloaded
+/// values for uh_flags
+enum {
+ UH_CHANGED = 0x01, ///< b_changed flag before undo/after redo
+ UH_EMPTYBUF = 0x02, ///< buffer was empty
+ UH_RELOAD = 0x04, ///< buffer was reloaded
+};
diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c
index e277bfb829..7c65af5138 100644
--- a/src/nvim/usercmd.c
+++ b/src/nvim/usercmd.c
@@ -20,7 +20,7 @@
#include "nvim/garray.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/keycodes.h"
#include "nvim/lua/executor.h"
#include "nvim/macros_defs.h"
diff --git a/src/nvim/version.c b/src/nvim/version.c
index d6fcfaaf1f..227ecf7b3c 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -24,7 +24,7 @@
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
-#include "nvim/highlight_defs.h"
+#include "nvim/highlight.h"
#include "nvim/lua/executor.h"
#include "nvim/mbyte.h"
#include "nvim/memory.h"
diff --git a/src/nvim/vim_defs.h b/src/nvim/vim_defs.h
index 42358fe4cb..84c81e0960 100644
--- a/src/nvim/vim_defs.h
+++ b/src/nvim/vim_defs.h
@@ -34,57 +34,17 @@ enum { NUMBUFLEN = 65, };
#define MAX_TYPENR 65535
-#define ROOT_UID 0
-
#include "nvim/gettext.h"
#include "nvim/keycodes.h"
#include "nvim/macros_defs.h"
-// special attribute addition: Put message in history
-#define MSG_HIST 0x1000
-
-// Values for State
-//
-// The lower bits up to 0x80 are used to distinguish normal/visual/op_pending
-// /cmdline/insert/replace/terminal mode. This is used for mapping. If none
-// of these bits are set, no mapping is done. See the comment above do_map().
-// The upper bits are used to distinguish between other states and variants of
-// the base modes.
-
-#define MODE_NORMAL 0x01 // Normal mode, command expected
-#define MODE_VISUAL 0x02 // Visual mode - use get_real_state()
-#define MODE_OP_PENDING 0x04 // Normal mode, operator is pending - use
- // get_real_state()
-#define MODE_CMDLINE 0x08 // Editing the command line
-#define MODE_INSERT 0x10 // Insert mode, also for Replace mode
-#define MODE_LANGMAP 0x20 // Language mapping, can be combined with
- // MODE_INSERT and MODE_CMDLINE
-#define MODE_SELECT 0x40 // Select mode, use get_real_state()
-#define MODE_TERMINAL 0x80 // Terminal mode
-
-#define MAP_ALL_MODES 0xff // all mode bits used for mapping
-
-#define REPLACE_FLAG 0x100 // Replace mode flag
-#define MODE_REPLACE (REPLACE_FLAG | MODE_INSERT)
-#define VREPLACE_FLAG 0x200 // Virtual-replace mode flag
-#define MODE_VREPLACE (REPLACE_FLAG | VREPLACE_FLAG | MODE_INSERT)
-#define MODE_LREPLACE (REPLACE_FLAG | MODE_LANGMAP)
-
-#define MODE_NORMAL_BUSY (0x1000 | MODE_NORMAL) // Normal mode, busy with a command
-#define MODE_HITRETURN (0x2000 | MODE_NORMAL) // waiting for return or command
-#define MODE_ASKMORE 0x3000 // Asking if you want --more--
-#define MODE_SETWSIZE 0x4000 // window size has changed
-#define MODE_EXTERNCMD 0x5000 // executing an external command
-#define MODE_SHOWMATCH (0x6000 | MODE_INSERT) // show matching paren
-#define MODE_CONFIRM 0x7000 // ":confirm" prompt
-
/// Directions.
typedef enum {
kDirectionNotSet = 0,
FORWARD = 1,
- BACKWARD = (-1),
+ BACKWARD = -1,
FORWARD_FILE = 3,
- BACKWARD_FILE = (-3),
+ BACKWARD_FILE = -3,
} Direction;
// return values for functions
@@ -95,36 +55,6 @@ typedef enum {
#define FAIL 0
#define NOTDONE 2 // not OK or FAIL but skipped
-// Minimal size for block 0 of a swap file.
-// NOTE: This depends on size of struct block0! It's not done with a sizeof(),
-// because struct block0 is defined in memline.c (Sorry).
-// The maximal block size is arbitrary.
-#define MIN_SWAP_PAGE_SIZE 1048
-#define MAX_SWAP_PAGE_SIZE 50000
-
-#define STATUS_HEIGHT 1 // height of a status line under a window
-#define QF_WINHEIGHT 10 // default height for quickfix window
-
-// Buffer sizes
-
-#ifndef CMDBUFFSIZE
-# define CMDBUFFSIZE 256 // size of the command processing buffer
-#endif
-
-#define LSIZE 512 // max. size of a line in the tags file
-
-#define DIALOG_MSG_SIZE 1000 // buffer size for dialog_msg()
-
-enum { FOLD_TEXT_LEN = 51, }; //!< buffer size for get_foldtext()
-
-// Maximum length of key sequence to be mapped.
-// Must be able to hold an Amiga resize report.
-
-#define MAXMAPLEN 50
-
-// Size in bytes of the hash used in the undo file.
-#define UNDO_HASH_SIZE 32
-
#define CLEAR_FIELD(field) memset(&(field), 0, sizeof(field))
#define CLEAR_POINTER(ptr) memset((ptr), 0, sizeof(*(ptr)))
@@ -160,45 +90,8 @@ enum { FOLD_TEXT_LEN = 51, }; //!< buffer size for get_foldtext()
#define STRCAT(d, s) strcat((char *)(d), (char *)(s)) // NOLINT(runtime/printf)
-// Character used as separated in autoload function/variable names.
-#define AUTOLOAD_CHAR '#'
-
-#include "nvim/message.h"
-
-// Prefer using semsg(), because perror() may send the output to the wrong
-// destination and mess up the screen.
-#define PERROR(msg) (void)semsg("%s: %s", (msg), strerror(errno))
-
-#include "nvim/path.h"
-
-// Enums need a typecast to be used as array index.
-#define HL_ATTR(n) hl_attr_active[(int)(n)]
-
-/// Maximum number of bytes in a multi-byte character. It can be one 32-bit
-/// character of up to 6 bytes, or one 16-bit character of up to three bytes
-/// plus six following composing characters of three bytes each.
-#define MB_MAXBYTES 21
-
-#ifndef MSWIN
-/// Headless (no UI) error message handler.
-# define os_errmsg(str) fprintf(stderr, "%s", (str))
-/// Headless (no UI) message handler.
-# define os_msg(str) printf("%s", (str))
-#endif
-
-#include "nvim/buffer_defs.h" // buffer and windows
-#include "nvim/ex_cmds_defs.h" // Ex command defines
-#include "nvim/globals.h" // global variables and messages
-
-// Lowest number used for window ID. Cannot have this many windows per tab.
-#define LOWEST_WIN_ID 1000
-
// BSD is supposed to cover FreeBSD and similar systems.
#if (defined(BSD) || defined(__FreeBSD_kernel__)) \
&& (defined(S_ISCHR) || defined(S_IFCHR))
# define OPEN_CHR_FILES
#endif
-
-// Replacement for nchar used by nv_replace().
-#define REPLACE_CR_NCHAR (-1)
-#define REPLACE_NL_NCHAR (-2)
diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c
index 914f9ef445..8b637fbb9b 100644
--- a/src/nvim/viml/parser/expressions.c
+++ b/src/nvim/viml/parser/expressions.c
@@ -58,6 +58,7 @@
#include "nvim/ascii_defs.h"
#include "nvim/assert_defs.h"
#include "nvim/charset.h"
+#include "nvim/eval.h"
#include "nvim/func_attr.h"
#include "nvim/gettext.h"
#include "nvim/keycodes.h"
@@ -65,7 +66,6 @@
#include "nvim/mbyte.h"
#include "nvim/memory.h"
#include "nvim/types_defs.h"
-#include "nvim/vim_defs.h"
#include "nvim/viml/parser/expressions.h"
#include "nvim/viml/parser/parser.h"
diff --git a/src/nvim/window.h b/src/nvim/window.h
index 39dd7f8766..3650fef46e 100644
--- a/src/nvim/window.h
+++ b/src/nvim/window.h
@@ -32,12 +32,15 @@ enum {
WSP_NEWLOC = 0x100, ///< don't copy location list
};
-/// Minimum screen size
enum {
- MIN_COLUMNS = 12, ///< minimal columns for screen
- MIN_LINES = 2, ///< minimal lines for screen
+ MIN_COLUMNS = 12, ///< minimal columns for screen
+ MIN_LINES = 2, ///< minimal lines for screen
+ STATUS_HEIGHT = 1, ///< height of a status line under a window
};
+/// Lowest number used for window ID. Cannot have this many windows per tab.
+enum { LOWEST_WIN_ID = 1000, };
+
/// Set to true if 'cmdheight' was explicitly set to 0.
EXTERN bool p_ch_was_zero INIT( = false);
diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua
index 3af1faaece..434f117956 100644
--- a/test/functional/api/keymap_spec.lua
+++ b/test/functional/api/keymap_spec.lua
@@ -487,7 +487,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
end)
it('error if LHS longer than MAXMAPLEN', function()
- -- assume MAXMAPLEN of 50 chars, as declared in vim.h
+ -- assume MAXMAPLEN of 50 chars, as declared in mapping_defs.h
local MAXMAPLEN = 50
local lhs = ''
for i=1,MAXMAPLEN do
diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua
index cb273aedba..1ad4ad3a02 100644
--- a/test/functional/api/server_requests_spec.lua
+++ b/test/functional/api/server_requests_spec.lua
@@ -199,7 +199,7 @@ describe('server -> client', function()
it('can communicate buffers, tabpages, and windows', function()
eq({1}, eval("rpcrequest(vim, 'nvim_list_tabpages')"))
- -- Window IDs start at 1000 (LOWEST_WIN_ID in vim.h)
+ -- Window IDs start at 1000 (LOWEST_WIN_ID in window.h)
eq({1000}, eval("rpcrequest(vim, 'nvim_list_wins')"))
local buf = eval("rpcrequest(vim, 'nvim_list_bufs')")[1]