mirror of
https://github.com/hyzendust/KickestEnd.nvim.git
synced 2026-02-15 14:01:13 +01:00
Fix: Yank notifications all over copy to clipboard notifcations
This commit is contained in:
@@ -1,21 +1,24 @@
|
||||
local M = {}
|
||||
vim.api.nvim_create_autocmd('TextYankPost', {
|
||||
pattern = '*',
|
||||
callback = function()
|
||||
local content = vim.fn.getreg '"'
|
||||
callback = function(ev)
|
||||
local regname = ev.regname or '"'
|
||||
-- Ignore clipboard yanks
|
||||
if regname == '+' or regname == '*' then
|
||||
return
|
||||
end
|
||||
local content = vim.fn.getreg(regname)
|
||||
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)
|
||||
vim.notify(string.format('Yanked %d line%s', line_count, plural), vim.log.levels.INFO, { title = 'Yank' })
|
||||
end)
|
||||
end,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user