aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/nvim/CMakeLists.txt6
-rw-r--r--src/nvim/api/private/helpers.c1
-rw-r--r--src/nvim/api/ui.c7
-rw-r--r--src/nvim/charset.c2
-rw-r--r--src/nvim/context.c4
-rw-r--r--src/nvim/drawline.c1
-rw-r--r--src/nvim/eval/buffer.c1
-rw-r--r--src/nvim/eval/encode.h1
-rw-r--r--src/nvim/eval/userfunc.c1
-rw-r--r--src/nvim/eval/window.c1
-rw-r--r--src/nvim/eval/window.h10
-rw-r--r--src/nvim/event/libuv_process.c2
-rw-r--r--src/nvim/event/process.c1
-rw-r--r--src/nvim/ex_session.c1
-rw-r--r--src/nvim/hashtab.c1
-rw-r--r--src/nvim/indent.c2
-rw-r--r--src/nvim/indent_c.c1
-rw-r--r--src/nvim/insexpand.c1
-rw-r--r--src/nvim/linematch.c1
-rw-r--r--src/nvim/lua/executor.c2
-rw-r--r--src/nvim/main.c7
-rw-r--r--src/nvim/mapping.c1
-rw-r--r--src/nvim/mark.c2
-rw-r--r--src/nvim/memfile.c1
-rw-r--r--src/nvim/memory.c1
-rw-r--r--src/nvim/menu.c1
-rw-r--r--src/nvim/mouse.c1
-rw-r--r--src/nvim/move.c2
-rw-r--r--src/nvim/msgpack_rpc/channel.c3
-rw-r--r--src/nvim/normal.h1
-rw-r--r--src/nvim/optionstr.c1
-rw-r--r--src/nvim/os/fileio.c2
-rw-r--r--src/nvim/os/fs.c4
-rw-r--r--src/nvim/path.c1
-rw-r--r--src/nvim/plines.c1
-rw-r--r--src/nvim/runtime.c1
-rw-r--r--src/nvim/shada.c1
-rw-r--r--src/nvim/statusline.c2
-rw-r--r--src/nvim/testdir/test_shell.vim209
-rw-r--r--src/nvim/testdir/test_startup.vim21
-rw-r--r--src/nvim/testdir/test_system.vim36
-rw-r--r--src/nvim/textobject.c2
-rw-r--r--src/nvim/tui/input.c8
-rw-r--r--src/nvim/tui/terminfo.c6
-rw-r--r--src/nvim/tui/tui.c6
-rw-r--r--src/nvim/ui.c9
-rw-r--r--src/nvim/ui_client.c5
-rw-r--r--src/nvim/ui_client.h6
-rw-r--r--src/nvim/ui_compositor.c1
-rw-r--r--src/nvim/window.c3
-rw-r--r--src/nvim/window.h1
51 files changed, 288 insertions, 105 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index b95709526b..316f12e302 100755
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -85,7 +85,7 @@ if(ENABLE_IWYU)
string(APPEND iwyu_flags "-Xiwyu;--mapping_file=${PROJECT_SOURCE_DIR}/cmake.config/iwyu/gcc.symbols.imp")
set_target_properties(nvim PROPERTIES C_INCLUDE_WHAT_YOU_USE "${iwyu_flags}")
- target_compile_definitions(nvim PRIVATE EXITFREE)
+ target_compile_definitions(main_lib INTERFACE EXITFREE)
endif()
if(MSVC)
@@ -977,7 +977,9 @@ add_glob_target(
TARGET lintc-clint
COMMAND ${PROJECT_SOURCE_DIR}/src/clint.py
FLAGS --output=${LINT_OUTPUT_FORMAT}
- FILES ${LINT_NVIM_SOURCES})
+ FILES ${LINT_NVIM_SOURCES}
+ EXCLUDE
+ tui/terminfo_defs.h)
add_custom_target(uncrustify-version
COMMAND ${CMAKE_COMMAND}
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 4ff600618d..bf19c8c395 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -33,7 +33,6 @@
#include "nvim/pos.h"
#include "nvim/ui.h"
#include "nvim/version.h"
-#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "api/private/funcs_metadata.generated.h"
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c
index 32b294c0ce..e67607a7e4 100644
--- a/src/nvim/api/ui.c
+++ b/src/nvim/api/ui.c
@@ -13,7 +13,11 @@
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/ui.h"
+#include "nvim/autocmd.h"
#include "nvim/channel.h"
+#include "nvim/event/loop.h"
+#include "nvim/event/wstream.h"
+#include "nvim/globals.h"
#include "nvim/grid.h"
#include "nvim/highlight.h"
#include "nvim/main.h"
@@ -27,13 +31,12 @@
#include "nvim/types.h"
#include "nvim/ui.h"
#include "nvim/vim.h"
-#include "nvim/window.h"
#define BUF_POS(data) ((size_t)((data)->buf_wptr - (data)->buf))
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "api/ui.c.generated.h"
-# include "ui_events_remote.generated.h"
+# include "ui_events_remote.generated.h" // IWYU pragma: export
#endif
static PMap(uint64_t) connected_uis = MAP_INIT;
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index 4115743e1c..aa2d845728 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -13,6 +13,7 @@
#include <string.h>
#include "auto/config.h"
+#include "klib/kvec.h"
#include "nvim/ascii.h"
#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
@@ -35,6 +36,7 @@
#include "nvim/plines.h"
#include "nvim/pos.h"
#include "nvim/state.h"
+#include "nvim/strings.h"
#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/context.c b/src/nvim/context.c
index b064a92b74..9de6c16536 100644
--- a/src/nvim/context.c
+++ b/src/nvim/context.c
@@ -5,7 +5,9 @@
#include <assert.h>
#include <stdbool.h>
+#include <stdint.h>
#include <stdio.h>
+#include <string.h>
#include "nvim/api/private/converter.h"
#include "nvim/api/private/helpers.h"
@@ -23,8 +25,6 @@
#include "nvim/message.h"
#include "nvim/option.h"
#include "nvim/shada.h"
-#include "nvim/types.h"
-#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "context.c.generated.h"
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 8fc1a4b029..77158e233a 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -21,7 +21,6 @@
#include "nvim/decoration_provider.h"
#include "nvim/diff.h"
#include "nvim/drawline.h"
-#include "nvim/eval.h"
#include "nvim/extmark_defs.h"
#include "nvim/fold.h"
#include "nvim/garray.h"
diff --git a/src/nvim/eval/buffer.c b/src/nvim/eval/buffer.c
index 72eb0f8d67..e8eca3f854 100644
--- a/src/nvim/eval/buffer.c
+++ b/src/nvim/eval/buffer.c
@@ -9,6 +9,7 @@
#include "nvim/ascii.h"
#include "nvim/autocmd.h"
#include "nvim/buffer.h"
+#include "nvim/buffer_defs.h"
#include "nvim/change.h"
#include "nvim/cursor.h"
#include "nvim/eval.h"
diff --git a/src/nvim/eval/encode.h b/src/nvim/eval/encode.h
index e66dab1cff..41e7614fc0 100644
--- a/src/nvim/eval/encode.h
+++ b/src/nvim/eval/encode.h
@@ -4,6 +4,7 @@
#include <msgpack.h>
#include <msgpack/pack.h>
#include <stddef.h>
+#include <string.h>
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index c70d56cd25..1a3fd13fe3 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -45,6 +45,7 @@
#include "nvim/runtime.h"
#include "nvim/search.h"
#include "nvim/strings.h"
+#include "nvim/types.h"
#include "nvim/ui.h"
#include "nvim/vim.h"
diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c
index 4bcbc13534..b1e1669826 100644
--- a/src/nvim/eval/window.c
+++ b/src/nvim/eval/window.c
@@ -12,6 +12,7 @@
#include "nvim/ascii.h"
#include "nvim/autocmd.h"
#include "nvim/buffer.h"
+#include "nvim/buffer_defs.h"
#include "nvim/cursor.h"
#include "nvim/eval/funcs.h"
#include "nvim/eval/typval.h"
diff --git a/src/nvim/eval/window.h b/src/nvim/eval/window.h
index 682a794113..995f0a55a9 100644
--- a/src/nvim/eval/window.h
+++ b/src/nvim/eval/window.h
@@ -2,9 +2,19 @@
#define NVIM_EVAL_WINDOW_H
#include <stdbool.h>
+#include <string.h>
+#include "nvim/buffer.h"
#include "nvim/buffer_defs.h"
+#include "nvim/cursor.h"
#include "nvim/eval/typval_defs.h"
+#include "nvim/globals.h"
+#include "nvim/mark.h"
+#include "nvim/option_defs.h"
+#include "nvim/os/os.h"
+#include "nvim/pos.h"
+#include "nvim/vim.h"
+#include "nvim/window.h"
/// Structure used by switch_win() to pass values to restore_win()
typedef struct {
diff --git a/src/nvim/event/libuv_process.c b/src/nvim/event/libuv_process.c
index 10a09275d9..e528d21a71 100644
--- a/src/nvim/event/libuv_process.c
+++ b/src/nvim/event/libuv_process.c
@@ -1,6 +1,7 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
+#include <assert.h>
#include <stdint.h>
#include <uv.h>
@@ -12,6 +13,7 @@
#include "nvim/log.h"
#include "nvim/macros.h"
#include "nvim/os/os.h"
+#include "nvim/ui_client.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "event/libuv_process.c.generated.h"
diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c
index 9dfd6f329a..1a524a56ca 100644
--- a/src/nvim/event/process.c
+++ b/src/nvim/event/process.c
@@ -20,6 +20,7 @@
#include "nvim/os/shell.h"
#include "nvim/os/time.h"
#include "nvim/rbuffer.h"
+#include "nvim/ui_client.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "event/process.c.generated.h"
diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c
index cae9c18309..f15c2d258f 100644
--- a/src/nvim/ex_session.c
+++ b/src/nvim/ex_session.c
@@ -38,7 +38,6 @@
#include "nvim/path.h"
#include "nvim/pos.h"
#include "nvim/runtime.h"
-#include "nvim/types.h"
#include "nvim/vim.h"
#include "nvim/window.h"
diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c
index 042cb43ce4..f805d99d4b 100644
--- a/src/nvim/hashtab.c
+++ b/src/nvim/hashtab.c
@@ -30,6 +30,7 @@
#include "nvim/hashtab.h"
#include "nvim/memory.h"
#include "nvim/message.h"
+#include "nvim/types.h"
#include "nvim/vim.h"
// Magic value for algorithm that walks through the array.
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index be1dfb77cf..ed4005d139 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -17,6 +17,7 @@
#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/eval/typval_defs.h"
+#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/extmark.h"
#include "nvim/gettext.h"
@@ -24,6 +25,7 @@
#include "nvim/indent.h"
#include "nvim/indent_c.h"
#include "nvim/mark.h"
+#include "nvim/mbyte.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index ccf4448e93..c2293add76 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -23,7 +23,6 @@
#include "nvim/pos.h"
#include "nvim/search.h"
#include "nvim/strings.h"
-#include "nvim/types.h"
#include "nvim/vim.h"
// Find result cache for cpp_baseclass
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index fa8e78f624..ba948ff924 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -7,6 +7,7 @@
#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/nvim/linematch.c b/src/nvim/linematch.c
index 629a31c913..a9dac40731 100644
--- a/src/nvim/linematch.c
+++ b/src/nvim/linematch.c
@@ -9,7 +9,6 @@
#include "nvim/linematch.h"
#include "nvim/macros.h"
#include "nvim/memory.h"
-#include "nvim/vim.h"
// struct for running the diff linematch algorithm
typedef struct {
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index 12ddbd094f..f23310304f 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -49,6 +49,7 @@
#include "nvim/message.h"
#include "nvim/msgpack_rpc/channel.h"
#include "nvim/option_defs.h"
+#include "nvim/os/fileio.h"
#include "nvim/os/os.h"
#include "nvim/path.h"
#include "nvim/pos.h"
@@ -56,7 +57,6 @@
#include "nvim/runtime.h"
#include "nvim/strings.h"
#include "nvim/ui.h"
-#include "nvim/ui_compositor.h"
#include "nvim/undo.h"
#include "nvim/usercmd.h"
#include "nvim/version.h"
diff --git a/src/nvim/main.c b/src/nvim/main.c
index f41e054d73..4dfb00f2db 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -10,7 +10,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <time.h>
#include "auto/config.h"
#include "nvim/arglist.h"
@@ -62,7 +61,6 @@
#include "nvim/os/fileio.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
-#include "nvim/os/pty_process.h"
#include "nvim/os/stdpaths_defs.h"
#include "nvim/os/time.h"
#include "nvim/path.h"
@@ -97,7 +95,6 @@
#include "nvim/msgpack_rpc/helpers.h"
#include "nvim/msgpack_rpc/server.h"
#include "nvim/os/signal.h"
-#include "nvim/tui/tui.h"
// values for "window_layout"
enum {
@@ -548,7 +545,9 @@ int main(int argc, char **argv)
if (params.diff_mode) {
// set options in each window for "nvim -d".
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
- diff_win_options(wp, true);
+ if (!wp->w_arg_idx_invalid) {
+ diff_win_options(wp, true);
+ }
}
}
diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c
index 04a0107fe8..2e1563760b 100644
--- a/src/nvim/mapping.c
+++ b/src/nvim/mapping.c
@@ -5,6 +5,7 @@
#include <assert.h>
#include <inttypes.h>
+#include <lauxlib.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index b98935e93d..a76472230d 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -5,6 +5,7 @@
#include <assert.h>
#include <limits.h>
+#include <stdint.h>
#include <stdio.h>
#include <string.h>
@@ -39,7 +40,6 @@
#include "nvim/sign.h"
#include "nvim/strings.h"
#include "nvim/textobject.h"
-#include "nvim/types.h"
#include "nvim/undo_defs.h"
#include "nvim/vim.h"
diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c
index 61d7893948..46be9ccea5 100644
--- a/src/nvim/memfile.c
+++ b/src/nvim/memfile.c
@@ -62,7 +62,6 @@
#include "nvim/os/os.h"
#include "nvim/path.h"
#include "nvim/pos.h"
-#include "nvim/types.h"
#include "nvim/vim.h"
#define MEMFILE_PAGE_SIZE 4096 /// default page size
diff --git a/src/nvim/memory.c b/src/nvim/memory.c
index aa8314b23d..5356300382 100644
--- a/src/nvim/memory.c
+++ b/src/nvim/memory.c
@@ -31,7 +31,6 @@
#include "nvim/message.h"
#include "nvim/sign.h"
#include "nvim/ui.h"
-#include "nvim/ui_compositor.h"
#include "nvim/usercmd.h"
#include "nvim/vim.h"
diff --git a/src/nvim/menu.c b/src/nvim/menu.c
index 0fa45ac24a..2a18b08d8d 100644
--- a/src/nvim/menu.c
+++ b/src/nvim/menu.c
@@ -6,6 +6,7 @@
#include <assert.h>
#include <stdbool.h>
+#include <stdint.h>
#include <string.h>
#include "nvim/ascii.h"
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c
index b7d15fe9af..258f596ecc 100644
--- a/src/nvim/mouse.c
+++ b/src/nvim/mouse.c
@@ -3,6 +3,7 @@
#include <assert.h>
#include <stdbool.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/nvim/move.c b/src/nvim/move.c
index dc2f4b4844..ee9edb3dc4 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -27,12 +27,14 @@
#include "nvim/eval/window.h"
#include "nvim/fold.h"
#include "nvim/getchar.h"
+#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
#include "nvim/highlight.h"
#include "nvim/macros.h"
#include "nvim/mbyte.h"
#include "nvim/memline_defs.h"
+#include "nvim/message.h"
#include "nvim/mouse.h"
#include "nvim/move.h"
#include "nvim/option.h"
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c
index 0c23a7798c..d60e18590f 100644
--- a/src/nvim/msgpack_rpc/channel.c
+++ b/src/nvim/msgpack_rpc/channel.c
@@ -20,14 +20,15 @@
#include "nvim/channel.h"
#include "nvim/event/defs.h"
#include "nvim/event/loop.h"
+#include "nvim/event/process.h"
#include "nvim/event/rstream.h"
#include "nvim/event/stream.h"
#include "nvim/event/wstream.h"
-#include "nvim/globals.h"
#include "nvim/log.h"
#include "nvim/main.h"
#include "nvim/map.h"
#include "nvim/memory.h"
+#include "nvim/message.h"
#include "nvim/msgpack_rpc/channel.h"
#include "nvim/msgpack_rpc/channel_defs.h"
#include "nvim/msgpack_rpc/helpers.h"
diff --git a/src/nvim/normal.h b/src/nvim/normal.h
index 90a5c4103e..bed1a40b97 100644
--- a/src/nvim/normal.h
+++ b/src/nvim/normal.h
@@ -4,6 +4,7 @@
#include <stdbool.h>
#include "nvim/buffer_defs.h"
+#include "nvim/macros.h"
#include "nvim/pos.h"
// Values for find_ident_under_cursor()
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c
index a97e9b7c7e..c8d5a10dbb 100644
--- a/src/nvim/optionstr.c
+++ b/src/nvim/optionstr.c
@@ -3,6 +3,7 @@
#include <assert.h>
#include <stdbool.h>
+#include <stdint.h>
#include <string.h>
#include "nvim/api/private/helpers.h"
diff --git a/src/nvim/os/fileio.c b/src/nvim/os/fileio.c
index e93e1febcb..5af39555c9 100644
--- a/src/nvim/os/fileio.c
+++ b/src/nvim/os/fileio.c
@@ -16,6 +16,8 @@
#include "auto/config.h"
#include "nvim/gettext.h"
+#include "nvim/globals.h"
+#include "nvim/log.h"
#include "nvim/macros.h"
#include "nvim/memory.h"
#include "nvim/message.h"
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index e0449d468a..98ec9aa826 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -302,7 +302,9 @@ static bool is_executable(const char *name, char **abspath)
static bool is_executable_ext(const char *name, char **abspath)
FUNC_ATTR_NONNULL_ARG(1)
{
- const bool is_unix_shell = strstr((char *)path_tail(p_sh), "sh") != NULL;
+ const bool is_unix_shell = strstr(path_tail(p_sh), "powershell") == NULL
+ && strstr(path_tail(p_sh), "pwsh") == NULL
+ && strstr(path_tail(p_sh), "sh") != NULL;
char *nameext = strrchr(name, '.');
size_t nameext_len = nameext ? strlen(nameext) : 0;
xstrlcpy(os_buf, name, sizeof(os_buf));
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 9350335e54..6d14db7de1 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -6,6 +6,7 @@
#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/nvim/plines.c b/src/nvim/plines.c
index e4d1ddf8d8..38ca91a6ac 100644
--- a/src/nvim/plines.c
+++ b/src/nvim/plines.c
@@ -23,7 +23,6 @@
#include "nvim/option.h"
#include "nvim/plines.h"
#include "nvim/pos.h"
-#include "nvim/types.h"
#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c
index e009b883ca..ea975042ed 100644
--- a/src/nvim/runtime.c
+++ b/src/nvim/runtime.c
@@ -9,7 +9,6 @@
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
-#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <uv.h>
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index 754139a147..92d47fbf49 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -53,7 +53,6 @@
#include "nvim/search.h"
#include "nvim/shada.h"
#include "nvim/strings.h"
-#include "nvim/types.h"
#include "nvim/version.h"
#include "nvim/vim.h"
diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c
index db3e3f91bf..b75b3c313f 100644
--- a/src/nvim/statusline.c
+++ b/src/nvim/statusline.c
@@ -31,12 +31,14 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/move.h"
+#include "nvim/normal.h"
#include "nvim/option.h"
#include "nvim/optionstr.h"
#include "nvim/os/os.h"
#include "nvim/path.h"
#include "nvim/pos.h"
#include "nvim/screen.h"
+#include "nvim/sign_defs.h"
#include "nvim/statusline.h"
#include "nvim/strings.h"
#include "nvim/types.h"
diff --git a/src/nvim/testdir/test_shell.vim b/src/nvim/testdir/test_shell.vim
new file mode 100644
index 0000000000..8b9c7a5b12
--- /dev/null
+++ b/src/nvim/testdir/test_shell.vim
@@ -0,0 +1,209 @@
+" Test for the shell related options ('shell', 'shellcmdflag', 'shellpipe',
+" 'shellquote', 'shellredir', 'shellxescape', and 'shellxquote')
+
+source check.vim
+source shared.vim
+
+func Test_shell_options()
+ " The expected value of 'shellcmdflag', 'shellpipe', 'shellquote',
+ " 'shellredir', 'shellxescape', 'shellxquote' for the supported shells.
+ let shells = []
+ if has('unix')
+ let shells += [['sh', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''],
+ \ ['ksh', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''],
+ \ ['mksh', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''],
+ \ ['zsh', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''],
+ \ ['zsh-beta', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''],
+ \ ['bash', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''],
+ \ ['fish', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''],
+ \ ['ash', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''],
+ \ ['dash', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''],
+ \ ['csh', '-c', '|& tee', '', '>&', '', ''],
+ \ ['tcsh', '-c', '|& tee', '', '>&', '', '']]
+ endif
+ if has('win32')
+ let shells += [['cmd', '/s /c', '>%s 2>&1', '', '>%s 2>&1', '', '"']]
+ endif
+
+ " start a new Vim instance with 'shell' set to each of the supported shells
+ " and check the default shell option settings
+ let after =<< trim END
+ let l = [&shell, &shellcmdflag, &shellpipe, &shellquote]
+ let l += [&shellredir, &shellxescape, &shellxquote]
+ call writefile([json_encode(l)], 'Xtestout')
+ qall!
+ END
+ for e in shells
+ if RunVim([], after, '--cmd "set shell=' .. e[0] .. '"')
+ call assert_equal(e, json_decode(readfile('Xtestout')[0]))
+ endif
+ endfor
+
+ " Test shellescape() for each of the shells.
+ for e in shells
+ exe 'set shell=' .. e[0]
+ if e[0] =~# '.*csh$' || e[0] =~# '.*csh.exe$'
+ let str1 = "'cmd \"arg1\" '\\''arg2'\\'' \\!%#'"
+ let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\\\!\\%\\#'"
+ elseif e[0] =~# '.*powershell$' || e[0] =~# '.*powershell.exe$'
+ let str1 = "'cmd \"arg1\" ''arg2'' !%#'"
+ let str2 = "'cmd \"arg1\" ''arg2'' \\!\\%\\#'"
+ else
+ let str1 = "'cmd \"arg1\" '\\''arg2'\\'' !%#'"
+ let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\!\\%\\#'"
+ endif
+ call assert_equal(str1, shellescape("cmd \"arg1\" 'arg2' !%#"), e[0])
+ call assert_equal(str2, shellescape("cmd \"arg1\" 'arg2' !%#", 1), e[0])
+
+ " Try running an external command with the shell.
+ if executable(e[0])
+ " set the shell options for the current 'shell'
+ let [&shellcmdflag, &shellpipe, &shellquote, &shellredir,
+ \ &shellxescape, &shellxquote] = e[1:6]
+ new
+ r !echo hello
+ call assert_equal('hello', substitute(getline(2), '\W', '', 'g'), e[0])
+ bwipe!
+ endif
+ endfor
+ set shell& shellcmdflag& shellpipe& shellquote&
+ set shellredir& shellxescape& shellxquote&
+ call delete('Xtestout')
+endfunc
+
+" Test for the 'shell' option
+func Test_shell()
+ throw 'Skipped: Nvim missing :shell currently'
+ CheckUnix
+ let save_shell = &shell
+ set shell=
+ let caught_e91 = 0
+ try
+ shell
+ catch /E91:/
+ let caught_e91 = 1
+ endtry
+ call assert_equal(1, caught_e91)
+ let &shell = save_shell
+endfunc
+
+" Test for the 'shellquote' option
+func Test_shellquote()
+ CheckUnix
+ set shellquote=#
+ set verbose=20
+ redir => v
+ silent! !echo Hello
+ redir END
+ set verbose&
+ set shellquote&
+ call assert_match(': "#echo Hello#"', v)
+endfunc
+
+" Test for the 'shellescape' option
+func Test_shellescape()
+ let save_shell = &shell
+ set shell=bash
+ call assert_equal("'text'", shellescape('text'))
+ call assert_equal("'te\"xt'", 'te"xt'->shellescape())
+ call assert_equal("'te'\\''xt'", shellescape("te'xt"))
+
+ call assert_equal("'te%xt'", shellescape("te%xt"))
+ call assert_equal("'te\\%xt'", shellescape("te%xt", 1))
+ call assert_equal("'te#xt'", shellescape("te#xt"))
+ call assert_equal("'te\\#xt'", shellescape("te#xt", 1))
+ call assert_equal("'te!xt'", shellescape("te!xt"))
+ call assert_equal("'te\\!xt'", shellescape("te!xt", 1))
+
+ call assert_equal("'te\nxt'", shellescape("te\nxt"))
+ call assert_equal("'te\\\nxt'", shellescape("te\nxt", 1))
+ set shell=tcsh
+ call assert_equal("'te\\!xt'", shellescape("te!xt"))
+ call assert_equal("'te\\\\!xt'", shellescape("te!xt", 1))
+ call assert_equal("'te\\\nxt'", shellescape("te\nxt"))
+ call assert_equal("'te\\\\\nxt'", shellescape("te\nxt", 1))
+
+ let &shell = save_shell
+endfunc
+
+" Test for 'shellslash'
+func Test_shellslash()
+ CheckOption shellslash
+ let save_shellslash = &shellslash
+ " The shell and cmdflag, and expected slash in tempname with shellslash set or
+ " unset. The assert checks the file separator before the leafname.
+ " ".*\\\\[^\\\\]*$"
+ let shells = [['cmd', '/c', '/', '/'],
+ \ ['powershell', '-Command', '/', '/'],
+ \ ['sh', '-c', '/', '/']]
+ for e in shells
+ exe 'set shell=' .. e[0] .. ' | set shellcmdflag=' .. e[1]
+ set noshellslash
+ let file = tempname()
+ call assert_match('^.\+' .. e[2] .. '[^' .. e[2] .. ']\+$', file, e[0] .. ' ' .. e[1] .. ' nossl')
+ set shellslash
+ let file = tempname()
+ call assert_match('^.\+' .. e[3] .. '[^' .. e[3] .. ']\+$', file, e[0] .. ' ' .. e[1] .. ' ssl')
+ endfor
+ let &shellslash = save_shellslash
+endfunc
+
+" Test for 'shellxquote'
+func Test_shellxquote()
+ CheckUnix
+
+ let save_shell = &shell
+ let save_sxq = &shellxquote
+ let save_sxe = &shellxescape
+
+ call writefile(['#!/bin/sh', 'echo "Cmd: [$*]" > Xlog'], 'Xtestshell')
+ call setfperm('Xtestshell', "r-x------")
+ set shell=./Xtestshell
+
+ set shellxquote=\\"
+ call feedkeys(":!pwd\<CR>\<CR>", 'xt')
+ call assert_equal(['Cmd: [-c "pwd"]'], readfile('Xlog'))
+
+ set shellxquote=(
+ call feedkeys(":!pwd\<CR>\<CR>", 'xt')
+ call assert_equal(['Cmd: [-c (pwd)]'], readfile('Xlog'))
+
+ set shellxquote=\\"(
+ call feedkeys(":!pwd\<CR>\<CR>", 'xt')
+ call assert_equal(['Cmd: [-c "(pwd)"]'], readfile('Xlog'))
+
+ set shellxescape=\"&<<()@^
+ set shellxquote=(
+ call feedkeys(":!pwd\"&<<{}@^\<CR>\<CR>", 'xt')
+ call assert_equal(['Cmd: [-c (pwd^"^&^<^<{}^@^^)]'], readfile('Xlog'))
+
+ let &shell = save_shell
+ let &shellxquote = save_sxq
+ let &shellxescape = save_sxe
+ call delete('Xtestshell')
+ call delete('Xlog')
+endfunc
+
+" Test for using the shell set in the $SHELL environment variable
+func Test_set_shell()
+ let after =<< trim [CODE]
+ call writefile([&shell], "Xtestout")
+ quit!
+ [CODE]
+
+ if has('win32')
+ let $SHELL = 'C:\with space\cmd.exe'
+ let expected = '"C:\with space\cmd.exe"'
+ else
+ let $SHELL = '/bin/with space/sh'
+ let expected = '"/bin/with space/sh"'
+ endif
+
+ if RunVimPiped([], after, '', '')
+ let lines = readfile('Xtestout')
+ call assert_equal(expected, lines[0])
+ endif
+ call delete('Xtestout')
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim
index 1f9f53eb43..1ee1d0dfe3 100644
--- a/src/nvim/testdir/test_startup.vim
+++ b/src/nvim/testdir/test_startup.vim
@@ -725,27 +725,6 @@ func Test_read_stdin()
call delete('Xtestout')
endfunc
-func Test_set_shell()
- let after =<< trim [CODE]
- call writefile([&shell], "Xtestout")
- quit!
- [CODE]
-
- if has('win32')
- let $SHELL = 'C:\with space\cmd.exe'
- let expected = '"C:\with space\cmd.exe"'
- else
- let $SHELL = '/bin/with space/sh'
- let expected = '"/bin/with space/sh"'
- endif
-
- if RunVimPiped([], after, '', '')
- let lines = readfile('Xtestout')
- call assert_equal(expected, lines[0])
- endif
- call delete('Xtestout')
-endfunc
-
func Test_progpath()
" Tests normally run with "./vim" or "../vim", these must have been expanded
" to a full path.
diff --git a/src/nvim/testdir/test_system.vim b/src/nvim/testdir/test_system.vim
index bfa8a277bd..6c8373b335 100644
--- a/src/nvim/testdir/test_system.vim
+++ b/src/nvim/testdir/test_system.vim
@@ -142,40 +142,4 @@ func Test_system_with_shell_quote()
endtry
endfunc
-" Test for 'shellxquote'
-func Test_Shellxquote()
- CheckUnix
-
- let save_shell = &shell
- let save_sxq = &shellxquote
- let save_sxe = &shellxescape
-
- call writefile(['#!/bin/sh', 'echo "Cmd: [$*]" > Xlog'], 'Xtestshell')
- call setfperm('Xtestshell', "r-x------")
- set shell=./Xtestshell
-
- set shellxquote=\\"
- call feedkeys(":!pwd\<CR>\<CR>", 'xt')
- call assert_equal(['Cmd: [-c "pwd"]'], readfile('Xlog'))
-
- set shellxquote=(
- call feedkeys(":!pwd\<CR>\<CR>", 'xt')
- call assert_equal(['Cmd: [-c (pwd)]'], readfile('Xlog'))
-
- set shellxquote=\\"(
- call feedkeys(":!pwd\<CR>\<CR>", 'xt')
- call assert_equal(['Cmd: [-c "(pwd)"]'], readfile('Xlog'))
-
- set shellxescape=\"&<<()@^
- set shellxquote=(
- call feedkeys(":!pwd\"&<<{}@^\<CR>\<CR>", 'xt')
- call assert_equal(['Cmd: [-c (pwd^"^&^<^<{}^@^^)]'], readfile('Xlog'))
-
- let &shell = save_shell
- let &shellxquote = save_sxq
- let &shellxescape = save_sxe
- call delete('Xtestshell')
- call delete('Xlog')
-endfunc
-
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c
index ee6c39a8ba..8d58966f46 100644
--- a/src/nvim/textobject.c
+++ b/src/nvim/textobject.c
@@ -4,6 +4,7 @@
// textobject.c: functions for text objects
#include <stdbool.h>
+#include <stdint.h>
#include <stdio.h>
#include <string.h>
@@ -28,7 +29,6 @@
#include "nvim/search.h"
#include "nvim/strings.h"
#include "nvim/textobject.h"
-#include "nvim/types.h"
#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c
index 91fbdf7886..5325ae3e4d 100644
--- a/src/nvim/tui/input.c
+++ b/src/nvim/tui/input.c
@@ -8,31 +8,27 @@
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
-#include "nvim/api/vim.h"
#include "nvim/ascii.h"
-#include "nvim/autocmd.h"
#include "nvim/charset.h"
#include "nvim/event/defs.h"
-#include "nvim/event/multiqueue.h"
-#include "nvim/globals.h"
#include "nvim/log.h"
#include "nvim/macros.h"
#include "nvim/main.h"
#include "nvim/map.h"
#include "nvim/memory.h"
-#include "nvim/message.h"
#include "nvim/option.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/tui/input.h"
#include "nvim/tui/input_defs.h"
#include "nvim/tui/tui.h"
+#include "nvim/types.h"
+#include "nvim/ui_client.h"
#ifdef MSWIN
# include "nvim/os/os_win_console.h"
#endif
#include "nvim/event/rstream.h"
#include "nvim/msgpack_rpc/channel.h"
-#include "nvim/ui.h"
#define KEY_BUFFER_SIZE 0xfff
diff --git a/src/nvim/tui/terminfo.c b/src/nvim/tui/terminfo.c
index 507e9df21e..d630a34ce2 100644
--- a/src/nvim/tui/terminfo.c
+++ b/src/nvim/tui/terminfo.c
@@ -7,12 +7,12 @@
#include <string.h>
#include <unibilium.h>
+#include "klib/kvec.h"
+#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
+#include "nvim/ascii.h"
#include "nvim/charset.h"
-#include "nvim/globals.h"
#include "nvim/memory.h"
-#include "nvim/message.h"
-#include "nvim/option.h"
#include "nvim/strings.h"
#include "nvim/tui/terminfo.h"
#include "nvim/tui/terminfo_defs.h"
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index e46dc892ea..44b99f6c84 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -16,7 +16,6 @@
#include "klib/kvec.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
-#include "nvim/api/vim.h"
#include "nvim/ascii.h"
#include "nvim/cursor_shape.h"
#include "nvim/event/defs.h"
@@ -32,12 +31,10 @@
#include "nvim/main.h"
#include "nvim/mbyte.h"
#include "nvim/memory.h"
-#include "nvim/message.h"
#include "nvim/msgpack_rpc/channel.h"
-#include "nvim/option.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
-#include "nvim/os/signal.h"
+#include "nvim/ui_client.h"
#ifdef MSWIN
# include "nvim/os/os_win_console.h"
#endif
@@ -46,7 +43,6 @@
#include "nvim/tui/tui.h"
#include "nvim/ugrid.h"
#include "nvim/ui.h"
-#include "nvim/vim.h"
// Space reserved in two output buffers to make the cursor normal or invisible
// when flushing. No existing terminal will require 32 bytes to do that.
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index b25fa04c8b..9f1cb87eb0 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -7,8 +7,8 @@
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
+#include <string.h>
-#include "auto/config.h"
#include "klib/kvec.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/ui.h"
@@ -17,8 +17,6 @@
#include "nvim/buffer_defs.h"
#include "nvim/cursor_shape.h"
#include "nvim/drawscreen.h"
-#include "nvim/event/defs.h"
-#include "nvim/event/loop.h"
#include "nvim/ex_getln.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
@@ -27,15 +25,14 @@
#include "nvim/highlight_defs.h"
#include "nvim/log.h"
#include "nvim/lua/executor.h"
-#include "nvim/main.h"
+#include "nvim/map.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/msgpack_rpc/channel.h"
#include "nvim/option.h"
#include "nvim/os/time.h"
#include "nvim/strings.h"
-#include "nvim/tui/tui.h"
#include "nvim/ui.h"
+#include "nvim/ui_client.h"
#include "nvim/ui_compositor.h"
#include "nvim/vim.h"
#include "nvim/window.h"
diff --git a/src/nvim/ui_client.c b/src/nvim/ui_client.c
index 47c255fc80..222ba3d5dd 100644
--- a/src/nvim/ui_client.c
+++ b/src/nvim/ui_client.c
@@ -6,15 +6,18 @@
#include <stdlib.h>
#include "nvim/api/private/helpers.h"
+#include "nvim/channel.h"
#include "nvim/eval.h"
+#include "nvim/eval/typval_defs.h"
#include "nvim/event/loop.h"
-#include "nvim/event/multiqueue.h"
#include "nvim/globals.h"
#include "nvim/highlight.h"
#include "nvim/log.h"
#include "nvim/main.h"
#include "nvim/memory.h"
#include "nvim/msgpack_rpc/channel.h"
+#include "nvim/msgpack_rpc/channel_defs.h"
+#include "nvim/os/os_defs.h"
#include "nvim/tui/tui.h"
#include "nvim/ui.h"
#include "nvim/ui_client.h"
diff --git a/src/nvim/ui_client.h b/src/nvim/ui_client.h
index 24b8fad4cc..201c97f9d3 100644
--- a/src/nvim/ui_client.h
+++ b/src/nvim/ui_client.h
@@ -1,11 +1,14 @@
#ifndef NVIM_UI_CLIENT_H
#define NVIM_UI_CLIENT_H
+#include <stdbool.h>
#include <stddef.h>
+#include <stdint.h>
#include "nvim/api/private/defs.h"
#include "nvim/grid_defs.h"
#include "nvim/macros.h"
+#include "nvim/types.h"
typedef struct {
const char *name;
@@ -35,10 +38,11 @@ EXTERN TriState ui_client_bg_respose INIT(= kNone);
EXTERN bool ui_client_forward_stdin INIT(= false);
#define UI_CLIENT_STDIN_FD 3
+// uncrustify:off
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "ui_client.h.generated.h"
-
# include "ui_events_client.h.generated.h"
#endif
+// uncrustify:on
#endif // NVIM_UI_CLIENT_H
diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c
index ad44e2ca22..9ff9eabff8 100644
--- a/src/nvim/ui_compositor.c
+++ b/src/nvim/ui_compositor.c
@@ -24,7 +24,6 @@
#include "nvim/highlight_group.h"
#include "nvim/log.h"
#include "nvim/macros.h"
-#include "nvim/map.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option_defs.h"
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 2bcbef14b0..627d418a55 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -11,12 +11,14 @@
#include <stdlib.h>
#include <string.h>
+#include "klib/kvec.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/arglist.h"
#include "nvim/ascii.h"
#include "nvim/autocmd.h"
#include "nvim/buffer.h"
+#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/decoration.h"
@@ -59,6 +61,7 @@
#include "nvim/option.h"
#include "nvim/optionstr.h"
#include "nvim/os/os.h"
+#include "nvim/os/os_defs.h"
#include "nvim/path.h"
#include "nvim/plines.h"
#include "nvim/pos.h"
diff --git a/src/nvim/window.h b/src/nvim/window.h
index f348f102c9..4ab2bea60a 100644
--- a/src/nvim/window.h
+++ b/src/nvim/window.h
@@ -6,6 +6,7 @@
#include "nvim/buffer.h"
#include "nvim/buffer_defs.h"
+#include "nvim/macros.h"
#include "nvim/mark.h"
#include "nvim/os/os.h"
#include "nvim/os/os_defs.h"