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

Error on exit if multiple components uses vim.schedule_wrap #203

Open
likalium opened this issue Jul 4, 2024 · 1 comment
Open

Error on exit if multiple components uses vim.schedule_wrap #203

likalium opened this issue Jul 4, 2024 · 1 comment

Comments

@likalium
Copy link

likalium commented Jul 4, 2024

Hello, I have three statusline components that, when updating, execute vim.schedule_wrap(function() ... end) as callback:

local viMode = {
  update = {
    "ModeChanged",
    pattern = "*:*",
    callback = vim.schedule_wrap(function()
      vim.cmd("redrawstatus")
    end),
  }
}
local git = {
  update = {
    "User",
    pattern = "GitSignsUpdate",
    callback = vim.schedule_wrap(function()
      vim.cmd("redrawstatus")
    end),
  }
}
local diagnostics = {
  update = {
    "DiagnosticChanged",
    callback = vim.schedule_wrap(function()
      vim.cmd("redrawstatus")
      vim.cmd("redrawtabline")
    end),
  }
}

The functions for the git and diagnostics component is to fix the fact that they are updated only on cursor move (see #182). In fact my update = {...} on these components is just an adaptation of the autocommands given in #182.

My problem is that, if more than one of these statusline components are loaded, then on exiting neovim spits an error (see below). But if only one of these is loaded, then no error is given on exit. Also, every component is working perfectly, even if it shows an error on exit. It's just annoying, because the error make neovim to delay when quitting, and also it's still concerning to have an error but you don't really know why. Also, #175 is maybe related.
I just wanted to conclude that, thank you VERY much for developing heirline.nvim. I find it an awesome plugin, and I'm really glad you're maintaining it!

The error message:

Error executing vim.schedule lua callback: vim/_editor.lua:0: nvim_exec2(): Vim(redrawstatus):E5108: Error executing lua ...hare/nvim/lazy/heirline.nvim/lua/heirline/statusline.lua:381: bad argument #1 to 'provider' (string expected, got nil)
stack traceback:
	[C]: in function 'provider'
	...hare/nvim/lazy/heirline.nvim/lua/heirline/statusline.lua:381: in function '_eval'
	...hare/nvim/lazy/heirline.nvim/lua/heirline/statusline.lua:398: in function '_eval'
	...hare/nvim/lazy/heirline.nvim/lua/heirline/statusline.lua:398: in function '_eval'
	...hare/nvim/lazy/heirline.nvim/lua/heirline/statusline.lua:398: in function '_eval'
	...hare/nvim/lazy/heirline.nvim/lua/heirline/statusline.lua:398: in function '_eval'
	...hare/nvim/lazy/heirline.nvim/lua/heirline/statusline.lua:398: in function '_eval'
	...hare/nvim/lazy/heirline.nvim/lua/heirline/statusline.lua:473: in function 'eval'
	...ocal/share/nvim/lazy/heirline.nvim/lua/heirline/init.lua:114: in function <...ocal/share/nvim/lazy/heirline.nvim/lua/heirline/init.lua:109>
	[C]: in function 'nvim_exec2'
	vim/_editor.lua: in function 'cmd'
	/home/sodium/.config/nvim/lua/plugins/bars-and-lines.lua:153: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>
stack traceback:
	[C]: in function 'nvim_exec2'
	vim/_editor.lua: in function 'cmd'
	/home/sodium/.config/nvim/lua/plugins/bars-and-lines.lua:153: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>

NB: "sodium" is my username

@likalium likalium changed the title Error on exit if multiple components uses vim.schedule_wrapin update = {} Error on exit if multiple components uses vim.schedule_wrap Jul 4, 2024
@rebelot
Copy link
Owner

rebelot commented Jul 4, 2024

This is related to #175 and I can reproduce only if I sufficiently shrink the window.

While I try to figure out how to properly handle this, here is a workaround:

:au VimLeavePre * set stl=

interestingly this does not work on VimLeavePre, but it does if done manually

:au VimLeavePre * au! Heirline_update_autocmds

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