When fidget.notification.notify() is triggered from a fast event (e.g., project.nvim history read), fidget calls vim.fn.sort() in notification/model.lua, which raises:
E5560: Vimscript function "sort" must not be called in a fast event context
To Reproduce
- Install
fidget.nvim and project.nvim via lazy.nvim
- Use default config (or enable
project.nvim history)
- Trigger a project history read (e.g., opening Neovim in a repo with project history enabled)
- Observe error in
:messages
Actual Behavior
Error thrown from fidget/notification/model.lua:270 (stack trace below).
Expected Behavior
Notifications should be safe even when triggered from fast events. fidget should avoid Vimscript calls in fast event context or schedule the update.
Stack trace
Error executing callback:
.../nvim/lazy/fidget.nvim/lua/fidget/notification/model.lua:270: E5560: Vimscript function "sort" must not be called in a fast event context
stack traceback:
[C]: in function 'sort'
.../nvim/lazy/fidget.nvim/lua/fidget/notification/model.lua:270: in function 'update'
.../share/nvim/lazy/fidget.nvim/lua/fidget/notification.lua:307: in function 'notify'
...hare/nvim/lazy/project.nvim/lua/project/util/history.lua:421: in function 'read_history'
...hare/nvim/lazy/project.nvim/lua/project/util/history.lua:385: in function <...hare/nvim/lazy/project.nvim/lua/project/util/history.lua:380>
Relevant code
In lua/fidget/notification/model.lua:
-- NOTE: we use vim.fn.sort() here because it is stable.
state.groups = vim.fn.sort(state.groups, function(a, b)
return (a.config.priority or 50) - (b.config.priority or 50)
end)
## Proposed fix
- Option 1: schedule notification.notify() or model.update() path with vim.schedule() when in fast event context.
- Option 2: replace vim.fn.sort() with a Lua stable sort implementation (avoids Vimscript calls in fast events).
## Workaround
User-side wrapper:
local ok, notif = pcall(require, "fidget.notification")
if ok then
local orig = notif.notify
notif.notify = function(msg, level, opts)
vim.schedule(function()
orig(msg, level, opts)
end)
end
end
## Environment
- OS: SUSE Linux Enterprise Server 15 SP4
- Neovim: v0.11.5
- fidget.nvim: commit:7fa433a
- project.nvim: commit:379f79a, https://github.com/DrKJeff16/project.nvim
---
Discalaimer: I used AI to help diagnose and build the wrapper.
When
fidget.notification.notify()is triggered from a fast event (e.g.,project.nvimhistory read),fidgetcallsvim.fn.sort()innotification/model.lua, which raises:E5560: Vimscript function "sort" must not be called in a fast event context
To Reproduce
fidget.nvimandproject.nvimvialazy.nvimproject.nvimhistory):messagesActual Behavior
Error thrown from
fidget/notification/model.lua:270(stack trace below).Expected Behavior
Notifications should be safe even when triggered from fast events.
fidgetshould avoid Vimscript calls in fast event context or schedule the update.Stack trace
Error executing callback:
.../nvim/lazy/fidget.nvim/lua/fidget/notification/model.lua:270: E5560: Vimscript function "sort" must not be called in a fast event context
stack traceback:
[C]: in function 'sort'
.../nvim/lazy/fidget.nvim/lua/fidget/notification/model.lua:270: in function 'update'
.../share/nvim/lazy/fidget.nvim/lua/fidget/notification.lua:307: in function 'notify'
...hare/nvim/lazy/project.nvim/lua/project/util/history.lua:421: in function 'read_history'
...hare/nvim/lazy/project.nvim/lua/project/util/history.lua:385: in function <...hare/nvim/lazy/project.nvim/lua/project/util/history.lua:380>
Relevant code
In
lua/fidget/notification/model.lua: