From b3389dc854ca56446defc93f5a7820f3a716994c Mon Sep 17 00:00:00 2001 From: Axel Navarro Date: Thu, 16 Apr 2026 15:32:50 -0300 Subject: [PATCH] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- lua/lazyvim/config/keymaps.lua | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index b12c3ea6..5c8b8a59 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -94,24 +94,22 @@ map("n", "l", "Lazy", { desc = "Lazy" }) -- new file map("n", "fn", "enew", { 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 map("n", "fy", function() - local path = vim.fn.expand("%: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) + copy_file_path("%:p") end, { desc = "Copy File Path" }) map("n", "fY", function() - local path = vim.fn.expand("%:~:.") - 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) + copy_file_path("%:~:.") end, { desc = "Copy Short File Path" }) -- location list