Skip to content

Commit 4f3ded4

Browse files
committed
feat: Add healthcheck for lazy loading and print_tag
1 parent c02b417 commit 4f3ded4

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

lua/debugprint/health.lua

+30-5
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,39 @@ local M = {}
33
M.check = function()
44
vim.health.start("debugprint.nvim report")
55

6-
local global_opts = require("debugprint").get_global_opts()
6+
local global_opts = require("debugprint")._get_global_opts()
77

88
if global_opts ~= nil then
9-
vim.health.ok(
10-
"debugprint is started with opts " .. vim.inspect(global_opts)
11-
)
9+
vim.health.ok("debugprint has been setup")
10+
11+
local success, config = pcall(require, "lazy.core.config")
12+
13+
if success then
14+
local plugin = config.spec.plugins["debugprint.nvim"]
15+
16+
if
17+
plugin
18+
and global_opts.print_tag ~= nil
19+
and global_opts.print_tag ~= ""
20+
then
21+
if plugin.lazy then
22+
vim.health.warn(
23+
"print_tag is set, but plugin is lazy-loaded, this won't highlight the lines correctly"
24+
)
25+
else
26+
vim.health.ok(
27+
"print_tag is set and plugin is not lazy-loaded, "
28+
.. "lines will be highlighted if mini.hipatterns is available"
29+
)
30+
end
31+
end
32+
end
33+
34+
vim.health.info("debugprint opts = " .. vim.inspect(global_opts))
1235
else
13-
vim.health.warn("debugprint is not yet started")
36+
vim.health.warn(
37+
"debugprint is not yet setup, checkhealth cannot fully run"
38+
)
1439
end
1540
end
1641

lua/debugprint/init.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ M.setup = function(opts)
433433
end
434434

435435
---@return DebugprintGlobalOptions
436-
M.get_global_opts = function()
436+
M._get_global_opts = function()
437437
return global_opts
438438
end
439439

0 commit comments

Comments
 (0)