nvim/lua/custom/plugins/harpoon.lua
Jeremie Fraeys f162354317
refactor: cleanup UI and navigation plugins
- Simplify telescope.lua configuration
- Streamline trouble.lua diagnostics
- Refactor oil.lua file manager
- Update harpoon.lua quick file navigation
- Clean up indent.lua, lualine.lua, which-key.lua
2026-03-23 20:34:20 -04:00

82 lines
2.3 KiB
Lua
Executable file

return {
'theprimeagen/harpoon',
branch = 'harpoon2',
keys = {
{ '<leader>a', desc = 'Harpoon: Add file' },
{ '<C-e>', desc = 'Harpoon: Toggle menu' },
{ '<C-h>', desc = 'Harpoon: Select 1' },
{ '<C-j>', desc = 'Harpoon: Select 2' },
{ '<C-k>', desc = 'Harpoon: Select 3' },
{ '<C-l>', desc = 'Harpoon: Select 4' },
{ '<C-p>', desc = 'Harpoon: Prev' },
{ '<C-n>', desc = 'Harpoon: Next' },
},
dependencies = { 'nvim-lua/plenary.nvim' },
config = function()
local harpoon = require('harpoon')
harpoon:setup({
settings = {
save_on_toggle = true,
sync_on_ui_close = true,
key = function()
return vim.uv.cwd() or 'global'
end,
},
})
vim.keymap.set('n', '<leader>a', function()
if vim.fn.expand('%:p'):sub(1, 6) == 'oil://' then
local ok_oil, oil = pcall(require, 'oil')
if not ok_oil then
vim.notify('Oil not found', vim.log.levels.WARN)
return
end
local entry = oil.get_cursor_entry()
if not entry or not entry.name then
vim.notify('No valid entry selected in Oil', vim.log.levels.INFO)
return
end
local full_path = oil.get_current_dir() .. entry.name
local stat = vim.uv.fs_stat(full_path)
if not stat or stat.type ~= 'file' then
vim.notify('Not a file: ' .. full_path, vim.log.levels.INFO)
return
end
harpoon:list():add({
value = entry.name,
context = { filename = entry.name, cwd = oil.get_current_dir() or 'global' },
})
vim.notify('Added ' .. entry.name .. ' to harpoon')
return
end
harpoon:list():add()
end, { desc = 'Harpoon: Add file' })
vim.keymap.set('n', '<C-e>', function()
harpoon.ui:toggle_quick_menu(harpoon:list())
end)
vim.keymap.set('n', '<C-h>', function()
harpoon:list():select(1)
end)
vim.keymap.set('n', '<C-j>', function()
harpoon:list():select(2)
end)
vim.keymap.set('n', '<C-k>', function()
harpoon:list():select(3)
end)
vim.keymap.set('n', '<C-l>', function()
harpoon:list():select(4)
end)
vim.keymap.set('n', '<C-p>', function()
harpoon:list():prev()
end)
vim.keymap.set('n', '<C-n>', function()
harpoon:list():next()
end)
end,
}