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 | |
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')
-rw-r--r-- | runtime/doc/news.txt | 3 | ||||
-rw-r--r-- | runtime/doc/windows.txt | 7 | ||||
-rw-r--r-- | runtime/lua/vim/health.lua | 29 |
3 files changed, 17 insertions, 22 deletions
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 9b40c4a596..454c9becc5 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -366,7 +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|. +• |:checkhealth| buffer can now be opened in a split window using modifiers like + |:vertical|, |:horizontal| and |:botright|. ============================================================================== REMOVED FEATURES *news-removed* diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt index d6fce89f23..b71e7c80ab 100644 --- a/runtime/doc/windows.txt +++ b/runtime/doc/windows.txt @@ -242,9 +242,10 @@ and 'winminwidth' are relevant. *:hor* *:horizontal* :hor[izontal] {cmd} Execute {cmd}. Currently only makes a difference for - `horizontal wincmd =`, which will equalize windows only - horizontally, and |:terminal|, which will open a |terminal| - buffer in a split window. + the following commands: + - `:wincmd =`: equalize windows only horizontally. + - |:terminal|: open a |terminal| buffer in a split window. + - |:checkhealth|: open a healthcheck buffer in a split window. :lefta[bove] {cmd} *:lefta* *:leftabove* :abo[veleft] {cmd} *:abo* *:aboveleft* 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://') |