mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-14 10:00:29 +00:00
feat: select gets list
added to its call. for #350
This commit is contained in:
parent
8dd3d909fd
commit
61406ca0b4
@ -120,8 +120,9 @@ harpoon:setup({
|
||||
--- This function gets invoked with the options being passed in from
|
||||
--- list:select(index, <...options...>)
|
||||
--- @param list_item {value: any, context: any}
|
||||
--- @param list { ... }
|
||||
--- @param option any
|
||||
select = function(list_item, option)
|
||||
select = function(list_item, list, option)
|
||||
-- WOAH, IS THIS HTMX LEVEL XSS ATTACK??
|
||||
vim.cmd(list_item.value)
|
||||
end
|
||||
@ -144,7 +145,7 @@ There is quite a bit of behavior you can configure via `harpoon:setup()`
|
||||
---@field encode? (fun(list_item: HarpoonListItem): string)
|
||||
---@field decode? (fun(obj: string): any)
|
||||
---@field display? (fun(list_item: HarpoonListItem): string)
|
||||
---@field select? (fun(list_item: HarpoonListItem, options: any?): nil)
|
||||
---@field select? (fun(list_item?: HarpoonListItem, list: HarpoonList, options: any?): nil)
|
||||
---@field equals? (fun(list_line_a: HarpoonListItem, list_line_b: HarpoonListItem): boolean)
|
||||
---@field add? fun(item: any?): HarpoonListItem
|
||||
---@field BufLeave? fun(evt: any, list: HarpoonList): nil
|
||||
|
@ -16,7 +16,7 @@ M.DEFAULT_LIST = DEFAULT_LIST
|
||||
---@field encode? (fun(list_item: HarpoonListItem): string)
|
||||
---@field decode? (fun(obj: string): any)
|
||||
---@field display? (fun(list_item: HarpoonListItem): string)
|
||||
---@field select? (fun(list_item?: HarpoonListItem, options: any?): nil)
|
||||
---@field select? (fun(list_item?: HarpoonListItem, list: HarpoonList, options: any?): nil)
|
||||
---@field equals? (fun(list_line_a: HarpoonListItem, list_line_b: HarpoonListItem): boolean)
|
||||
---@field add? fun(config: HarpoonPartialConfigItem, item: any?): HarpoonListItem
|
||||
---@field BufLeave? fun(evt: any, list: HarpoonList): nil
|
||||
@ -80,8 +80,9 @@ function M.get_default_config()
|
||||
|
||||
--- the select function is called when a user selects an item from the corresponding list and can be nil if select_with_nil is true
|
||||
---@param list_item? HarpoonListFileItem
|
||||
---@param list HarpoonList
|
||||
---@param options HarpoonListFileOptions
|
||||
select = function(list_item, options)
|
||||
select = function(list_item, list, options)
|
||||
options = options or {}
|
||||
if list_item == nil then
|
||||
return
|
||||
|
@ -160,7 +160,7 @@ function HarpoonList:select(index, options)
|
||||
Listeners.event_names.SELECT,
|
||||
{ list = self, item = item, idx = index }
|
||||
)
|
||||
self.config.select(item, options)
|
||||
self.config.select(item, self, options)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user