aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/health.lua
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/lua/vim/health.lua')
-rw-r--r--runtime/lua/vim/health.lua29
1 files changed, 11 insertions, 18 deletions
diff --git a/runtime/lua/vim/health.lua b/runtime/lua/vim/health.lua
index 4659ab1694..6c96a703bb 100644
--- a/runtime/lua/vim/health.lua
+++ b/runtime/lua/vim/health.lua
@@ -266,29 +266,22 @@ M._complete = function()
return vim.tbl_keys(unique)
end
--- Runs the specified healthchecks.
--- Runs all discovered healthchecks if plugin_names is empty.
--- splitmod controls how the healthcheck window opens: "vertical", "horizontal" or "tab"
-function M._check(splitmod, plugin_names)
+--- Runs the specified healthchecks.
+--- Runs all discovered healthchecks if plugin_names is empty.
+---
+--- @param mods string command modifiers that affect splitting a window.
+function M._check(mods, plugin_names)
local healthchecks = plugin_names == '' and get_healthcheck('*') or get_healthcheck(plugin_names)
local emptybuf = vim.fn.bufnr('$') == 1 and vim.fn.getline(1) == '' and 1 == vim.fn.line('$')
- local mod = function()
- if splitmod == 'vertical' then
- return 'vertical sbuffer'
- elseif splitmod == 'horizontal' then
- return 'horizontal sbuffer'
- elseif emptybuf then
- -- if this is the default buffer when Nvim starts, open healthcheck directly
- return 'buffer'
- else
- -- if not specified otherwise open healthcheck in a tab
- return 'tab sbuffer'
- end
- end
+
+ -- When no command modifiers are used:
+ -- - If the current buffer is empty, open healthcheck directly.
+ -- - If not specified otherwise open healthcheck in a tab.
+ local buf_cmd = #mods > 0 and (mods .. ' sbuffer') or emptybuf and 'buffer' or 'tab sbuffer'
local bufnr = vim.api.nvim_create_buf(true, true)
- vim.cmd(mod() .. ' ' .. bufnr)
+ vim.cmd(buf_cmd .. ' ' .. bufnr)
if vim.fn.bufexists('health://') == 1 then
vim.cmd.bwipe('health://')