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.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 2f06a2cbf2..7dc299e73b 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -12,6 +12,8 @@
#include <string.h>
#include <stdbool.h>
+#include <msgpack.h>
+
#include "nvim/ascii.h"
#include "nvim/vim.h"
#include "nvim/main.h"
@@ -57,6 +59,9 @@
#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/os/signal.h"
+#include "nvim/os/msgpack_rpc_helpers.h"
+#include "nvim/api/private/defs.h"
+#include "nvim/api/private/helpers.h"
/* Maximum number of commands from + or -c arguments. */
#define MAX_ARG_CMDS 10
@@ -116,9 +121,6 @@ static void init_locale(void);
# endif
#endif /* NO_VIM_MAIN */
-extern const uint8_t msgpack_metadata[];
-extern const unsigned int msgpack_metadata_size;
-
/*
* Different types of error messages.
*/
@@ -190,6 +192,7 @@ int main(int argc, char **argv)
init_yank(); /* init yank buffers */
alist_init(&global_alist); /* Init the argument list to empty. */
+ global_alist.id = 0;
/*
* Set the default values for the options.
@@ -471,11 +474,10 @@ int main(int argc, char **argv)
edit_buffers(&params);
if (params.diff_mode) {
- win_T *wp;
-
/* set options in each window for "vimdiff". */
- for (wp = firstwin; wp != NULL; wp = wp->w_next)
+ FOR_ALL_WINDOWS(wp) {
diff_win_options(wp, TRUE);
+ }
}
/*
@@ -1027,12 +1029,18 @@ static void command_line_scan(mparm_T *parmp)
msg_putchar('\n');
msg_didout = FALSE;
mch_exit(0);
- } else if (STRICMP(argv[0] + argv_idx, "api-msgpack-metadata") == 0) {
- for (unsigned int i = 0; i<msgpack_metadata_size; i++) {
- putchar(msgpack_metadata[i]);
+ } else if (STRICMP(argv[0] + argv_idx, "api-info") == 0) {
+ msgpack_sbuffer* b = msgpack_sbuffer_new();
+ msgpack_packer* p = msgpack_packer_new(b, msgpack_sbuffer_write);
+ Object md = DICTIONARY_OBJ(api_metadata());
+ msgpack_rpc_from_object(md, p);
+
+ for (size_t i = 0; i < b->size; i++) {
+ putchar(b->data[i]);
}
+
mch_exit(0);
- } else if (STRICMP(argv[0] + argv_idx, "embedded-mode") == 0) {
+ } else if (STRICMP(argv[0] + argv_idx, "embed") == 0) {
embedded_mode = true;
} else if (STRNICMP(argv[0] + argv_idx, "literal", 7) == 0) {
#if !defined(UNIX)
@@ -2094,9 +2102,9 @@ static int file_owned(char *fname)
{
uid_t uid = getuid();
FileInfo file_info;
- bool file_owned = os_get_file_info(fname, &file_info)
+ bool file_owned = os_fileinfo(fname, &file_info)
&& file_info.stat.st_uid == uid;
- bool link_owned = os_get_file_info_link(fname, &file_info)
+ bool link_owned = os_fileinfo_link(fname, &file_info)
&& file_info.stat.st_uid == uid;
return file_owned && link_owned;
}
@@ -2213,8 +2221,8 @@ static void usage(void)
main_msg(_("-W <scriptout>\tWrite all typed commands to file <scriptout>"));
main_msg(_("--startuptime <file>\tWrite startup timing messages to <file>"));
main_msg(_("-i <viminfo>\t\tUse <viminfo> instead of .viminfo"));
- main_msg(_("--api-msgpack-metadata\tDump API metadata information and exit"));
- main_msg(_("--embedded-mode\tUse stdin/stdout as a msgpack-rpc channel. "
+ main_msg(_("--api-info\t\tDump API metadata serialized to msgpack and exit"));
+ main_msg(_("--embed\t\tUse stdin/stdout as a msgpack-rpc channel. "
"This can be used for embedding Neovim into other programs"));
main_msg(_("-h or --help\tPrint Help (this message) and exit"));
main_msg(_("--version\t\tPrint version information and exit"));