fix(trashCmd): handle unknown operating system
parent
e04857f290
commit
081b0c13cf
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue