diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-11-10 22:37:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-10 22:37:54 +0100 |
commit | f5d4da0144c97ba13f530ea7dbd50f7b9768cb34 (patch) | |
tree | 02c8c2cb07a58db80d2aec6be5655b33b25abe6d | |
parent | 314ff440f7130c39d7990295535a8cfde92de4ba (diff) | |
download | rneovim-f5d4da0144c97ba13f530ea7dbd50f7b9768cb34.tar.gz rneovim-f5d4da0144c97ba13f530ea7dbd50f7b9768cb34.tar.bz2 rneovim-f5d4da0144c97ba13f530ea7dbd50f7b9768cb34.zip |
:checkhealth : validate 'runtimepath' (#7526)
-rw-r--r-- | runtime/doc/pi_health.txt | 10 | ||||
-rw-r--r-- | src/nvim/eval.c | 10 | ||||
-rw-r--r-- | test/functional/plugin/health_spec.lua | 7 |
3 files changed, 19 insertions, 8 deletions
diff --git a/runtime/doc/pi_health.txt b/runtime/doc/pi_health.txt index 99ff519bb9..bb688770fc 100644 --- a/runtime/doc/pi_health.txt +++ b/runtime/doc/pi_health.txt @@ -23,11 +23,11 @@ Commands *health-commands* *:checkhealth* *:CheckHealth* :checkhealth Run all healthchecks. *E5009* - Nvim depends on the |$VIMRUNTIME| environment variable - to find the standard "runtime files" for syntax - highlighting, filetype-specific behavior, and standard - plugins such as :checkhealth. If $VIMRUNTIME is invalid - then those features will not work. + Nvim depends on |$VIMRUNTIME| and 'runtimepath' to find + the standard "runtime files" for syntax highlighting, + filetype-specific behavior, and standard plugins + (including :checkhealth). If the runtime files cannot + be found then those features will not work. :checkhealth {plugins} Run healthcheck(s) for one or more plugins. E.g. to run diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 0c0c03c8ed..33bea8ef87 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -22883,11 +22883,15 @@ void ex_checkhealth(exarg_T *eap) 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; + bool rtp_ok = NULL != strstr((char *)p_rtp, vimruntime_env); + if (rtp_ok) { + EMSG2(_("E5009: Invalid $VIMRUNTIME: %s"), vimruntime_env); + } else { + EMSG(_("E5009: Invalid 'runtimepath'")); + } } + return; } size_t bufsize = STRLEN(eap->arg) + sizeof("call health#check('')"); diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua index b5374210e6..8ee0f258d0 100644 --- a/test/functional/plugin/health_spec.lua +++ b/test/functional/plugin/health_spec.lua @@ -16,6 +16,13 @@ describe(':checkhealth', function() eq(false, status) eq('Invalid $VIMRUNTIME: bogus', string.match(err, 'Invalid.*')) end) + it("detects invalid 'runtimepath'", function() + clear() + command('set runtimepath=bogus') + local status, err = pcall(command, 'checkhealth') + eq(false, status) + eq("Invalid 'runtimepath'", string.match(err, 'Invalid.*')) + end) it("detects invalid $VIM", function() clear() -- Do this after startup, otherwise it just breaks $VIMRUNTIME. |