You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The API docs state that you can customize your add function by using the following line of code:
localharpoon=require("harpoon")
harpoon:setup({
-- Setting up custom behavior for a list named "cmd""cmd" = {
-- When you call list:add() this function is called and the return-- value will be put in the list at the end.---- which means same behavior for prepend except where in the list the-- return value is added---- @param possible_value string only passed in when you alter the ui manualadd=function(possible_value)
-- get the current line idxlocalidx=vim.fn.line(".")
-- read the current linelocalcmd=vim.api.nvim_buf_get_lines(0, idx-1, idx, false)[1]
ifcmd==nilthenreturnnilendreturn {
value=cmd,
context= { ...anydatayouwant... },
}
end,
--- This function gets invoked with the options being passed in from--- list:select(index, <...options...>)--- @paramlist_item{value: any, context: any}--- @paramlist{ ... }--- @paramoptionanyselect=function(list_item, list, option)
-- WOAH, IS THIS HTMX LEVEL XSS ATTACK??vim.cmd(list_item.value)
end
}
})
Firstly this is not proper lua code, the dictionary key should be ["cmd"].
Secondly, the function you're supposed to customize is create_list_item, not add. Just look at config.lua line 188:
The API docs state that you can customize your add function by using the following line of code:
Firstly this is not proper lua code, the dictionary key should be
["cmd"]
.Secondly, the function you're supposed to customize is
create_list_item
, notadd
. Just look atconfig.lua
line188
:I would create a PR but it seems like PRs on docs don't get merged. The fact the only example of
API
in the README doesn't even work is frustrating.The text was updated successfully, but these errors were encountered: