:checkhealth : validate $VIM

This commit is contained in:
Justin M. Keyes 2017-10-17 00:10:52 +02:00
parent 014bd59957
commit 3bcee71cc8
2 changed files with 14 additions and 7 deletions

View File

@ -4,12 +4,19 @@ function! s:check_config() abort
let ok = v:true let ok = v:true
call health#report_start('Configuration') call health#report_start('Configuration')
" If $VIM is empty we don't care. Else make sure it is valid.
if !empty($VIM) && !filereadable($VIM.'/runtime/doc/nvim.txt')
let ok = v:false
call health#report_error("$VIM is invalid: ".$VIM)
endif
if exists('$NVIM_TUI_ENABLE_CURSOR_SHAPE') if exists('$NVIM_TUI_ENABLE_CURSOR_SHAPE')
let ok = v:false let ok = v:false
call health#report_warn("$NVIM_TUI_ENABLE_CURSOR_SHAPE is ignored in Nvim 0.2+", call health#report_warn("$NVIM_TUI_ENABLE_CURSOR_SHAPE is ignored in Nvim 0.2+",
\ [ "Use the 'guicursor' option to configure cursor shape. :help 'guicursor'", \ [ "Use the 'guicursor' option to configure cursor shape. :help 'guicursor'",
\ 'https://github.com/neovim/neovim/wiki/Following-HEAD#20170402' ]) \ 'https://github.com/neovim/neovim/wiki/Following-HEAD#20170402' ])
endif endif
if &paste if &paste
let ok = v:false let ok = v:false
call health#report_error("'paste' is enabled. This option is only for pasting text.\nIt should not be set in your config.", call health#report_error("'paste' is enabled. This option is only for pasting text.\nIt should not be set in your config.",

View File

@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen')
local plugin_helpers = require('test.functional.plugin.helpers') local plugin_helpers = require('test.functional.plugin.helpers')
local clear = helpers.clear local clear = helpers.clear
local curbuf_contents = helpers.curbuf_contents
local command = helpers.command local command = helpers.command
local eq = helpers.eq local eq = helpers.eq
@ -16,13 +17,12 @@ describe(':checkhealth', function()
eq('Invalid $VIMRUNTIME: bogus', string.match(err, 'Invalid.*')) eq('Invalid $VIMRUNTIME: bogus', string.match(err, 'Invalid.*'))
end) end)
it("detects invalid $VIM", function() it("detects invalid $VIM", function()
clear({ clear()
env={ VIM='bogus', }, -- Do this after startup, otherwise it just breaks $VIMRUNTIME.
}) command("let $VIM='zub'")
local status, err = pcall(command, 'checkhealth') command("checkhealth nvim")
eq(false, status) eq("ERROR: $VIM is invalid: zub",
-- Invalid $VIM causes $VIMRUNTIME to be broken. string.match(curbuf_contents(), "ERROR: $VIM .* zub"))
eq('Invalid $VIMRUNTIME: bogus', string.match(err, 'Invalid.*'))
end) end)
end) end)