ecthelionvi / NeoComposer.nvim

Neovim plugin that simplifies macros, enhancing productivity with harmony.
MIT License
400 stars 9 forks source link

Plugin UI menu broken due to duplicate buffer name #27

Open uwla opened 2 months ago

uwla commented 2 months ago

Sometimes the plugin UI menu gets broken due to duplicate buffer name. Possibly a conflict with another plugin and a hidden buffer?

NEOCOMPOSER

I cannot access the UI menu to edit the macros as in the screenshot above. This is the error.

Error  05:09:37 PM msg_show.lua_error E5108: Error executing lua .../share/nvim/lazy/NeoComposer.nvim/lua/NeoComposer/ui.lua:230: Vim:E95: Buffer with this name already exists
stack traceback:
    [C]: in function 'nvim_buf_set_name'
    .../share/nvim/lazy/NeoComposer.nvim/lua/NeoComposer/ui.lua:230: in function 'toggle_macro_menu'
    [string ":lua"]:1: in main chunk
Info  05:09:39 PM notify.info NeoComposer Macro Recording
Info  05:09:40 PM notify.info NeoComposer Macro Saved ()

However, if I delete the vim session and start a fresh one, it does work. Its seems to be duplicated buffername is the problem, and many neovim plugins like this one use temporary hidden buffers to show UIs in floating windows.

ecthelionvi commented 2 months ago

I added a check to see if the buffer already exists and to just reuse it. Hopefully this will solve the issue. Please go ahead and use the dev branch and let me know if that fixes it. Thank you.

uwla commented 2 months ago

Hello @ecthelionvi . I have switch to the dev branch and pulled the latest changes:

$ cd ~/.local/share/nvim/lazy/NeoComposer.nvim
$ git switch dev
$ git pull origin dev

But the issue persisted...

After some troubleshooting, I'm no longer sure if the bug lies within this plugin, but may be caused by resession https://github.com/stevearc/resession.nvim, a session manager I'm using. It is storing in its session file information about a hidden buffer previously used by neocomposer. Resession does this for other hidden buffers but for some reason I only get the bug by using neocomposer... Clearing the session and starting a new one makes neocomposer menu work but I don't like restarting my sessions.

Sorry for the trouble.

uwla commented 2 months ago

I still get it:

E5108: Error executing lua .../share/nvim/lazy/NeoComposer.nvim/lua/NeoComposer/ui.lua:230: Vim:E95: Buffer with this name already exists
stack traceback:
    [C]: in function 'nvim_buf_set_name'
    .../share/nvim/lazy/NeoComposer.nvim/lua/NeoComposer/ui.lua:230: in function 'toggle_macro_menu'
    [string ":lua"]:1: in main chunk

I was inspecting the session files generated by ressession and confirmed my hipothesis:

    {
      "name": "<path/to/my-awesome-project>/neocomposer-menu",
      "last_pos": [1, 0],
      "options": {
        "binary": false,
        "bufhidden": "",
        "modifiable": true,
        "filetype": "",
        "buflisted": false,
        "readonly": false
      },
      "loaded": true
    },

neocomposer-menu buffer is stored by resession even though it is not listed and hidden. When I attempt to repon neocomposer it fails because the buffer name already existed.

I will try to tweak resession.