Skip to content

Commit

Permalink
feat: Add healthcheck for lazy loading and print_tag
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewferrier committed Jan 11, 2025
1 parent c02b417 commit 4f3ded4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
35 changes: 30 additions & 5 deletions lua/debugprint/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,39 @@ local M = {}
M.check = function()
vim.health.start("debugprint.nvim report")

local global_opts = require("debugprint").get_global_opts()
local global_opts = require("debugprint")._get_global_opts()

if global_opts ~= nil then
vim.health.ok(
"debugprint is started with opts " .. vim.inspect(global_opts)
)
vim.health.ok("debugprint has been setup")

local success, config = pcall(require, "lazy.core.config")

if success then
local plugin = config.spec.plugins["debugprint.nvim"]

if
plugin
and global_opts.print_tag ~= nil
and global_opts.print_tag ~= ""
then
if plugin.lazy then
vim.health.warn(
"print_tag is set, but plugin is lazy-loaded, this won't highlight the lines correctly"
)
else
vim.health.ok(
"print_tag is set and plugin is not lazy-loaded, "
.. "lines will be highlighted if mini.hipatterns is available"
)
end
end
end

vim.health.info("debugprint opts = " .. vim.inspect(global_opts))
else
vim.health.warn("debugprint is not yet started")
vim.health.warn(
"debugprint is not yet setup, checkhealth cannot fully run"
)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lua/debugprint/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ M.setup = function(opts)
end

---@return DebugprintGlobalOptions
M.get_global_opts = function()
M._get_global_opts = function()
return global_opts
end

Expand Down

0 comments on commit 4f3ded4

Please sign in to comment.