From f1e8c4048ddd5a3017424b89ace08cf59ac53848 Mon Sep 17 00:00:00 2001 From: Mike <10135646+mikesmithgh@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:29:06 -0400 Subject: [PATCH] fix(healthcheck): add fallback logic for < 0.10 closes #23 (#26) --- README.md | 1 + doc/kitty-scrollback.nvim.txt | 1 + lua/kitty-scrollback/health.lua | 17 ++++++++++++----- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 969e1129..9e35274d 100644 --- a/README.md +++ b/README.md @@ -328,6 +328,7 @@ The following plugins are nice additions to your Neovim and Kitty setup. - StackExchange [CamelCase2snake_case()](https://codegolf.stackexchange.com/a/177958/119424) - for converting Neovim highlight names to `SCREAMING_SNAKE_CASE` - [panvimdoc](https://github.com/kdheepak/panvimdoc) - generating vimdocs from README - [lemmy-help](https://github.com/numToStr/lemmy-help) - generating vimdocs from Lua annotations +- [bob](https://github.com/MordechaiHadad/bob) - easy Neovim version management to check backward compatibility ## 🐶 Alternatives - [kitty_grab](https://github.com/yurikhan/kitty_grab) - Keyboard-driven screen grabber for Kitty diff --git a/doc/kitty-scrollback.nvim.txt b/doc/kitty-scrollback.nvim.txt index b8560b88..66f24c5b 100644 --- a/doc/kitty-scrollback.nvim.txt +++ b/doc/kitty-scrollback.nvim.txt @@ -410,6 +410,7 @@ ACKNOWLEDGEMENTS *kitty-scrollback.nvim-acknowledgements* - StackExchange CamelCase2snake_case() - for converting Neovim highlight names to `SCREAMING_SNAKE_CASE` - panvimdoc - generating vimdocs from README - lemmy-help - generating vimdocs from Lua annotations +- bob - easy Neovim version management to check backward compatibility ALTERNATIVES *kitty-scrollback.nvim-alternatives* diff --git a/lua/kitty-scrollback/health.lua b/lua/kitty-scrollback/health.lua index 9e8d48d0..3c938084 100644 --- a/lua/kitty-scrollback/health.lua +++ b/lua/kitty-scrollback/health.lua @@ -183,18 +183,22 @@ local function check_sed() end M.check_nvim_version = function(check_only) + -- fallback to older health report calls if using < 0.10 + local start_fn = vim.health.start or vim.health.report_start + local ok_fn = vim.health.ok or vim.health.report_ok + local error_fn = vim.health.error or vim.health.report_error if not check_only then - vim.health.start('kitty-scrollback: Neovim version 0.10+') + start_fn('kitty-scrollback: Neovim version 0.10+') end local nvim_version = 'NVIM ' .. ksb_util.nvim_version_tostring() if vim.fn.has('nvim-0.10') > 0 then if not check_only then - vim.health.ok(nvim_version) + ok_fn(nvim_version) end return true else if not check_only then - vim.health.error(nvim_version, M.advice().nvim_version) + error_fn(nvim_version, M.advice().nvim_version) end end return false @@ -274,12 +278,15 @@ local function check_kitty_scrollback_nvim_version() \| | `|`_`|`/\ /_// ___/ *Bonus* *points* *for* *cat* *memes* \_) ]]) + + -- Always consider true even if git version is not found to provide additional health checks + return true end M.check = function() - check_kitty_scrollback_nvim_version() if - M.check_nvim_version() + M.check_nvim_version() -- always check first to avoid undefined calls in versions < 0.10 + and check_kitty_scrollback_nvim_version() and check_kitty_remote_control() and check_has_kitty_data() and M.check_kitty_version()