mirror of
https://github.com/hyzendust/KickestEnd.nvim.git
synced 2026-02-15 00:21:15 +01:00
23 lines
702 B
Lua
23 lines
702 B
Lua
local M = {}
|
|
function M.trim_clipboard()
|
|
-- Get content from default register
|
|
local content = vim.fn.getreg '"'
|
|
if not content or content == '' then
|
|
return
|
|
end
|
|
-- Remove trailing newline
|
|
content = content:gsub('\n$', '')
|
|
-- Copy to system clipboard
|
|
vim.fn.setreg('+', content)
|
|
vim.fn.setreg('*', content)
|
|
-- Count lines
|
|
local line_count = select(2, content:gsub('\n', '')) + 1
|
|
local plural = line_count == 1 and '' or 's'
|
|
-- Delay clipboard notification slightly to appear after yank notification
|
|
vim.defer_fn(function()
|
|
vim.notify(string.format('Copied %d line%s to clipboard', line_count, plural), vim.log.levels.INFO, { title = 'Clipboard' })
|
|
end, 50) -- 50ms delay
|
|
end
|
|
|
|
return M
|