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

fix: do not defer notify when nvim is running in a headless mode #227

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion lua/notify/init.lua
Expand Up @@ -3,6 +3,7 @@

local config = require("notify.config")
local instance = require("notify.instance")
local headless = (#vim.api.nvim_list_uis() == 0)

---@class notify
local notify = {}
Expand Down Expand Up @@ -186,7 +187,7 @@ end

setmetatable(notify, {
__call = function(_, m, l, o)
if vim.in_fast_event() or vim.fn.has("vim_starting") == 1 then
if vim.in_fast_event() or (not headless and vim.fn.has("vim_starting") == 1) then
vim.schedule(function()
notify.notify(m, l, o)
end)
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/init_spec.lua
Expand Up @@ -62,6 +62,8 @@ describe("checking public interface", function()
it("inherits options", function()
local orig = notify("first", "info", { title = "test", icon = "x" })
local next = notify("second", nil, { replace = orig })
assert.Not.Nil(orig)
assert.Not.Nil(next)

assert.are.same(
next,
Expand All @@ -71,6 +73,7 @@ describe("checking public interface", function()

a.it("uses same window", function()
local orig = async_notify("first", "info", { timeout = false })
assert.Not.Nil(orig)
local win = orig.events.open()
async_notify("second", nil, { replace = orig, timeout = 100 })
async.util.scheduler()
Expand Down