aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/main.c')
-rw-r--r--src/nvim/main.c284
1 files changed, 136 insertions, 148 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 6585bd1df7..ea189aaa0c 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -25,15 +25,19 @@
#include "nvim/arglist.h"
#include "nvim/ascii_defs.h"
#include "nvim/autocmd.h"
+#include "nvim/autocmd_defs.h"
#include "nvim/buffer.h"
#include "nvim/buffer_defs.h"
#include "nvim/channel.h"
+#include "nvim/channel_defs.h"
#include "nvim/decoration.h"
#include "nvim/decoration_provider.h"
#include "nvim/diff.h"
+#include "nvim/drawline.h"
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
+#include "nvim/eval/typval_defs.h"
#include "nvim/eval/userfunc.h"
#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
@@ -42,12 +46,12 @@
#include "nvim/ex_cmds.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
+#include "nvim/extmark.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
-#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
-#include "nvim/gettext.h"
+#include "nvim/gettext_defs.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
#include "nvim/hashtab.h"
@@ -66,18 +70,20 @@
#include "nvim/mouse.h"
#include "nvim/move.h"
#include "nvim/msgpack_rpc/channel.h"
-#include "nvim/msgpack_rpc/helpers.h"
#include "nvim/msgpack_rpc/server.h"
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
+#include "nvim/option_defs.h"
#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/fileio.h"
+#include "nvim/os/fileio_defs.h"
#include "nvim/os/fs.h"
#include "nvim/os/input.h"
#include "nvim/os/lang.h"
#include "nvim/os/os.h"
+#include "nvim/os/os_defs.h"
#include "nvim/os/signal.h"
#include "nvim/os/stdpaths_defs.h"
#include "nvim/path.h"
@@ -85,6 +91,7 @@
#include "nvim/profile.h"
#include "nvim/quickfix.h"
#include "nvim/runtime.h"
+#include "nvim/runtime_defs.h"
#include "nvim/shada.h"
#include "nvim/statusline.h"
#include "nvim/strings.h"
@@ -97,10 +104,16 @@
#include "nvim/version.h"
#include "nvim/vim_defs.h"
#include "nvim/window.h"
+#include "nvim/winfloat.h"
+
#ifdef MSWIN
# include "nvim/os/os_win_console.h"
#endif
+#if defined(MSWIN) && !defined(MAKE_LIB)
+# include "nvim/mbyte.h"
+#endif
+
// values for "window_layout"
enum {
WIN_HOR = 1, // "-o" horizontally split windows
@@ -138,11 +151,9 @@ void event_init(void)
loop_init(&main_loop, NULL);
resize_events = multiqueue_new_child(main_loop.events);
- // early msgpack-rpc initialization
- msgpack_rpc_helpers_init();
input_init();
signal_init();
- // finish mspgack-rpc initialization
+ // mspgack-rpc initialization
channel_init();
terminal_init();
ui_init();
@@ -247,7 +258,7 @@ int main(int argc, char **argv)
argv0 = argv[0];
if (!appname_is_valid()) {
- os_errmsg("$NVIM_APPNAME must be a name or relative path.\n");
+ fprintf(stderr, "$NVIM_APPNAME must be a name or relative path.\n");
exit(1);
}
@@ -336,7 +347,7 @@ int main(int argc, char **argv)
ui_client_forward_stdin = !stdin_isatty;
uint64_t rv = ui_client_start_server(params.argc, params.argv);
if (!rv) {
- os_errmsg("Failed to start Nvim server!\n");
+ fprintf(stderr, "Failed to start Nvim server!\n");
os_exit(1);
}
ui_client_channel_id = rv;
@@ -352,7 +363,7 @@ int main(int argc, char **argv)
setbuf(stdout, NULL); // NOLINT(bugprone-unsafe-functions)
- full_screen = !silent_mode;
+ full_screen = !silent_mode || exmode_active;
// Set the default values for the options that use Rows and Columns.
win_init_size();
@@ -385,6 +396,7 @@ int main(int argc, char **argv)
}
if (ui_client_channel_id) {
+ time_finish();
ui_client_run(remote_ui); // NORETURN
}
assert(!ui_client_channel_id && !use_builtin_ui);
@@ -411,7 +423,19 @@ int main(int argc, char **argv)
params.edit_type = EDIT_STDIN;
}
- open_script_files(&params);
+ if (params.scriptin) {
+ if (!open_scriptin(params.scriptin)) {
+ os_exit(2);
+ }
+ }
+ if (params.scriptout) {
+ scriptout = os_fopen(params.scriptout, params.scriptout_append ? APPENDBIN : WRITEBIN);
+ if (scriptout == NULL) {
+ fprintf(stderr, _("Cannot open for script output: \""));
+ fprintf(stderr, "%s\"\n", params.scriptout);
+ os_exit(2);
+ }
+ }
nlua_init_defaults();
@@ -615,7 +639,7 @@ int main(int argc, char **argv)
// WORKAROUND(mhi): #3023
if (cb_flags & CB_UNNAMEDMASK) {
- (void)eval_has_provider("clipboard");
+ eval_has_provider("clipboard");
}
if (params.luaf != NULL) {
@@ -681,6 +705,9 @@ void getout(int exitval)
assert(!ui_client_channel_id);
exiting = true;
+ // make sure startuptimes have been flushed
+ time_finish();
+
// On error during Ex mode, exit with a non-zero code.
// POSIX requires this, although it's not 100% clear from the standard.
if (exmode_active) {
@@ -823,8 +850,7 @@ void preserve_exit(const char *errmsg)
ui_client_stop();
}
if (errmsg != NULL) {
- os_errmsg(errmsg);
- os_errmsg("\n");
+ fprintf(stderr, "%s\n", errmsg);
}
if (ui_client_channel_id) {
os_exit(1);
@@ -835,7 +861,7 @@ void preserve_exit(const char *errmsg)
FOR_ALL_BUFFERS(buf) {
if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL) {
if (errmsg != NULL) {
- os_errmsg("Vim: preserving files...\r\n");
+ fprintf(stderr, "Vim: preserving files...\r\n");
}
ml_sync_all(false, false, true); // preserve all swap files
break;
@@ -845,7 +871,7 @@ void preserve_exit(const char *errmsg)
ml_close_all(false); // close all memfiles, without deleting
if (errmsg != NULL) {
- os_errmsg("Vim: Finished.\r\n");
+ fprintf(stderr, "Vim: Finished.\r\n");
}
getout(1);
@@ -910,14 +936,11 @@ static void remote_request(mparm_T *params, int remote_args, char *server_addr,
if (is_ui) {
if (!chan) {
- os_errmsg("Remote ui failed to start: ");
- os_errmsg(connect_error);
- os_errmsg("\n");
+ fprintf(stderr, "Remote ui failed to start: %s\n", connect_error);
os_exit(1);
} else if (strequal(server_addr, os_getenv("NVIM"))) {
- os_errmsg("Cannot attach UI of :terminal child to its parent. ");
- os_errmsg("(Unset $NVIM to skip this check)");
- os_errmsg("\n");
+ fprintf(stderr, "%s", "Cannot attach UI of :terminal child to its parent. ");
+ fprintf(stderr, "%s\n", "(Unset $NVIM to skip this check)");
os_exit(1);
}
@@ -926,30 +949,29 @@ static void remote_request(mparm_T *params, int remote_args, char *server_addr,
}
Array args = ARRAY_DICT_INIT;
+ kv_resize(args, (size_t)(argc - remote_args));
for (int t_argc = remote_args; t_argc < argc; t_argc++) {
- String arg_s = cstr_to_string(argv[t_argc]);
- ADD(args, STRING_OBJ(arg_s));
+ ADD_C(args, CSTR_AS_OBJ(argv[t_argc]));
}
Error err = ERROR_INIT;
- Array a = ARRAY_DICT_INIT;
- ADD(a, INTEGER_OBJ((int)chan));
- ADD(a, CSTR_TO_OBJ(server_addr));
- ADD(a, CSTR_TO_OBJ(connect_error));
- ADD(a, ARRAY_OBJ(args));
+ MAXSIZE_TEMP_ARRAY(a, 4);
+ ADD_C(a, INTEGER_OBJ((int)chan));
+ ADD_C(a, CSTR_AS_OBJ(server_addr));
+ ADD_C(a, CSTR_AS_OBJ(connect_error));
+ ADD_C(a, ARRAY_OBJ(args));
String s = STATIC_CSTR_AS_STRING("return vim._cs_remote(...)");
- Object o = nlua_exec(s, a, &err);
- api_free_array(a);
+ Object o = nlua_exec(s, a, kRetObject, NULL, &err);
+ kv_destroy(args);
if (ERROR_SET(&err)) {
- os_errmsg(err.msg);
- os_errmsg("\n");
+ fprintf(stderr, "%s\n", err.msg);
os_exit(2);
}
if (o.type == kObjectTypeDictionary) {
rvobj.data.dictionary = o.data.dictionary;
} else {
- os_errmsg("vim._cs_remote returned unexpected value\n");
+ fprintf(stderr, "vim._cs_remote returned unexpected value\n");
os_exit(2);
}
@@ -959,34 +981,33 @@ static void remote_request(mparm_T *params, int remote_args, char *server_addr,
for (size_t i = 0; i < rvobj.data.dictionary.size; i++) {
if (strequal(rvobj.data.dictionary.items[i].key.data, "errmsg")) {
if (rvobj.data.dictionary.items[i].value.type != kObjectTypeString) {
- os_errmsg("vim._cs_remote returned an unexpected type for 'errmsg'\n");
+ fprintf(stderr, "vim._cs_remote returned an unexpected type for 'errmsg'\n");
os_exit(2);
}
- os_errmsg(rvobj.data.dictionary.items[i].value.data.string.data);
- os_errmsg("\n");
+ fprintf(stderr, "%s\n", rvobj.data.dictionary.items[i].value.data.string.data);
os_exit(2);
} else if (strequal(rvobj.data.dictionary.items[i].key.data, "result")) {
if (rvobj.data.dictionary.items[i].value.type != kObjectTypeString) {
- os_errmsg("vim._cs_remote returned an unexpected type for 'result'\n");
+ fprintf(stderr, "vim._cs_remote returned an unexpected type for 'result'\n");
os_exit(2);
}
- os_msg(rvobj.data.dictionary.items[i].value.data.string.data);
+ printf("%s", rvobj.data.dictionary.items[i].value.data.string.data);
} else if (strequal(rvobj.data.dictionary.items[i].key.data, "tabbed")) {
if (rvobj.data.dictionary.items[i].value.type != kObjectTypeBoolean) {
- os_errmsg("vim._cs_remote returned an unexpected type for 'tabbed'\n");
+ fprintf(stderr, "vim._cs_remote returned an unexpected type for 'tabbed'\n");
os_exit(2);
}
tabbed = rvobj.data.dictionary.items[i].value.data.boolean ? kTrue : kFalse;
} else if (strequal(rvobj.data.dictionary.items[i].key.data, "should_exit")) {
if (rvobj.data.dictionary.items[i].value.type != kObjectTypeBoolean) {
- os_errmsg("vim._cs_remote returned an unexpected type for 'should_exit'\n");
+ fprintf(stderr, "vim._cs_remote returned an unexpected type for 'should_exit'\n");
os_exit(2);
}
should_exit = rvobj.data.dictionary.items[i].value.data.boolean ? kTrue : kFalse;
}
}
if (should_exit == kNone || tabbed == kNone) {
- os_errmsg("vim._cs_remote didn't return a value for should_exit or tabbed, bailing\n");
+ fprintf(stderr, "vim._cs_remote didn't return a value for should_exit or tabbed, bailing\n");
os_exit(2);
}
api_free_object(o);
@@ -1008,6 +1029,7 @@ static bool edit_stdin(mparm_T *parmp)
&& !(embedded_mode && stdin_fd <= 0)
&& (!exmode_active || parmp->input_istext)
&& !stdin_isatty
+ && parmp->edit_type <= EDIT_STDIN
&& parmp->scriptin == NULL; // `-s -` was not given.
return parmp->had_stdin_file || implicit;
}
@@ -1019,7 +1041,7 @@ static void command_line_scan(mparm_T *parmp)
char **argv = parmp->argv;
int argv_idx; // index in argv[n][]
bool had_minmin = false; // found "--" argument
- int want_argument; // option argument with argument
+ bool want_argument; // option argument with argument
int n;
argc--;
@@ -1078,20 +1100,16 @@ static void command_line_scan(mparm_T *parmp)
FileDescriptor fp;
const int fof_ret = file_open_fd(&fp, STDOUT_FILENO,
kFileWriteOnly);
- msgpack_packer *p = msgpack_packer_new(&fp, msgpack_file_write);
-
if (fof_ret != 0) {
semsg(_("E5421: Failed to open stdin: %s"), os_strerror(fof_ret));
}
- if (p == NULL) {
- emsg(_(e_outofmem));
+ String data = api_metadata_raw();
+ const ptrdiff_t written_bytes = file_write(&fp, data.data, data.size);
+ if (written_bytes < 0) {
+ msgpack_file_write_error((int)written_bytes);
}
- Object md = DICTIONARY_OBJ(api_metadata());
- msgpack_rpc_from_object(md, p);
-
- msgpack_packer_free(p);
const int ff_ret = file_flush(&fp);
if (ff_ret < 0) {
msgpack_file_write_error(ff_ret);
@@ -1122,7 +1140,7 @@ static void command_line_scan(mparm_T *parmp)
} else if (STRNICMP(argv[0] + argv_idx, "clean", 5) == 0) {
parmp->use_vimrc = "NONE";
parmp->clean = true;
- set_option_value_give_err("shadafile", STATIC_CSTR_AS_OPTVAL("NONE"), 0);
+ set_option_value_give_err(kOptShadafile, STATIC_CSTR_AS_OPTVAL("NONE"), 0);
} else if (STRNICMP(argv[0] + argv_idx, "luamod-dev", 9) == 0) {
nlua_disable_preload = true;
} else {
@@ -1136,7 +1154,7 @@ static void command_line_scan(mparm_T *parmp)
}
break;
case 'A': // "-A" start in Arabic mode.
- set_option_value_give_err("arabic", BOOLEAN_OPTVAL(true), 0);
+ set_option_value_give_err(kOptArabic, BOOLEAN_OPTVAL(true), 0);
break;
case 'b': // "-b" binary mode.
// Needs to be effective before expanding file names, because
@@ -1166,8 +1184,8 @@ static void command_line_scan(mparm_T *parmp)
usage();
os_exit(0);
case 'H': // "-H" start in Hebrew mode: rl + keymap=hebrew set.
- set_option_value_give_err("keymap", STATIC_CSTR_AS_OPTVAL("hebrew"), 0);
- set_option_value_give_err("rl", BOOLEAN_OPTVAL(true), 0);
+ set_option_value_give_err(kOptKeymap, STATIC_CSTR_AS_OPTVAL("hebrew"), 0);
+ set_option_value_give_err(kOptRightleft, BOOLEAN_OPTVAL(true), 0);
break;
case 'M': // "-M" no changes or writing of files
reset_modifiable();
@@ -1247,7 +1265,7 @@ static void command_line_scan(mparm_T *parmp)
// default is 10: a little bit verbose
p_verbose = get_number_arg(argv[0], &argv_idx, 10);
if (argv[0][argv_idx] != NUL) {
- set_option_value_give_err("verbosefile", CSTR_AS_OPTVAL(argv[0] + argv_idx), 0);
+ set_option_value_give_err(kOptVerbosefile, CSTR_AS_OPTVAL(argv[0] + argv_idx), 0);
argv_idx = (int)strlen(argv[0]);
}
break;
@@ -1255,7 +1273,7 @@ static void command_line_scan(mparm_T *parmp)
// "-w {scriptout}" write to script
if (ascii_isdigit((argv[0])[argv_idx])) {
n = get_number_arg(argv[0], &argv_idx, 10);
- set_option_value_give_err("window", NUMBER_OPTVAL((OptInt)n), 0);
+ set_option_value_give_err(kOptWindow, NUMBER_OPTVAL((OptInt)n), 0);
break;
}
want_argument = true;
@@ -1351,7 +1369,7 @@ static void command_line_scan(mparm_T *parmp)
break;
case 'i': // "-i {shada}" use for shada
- set_option_value_give_err("shadafile", CSTR_AS_OPTVAL(argv[0]), 0);
+ set_option_value_give_err(kOptShadafile, CSTR_AS_OPTVAL(argv[0]), 0);
break;
case 'l': // "-l" Lua script: args after "-l".
@@ -1361,7 +1379,7 @@ static void command_line_scan(mparm_T *parmp)
parmp->no_swap_file = true;
parmp->use_vimrc = parmp->use_vimrc ? parmp->use_vimrc : "NONE";
if (p_shadafile == NULL || *p_shadafile == NUL) {
- set_option_value_give_err("shadafile", STATIC_CSTR_AS_OPTVAL("NONE"), 0);
+ set_option_value_give_err(kOptShadafile, STATIC_CSTR_AS_OPTVAL("NONE"), 0);
}
parmp->luaf = argv[0];
argc--;
@@ -1377,7 +1395,7 @@ scripterror:
vim_snprintf(IObuff, IOSIZE,
_("Attempt to open script file again: \"%s %s\"\n"),
argv[-1], argv[0]);
- os_errmsg(IObuff);
+ fprintf(stderr, "%s", IObuff);
os_exit(2);
}
parmp->scriptin = argv[0];
@@ -1397,7 +1415,7 @@ scripterror:
if (ascii_isdigit(*(argv[0]))) {
argv_idx = 0;
n = get_number_arg(argv[0], &argv_idx, 10);
- set_option_value_give_err("window", NUMBER_OPTVAL((OptInt)n), 0);
+ set_option_value_give_err(kOptWindow, NUMBER_OPTVAL((OptInt)n), 0);
argv_idx = -1;
break;
}
@@ -1486,9 +1504,16 @@ static void init_params(mparm_T *paramp, int argc, char **argv)
/// Initialize global startuptime file if "--startuptime" passed as an argument.
static void init_startuptime(mparm_T *paramp)
{
+ bool is_embed = false;
+ for (int i = 1; i < paramp->argc - 1; i++) {
+ if (STRICMP(paramp->argv[i], "--embed") == 0) {
+ is_embed = true;
+ break;
+ }
+ }
for (int i = 1; i < paramp->argc - 1; i++) {
if (STRICMP(paramp->argv[i], "--startuptime") == 0) {
- time_fd = fopen(paramp->argv[i + 1], "a");
+ time_init(paramp->argv[i + 1], is_embed ? "Embedded" : "Primary/TUI");
time_start("--- NVIM STARTING ---");
break;
}
@@ -1548,7 +1573,7 @@ static void handle_quickfix(mparm_T *paramp)
{
if (paramp->edit_type == EDIT_QF) {
if (paramp->use_ef != NULL) {
- set_string_option_direct("ef", -1, paramp->use_ef, OPT_FREE, SID_CARG);
+ set_string_option_direct(kOptErrorfile, paramp->use_ef, 0, SID_CARG);
}
vim_snprintf(IObuff, IOSIZE, "cfile %s", p_ef);
if (qf_init(NULL, p_ef, p_efm, true, IObuff, p_menc) < 0) {
@@ -1587,7 +1612,7 @@ static void read_stdin(void)
bool save_msg_didany = msg_didany;
set_buflisted(true);
// Create memfile and read from stdin.
- (void)open_buffer(true, NULL, 0);
+ open_buffer(true, NULL, 0);
if (buf_is_empty(curbuf) && curbuf->b_next != NULL) {
// stdin was empty, go to buffer 2 (e.g. "echo file1 | xargs nvim"). #8561
do_cmdline_cmd("silent! bnext");
@@ -1600,38 +1625,6 @@ static void read_stdin(void)
check_swap_exists_action();
}
-static void open_script_files(mparm_T *parmp)
-{
- if (parmp->scriptin) {
- int error;
- if (strequal(parmp->scriptin, "-")) {
- FileDescriptor *stdin_dup = file_open_stdin();
- scriptin[0] = stdin_dup;
- } else {
- scriptin[0] = file_open_new(&error, parmp->scriptin,
- kFileReadOnly|kFileNonBlocking, 0);
- if (scriptin[0] == NULL) {
- vim_snprintf(IObuff, IOSIZE,
- _("Cannot open for reading: \"%s\": %s\n"),
- parmp->scriptin, os_strerror(error));
- os_errmsg(IObuff);
- os_exit(2);
- }
- }
- save_typebuf();
- }
-
- if (parmp->scriptout) {
- scriptout = os_fopen(parmp->scriptout, parmp->scriptout_append ? APPENDBIN : WRITEBIN);
- if (scriptout == NULL) {
- os_errmsg(_("Cannot open for script output: \""));
- os_errmsg(parmp->scriptout);
- os_errmsg("\"\n");
- os_exit(2);
- }
- }
-}
-
// Create the requested number of windows and edit buffers in them.
// Also does recovery if "recoverymode" set.
static void create_windows(mparm_T *parmp)
@@ -1679,7 +1672,7 @@ static void create_windows(mparm_T *parmp)
// Don't execute Win/Buf Enter/Leave autocommands here
autocmd_no_enter++;
autocmd_no_leave++;
- int dorewind = true;
+ bool dorewind = true;
while (done++ < 1000) {
if (dorewind) {
if (parmp->window_layout == WIN_TABS) {
@@ -1710,7 +1703,7 @@ static void create_windows(mparm_T *parmp)
set_buflisted(true);
// create memfile, read file
- (void)open_buffer(false, NULL, 0);
+ open_buffer(false, NULL, 0);
if (swap_exists_action == SEA_QUIT) {
if (got_int || only_one_window()) {
@@ -1732,7 +1725,7 @@ static void create_windows(mparm_T *parmp)
}
os_breakcheck();
if (got_int) {
- (void)vgetc(); // only break the file loading, not the rest
+ vgetc(); // only break the file loading, not the rest
break;
}
}
@@ -1793,7 +1786,7 @@ static void edit_buffers(mparm_T *parmp, char *cwd)
p_shm_save = xstrdup(p_shm);
snprintf(buf, sizeof(buf), "F%s", p_shm);
- set_option_value_give_err("shm", CSTR_AS_OPTVAL(buf), 0);
+ set_option_value_give_err(kOptShortmess, CSTR_AS_OPTVAL(buf), 0);
}
} else {
if (curwin->w_next == NULL) { // just checking
@@ -1811,9 +1804,9 @@ static void edit_buffers(mparm_T *parmp, char *cwd)
// Edit file from arg list, if there is one. When "Quit" selected
// at the ATTENTION prompt close the window.
swap_exists_did_quit = false;
- (void)do_ecmd(0, arg_idx < GARGCOUNT
- ? alist_name(&GARGLIST[arg_idx])
- : NULL, NULL, NULL, ECMD_LASTL, ECMD_HIDE, curwin);
+ do_ecmd(0, arg_idx < GARGCOUNT
+ ? alist_name(&GARGLIST[arg_idx])
+ : NULL, NULL, NULL, ECMD_LASTL, ECMD_HIDE, curwin);
if (swap_exists_did_quit) {
// abort or quit selected
if (got_int || only_one_window()) {
@@ -1832,13 +1825,13 @@ static void edit_buffers(mparm_T *parmp, char *cwd)
}
os_breakcheck();
if (got_int) {
- (void)vgetc(); // only break the file loading, not the rest
+ vgetc(); // only break the file loading, not the rest
break;
}
}
if (p_shm_save != NULL) {
- set_option_value_give_err("shm", CSTR_AS_OPTVAL(p_shm_save), 0);
+ set_option_value_give_err(kOptShortmess, CSTR_AS_OPTVAL(p_shm_save), 0);
xfree(p_shm_save);
}
@@ -1964,7 +1957,7 @@ static void do_system_initialization(void)
#ifdef SYS_VIMRC_FILE
// Get system wide defaults, if the file name is defined.
- (void)do_source(SYS_VIMRC_FILE, false, DOSO_NONE, NULL);
+ do_source(SYS_VIMRC_FILE, false, DOSO_NONE, NULL);
#endif
}
@@ -2066,7 +2059,7 @@ static void do_exrc_initialization(void)
str = nlua_read_secure(VIMRC_LUA_FILE);
if (str != NULL) {
Error err = ERROR_INIT;
- nlua_exec(cstr_as_string(str), (Array)ARRAY_DICT_INIT, &err);
+ nlua_exec(cstr_as_string(str), (Array)ARRAY_DICT_INIT, kRetNilBool, NULL, &err);
xfree(str);
if (ERROR_SET(&err)) {
semsg("Error detected while processing %s:", VIMRC_LUA_FILE);
@@ -2158,17 +2151,12 @@ static void print_mainerr(const char *errstr, const char *str)
signal_stop(); // kill us with CTRL-C here, if you like
- os_errmsg(prgname);
- os_errmsg(": ");
- os_errmsg(_(errstr));
+ fprintf(stderr, "%s: %s", prgname, _(errstr));
if (str != NULL) {
- os_errmsg(": \"");
- os_errmsg(str);
- os_errmsg("\"");
+ fprintf(stderr, ": \"%s\"", str);
}
- os_errmsg(_("\nMore info with \""));
- os_errmsg(prgname);
- os_errmsg(" -h\"\n");
+ fprintf(stderr, _("\nMore info with \""));
+ fprintf(stderr, "%s -h\"\n", prgname);
}
/// Prints version information for "nvim -v" or "nvim --version".
@@ -2176,7 +2164,7 @@ static void version(void)
{
// TODO(bfred): not like this?
nlua_init(NULL, 0, -1);
- info_message = true; // use os_msg(), not os_errmsg()
+ info_message = true; // use stdout, not stderr
list_version();
msg_putchar('\n');
msg_didout = false;
@@ -2187,38 +2175,38 @@ static void usage(void)
{
signal_stop(); // kill us with CTRL-C here, if you like
- os_msg(_("Usage:\n"));
- os_msg(_(" nvim [options] [file ...]\n"));
- os_msg(_("\nOptions:\n"));
- os_msg(_(" --cmd <cmd> Execute <cmd> before any config\n"));
- os_msg(_(" +<cmd>, -c <cmd> Execute <cmd> after config and first file\n"));
- os_msg(_(" -l <script> [args...] Execute Lua <script> (with optional args)\n"));
- os_msg(_(" -S <session> Source <session> after loading the first file\n"));
- os_msg(_(" -s <scriptin> Read Normal mode commands from <scriptin>\n"));
- os_msg(_(" -u <config> Use this config file\n"));
- os_msg("\n");
- os_msg(_(" -d Diff mode\n"));
- os_msg(_(" -es, -Es Silent (batch) mode\n"));
- os_msg(_(" -h, --help Print this help message\n"));
- os_msg(_(" -i <shada> Use this shada file\n"));
- os_msg(_(" -n No swap file, use memory only\n"));
- os_msg(_(" -o[N] Open N windows (default: one per file)\n"));
- os_msg(_(" -O[N] Open N vertical windows (default: one per file)\n"));
- os_msg(_(" -p[N] Open N tab pages (default: one per file)\n"));
- os_msg(_(" -R Read-only (view) mode\n"));
- os_msg(_(" -v, --version Print version information\n"));
- os_msg(_(" -V[N][file] Verbose [level][file]\n"));
- os_msg("\n");
- os_msg(_(" -- Only file names after this\n"));
- os_msg(_(" --api-info Write msgpack-encoded API metadata to stdout\n"));
- os_msg(_(" --clean \"Factory defaults\" (skip user config and plugins, shada)\n"));
- os_msg(_(" --embed Use stdin/stdout as a msgpack-rpc channel\n"));
- os_msg(_(" --headless Don't start a user interface\n"));
- os_msg(_(" --listen <address> Serve RPC API from this address\n"));
- os_msg(_(" --remote[-subcommand] Execute commands remotely on a server\n"));
- os_msg(_(" --server <address> Specify RPC server to send commands to\n"));
- os_msg(_(" --startuptime <file> Write startup timing messages to <file>\n"));
- os_msg(_("\nSee \":help startup-options\" for all options.\n"));
+ printf(_("Usage:\n"));
+ printf(_(" nvim [options] [file ...]\n"));
+ printf(_("\nOptions:\n"));
+ printf(_(" --cmd <cmd> Execute <cmd> before any config\n"));
+ printf(_(" +<cmd>, -c <cmd> Execute <cmd> after config and first file\n"));
+ printf(_(" -l <script> [args...] Execute Lua <script> (with optional args)\n"));
+ printf(_(" -S <session> Source <session> after loading the first file\n"));
+ printf(_(" -s <scriptin> Read Normal mode commands from <scriptin>\n"));
+ printf(_(" -u <config> Use this config file\n"));
+ printf("\n");
+ printf(_(" -d Diff mode\n"));
+ printf(_(" -es, -Es Silent (batch) mode\n"));
+ printf(_(" -h, --help Print this help message\n"));
+ printf(_(" -i <shada> Use this shada file\n"));
+ printf(_(" -n No swap file, use memory only\n"));
+ printf(_(" -o[N] Open N windows (default: one per file)\n"));
+ printf(_(" -O[N] Open N vertical windows (default: one per file)\n"));
+ printf(_(" -p[N] Open N tab pages (default: one per file)\n"));
+ printf(_(" -R Read-only (view) mode\n"));
+ printf(_(" -v, --version Print version information\n"));
+ printf(_(" -V[N][file] Verbose [level][file]\n"));
+ printf("\n");
+ printf(_(" -- Only file names after this\n"));
+ printf(_(" --api-info Write msgpack-encoded API metadata to stdout\n"));
+ printf(_(" --clean \"Factory defaults\" (skip user config and plugins, shada)\n"));
+ printf(_(" --embed Use stdin/stdout as a msgpack-rpc channel\n"));
+ printf(_(" --headless Don't start a user interface\n"));
+ printf(_(" --listen <address> Serve RPC API from this address\n"));
+ printf(_(" --remote[-subcommand] Execute commands remotely on a server\n"));
+ printf(_(" --server <address> Specify RPC server to send commands to\n"));
+ printf(_(" --startuptime <file> Write startup timing messages to <file>\n"));
+ printf(_("\nSee \":help startup-options\" for all options.\n"));
}
// Check the result of the ATTENTION dialog: