From 5baeb4a49c061472a125f98af798c522d8504fbe Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 15 Oct 2017 18:29:53 +0200 Subject: ex-cmds: :checkhealth Built-in `:checkhealth` checks for valid $VIMRUNTIME by attempting to autoload `health#check()`. closes #2977 closes #3159 --- src/nvim/eval.c | 29 +++++++++++++++++++++++++++++ src/nvim/ex_cmds.lua | 6 ++++++ 2 files changed, 35 insertions(+) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index b2a0d9a767..986c4a9a17 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -22850,3 +22850,32 @@ void eval_format_source_name_line(char *buf, size_t bufsize) (sourcing_name ? sourcing_name : (char_u *)"?"), (sourcing_name ? sourcing_lnum : 0)); } + +/// ":checkhealth [plugins]" +void ex_checkhealth(exarg_T *eap) +{ + bool found = !!find_func((char_u *)"health#check"); + if (!found + && script_autoload("health#check", sizeof("health#check") - 1, false)) { + found = !!find_func((char_u *)"health#check"); + } + if (!found) { + const char *vimruntime_env = os_getenv("VIMRUNTIME"); + if (vimruntime_env == NULL) { + EMSG(_("E5009: $VIMRUNTIME is empty or unset")); + return; + } else { + EMSG2(_("E5009: Invalid $VIMRUNTIME: %s"), os_getenv("VIMRUNTIME")); + return; + } + } + + size_t bufsize = STRLEN(eap->arg) + strlen("CheckHealth ") + 1; + char *buf = xmalloc(bufsize); + snprintf(buf, bufsize, "CheckHealth %s", eap->arg); + + do_cmdline_cmd(buf); + + xfree(buf); +} + diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index 5a578cd088..f99954db7a 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -450,6 +450,12 @@ return { addr_type=ADDR_LINES, func='ex_changes', }, + { + command='checkhealth', + flags=bit.bor(EXTRA, TRLBAR), + addr_type=ADDR_LINES, + func='ex_checkhealth', + }, { command='checkpath', flags=bit.bor(TRLBAR, BANG, CMDWIN), -- cgit From d214df4e9b23b5f2d9f7e6c78624881a7d298cdb Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 15 Oct 2017 20:31:12 +0200 Subject: doc: replace ":CheckHealth" with ":checkhealth" --- src/nvim/ops.c | 2 +- src/nvim/version.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index e7bc20698b..c6df71ea46 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -5535,7 +5535,7 @@ int get_default_register_name(void) static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing) { #define MSG_NO_CLIP "clipboard: No provider. " \ - "Try \":CheckHealth\" or \":h clipboard\"." + "Try \":checkhealth\" or \":h clipboard\"." yankreg_T *target = NULL; bool explicit_cb_reg = (*name == '*' || *name == '+'); diff --git a/src/nvim/version.c b/src/nvim/version.c index 7e59f3327a..c2a8dcac07 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -1365,7 +1365,7 @@ void intro_message(int colon) N_("https://neovim.io/community"), "", N_("type :help nvim if you are new! "), - N_("type :CheckHealth to optimize Nvim"), + N_("type :checkhealth to optimize Nvim"), N_("type :q to exit "), N_("type :help for help "), "", -- cgit From 014bd59957beb3f94cfb014a7acde3d2544bdfd9 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 16 Oct 2017 00:05:35 +0200 Subject: ex_checkhealth: call health#check() directly This allows us to remove :CheckHealth later (avoids wildmenu noise). --- src/nvim/eval.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 986c4a9a17..aab777955c 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -22870,9 +22870,9 @@ void ex_checkhealth(exarg_T *eap) } } - size_t bufsize = STRLEN(eap->arg) + strlen("CheckHealth ") + 1; + size_t bufsize = STRLEN(eap->arg) + sizeof("call health#check('')"); char *buf = xmalloc(bufsize); - snprintf(buf, bufsize, "CheckHealth %s", eap->arg); + snprintf(buf, bufsize, "call health#check('%s')", eap->arg); do_cmdline_cmd(buf); -- cgit