ThePrimeagen/harpoon

Problem with Harpoon + Telescope integration on Windows

Opened this issue · 2 comments

With the setup on the readme whenever I use the telescope harpoon menu and choose a buffer to go, instead it leads me to an empty buffer with a location "C".

See image:
image
Moreover, this problem is only on windows as in WSL with the same setup this isn't an issue.

This is my current Harpoon2 Setup with lazy.vim:

return {
    "ThePrimeagen/harpoon",
    branch = "harpoon2",
    dependencies = { "nvim-lua/plenary.nvim", 'nvim-telescope/telescope.nvim', },
    config = function()
        local harpoon = require('harpoon')
        harpoon:setup({})

        -- 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({}),
            }):find()
        end

        vim.keymap.set("n", "<leader><Space>", function() toggle_telescope(harpoon:list()) end,
            { desc = "Open harpoon window" })

        vim.keymap.set("n", "<leader>x", function() harpoon:list():append() end, { desc = "Harpoon Mark" })
        vim.keymap.set("n", "<leader>X", function() harpoon:list():remove() end, { desc = "Harpoon Unmark" })
        -- vim.keymap.set("n", "<leader><Space>", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end,
        --     { desc = "Open harpoon window" })

        vim.keymap.set("n", "<M-1>", function() harpoon:list():select(1) end)
        vim.keymap.set("n", "<M-2>", function() harpoon:list():select(2) end)
        vim.keymap.set("n", "<M-3>", function() harpoon:list():select(3) end)
        vim.keymap.set("n", "<M-4>", function() harpoon:list():select(4) end)
        vim.keymap.set("n", "<M-5>", function() harpoon:list():select(5) end)
        vim.keymap.set("n", "<M-6>", function() harpoon:list():select(6) end)
        vim.keymap.set("n", "<M-7>", function() harpoon:list():select(7) end)
        vim.keymap.set("n", "<M-8>", function() harpoon:list():select(8) end)
        vim.keymap.set("n", "<M-9>", function() harpoon:list():select(9) end)

        -- Toggle previous & next buffers stored within Harpoon list
        vim.keymap.set("n", "<M-,>", function() harpoon:list():prev() end)
        vim.keymap.set("n", "<M-.>", function() harpoon:list():next() end)
    end,
};

I tried to fix the issue and created a PR #497. For me the problem is solved for both windows 10 and WSL Ubuntu

I also have this same issue and I'm on Windows 10. From my logs, I think the source the issue is due to HarpoonList's select method not being called when using the telescope implementation rather than a path normalization issue. One other note, the harpoon ui implementation works for me, so that's been my go to.

Logs for telescope:

config_default#create_list_item C:/Users/Nick/AppData/Local/projects/harpoon/lua/harpoon/autocmd.lua
HarpoonList:append { index = -1, item = { context = { col = 0, row = 1 }, value = "C:/Users/Nick/AppData/Local/projects/harpoon/lua/harpoon/autocmd.lua" } }
config_default#BufLeave updating position 9 C:/Users/Nick/AppData/Local/projects/harpoon/lua/harpoon/autocmd.lua { context = { col = 0, row = 1 }, value = "C:/Users/Nick/AppData/Local/projects/harpoon/lua/harpoon/autocmd.lua" } to position { 1, 0 }
config_default#create_list_item C:/Users/Nick/AppData/Local/projects/harpoon/lua/harpoon/buffer.lua
HarpoonList:append { index = -1, item = { context = { col = 0, row = 1 }, value = "C:/Users/Nick/AppData/Local/projects/harpoon/lua/harpoon/buffer.lua" } }
config_default#BufLeave updating position 11 C:/Users/Nick/AppData/Local/projects/harpoon/lua/harpoon/buffer.lua { context = { col = 0, row = 1 }, value = "C:/Users/Nick/AppData/Local/projects/harpoon/lua/harpoon/buffer.lua" } to position { 1, 0 }
config_default#BufLeave updating position 11 C:/Users/Nick/AppData/Local/projects/harpoon/lua/harpoon/buffer.lua { context = { col = 0, row = 1 }, value = "C:/Users/Nick/AppData/Local/projects/harpoon/lua/harpoon/buffer.lua" } to position { 1, 0 }

Logs for harpoon.ui

config_default#create_list_item C:/Users/Nick/AppData/Local/nvim/init.lua
HarpoonList:append { index = -1, item = { context = { col = 0, row = 1 }, value = "C:/Users/Nick/AppData/Local/nvim/init.lua" } }
config_default#BufLeave updating position 2 C:/Users/Nick/AppData/Local/nvim/init.lua { context = { col = 0, row = 1 }, value = "C:/Users/Nick/AppData/Local/nvim/init.lua" } to position { 1, 0 }
config_default#create_list_item C:/Users/Nick/AppData/Local/nvim/lazy-lock.json
HarpoonList:append { index = -1, item = { context = { col = 0, row = 1 }, value = "C:/Users/Nick/AppData/Local/nvim/lazy-lock.json" } }
ui#toggle_quick_menu#opening __harpoon_files
config_default#BufLeave updating position 4 C:/Users/Nick/AppData/Local/nvim/lazy-lock.json { context = { col = 0, row = 1 }, value = "C:/Users/Nick/AppData/Local/nvim/lazy-lock.json" } to position { 2, 0 }
select by keymap '<CR>'
ui#select_menu_item selecting item 2 from { "C:/Users/Nick/AppData/Local/nvim/init.lua", "C:/Users/Nick/AppData/Local/nvim/lazy-lock.json" } options
ui#close_menu name: __harpoon_files win and bufnr { bufnr = 5, win = 1002 }
toggle by BufLeave
ui#toggle_quick_menu#closing
config_default#select { context = { col = 0, row = 2 }, value = "C:/Users/Nick/AppData/Local/nvim/lazy-lock.json" } __harpoon_files
ui#toggle_quick_menu#opening __harpoon_files
config_default#BufLeave updating position 4 C:/Users/Nick/AppData/Local/nvim/lazy-lock.json { context = { col = 0, row = 2 }, value = "C:/Users/Nick/AppData/Local/nvim/lazy-lock.json" } to position { 2, 0 }
select by keymap '<CR>'
ui#select_menu_item selecting item 1 from { "C:/Users/Nick/AppData/Local/nvim/init.lua", "C:/Users/Nick/AppData/Local/nvim/lazy-lock.json" } options
ui#close_menu name: __harpoon_files win and bufnr { bufnr = 6, win = 1003 }
toggle by BufLeave
ui#toggle_quick_menu#closing
config_default#select { context = { col = 0, row = 1 }, value = "C:/Users/Nick/AppData/Local/nvim/init.lua" } __harpoon_files
config_default#BufLeave updating position 4 C:/Users/Nick/AppData/Local/nvim/lazy-lock.json { context = { col = 0, row = 2 }, value = "C:/Users/Nick/AppData/Local/nvim/lazy-lock.json" } to position { 2, 0 }