irongit

Configure synchronization of files and directories through a plugin.

54 lines1.0 KBLua
1local M = {
2 opts = require("syncmap.default"),
3}
4
5---@param opts FinalSyncmapOpts
6function M.setup(opts)
7 M.opts = opts
8end
9
10---@type table<LogLevel, vim.log.levels>
11M.log_table = {
12 ["trace"] = vim.log.levels.TRACE,
13 ["debug"] = vim.log.levels.DEBUG,
14 ["info"] = vim.log.levels.INFO,
15 ["error"] = vim.log.levels.ERROR,
16 ["off"] = vim.log.levels.OFF,
17}
18
19---Logs a message based on options log level
20---@param msg any
21---@param level vim.log.levels
22function M.log(msg, level)
23 if level >= M.log_table[M.opts.log_level] then
24 vim.schedule(function()
25 vim.notify("[syncmap] " .. msg, level)
26 end)
27 end
28end
29
30---Logs message as info
31---@param msg any
32function M.info(msg)
33 M.log(msg, vim.log.levels.INFO)
34end
35
36---Logs message as debug
37---@param msg any
38function M.debug(msg)
39 M.log(msg, vim.log.levels.DEBUG)
40end
41
42---Logs message as trace
43---@param msg any
44function M.trace(msg)
45 M.log(msg, vim.log.levels.TRACE)
46end
47
48---Logs message as error
49---@param msg any
50function M.error(msg)
51 M.log(msg, vim.log.levels.ERROR)
52end
53
54return M