Skip to content

Commit

Permalink
chore: autoformat with stylua
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro authored and benlubas committed Jan 11, 2024
1 parent 3a75ff8 commit cd2d490
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 74 deletions.
18 changes: 11 additions & 7 deletions lua/neorg/modules/core/clipboard/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@ module.load = function()

return callback.cb(
node,
vim.split(register, "\n", { ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
plain = true,
-- TODO: This causes problems in places
-- where you actually want to copy
-- newlines.
trimempty = true,
}),
vim.split(
register,
"\n",
{ ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
plain = true,
-- TODO: This causes problems in places
-- where you actually want to copy
-- newlines.
trimempty = true,
}
),
{
start = range[1],
["end"] = range[2],
Expand Down
4 changes: 3 additions & 1 deletion lua/neorg/modules/core/esupports/hop/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,9 @@ module.public = {
return
end

local target = module.required["core.integrations.treesitter"]
local target = module
.required
["core.integrations.treesitter"]
.get_node_text(anchor_decl_node:named_child(0):named_child(0)) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
:gsub("[%s\\]", "")

Expand Down
11 changes: 7 additions & 4 deletions lua/neorg/modules/core/esupports/metagen/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,14 @@ local function fill_template_defaults()
end
end

module.config.public.template = lib.map(module.config.public.template, function(_key, elem) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
if not elem[2] then
return lib.filter(default_template, match_first(elem[1]))
module.config.public.template = lib.map(
module.config.public.template,
function(_key, elem) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
if not elem[2] then
return lib.filter(default_template, match_first(elem[1]))
end
end
end)
)
end

module.setup = function()
Expand Down
56 changes: 37 additions & 19 deletions lua/neorg/modules/core/export/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,28 @@ module.on_event = function(event)
local filetype = event.content[2] or vim.filetype.match({ filename = filepath }) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
local exported = module.public.export(event.buffer, filetype) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>

vim.loop.fs_open(filepath, "w", 438, function(err, fd) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
assert(not err, lib.lazy_string_concat("Failed to open file '", filepath, "' for export: ", err))

vim.loop.fs_write(fd, exported, 0, function(werr) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
assert(not werr, lib.lazy_string_concat("Failed to write to file '", filepath, "' for export: ", werr))
end)
vim.loop.fs_open(
filepath,
"w",
438,
function(err, fd) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
assert(not err, lib.lazy_string_concat("Failed to open file '", filepath, "' for export: ", err))

vim.loop.fs_write(
fd,
exported,
0,
function(werr) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
assert(
not werr,
lib.lazy_string_concat("Failed to write to file '", filepath, "' for export: ", werr)
)
end
)

vim.schedule(lib.wrap(utils.notify, "Successfully exported 1 file!"))
end)
vim.schedule(lib.wrap(utils.notify, "Successfully exported 1 file!"))
end
)
elseif event.type == "core.neorgcmd.events.export.directory" then
local path = event.content[3] and vim.fn.expand(event.content[3])
or module.config.public.export_dir
Expand Down Expand Up @@ -296,19 +309,24 @@ module.on_event = function(event)
lib.lazy_string_concat("Failed to open file '", write_path, "' for export: ", fs_err)
)

vim.loop.fs_write(fd, exported, 0, function(werr) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
assert(
not werr,
lib.lazy_string_concat(
"Failed to write to file '",
write_path,
"' for export: ",
werr
vim.loop.fs_write(
fd,
exported,
0,
function(werr) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
assert(
not werr,
lib.lazy_string_concat(
"Failed to write to file '",
write_path,
"' for export: ",
werr
)
)
)

check_counters()
end)
check_counters()
end
)
end)
end)
end
Expand Down
9 changes: 6 additions & 3 deletions lua/neorg/modules/core/keybinds/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ module.load = function()
module.required["core.autocommands"].enable_autocommand("BufLeave")

if module.config.public.hook then
neorg.callbacks.on_event("core.keybinds.events.enable_keybinds", function(_, keybinds) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
module.config.public.hook(keybinds)
end)
neorg.callbacks.on_event(
"core.keybinds.events.enable_keybinds",
function(_, keybinds) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
module.config.public.hook(keybinds)
end
)
end
end

Expand Down
52 changes: 31 additions & 21 deletions lua/neorg/modules/core/tangle/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -429,31 +429,41 @@ module.on_event = function(event)
local tangled_count = 0

for file, content in pairs(tangles) do
vim.loop.fs_open(vim.fn.expand(file), "w", 438, function(err, fd) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
file_count = file_count - 1
assert(not err, lib.lazy_string_concat("Failed to open file '", file, "' for tangling: ", err))

vim.loop.fs_write(fd, table.concat(content, "\n"), 0, function(werr) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
assert(
not werr,
lib.lazy_string_concat("Failed to write to file '", file, "' for tangling: ", werr)
vim.loop.fs_open(
vim.fn.expand(file),
"w",
438,
function(err, fd) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
file_count = file_count - 1
assert(not err, lib.lazy_string_concat("Failed to open file '", file, "' for tangling: ", err))

vim.loop.fs_write(
fd,
table.concat(content, "\n"),
0,
function(werr) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
assert(
not werr,
lib.lazy_string_concat("Failed to write to file '", file, "' for tangling: ", werr)
)
end
)
end)

tangled_count = tangled_count + 1
if file_count == 0 then
vim.schedule(
lib.wrap(
utils.notify,
string.format(
"Successfully tangled %d file%s!",
tangled_count,
tangled_count == 1 and "" or "s"

tangled_count = tangled_count + 1
if file_count == 0 then
vim.schedule(
lib.wrap(
utils.notify,
string.format(
"Successfully tangled %d file%s!",
tangled_count,
tangled_count == 1 and "" or "s"
)
)
)
)
end
end
end)
)
end
end
end
Expand Down
22 changes: 14 additions & 8 deletions lua/neorg/modules/core/tempus/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,20 @@ module.public = {
to_lua_date = function(parsed_date)
return os.date( ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
"*t",
os.time(vim.tbl_deep_extend("force", os.date("*t"), { ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
day = parsed_date.day,
month = parsed_date.month and parsed_date.month.number or nil,
year = parsed_date.year,
hour = parsed_date.time and parsed_date.time.hour,
min = parsed_date.time and parsed_date.time.minute,
sec = parsed_date.time and parsed_date.time.second,
}))
os.time(
vim.tbl_deep_extend(
"force",
os.date("*t"),
{ ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
day = parsed_date.day,
month = parsed_date.month and parsed_date.month.number or nil,
year = parsed_date.year,
hour = parsed_date.time and parsed_date.time.hour,
min = parsed_date.time and parsed_date.time.minute,
sec = parsed_date.time and parsed_date.time.second,
}
)
)
)
end,

Expand Down
3 changes: 2 additions & 1 deletion lua/neorg/modules/core/ui/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ module.examples = {
local buffer = module.public.create_split("selection/Test selection")

-- Binds a selection to that buffer
local selection = module.public
local selection = module
.public
.begin_selection(buffer) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
:apply({
-- A title will simply be text with a custom highlight
Expand Down
38 changes: 28 additions & 10 deletions lua/neorg/modules/core/upgrade/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,17 @@ module.on_event = function(event)
vim.loop.fs_open(path, "w", 438, function(err, fd)
assert(not err, lib.lazy_string_concat("Failed to open file '", path, "' for upgrade: ", err))

vim.loop.fs_write(fd, output, 0, function(werr) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
assert(not werr, lib.lazy_string_concat("Failed to write to file '", path, "' for upgrade: ", werr))
end)
vim.loop.fs_write(
fd,
output,
0,
function(werr) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
assert(
not werr,
lib.lazy_string_concat("Failed to write to file '", path, "' for upgrade: ", werr)
)
end
)

vim.schedule(lib.wrap(utils.notify, "Successfully upgraded 1 file!"))
end)
Expand Down Expand Up @@ -363,14 +371,24 @@ module.on_event = function(event)
lib.lazy_string_concat("Failed to open file '", filepath, "' for upgrade: ", fs_err)
)

vim.loop.fs_write(fd, output, 0, function(werr) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
assert(
not werr,
lib.lazy_string_concat("Failed to write to file '", filepath, "' for upgrade: ", werr)
)
vim.loop.fs_write(
fd,
output,
0,
function(werr) ---@diagnostic disable-line -- TODO: type error workaround <pysan3>
assert(
not werr,
lib.lazy_string_concat(
"Failed to write to file '",
filepath,
"' for upgrade: ",
werr
)
)

check_counters()
end)
check_counters()
end
)
end)
end)
end)
Expand Down

0 comments on commit cd2d490

Please sign in to comment.