30 lines
619 B
Lua
30 lines
619 B
Lua
local M = {}
|
|
|
|
-- Retrieves clipboard content and trims trailing whitespace/newlines
|
|
function M.get_clipboard_content()
|
|
local content = vim.fn.getreg('+')
|
|
content = content:gsub("%s+$", "")
|
|
return content
|
|
end
|
|
|
|
function M.write_file(filepath, content)
|
|
local dir = filepath:match("(.*/)")
|
|
if dir and dir ~= "" then
|
|
vim.fn.mkdir(dir, "p")
|
|
end
|
|
|
|
local f = io.open(filepath, "w")
|
|
if f then
|
|
f:write(content)
|
|
f:close()
|
|
else
|
|
vim.api.nvim_err_writeln("Failed to write file: " .. filepath)
|
|
end
|
|
end
|
|
|
|
function M.finish()
|
|
print("All files processed. You can now continue working.")
|
|
end
|
|
|
|
return M
|