function number_switch(harpoon)
	for i = 1, 9, 1 do
		vim.keymap.set("n", "<leader>" .. i, function()
			harpoon:list():select(i)
		end)
	end
end

return {
	"ThePrimeagen/harpoon",
	branch = "harpoon2",
	dependencies = {
		"nvim-lua/plenary.nvim",
	},

	opts = {
		settings = {
			save_on_toggle = false,
			save_on_change = true,
			excluded_filetypes = { "harpoon" },
		},
		menu = {
			width = vim.api.nvim_win_get_width(0) - 4,
		},
	},

	config = function()
		local harpoon = require("harpoon")
		harpoon:setup()

		local harpoon_extensions = require("harpoon.extensions")
		harpoon:extend(harpoon_extensions.builtins.highlight_current_file())

		vim.keymap.set("n", "<leader>h", function()
			harpoon.ui:toggle_quick_menu(harpoon:list())
		end)
		vim.keymap.set("n", "<leader>H", function()
			harpoon:list():add()
		end)
		vim.keymap.set("n", "<leader>l", function()
			harpoon:list():remove()
		end)
		vim.keymap.set("n", "<leader>L", function()
			harpoon:list():clear()
		end)

		vim.keymap.set("n", "<M-h>", function()
			harpoon:list():prev()
		end)
		vim.keymap.set("n", "<M-l>", function()
			harpoon:list():next()
		end)

		number_switch(harpoon)
	end,
}
