Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra side buffers #221

Open
ariel-frischer opened this issue Apr 8, 2023 · 11 comments
Open

Extra side buffers #221

ariel-frischer opened this issue Apr 8, 2023 · 11 comments
Labels
enhancement New feature or request need investigation When an issue lack context/is not straight forward to solve not confirmed when a bug is reported but not yet reproduced
Milestone

Comments

@ariel-frischer
Copy link

Description

Bunch of extra side buffers open on every new session.

Steps to reproduce

Use this plugin with:
https://github.com/rmagatti/auto-session

enable autocmds:

        autocmds = {
          -- enableOnVimEnter = true,
          -- enableOnTabEnter = true,
        },

Expected behavior

Only two side buffers should be showing up by default

Environment

  • Neovim version: NVIM v0.9.0-dev-1259+g434f3d6a0-dirty
  • no-neck-pain.nvim version: latest
  • Plugin clash: rmagatti/auto-session
@shortcuts shortcuts added need investigation When an issue lack context/is not straight forward to solve not confirmed when a bug is reported but not yet reproduced labels Apr 9, 2023
@shortcuts
Copy link
Owner

Hey! Thanks for opening the issue

I'll try to reproduce and see where the issue come from, thanks!

@shortcuts
Copy link
Owner

At first glance, there's indeed something clashing between the two plugins.

On the https://github.com/rmagatti/auto-session, it seems that it fully resets the _G global index values, so NNP state is unsync'd and re-creates everything from scratch.

I can try to find a way to cleanup existing buffers but not sure if I can properly identify them.

@shortcuts shortcuts added the enhancement New feature or request label Apr 23, 2023
@ivanjermakov
Copy link

I managed to mitigate this bug by removing some options from sessionoptions:

vim.opt.sessionoptions = "buffers,curdir,terminal"

@shortcuts
Copy link
Owner

oh this is huge @ivanjermakov, thanks a lot! I'll try it myself and adds them as a default integration if it works

@sand4rt
Copy link

sand4rt commented Mar 8, 2024

I can't get auto-session working together with no-neck-pain either. When i close nvim with :q, auto-session thinks one of the side buffers is the last buffer, causing me to see an empty buffer when reopening nvim. It does work with :qa though.

@shortcuts do you know how to solve this? I tried calling require("no-neck-pain").disable() in auto-session's pre_save_cmds hook to close no-neck-pain before it saves the session, but it still saves when one of the side buffers as last session.

@shortcuts
Copy link
Owner

shortcuts commented Mar 8, 2024

@shortcuts do you know how to solve this? I tried calling require("no-neck-pain").disable() in auto-session's pre_save_cmds hook to close no-neck-pain before it saves the session, but it still saves when one of the side buffers as last session.

Hey, I believe there is a race condition in that case because both auto-session and no-neck-pain might listen to the QuitPre/WinClosed events.

Do you know if there is a way to filter out windows/buffers given a buftype on session save from auto-session? this could be a quickwin since nnp buffers have a default butype but also allows you to provide a custom one

@sand4rt

This comment was marked as outdated.

@sand4rt
Copy link

sand4rt commented Mar 9, 2024

a way to filter out windows/buffers given a buftype

@shortcuts thanks for the pointer. I double-checked it and indeed found an option to accomplish this. I ended up using:

return {
    "rmagatti/auto-session",
    lazy = false,
    init = function()
        vim.opt.sessionoptions = "buffers,curdir,terminal"
    end,
    keys = {
        {
            "<leader>ss",
            "<cmd>Autosession search<cr>",
            desc = "[S]earch [S]essions",
        },
        {
            "<leader>sd",
            "<cmd>Autosession delete<cr>",
            desc = "[S]earch [D]elete",
        },
    },
    opts = {
        log_level = "error",
        auto_session_use_git_branch = true,
        bypass_session_save_file_types = {
            "",
            "no-neck-pain",
            "neo-tree",
            "noice",
            "notify",
            "fugitive",
            "neotest-summary",
        },
    },
}

I used this keymap while focusing on windows to identify the file types of the plugins i want to disable:

vim.keymap.set("n", "<leader>m", function()
    local bufnr = vim.fn.bufnr("%")
    local buftype = vim.api.nvim_buf_get_option(bufnr, "filetype")
    vim.notify(buftype, "error")
end)

@shortcuts
Copy link
Owner

Great find @sand4rt! that's a good enough workaround for people that don't use the no-neck-pain side buffers as scratchpad however for custom filetypes it wouldn't work :/ I'll think of a way to natively fix that

Thanks again for using the plugin and the feedbacks!!

shortcuts added a commit that referenced this issue Mar 13, 2024
## 📃 Summary

saving state after important executions prevent inconsistencies when
accessing it, this will also allowing introducing debouncing at any time
of the plugin toggling, which might help for
#221 and
#227
@alex35mil
Copy link

Same thing happens with persistence. When I restore a session, 4 side-buffers are created.

I realized that I don't use scratchpads, so I just disabled them. But then, this error pops up on session restoration:

Error executing vim.schedule lua callback: ...e/nvim/lazy/no-neck-pain.nvim/lua/no-neck-pain/state.lua:391: attempt to index field 'tabs' (a nil value)
stack traceback:
	...e/nvim/lazy/no-neck-pain.nvim/lua/no-neck-pain/state.lua:391: in function 'getSideID'
	...re/nvim/lazy/no-neck-pain.nvim/lua/no-neck-pain/main.lua:431: in function <...re/nvim/lazy/no-neck-pain.nvim/lua/no-neck-pain/main.lua:430>
	vim/shared.lua: in function 'tbl_filter'
	...re/nvim/lazy/no-neck-pain.nvim/lua/no-neck-pain/main.lua:430: in function 'callback'
	...vim/lazy/no-neck-pain.nvim/lua/no-neck-pain/util/api.lua:143: in function <...vim/lazy/no-neck-pain.nvim/lua/no-neck-pain/util/api.lua:142>

@shortcuts
Copy link
Owner

Hey @alex35mil thanks for reporting and using the plugin! I have a somewhat viable solution for the next major version but will try to come up with a fix for the current version

@shortcuts shortcuts added this to the next milestone Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request need investigation When an issue lack context/is not straight forward to solve not confirmed when a bug is reported but not yet reproduced
Projects
None yet
Development

No branches or pull requests

5 participants