diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/news.txt | 2 | ||||
-rw-r--r-- | runtime/lua/vim/health.lua | 21 |
2 files changed, 19 insertions, 4 deletions
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 75ef2c245b..9b40c4a596 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -366,6 +366,8 @@ The following changes to existing APIs or features add new behavior. • Attempting to set an invalid keycode option (e.g. `set t_foo=123`) no longer gives an error. +• |:checkhealth| buffer can now be opened in a split window using |:vertical| or |:horizontal|. + ============================================================================== REMOVED FEATURES *news-removed* diff --git a/runtime/lua/vim/health.lua b/runtime/lua/vim/health.lua index 6e47a22d03..4659ab1694 100644 --- a/runtime/lua/vim/health.lua +++ b/runtime/lua/vim/health.lua @@ -268,14 +268,27 @@ end -- Runs the specified healthchecks. -- Runs all discovered healthchecks if plugin_names is empty. -function M._check(plugin_names) +-- splitmod controls how the healthcheck window opens: "vertical", "horizontal" or "tab" +function M._check(splitmod, plugin_names) local healthchecks = plugin_names == '' and get_healthcheck('*') or get_healthcheck(plugin_names) - -- Create buffer and open in a tab, unless this is the default buffer when Nvim starts. local emptybuf = vim.fn.bufnr('$') == 1 and vim.fn.getline(1) == '' and 1 == vim.fn.line('$') - local mod = emptybuf and 'buffer' or 'tab sbuffer' + 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 + local bufnr = vim.api.nvim_create_buf(true, true) - vim.cmd(mod .. ' ' .. bufnr) + vim.cmd(mod() .. ' ' .. bufnr) if vim.fn.bufexists('health://') == 1 then vim.cmd.bwipe('health://') |