Skip to content

Commit

Permalink
partial: i don't know if the splits ackshually work
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePrimeagen committed Nov 4, 2023
1 parent 362b79f commit e080204
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lua/harpoon2/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -75,7 +75,16 @@ function M.get_default_config()
bufnr = vim.fn.bufnr(file_item.value, true)
end

vim.api.nvim_set_current_buf(bufnr)
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,
Expand Down
7 changes: 7 additions & 0 deletions lua/harpoon2/list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down

0 comments on commit e080204

Please sign in to comment.