harpoon
harpoon copied to clipboard
Need markers.
What issue are you having that you need harpoon to solve?
-
Can I get a mark like this on the gutter for a line that is marked with harpoon?
-
No highlight of the line that was marked in the telescope previewer... When I look at the previewer there is so much lines of code I don't know which line I marked...
Why doesn't the current config help?
What proposed api changes are you suggesting?
For the first request, I can replicate that with some autocmds and nvim apis
local api = vim.api
local function harpoon_ns()
return api.nvim_create_namespace('harpoon_sign')
end
api.nvim_set_hl(0, "HarpoonSign", { fg = "#8aadf4", bold = true })
local function harpoon_sign(row)
api.nvim_buf_set_extmark(0, harpoon_ns(), row - 1, -1,
{
sign_text = " ", -- check your `signcolumn` option
sign_hl_group = "HarpoonSign",
})
end
api.nvim_create_autocmd({ "BufEnter" }, {
pattern = "*",
callback = function()
api.nvim_buf_clear_namespace(0, harpoon_ns(), 0, -1)
local filename = vim.fn.expand("%:p:.")
local harpoon_marks = harpoon:list().items
for _, mark in ipairs(harpoon_marks) do
if mark.value == filename then
harpoon_sign(mark.context.row)
return
end
end
end,
})
local function harpoon_add()
api.nvim_buf_clear_namespace(0, harpoon_ns(), 0, -1)
harpoon_sign(vim.fn.line("."))
harpoon:list():append()
end
vim.keymap.set("n", "<leader>a", harpoon_add, { desc = "Harpoon: Add", })
Neat idea. These are good situations where the existing nvim and harpoon api are already able to meet your specific use case.
For the Telescope request, you could build your own picker by copying the logic in this file but customizing the previewer.