mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
Apply suggestion from @Copilot
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
fded1c6a19
commit
b3389dc854
1 changed files with 12 additions and 14 deletions
|
|
@ -94,24 +94,22 @@ map("n", "<leader>l", "<cmd>Lazy<cr>", { desc = "Lazy" })
|
||||||
-- new file
|
-- new file
|
||||||
map("n", "<leader>fn", "<cmd>enew<cr>", { desc = "New File" })
|
map("n", "<leader>fn", "<cmd>enew<cr>", { desc = "New File" })
|
||||||
|
|
||||||
|
local function copy_file_path(modifier)
|
||||||
|
local path = vim.fn.expand(modifier)
|
||||||
|
if path == "" then
|
||||||
|
vim.notify("No file path available for the current buffer", vim.log.levels.WARN)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
vim.fn.setreg("+", path)
|
||||||
|
vim.notify("Copied: " .. path)
|
||||||
|
end
|
||||||
|
|
||||||
-- copy file path
|
-- copy file path
|
||||||
map("n", "<leader>fy", function()
|
map("n", "<leader>fy", function()
|
||||||
local path = vim.fn.expand("%:p")
|
copy_file_path("%:p")
|
||||||
if path == "" then
|
|
||||||
vim.notify("No file path available for the current buffer", vim.log.levels.WARN)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
vim.fn.setreg("+", path)
|
|
||||||
vim.notify("Copied: " .. path)
|
|
||||||
end, { desc = "Copy File Path" })
|
end, { desc = "Copy File Path" })
|
||||||
map("n", "<leader>fY", function()
|
map("n", "<leader>fY", function()
|
||||||
local path = vim.fn.expand("%:~:.")
|
copy_file_path("%:~:.")
|
||||||
if path == "" then
|
|
||||||
vim.notify("No file path available for the current buffer", vim.log.levels.WARN)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
vim.fn.setreg("+", path)
|
|
||||||
vim.notify("Copied: " .. path)
|
|
||||||
end, { desc = "Copy Short File Path" })
|
end, { desc = "Copy Short File Path" })
|
||||||
|
|
||||||
-- location list
|
-- location list
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue