From cd2d4900ab8b0fff9098d7f040464e70e99490b9 Mon Sep 17 00:00:00 2001 From: vhyrro Date: Wed, 15 Nov 2023 14:26:25 +0000 Subject: [PATCH] chore: autoformat with stylua --- lua/neorg/modules/core/clipboard/module.lua | 18 +++--- .../modules/core/esupports/hop/module.lua | 4 +- .../modules/core/esupports/metagen/module.lua | 11 ++-- lua/neorg/modules/core/export/module.lua | 56 ++++++++++++------- lua/neorg/modules/core/keybinds/module.lua | 9 ++- lua/neorg/modules/core/tangle/module.lua | 52 ++++++++++------- lua/neorg/modules/core/tempus/module.lua | 22 +++++--- lua/neorg/modules/core/ui/module.lua | 3 +- lua/neorg/modules/core/upgrade/module.lua | 38 +++++++++---- 9 files changed, 139 insertions(+), 74 deletions(-) diff --git a/lua/neorg/modules/core/clipboard/module.lua b/lua/neorg/modules/core/clipboard/module.lua index 182de1319..1cdd957e9 100644 --- a/lua/neorg/modules/core/clipboard/module.lua +++ b/lua/neorg/modules/core/clipboard/module.lua @@ -48,13 +48,17 @@ module.load = function() return callback.cb( node, - vim.split(register, "\n", { ---@diagnostic disable-line -- TODO: type error workaround - 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 + plain = true, + -- TODO: This causes problems in places + -- where you actually want to copy + -- newlines. + trimempty = true, + } + ), { start = range[1], ["end"] = range[2], diff --git a/lua/neorg/modules/core/esupports/hop/module.lua b/lua/neorg/modules/core/esupports/hop/module.lua index 44a6b06b6..d32db3bb6 100644 --- a/lua/neorg/modules/core/esupports/hop/module.lua +++ b/lua/neorg/modules/core/esupports/hop/module.lua @@ -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 :gsub("[%s\\]", "") diff --git a/lua/neorg/modules/core/esupports/metagen/module.lua b/lua/neorg/modules/core/esupports/metagen/module.lua index 63bfaeba9..1d61af4d8 100644 --- a/lua/neorg/modules/core/esupports/metagen/module.lua +++ b/lua/neorg/modules/core/esupports/metagen/module.lua @@ -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 - 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 + if not elem[2] then + return lib.filter(default_template, match_first(elem[1])) + end end - end) + ) end module.setup = function() diff --git a/lua/neorg/modules/core/export/module.lua b/lua/neorg/modules/core/export/module.lua index 1af83a117..79ba4b23d 100644 --- a/lua/neorg/modules/core/export/module.lua +++ b/lua/neorg/modules/core/export/module.lua @@ -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 local exported = module.public.export(event.buffer, filetype) ---@diagnostic disable-line -- TODO: type error workaround - vim.loop.fs_open(filepath, "w", 438, function(err, fd) ---@diagnostic disable-line -- TODO: type error workaround - 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 - 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 + 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 + 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 @@ -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 - 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 + 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 diff --git a/lua/neorg/modules/core/keybinds/module.lua b/lua/neorg/modules/core/keybinds/module.lua index 3a31dd875..b250f38df 100644 --- a/lua/neorg/modules/core/keybinds/module.lua +++ b/lua/neorg/modules/core/keybinds/module.lua @@ -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 - module.config.public.hook(keybinds) - end) + neorg.callbacks.on_event( + "core.keybinds.events.enable_keybinds", + function(_, keybinds) ---@diagnostic disable-line -- TODO: type error workaround + module.config.public.hook(keybinds) + end + ) end end diff --git a/lua/neorg/modules/core/tangle/module.lua b/lua/neorg/modules/core/tangle/module.lua index f7c85c417..ad148bac5 100644 --- a/lua/neorg/modules/core/tangle/module.lua +++ b/lua/neorg/modules/core/tangle/module.lua @@ -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 - 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 - 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 + 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 + 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 diff --git a/lua/neorg/modules/core/tempus/module.lua b/lua/neorg/modules/core/tempus/module.lua index 21d6c7b0b..4e84671f8 100644 --- a/lua/neorg/modules/core/tempus/module.lua +++ b/lua/neorg/modules/core/tempus/module.lua @@ -224,14 +224,20 @@ module.public = { to_lua_date = function(parsed_date) return os.date( ---@diagnostic disable-line -- TODO: type error workaround "*t", - os.time(vim.tbl_deep_extend("force", os.date("*t"), { ---@diagnostic disable-line -- TODO: type error workaround - 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 + 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, diff --git a/lua/neorg/modules/core/ui/module.lua b/lua/neorg/modules/core/ui/module.lua index 5399302be..deb31d25d 100644 --- a/lua/neorg/modules/core/ui/module.lua +++ b/lua/neorg/modules/core/ui/module.lua @@ -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 :apply({ -- A title will simply be text with a custom highlight diff --git a/lua/neorg/modules/core/upgrade/module.lua b/lua/neorg/modules/core/upgrade/module.lua index b718b2a67..49987a5f8 100644 --- a/lua/neorg/modules/core/upgrade/module.lua +++ b/lua/neorg/modules/core/upgrade/module.lua @@ -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 - 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 + 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) @@ -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 - 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 + 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)