j-morano / buffer_manager.nvim

A simple plugin to easily manage Neovim buffers.
MIT License
232 stars 12 forks source link

2 buffers with same name make it duplicate #24

Closed tomiis4 closed 1 year ago

tomiis4 commented 1 year ago

when you set both short names, it duplicate buffers with same name.

short_file_names = true, -- if you set it to true, it fix the problem.
short_term_names = true,

image

How to reproduce?

  1. open 2 files with same name
  2. using buffer manager select one of them
  3. re-open buffer manager and you see 3 buffers with same name

Full configuration:

        local opts = { noremap = true, silent = true }
        local map = vim.keymap.set
        -- Setup
        require("buffer_manager").setup({
            select_menu_item_commands = {
                v = {
                    key = "<C-v>",
                    command = "vsplit"
                },
                h = {
                    key = "<C-h>",
                    command = "split"
                }
            },
            focus_alternate_buffer = false,
            short_file_names = true,
            short_term_names = true,
            loop_nav = false,
        })

        local bmui = require("buffer_manager.ui")
        local keys = '1234567890'
        for i = 1, #keys do
            local key = keys:sub(i, i)
            map(
                'n',
                string.format('<leader>%s', key),
                function() bmui.nav_file(i) end,
                opts
            )
        end
        map('n', '<leader>o', bmui.toggle_quick_menu, opts)
j-morano commented 1 year ago

Hello! Thank you very much for the feedback and the comprehensive explanation of the issue. You are completely right. I created the branch handle-short-duplicates with one commit that should solve the problem. Please test that everything works as intended.

As you probably know, you can select the branch using your plugin manager. For example, for packer:

use { 'j-morano/buffer_manager.nvim', branch = 'handle-short-duplicates' }
tomiis4 commented 1 year ago

Thanks, it works perfectly.

j-morano commented 1 year ago

Perfect then. I just merged the branch to main. Thank you again for the feedback! And, of course, feel free to open another issue if you find more bugs or you have a feature request.