Skip to content

Commit

Permalink
refactor(harpoon): new config structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Allaman committed Mar 25, 2024
1 parent ba79ac3 commit 0c44c40
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
24 changes: 0 additions & 24 deletions lua/config/defaults/plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,6 @@ return {
-- https://github.com/olexsmir/gopher.nvim
enable = false,
},
harpoon = {
-- https://github.com/ThePrimeagen/harpoon
enable = false,
key_mappings = function(harpoon)
vim.keymap.set("n", "<leader>a", function()
harpoon:list():append()
end, { desc = "Harpoon append" })
vim.keymap.set("n", "<leader>0", function()
harpoon.ui:toggle_quick_menu(harpoon:list())
end, { desc = "Harpoon UI" })
vim.keymap.set("n", "<leader>1", function()
harpoon:list():select(1)
end, { desc = "Harpoon 2" })
vim.keymap.set("n", "<leader>2", function()
harpoon:list():select(2)
end, { desc = "Harpoon 2" })
vim.keymap.set("n", "<leader>3", function()
harpoon:list():select(3)
end, { desc = "Harpoon 3" })
vim.keymap.set("n", "<leader>4", function()
harpoon:list():select(4)
end, { desc = "Harpoon 4" })
end,
},
indent_blankline = {
enable = false,
enable_scope = true,
Expand Down
24 changes: 22 additions & 2 deletions lua/core/plugins/harpoon.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
local user_config = (vim.g.config.plugins.harpoon or {})

local default_config = {
enabled = false,
opts = {},
keys = {
-- stylua: ignore start
{ "<leader>a", function() require("harpoon"):list():append() end, desc = "Harpoon append", },
{ "<leader>0", function() require("harpoon").ui:toggle_quick_menu(require("harpoon"):list()) end, desc = "Harpoon UI", },
{ "<leader>1", function() require("harpoon"):list():select(1) end, desc = "Harpoon 2", },
{ "<leader>2", function() require("harpoon"):list():select(2) end, desc = "Harpoon 2", },
{ "<leader>3", function() require("harpoon"):list():select(3) end, desc = "Harpoon 3", },
{ "<leader>4", function() require("harpoon"):list():select(4) end, desc = "Harpoon 4", },
-- stylua: ignore end
},
}

local config = vim.tbl_deep_extend("force", default_config, user_config)
vim.print(config)

return {
"ThePrimeagen/harpoon",
enabled = vim.g.config.plugins.harpoon.enable,
enabled = config.enabled,
dependencies = { "nvim-lua/plenary.nvim" },
event = "VeryLazy",
branch = "harpoon2",
keys = config.keys,
config = function()
local harpoon = require("harpoon")
harpoon:setup()
vim.g.config.plugins.harpoon.key_mappings(harpoon)
end,
}

0 comments on commit 0c44c40

Please sign in to comment.