IT WORKSga .

This commit is contained in:
pika 2024-08-20 17:53:04 +02:00
parent e5708ff4ed
commit 75a6f762d0

View file

@ -51,17 +51,16 @@ M.snippet_picker = function()
attach_mappings = function(_, map) attach_mappings = function(_, map)
map("i", "<CR>", function(prompt_bufnr) map("i", "<CR>", function(prompt_bufnr)
local selection = require("telescope.actions.state").get_selected_entry() local selection = require("telescope.actions.state").get_selected_entry()
local snippet_content = table.concat(vim.fn.readfile(selection.path), "\n") local snippet_content = vim.fn.readfile(selection.path)
-- Copy to clipboard
vim.fn.setreg("+", snippet_content)
vim.fn.setreg('"', snippet_content)
-- Close Telescope prompt -- Close Telescope prompt
require("telescope.actions").close(prompt_bufnr) require("telescope.actions").close(prompt_bufnr)
-- Insert snippet directly into the buffer
vim.api.nvim_put(snippet_content, "l", true, true)
-- Notify user -- Notify user
print("Snippet copied to clipboard. Press p to paste.") print("Snippet inserted.")
end) end)
return true return true
end, end,