Common library code for other vc*.nvim projects.
1local M = {}
2
3function M.verbose_logger(namespace)
4 --- Print a message to the user if verbose mode is enabled.
5 ---@param msg string|table The message to print.
6 ---@param label string|nil An optional label to include in the message.
7 local function verbose(msg, label)
8 label = label or debug.getinfo(3, "n").name
9
10 vim.schedule(function()
11 if vim.o.verbose ~= 0 then
12 local l = label and ":" .. label or ""
13 if type(msg) == "string" then
14 print("[" .. namespace .. l .. "] " .. msg)
15 else
16 print("[" .. namespace .. l .. "] " .. vim.inspect(msg))
17 end
18 end
19 end)
20 end
21 return verbose
22end
23
24M.vclib_verbose = M.verbose_logger "vclib"
25
26return M