diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-12-25 10:21:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-25 10:21:13 +0800 |
commit | 2877672d70e76f71ae1190090b8aea7044d458be (patch) | |
tree | c078af69d7a394a8e83f2316cf707548d70368f4 /runtime/lua/vim/health.lua | |
parent | 2ff2785c396e66c285fecf5b151d8f8863f9d4e6 (diff) | |
download | rneovim-2877672d70e76f71ae1190090b8aea7044d458be.tar.gz rneovim-2877672d70e76f71ae1190090b8aea7044d458be.tar.bz2 rneovim-2877672d70e76f71ae1190090b8aea7044d458be.zip |
feat(health): make :checkhealth support more split modifiers (#26731)
Diffstat (limited to 'runtime/lua/vim/health.lua')
-rw-r--r-- | runtime/lua/vim/health.lua | 29 |
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://') |