aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/health.lua
diff options
context:
space:
mode:
authorPablo Arias <pabloariasal@gmail.com>2023-12-25 01:30:56 +0100
committerGitHub <noreply@github.com>2023-12-25 08:30:56 +0800
commit2ff2785c396e66c285fecf5b151d8f8863f9d4e6 (patch)
treea5328e075c2ccf9c1013fcdb07b722a13ab14ede /runtime/lua/vim/health.lua
parent675522af18f59918a64e6dbe5f0ba3b1d3b4eb65 (diff)
downloadrneovim-2ff2785c396e66c285fecf5b151d8f8863f9d4e6.tar.gz
rneovim-2ff2785c396e66c285fecf5b151d8f8863f9d4e6.tar.bz2
rneovim-2ff2785c396e66c285fecf5b151d8f8863f9d4e6.zip
feat(health): checkhealth buffer can show in a split window (#26714)
:checkhealth now respects :vertical and :horizontal. For example: :vertical checkhealth foo bar will open the healthcheck buffer in a vertical split.
Diffstat (limited to 'runtime/lua/vim/health.lua')
-rw-r--r--runtime/lua/vim/health.lua21
1 files changed, 17 insertions, 4 deletions
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://')