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

Use with auto-sessions breaks beacon. #36

Open
BerkeleyTrue opened this issue Jan 9, 2025 · 1 comment
Open

Use with auto-sessions breaks beacon. #36

BerkeleyTrue opened this issue Jan 9, 2025 · 1 comment

Comments

@BerkeleyTrue
Copy link

I use rmagatti/auto-session to manage nvim sessions. Beacon seems to work great without a fresh session, but when ever resuming a session beacon throws errors due to invalid buffer ids

Error executing vim.schedule lua callback: ...eytrue/.local/share/nvim/lazy/beacon.nvim/lua/beacon.lua:38: Invalid buffer id: 2
stack traceback:
	[C]: in function 'nvim_open_win'
	...eytrue/.local/share/nvim/lazy/beacon.nvim/lua/beacon.lua:38: in function 'create_window'
	...eytrue/.local/share/nvim/lazy/beacon.nvim/lua/beacon.lua:76: in function <...eytrue/.local/share/nvim/lazy/beacon.nvim/lua/beacon.lua:56>

Maybe a race condition? Maybe auto-session is removing buffers that don't exist in the session?

@f-leeske
Copy link

The problem is the incorrect buffer id of beacon's fake buffer that it uses to play the animation, in beacon.lua, l.31:

local fake_buffer = vim.api.nvim_create_buf(false, true)

local function create_window(cfg)
  local window = vim.api.nvim_open_win(fake_buffer, false, {  -- <-- fake_buffer is off if session was loaded with at least one buffer
    relative = 'cursor',
    row = 0,
    col = 0,
    width = cfg.width,
    height = 1,
    style = 'minimal',
    focusable = false,
    noautocmd = true,
  })

My workaround is to lazy-load beacon on the "CursorMoved" event, and I haven't encountered any issues so far:

return {
    "danilamihailov/beacon.nvim",
    event = "CursorMoved",
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants