Skip to content

Commit 179b737

Browse files
committed
refactoring
1 parent a93df5a commit 179b737

File tree

34 files changed

+289
-294
lines changed

34 files changed

+289
-294
lines changed

lua/down/mod.lua

+7-7
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ function Mod.split_event_type(type)
538538
return split_event_type
539539
end
540540

541-
--- Returns an event template defined in `init.events.defined`.
541+
--- Returns an event template defined in `init.events`.
542542
--- @param m down.Mod A reference to the init invoking the function
543543
--- @param type string A full path to a valid event type (e.g. `init.events.some_event`)
544544
--- @return down.Event?
@@ -561,7 +561,7 @@ function Mod.get_event_template(m, type)
561561
log.trace("Returning" .. split_type[2] .. "for init" .. split_type[1])
562562

563563
-- Return the defined event from the specific init
564-
return Mod.loaded_mod[m.name].events.defined[split_type[2]]
564+
return Mod.loaded_mod[m.name].events[split_type[2]]
565565
end
566566

567567
--- Creates a deep copy of the `mod.base_event` event and returns it with a custom type and referrer.
@@ -606,7 +606,7 @@ function Mod.create_event(m, type, content, ev)
606606
-- Get the init that contains the event
607607
local modn = Mod.split_event_type(type)[1]
608608

609-
-- Retrieve the template from init.events.defined
609+
-- Retrieve the template from init.events
610610
local event_template =
611611
Mod.get_event_template(Mod.loaded_mod[modn] or { name = "" }, type)
612612

@@ -661,8 +661,8 @@ function Mod.broadcast(event, callback)
661661
cb.handle(event)
662662

663663
for _, cm in pairs(Mod.loaded_mod) do
664-
if cm.events.subscribed and cm.events.subscribed[event.split_type[1]] then
665-
local evt = cm.events.subscribed[event.split_type[1]][event.split_type[2]]
664+
if cm.subscribed and cm.subscribed[event.split_type[1]] then
665+
local evt = cm.subscribed[event.split_type[1]][event.split_type[2]]
666666
if evt ~= nil and evt == true then
667667
cm.on(event)
668668
end
@@ -687,8 +687,8 @@ function Mod.send_event(recv, ev)
687687
ev.broadcast = false
688688
cb.handle(ev)
689689
local modl = Mod.loaded_mod[recv]
690-
if modl.events.subscribed and modl.events.subscribed[ev.split_type[1]] then
691-
local evt = modl.events.subscribed[ev.split_type[1]][ev.split_type[2]]
690+
if modl.subscribed and modl.subscribed[ev.split_type[1]] then
691+
local evt = modl.subscribed[ev.split_type[1]][ev.split_type[2]]
692692
if evt ~= nil and evt == true then
693693
modl.on(ev)
694694
end

lua/down/mod/cmd/back/init.lua

+7-16
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1-
--[[
2-
file: cmd-return
3-
title: Provides the `:down return` Command
4-
summary: Return to last location before entering down.
5-
internal: true
6-
---
7-
When executed (`:down return`), all currently open `.down` files are deleted from
8-
the buffer list, and the current workspace is set to "config".
9-
--]]
10-
111
local down = require("down")
122
local mod = down.mod
133

14-
local init = mod.create("cmd.back")
4+
local M = mod.create("cmd.back")
155

16-
init.setup = function()
6+
M.setup = function()
177
return { loaded = true, requires = { "cmd" } }
188
end
199

20-
init.data = {
10+
---@class down.cmd.back.Data
11+
M.data = {
2112
commands = {
2213
back = {
2314
args = 0,
@@ -26,7 +17,7 @@ init.data = {
2617
},
2718
}
2819

29-
init.on = function(event)
20+
M.on = function(event)
3021
if event.type == "cmd.events.back" then
3122
-- Get all the buffers
3223
local buffers = vim.api.nvim_list_bufs()
@@ -50,10 +41,10 @@ init.on = function(event)
5041
end
5142
end
5243

53-
init.events.subscribed = {
44+
M.subscribed = {
5445
cmd = {
5546
["back"] = true,
5647
},
5748
}
5849

59-
return init
50+
return M

lua/down/mod/cmd/find/init.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
local M = require("down.mod").create("cmd.find")
22

3-
---@class down.find.Config
3+
---@class down.cmd.find.Config
44
M.config = {}
55

6-
---@class down.find.Data
6+
---@class down.cmd.find.Data
77
M.data = {}
88

99
M.setup = function()

0 commit comments

Comments
 (0)