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

View File

@@ -1,10 +1,17 @@
local M = {}
function M.trim_clipboard()
-- Get the content of the '+' register
local content = vim.fn.getreg '+'
-- Remove single trailing newline if present
content = content:gsub('\n$', '')
-- Update '+' and '*' registers
vim.fn.setreg('+', content)
vim.fn.setreg('*', content)
vim.notify('Copied selection to clipboard', vim.log.levels.INFO)
-- Count the number of lines copied
local line_count = select(2, content:gsub('\n', '')) + 1 -- Number of newlines + 1
-- Notification with line count
local plural = line_count == 1 and '' or 's'
vim.notify(string.format('Copied %d line%s to clipboard', line_count, plural), vim.log.levels.INFO)
end
return M