diff --git a/lua/winmove/float.lua b/lua/winmove/float.lua index af88df7..8a6c066 100644 --- a/lua/winmove/float.lua +++ b/lua/winmove/float.lua @@ -1,11 +1,12 @@ local float = {} +local compat = require("winmove.compat") local config = require("winmove.config") local message = require("winmove.message") local winutil = require("winmove.winutil") local api = vim.api -local has_title = vim.fn.has("nvim-0.9.0") == 1 +local has_title = compat.has("nvim-0.9.0") local float_win_id = nil ---@type integer? diff --git a/lua/winmove/health.lua b/lua/winmove/health.lua index 58075c6..44ba683 100644 --- a/lua/winmove/health.lua +++ b/lua/winmove/health.lua @@ -1,24 +1,39 @@ local health = {} +local compat = require("winmove.compat") local config = require("winmove.config") local min_neovim_version = "0.8.0" +---@diagnostic disable-next-line: deprecated +local report_start = vim.health.report_start +---@diagnostic disable-next-line: deprecated +local report_ok = vim.health.report_ok +---@diagnostic disable-next-line: deprecated +local report_error = vim.health.report_error +---@diagnostic disable-next-line: deprecated + +if compat.has("nvim-0.10") then + report_start = vim.health.start + report_ok = vim.health.ok + report_error = vim.health.error +end + function health.check() - vim.health.report_start("winmove") + report_start("winmove") - if vim.fn.has("nvim-" .. min_neovim_version) == 1 then - vim.health.report_ok(("has neovim %s+"):format(min_neovim_version)) + if compat.has("nvim-" .. min_neovim_version) then + report_ok(("has neovim %s+"):format(min_neovim_version)) else - vim.health.report_error("winmove.nvim requires at least neovim " .. min_neovim_version) + report_error("winmove.nvim requires at least neovim " .. min_neovim_version) end local ok, error = config.validate(config) if ok then - vim.health.report_ok("found no errors in config") + report_ok("found no errors in config") else - vim.health.report_error("config has errors: " .. error) + report_error("config has errors: " .. error) end end diff --git a/tests/healthcheck_spec.lua b/tests/healthcheck_spec.lua new file mode 100644 index 0000000..d5c02b8 --- /dev/null +++ b/tests/healthcheck_spec.lua @@ -0,0 +1,7 @@ +local health = require("winmove.health") + +describe("healthcheck", function() + it("runs healthcheck without failing", function() + assert.has_no_error(health.check) + end) +end)