partial: i don't know if the splits ackshually work

This commit is contained in:
mpaulson 2023-11-03 19:43:44 -06:00
parent 362b79fe78
commit e08020477a
2 changed files with 19 additions and 3 deletions

View File

@ -8,7 +8,7 @@ local M = {}
---@field decode? (fun(obj: string): any)
---@field key? (fun(): string)
---@field display? (fun(list_item: HarpoonListItem): string)
---@field select? (fun(list_item: HarpoonListItem): nil)
---@field select? (fun(list_item: HarpoonListItem, options: any?): nil)
---@field equals? (fun(list_line_a: HarpoonListItem, list_line_b: HarpoonListItem): boolean)
---@field add? fun(item: any?): HarpoonListItem
@ -63,7 +63,7 @@ function M.get_default_config()
end,
---@param file_item HarpoonListFileItem
select = function(file_item)
select = function(file_item, options)
if file_item == nil then
return
end
@ -75,7 +75,16 @@ function M.get_default_config()
bufnr = vim.fn.bufnr(file_item.value, true)
end
if not options or not options.vsplit or not options.split then
vim.api.nvim_set_current_buf(bufnr)
elseif options.vsplit then
vim.cmd("vsplit")
vim.api.nvim_set_current_buf(bufnr)
elseif options.split then
vim.cmd("split")
vim.api.nvim_set_current_buf(bufnr)
end
if set_position then
vim.api.nvim_win_set_cursor(0, {
file_item.context.row or 1,

View File

@ -96,6 +96,13 @@ function HarpoonList:resolve_displayed(displayed)
self.items = new_list
end
function HarpoonList:select(index, options)
local item = self.items[index]
if item then
self.config.select(item, options)
end
end
--- @return string[]
function HarpoonList:display()
local out = {}