fix: checkhealth warning even if init.lua exists #25306

Problem:
`:checkhealth nvim` warns about missing vimrc if `init.lua` exists but
`init.vim` does not.

Solution:
Check for any of: init.vim, init.lua, $MYVIMRC.
Fix #25291
This commit is contained in:
Tom Blake 2023-09-24 18:43:55 +01:00 committed by GitHub
parent 61ecb3e16c
commit 3bbb0aa399
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,15 +54,19 @@ local function check_config()
health.start('Configuration')
local ok = true
local vimrc = (
empty(vim.env.MYVIMRC) and vim.fn.stdpath('config') .. '/init.vim' or vim.env.MYVIMRC
)
if not filereadable(vimrc) then
local init_lua = vim.fn.stdpath('config') .. '/init.lua'
local init_vim = vim.fn.stdpath('config') .. '/init.vim'
local vimrc = empty(vim.env.MYVIMRC) and init_lua or vim.env.MYVIMRC
if not filereadable(vimrc) and not filereadable(init_vim) then
ok = false
local has_vim = filereadable(vim.fn.expand('~/.vimrc'))
health.warn(
(-1 == vim.fn.getfsize(vimrc) and 'Missing' or 'Unreadable') .. ' user config file: ' .. vimrc,
{ has_vim and ':help nvim-from-vim' or ':help init.vim' }
('%s user config file: %s'):format(
-1 == vim.fn.getfsize(vimrc) and 'Missing' or 'Unreadable',
vimrc
),
{ has_vim and ':help nvim-from-vim' or ':help config' }
)
end