aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Blake <tjmblake@outlook.com>2023-09-24 18:43:55 +0100
committerGitHub <noreply@github.com>2023-09-24 10:43:55 -0700
commit3bbb0aa3993fb8760fa693aae2133186cb61db77 (patch)
tree893efcb693a6a61dd72ff5190e7bcbf3557e4395
parent61ecb3e16c22eec9cb8eb77f76d9e8ddfc3601bc (diff)
downloadrneovim-3bbb0aa3993fb8760fa693aae2133186cb61db77.tar.gz
rneovim-3bbb0aa3993fb8760fa693aae2133186cb61db77.tar.bz2
rneovim-3bbb0aa3993fb8760fa693aae2133186cb61db77.zip
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
-rw-r--r--runtime/lua/nvim/health.lua16
1 files changed, 10 insertions, 6 deletions
diff --git a/runtime/lua/nvim/health.lua b/runtime/lua/nvim/health.lua
index 7ccb082a40..6b6370fa19 100644
--- a/runtime/lua/nvim/health.lua
+++ b/runtime/lua/nvim/health.lua
@@ -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