refactor: update funcs from `vim.fn` to `vim.api`
parent
e9868e9780
commit
0b71c9c21f
|
|
@ -12,9 +12,9 @@ local u = require("genghis.utils")
|
||||||
---Performing common file operation tasks
|
---Performing common file operation tasks
|
||||||
---@param op "rename"|"duplicate"|"new"|"newFromSel"|"move-rename"
|
---@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 oldFilePath = vim.api.nvim_buf_get_name(0)
|
||||||
local oldName = expand("%:t")
|
local oldName = vim.fs.basename(oldFilePath)
|
||||||
local oldFilePath = expand("%:p")
|
local dir = vim.fs.dirname(oldFilePath) -- same directory, *not* pwd
|
||||||
local oldNameNoExt = oldName:gsub("%.%w+$", "")
|
local oldNameNoExt = oldName:gsub("%.%w+$", "")
|
||||||
local oldExt = expand("%:e")
|
local oldExt = expand("%:e")
|
||||||
if oldExt ~= "" then oldExt = "." .. oldExt end
|
if oldExt ~= "" then oldExt = "." .. oldExt end
|
||||||
|
|
@ -154,7 +154,7 @@ function M.copyRelativeDirectoryPath() copyOp("%:~:.:h") end
|
||||||
|
|
||||||
---Makes current file executable
|
---Makes current file executable
|
||||||
function M.chmodx()
|
function M.chmodx()
|
||||||
local filename = expand("%")
|
local filename = vim.api.nvim_buf_get_name(0)
|
||||||
local perm = fn.getfperm(filename)
|
local perm = fn.getfperm(filename)
|
||||||
perm = perm:gsub("r(.)%-", "r%1x") -- add x to every group that has r
|
perm = perm:gsub("r(.)%-", "r%1x") -- add x to every group that has r
|
||||||
fn.setfperm(filename, perm)
|
fn.setfperm(filename, perm)
|
||||||
|
|
@ -167,8 +167,8 @@ function M.trashFile(opts)
|
||||||
cmd.update { bang = true }
|
cmd.update { bang = true }
|
||||||
local trash
|
local trash
|
||||||
local home = os.getenv("HOME")
|
local home = os.getenv("HOME")
|
||||||
local oldName = expand("%:t")
|
local oldFilePath = vim.api.nvim_buf_get_name(0)
|
||||||
local oldFilePath = expand("%:p")
|
local oldName = vim.fs.basename(oldFilePath)
|
||||||
|
|
||||||
-- Default trash locations
|
-- Default trash locations
|
||||||
if fn.has("linux") == 1 then
|
if fn.has("linux") == 1 then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue