Open JockeM opened 2 months ago
This is fixed, and this is the new default config for the Pasted action:
Pasted = {
keymap = "p",
cmd = "put",
cmd_args = function() -- This function needs to return a string as a parameter to cmd
return vim.v.register -- Return the register
end,
},
I'm not closing the issue right now, because keymap = "P" still doesnt work ( well it works without highlighting or it behave like keymap = "p" )
I've got something working but it highlights the whole line:
InlinePasted = {
keymap = "P",
cmd = function()
local line = vim.api.nvim_get_current_line() -- Get the current line
local cursor_pos = vim.api.nvim_win_get_cursor(0) -- Get the cursor position (row, col)
local col = cursor_pos[2]
local clipboard_data = vim.fn.getreg(vim.v.register)
-- Insert clipboard data at the cursor position
local new_line = line:sub(1, col) .. clipboard_data .. line:sub(col + 1)
vim.api.nvim_set_current_line(new_line)
end,
},
fixed by the original author of highlight-undo, made some changes to what he did. Here's the new default config:
{
"iguanacucumber/highlight-actions.nvim",
keys = { "p", "P", "u", "<C-r>" },
opts = {
duration = 300,
keymaps = {
{
fg = "#dcd7ba", -- default
bg = "#2d4f67", -- default
hlgroup = "HighlightUndo", -- Automatically set by "Highlight" .. lhs
mode = "n", -- default
lhs = "u", -- Only thing that's mandatory here
rhs = "u", -- if not set rhs = lhs, can also be a function
callback = function() -- do something after rhs
openFoldsOnUndo()
end,
opts = { desc = "HighlightUndo" }, -- opts to vim.keymap.set()
},
{
lhs = "<C-r>",
callback = function()
openFoldsOnUndo()
end,
opts = { desc = "HighlightRedo" },
},
{ opts = { desc = "HighlightPaste" }, lhs = "p" },
{ opts = { desc = "HighlightInlinePaste" }, lhs = "P" },
-- you also can add an action as simply as this:
-- { lhs = 'p' }
},
},
},
Pasting now always uses the normal reg So
"0p
wont work