chore: cleanup comments
parent
8349eb8843
commit
ce4dd7f098
|
|
@ -3,13 +3,11 @@ local M = {}
|
||||||
local expand = vim.fn.expand
|
local expand = vim.fn.expand
|
||||||
local fn = vim.fn
|
local fn = vim.fn
|
||||||
local cmd = vim.cmd
|
local cmd = vim.cmd
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
---@param bufnr? number|"#"|"$"
|
---@param bufnr? number|"#"|"$"
|
||||||
local function bwipeout(bufnr)
|
local function bwipeout(bufnr)
|
||||||
---@diagnostic disable-next-line: param-type-mismatch
|
bufnr = bufnr and fn.bufnr(bufnr) or 0 ---@diagnostic disable-line: param-type-mismatch
|
||||||
bufnr = bufnr and fn.bufnr(bufnr) or 0
|
|
||||||
vim.api.nvim_buf_delete(bufnr, { force = true })
|
vim.api.nvim_buf_delete(bufnr, { force = true })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -91,7 +89,7 @@ end
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
---Performing common file operation tasks
|
---Performing common file operation tasks
|
||||||
---@param op string rename|duplicate|new|newFromSel
|
---@param op "rename"|"duplicate"|"new"|"newFromSel"|"move-rename"
|
||||||
local function fileOp(op)
|
local function fileOp(op)
|
||||||
local dir = expand("%:p:h") -- same directory, *not* pwd
|
local dir = expand("%:p:h") -- same directory, *not* pwd
|
||||||
local oldName = expand("%:t")
|
local oldName = expand("%:t")
|
||||||
|
|
@ -122,7 +120,6 @@ local function fileOp(op)
|
||||||
prefill = ""
|
prefill = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
-- selene: allow(high_cyclomatic_complexity)
|
|
||||||
-- INFO completion = "dir" allows for completion via cmp-omni
|
-- INFO completion = "dir" allows for completion via cmp-omni
|
||||||
vim.ui.input({ prompt = promptStr, default = prefill, completion = "dir" }, function(newName)
|
vim.ui.input({ prompt = promptStr, default = prefill, completion = "dir" }, function(newName)
|
||||||
cmd.redraw() -- Clear message area from ui.input prompt
|
cmd.redraw() -- Clear message area from ui.input prompt
|
||||||
|
|
@ -199,19 +196,10 @@ local function fileOp(op)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Rename Current File
|
|
||||||
function M.renameFile() fileOp("rename") end
|
function M.renameFile() fileOp("rename") end
|
||||||
|
|
||||||
---Move and Rename Current File
|
|
||||||
function M.moveAndRenameFile() fileOp("move-rename") end
|
function M.moveAndRenameFile() fileOp("move-rename") end
|
||||||
|
|
||||||
---Duplicate Current File
|
|
||||||
function M.duplicateFile() fileOp("duplicate") end
|
function M.duplicateFile() fileOp("duplicate") end
|
||||||
|
|
||||||
---Create New File
|
|
||||||
function M.createNewFile() fileOp("new") end
|
function M.createNewFile() fileOp("new") end
|
||||||
|
|
||||||
---Move Selection to New File
|
|
||||||
function M.moveSelectionToNewFile() fileOp("newFromSel") end
|
function M.moveSelectionToNewFile() fileOp("newFromSel") end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
@ -230,19 +218,10 @@ local function copyOp(expandOperation)
|
||||||
vim.notify(toCopy, vim.log.levels.INFO, { title = "Copied" })
|
vim.notify(toCopy, vim.log.levels.INFO, { title = "Copied" })
|
||||||
end
|
end
|
||||||
|
|
||||||
---Copy absolute path of current file
|
|
||||||
function M.copyFilepath() copyOp("%:p") end
|
function M.copyFilepath() copyOp("%:p") end
|
||||||
|
|
||||||
---Copy name of current file
|
|
||||||
function M.copyFilename() copyOp("%:t") end
|
function M.copyFilename() copyOp("%:t") end
|
||||||
|
|
||||||
---Copy relative path of current file
|
|
||||||
function M.copyRelativePath() copyOp("%:~:.") end
|
function M.copyRelativePath() copyOp("%:~:.") end
|
||||||
|
|
||||||
---Copy absolute directory path of current file
|
|
||||||
function M.copyDirectoryPath() copyOp("%:p:h") end
|
function M.copyDirectoryPath() copyOp("%:p:h") end
|
||||||
|
|
||||||
---Copy relative directory path of current file
|
|
||||||
function M.copyRelativeDirectoryPath() copyOp("%:~:.:h") end
|
function M.copyRelativeDirectoryPath() copyOp("%:~:.:h") end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
@ -257,7 +236,6 @@ function M.chmodx()
|
||||||
cmd.edit()
|
cmd.edit()
|
||||||
end
|
end
|
||||||
|
|
||||||
---Trash the current File.
|
|
||||||
---@param opts? table
|
---@param opts? table
|
||||||
function M.trashFile(opts)
|
function M.trashFile(opts)
|
||||||
cmd.update { bang = true }
|
cmd.update { bang = true }
|
||||||
|
|
@ -284,11 +262,10 @@ function M.trashFile(opts)
|
||||||
-- overwrite trash location, if specified by user
|
-- overwrite trash location, if specified by user
|
||||||
if opts and opts.trashLocation then
|
if opts and opts.trashLocation then
|
||||||
trash = opts.trashLocation
|
trash = opts.trashLocation
|
||||||
if not (trash:find("/$")) then trash = trash .. "/" end -- append "/"
|
if not (trash:find("/$")) then trash = trash .. "/" end
|
||||||
end
|
end
|
||||||
|
|
||||||
fn.mkdir(trash, "p")
|
fn.mkdir(trash, "p")
|
||||||
|
|
||||||
if fileExists(trash .. oldName) then oldName = oldName .. "~" end
|
if fileExists(trash .. oldName) then oldName = oldName .. "~" end
|
||||||
|
|
||||||
if moveFile(oldFilePath, trash .. oldName) then
|
if moveFile(oldFilePath, trash .. oldName) then
|
||||||
|
|
@ -298,5 +275,4 @@ function M.trashFile(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue