refactor: correctness fixes, API modernization, and cleanup

This commit is contained in:
2026-04-13 01:20:52 +02:00
parent 62e64182de
commit fc7060e0ed
12 changed files with 166 additions and 223 deletions
+15 -8
View File
@@ -32,7 +32,12 @@ end
---@param plugin ow.Pack.Plugin
local function load(plugin)
local name = plugin.name:match("[^.]+"):lower()
local name = plugin.name:match("[^.]+")
if not name then
log.error("Invalid plugin name: %s", plugin.name)
return
end
name = name:lower()
local path = string.format("%s/lua/plugins/%s.lua", config_dir, name)
if vim.uv.fs_stat(path) then
@@ -121,7 +126,7 @@ end
---@type uv.uv_fs_event_t?
local watcher = nil
---@type table<string, uv.uv_timer_t>
---@type table<string, uv.uv_timer_t?>
local timers = {}
---@class ow.Pack
@@ -183,18 +188,20 @@ function M.watch()
return
end
if timers[filename] then
timers[filename]:stop()
local timer = timers[filename]
if timer ~= nil then
timer:stop()
else
timers[filename] = vim.uv.new_timer()
timer = vim.uv.new_timer()
timers[filename] = timer
end
timers[filename]:start(
timer:start(
100,
0,
vim.schedule_wrap(function()
timers[filename]:stop()
timers[filename]:close()
timer:stop()
timer:close()
timers[filename] = nil
local path = plugins_dir .. "/" .. filename