mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-16 11:00:23 +00:00
fix: harpoon:setup and harpoon.setup now work
This commit is contained in:
parent
07cca27cf1
commit
70703d6ce1
@ -35,38 +35,6 @@ function Harpoon:new()
|
|||||||
return harpoon
|
return harpoon
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param partial_config HarpoonPartialConfig
|
|
||||||
---@return Harpoon
|
|
||||||
function Harpoon:setup(partial_config)
|
|
||||||
self.config = Config.merge_config(partial_config, self.config)
|
|
||||||
self.ui:configure(self.config.settings)
|
|
||||||
|
|
||||||
---TODO: should we go through every seen list and update its config?
|
|
||||||
|
|
||||||
if self.hooks_setup == false then
|
|
||||||
vim.api.nvim_create_autocmd({ "BufLeave", "VimLeavePre" }, {
|
|
||||||
group = HarpoonGroup,
|
|
||||||
pattern = "*",
|
|
||||||
callback = function(ev)
|
|
||||||
self:_for_each_list(function(list, config)
|
|
||||||
local fn = config[ev.event]
|
|
||||||
if fn ~= nil then
|
|
||||||
fn(ev, list)
|
|
||||||
end
|
|
||||||
|
|
||||||
if ev.event == "VimLeavePre" then
|
|
||||||
self:sync()
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
self.hooks_setup = true
|
|
||||||
end
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
---@param name string?
|
---@param name string?
|
||||||
---@return HarpoonList
|
---@return HarpoonList
|
||||||
function Harpoon:list(name)
|
function Harpoon:list(name)
|
||||||
@ -141,4 +109,46 @@ function Harpoon:__debug_reset()
|
|||||||
require("plenary.reload").reload_module("harpoon")
|
require("plenary.reload").reload_module("harpoon")
|
||||||
end
|
end
|
||||||
|
|
||||||
return Harpoon:new()
|
local the_harpoon = Harpoon:new()
|
||||||
|
|
||||||
|
---@param self Harpoon
|
||||||
|
---@param partial_config HarpoonPartialConfig
|
||||||
|
---@return Harpoon
|
||||||
|
function Harpoon.setup(self, partial_config)
|
||||||
|
if self ~= the_harpoon then
|
||||||
|
---@diagnostic disable-next-line: cast-local-type
|
||||||
|
partial_config = self
|
||||||
|
self = the_harpoon
|
||||||
|
end
|
||||||
|
|
||||||
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
|
self.config = Config.merge_config(partial_config, self.config)
|
||||||
|
self.ui:configure(self.config.settings)
|
||||||
|
|
||||||
|
---TODO: should we go through every seen list and update its config?
|
||||||
|
|
||||||
|
if self.hooks_setup == false then
|
||||||
|
vim.api.nvim_create_autocmd({ "BufLeave", "VimLeavePre" }, {
|
||||||
|
group = HarpoonGroup,
|
||||||
|
pattern = "*",
|
||||||
|
callback = function(ev)
|
||||||
|
self:_for_each_list(function(list, config)
|
||||||
|
local fn = config[ev.event]
|
||||||
|
if fn ~= nil then
|
||||||
|
fn(ev, list)
|
||||||
|
end
|
||||||
|
|
||||||
|
if ev.event == "VimLeavePre" then
|
||||||
|
self:sync()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
self.hooks_setup = true
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
return the_harpoon
|
||||||
|
Loading…
x
Reference in New Issue
Block a user