harpoon2: proper configure

This commit is contained in:
xinyangli 2024-12-06 19:46:23 +08:00
parent 4af5cb648b
commit 493148c3b8
Signed by: xin
SSH key fingerprint: SHA256:UU5pRTl7NiLFJbWJZa+snLylZSXIz5rgHmwjzv8v4oE

View file

@ -1,5 +1,53 @@
{ pkgs, ... }:
{
plugins.harpoon = {
enable = true;
};
# keymaps for this plugin are difined in config/keymaps/window-movements module
extraPlugins = with pkgs.vimPlugins; [
harpoon2
];
extraConfigLua = ''
local harpoon = require("harpoon")
harpoon:setup(
{
settings = {
save_on_toggle = true,
sync_on_ui_close = true,
key = function()
return vim.loop.cwd()
end,
},
}
)
-- basic telescope configuration
-- local conf = require("telescope.config").values
-- local function toggle_telescope(harpoon_files)
-- local file_paths = {}
-- for _, item in ipairs(harpoon_files.items) do
-- table.insert(file_paths, item.value)
-- end
--
-- require("telescope.pickers").new({}, {
-- prompt_title = "Harpoon",
-- finder = require("telescope.finders").new_table({
-- results = file_paths,
-- }),
-- previewer = conf.file_previewer({}),
-- sorter = conf.generic_sorter({}),
-- layout_strategy = getLayoutStrategy()
-- }):find()
-- end
--
-- vim.keymap.set("n", "<C-e>", function() toggle_telescope(harpoon:list()) end,
-- { desc = "Open harpoon window" })
vim.keymap.set("n", "<C-e>", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end)
vim.keymap.set("n", "<leader>a", function() harpoon:list():add() end)
vim.keymap.set("n", "<C-a>", function() harpoon:list():select(1) end)
vim.keymap.set("n", "<C-s>", function() harpoon:list():select(2) end)
vim.keymap.set("n", "<C-f>", function() harpoon:list():select(3) end)
vim.keymap.set("n", "<C-g>", function() harpoon:list():select(4) end)
-- Toggle previous & next buffers stored within Harpoon list
vim.keymap.set("n", "<C-S-k>", function() harpoon:list():prev() end)
vim.keymap.set("n", "<C-S-j>", function() harpoon:list():next() end)
'';
}