diff --git a/lua/genghis/config.lua b/lua/genghis/config.lua index e25b325..e452cc1 100644 --- a/lua/genghis/config.lua +++ b/lua/genghis/config.lua @@ -1,16 +1,17 @@ local M = {} -------------------------------------------------------------------------------- ----@return string|string[] +---@return string|string[]|false local function setDefaultTrashCmd() local osTrashCmd - local system = jit.os:lower() - if system == "mac" or system == "osx" then + if jit.os == "osx" then osTrashCmd = "trash" - elseif system == "windows" then + elseif jit.os == "Windows" then osTrashCmd = "trash" - else + elseif jit.os == "Linux" then osTrashCmd = { "gio", "trash" } + else + return false end return osTrashCmd end diff --git a/lua/genghis/operations/other.lua b/lua/genghis/operations/other.lua index 3016379..b777356 100644 --- a/lua/genghis/operations/other.lua +++ b/lua/genghis/operations/other.lua @@ -13,19 +13,17 @@ function M.chmodx() vim.cmd.edit() -- reload the file end -function M.trashFile(opts) - ---DEPRECATION - if opts then - u.notify("The `trashCmd` option has been moved to the setup call.", "warn") - return - end - +function M.trashFile() vim.cmd("silent! update") local oldFilePath = vim.api.nvim_buf_get_name(0) local oldName = vim.fs.basename(oldFilePath) -- execute the trash command local trashCmd = require("genghis.config").config.trashCmd + if not trashCmd then + u.notify("Unknown operating system. Please provide a custom `trashCmd`.", "warn") + return + end if type(trashCmd) == "string" then trashCmd = { trashCmd } end table.insert(trashCmd, oldFilePath) local result = vim.system(trashCmd):wait()