Skip to content

Commit

Permalink
fix(healthcheck): add fallback logic for < 0.10 closes #23 (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesmithgh authored Sep 28, 2023
1 parent 1100dfe commit f1e8c40
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions doc/kitty-scrollback.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ ACKNOWLEDGEMENTS *kitty-scrollback.nvim-acknowledgements*
- 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-scrollback.nvim-alternatives*
Expand Down
17 changes: 12 additions & 5 deletions lua/kitty-scrollback/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit f1e8c40

Please sign in to comment.