Skip to content

Commit

Permalink
Update healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
MisanthropicBit committed Nov 26, 2024
1 parent 4e61d08 commit a2e40c3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lua/winmove/float.lua
Original file line number Diff line number Diff line change
@@ -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?

Expand Down
27 changes: 21 additions & 6 deletions lua/winmove/health.lua
Original file line number Diff line number Diff line change
@@ -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

Expand Down
7 changes: 7 additions & 0 deletions tests/healthcheck_spec.lua
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit a2e40c3

Please sign in to comment.