yank_notification: show line numbers. Clipboard copy notification to have line counts. Fix: Paste clipboard over selection

This commit is contained in:
psychhim
2025-10-09 03:26:44 +05:30
parent 7c56ba0821
commit 009b3aa8c0
4 changed files with 70 additions and 17 deletions

23
lua/yank_notification.lua Normal file
View File

@@ -0,0 +1,23 @@
local M = {}
vim.api.nvim_create_autocmd('TextYankPost', {
pattern = '*',
callback = function()
local content = vim.fn.getreg '"'
if not content or content == '' then
return
end
-- Split by newline
local lines = vim.split(content, '\n', true)
-- Remove trailing empty line if present
if lines[#lines] == '' then
table.remove(lines, #lines)
end
local line_count = #lines
vim.schedule(function()
local plural = line_count == 1 and '' or 's'
vim.notify(string.format('Yanked %d line%s', line_count, plural), vim.log.levels.INFO)
end)
end,
})
return M