nvim-notify icon indicating copy to clipboard operation
nvim-notify copied to clipboard

No matching notification found to replace

Open rickalex21 opened this issue 1 year ago • 3 comments

Hello, my configuration has been working fine for a while now. All of the sudden I started to get this message. I'm not sure what this means or where to fix it?

023-02-23T21:58:44 lua_ls: Loading workspace ⣾ INFO 100%       65/65                                                                                                         
2023-02-23T21:58:44 lua_ls: Loading workspace ⣾ INFO 95%        89/93                                                                                                         
2023-02-23T21:58:44  INFO No matching notification found to replace                                                                                                          
2023-02-23T21:58:44  INFO No matching notification found to replace                                                                                                          
Press ENTER or type command to continue         

This is might be of interest I don't know.

	if val.kind == "begin" then
		local message = format_message(val.message, val.percentage)

		notif_data.notification = vim.notify(message, "info", {
			title = format_title(val.title, vim.lsp.get_client_by_id(client_id).name),
			icon = spinner_frames[1],
			timeout = 100,
			hide_from_history = false,
		})
-- .......

Thanks

rickalex21 avatar Feb 24 '23 04:02 rickalex21

Hi, could you try this:

if val.kind == "begin" then
local message = format_message(val.message, val.percentage)

notif_data.notification = vim.notify(message, "info", {
	title = format_title(val.title, vim.lsp.get_client_by_id(client_id).name),
	icon = spinner_frames[1],
	timeout = 100,
	hide_from_history = false,
	replace = notif_data.notification.id -- <--- This will hopefully help resolve the issue
})

dmmulroy avatar May 10 '23 11:05 dmmulroy

In my case I wanted to show notifications that are dismissed after 2000ms, also I wanted to reuse same notification as I run this function multiple times. The workaround for me was to clean up notification record on_close

local notifications = {}

local function toggle_theme()
  -- code to toggle theme
  local options = {
    title = 'Colorscheme',
    timeout = 2000,
    replace = notifications.current,
    hide_from_history = true,
    animate = true,
    render = 'compact',
    on_close = function() notifications.current = nil end, -- this line will fix the error
  }
  notifications.current = vim.notify(vim.g.current_theme .. ' set', vim.log.levels.INFO, options)
end

yogeshlonkar avatar Dec 09 '23 14:12 yogeshlonkar

@dmmulroy I tried adding that line, I see the lsp Undefined field id, now getting this error:

notify.lua:111: attempt to index field 'notification' (a nil value)  

Which is an error pointing to the line added.

Here is the full code:

vim.lsp.handlers["$/progress"] = function(_, result, ctx)
	local client_id = ctx.client_id

	local val = result.value

	if not val.kind then
		return
	end
	local client_name = vim.lsp.get_client_by_id(client_id).name
	if client_name == "null-ls" then
		return
	end
	-- if title == "null-ls"

	local notif_data = get_notif_data(client_id, result.token)

	if val.kind == "begin" then
		local message = format_message(val.message, val.percentage)

		notif_data.notification = vim.notify(message, "info", {
			title = format_title(val.title, vim.lsp.get_client_by_id(client_id).name),
			icon = spinner_frames[1],
			timeout = 100,
			hide_from_history = false,
		})

		notif_data.spinner = 1
		update_spinner(client_id, result.token)
	elseif val.kind == "report" and notif_data then
		notif_data.notification = vim.notify(format_message(val.message, val.percentage), "info", {
			replace = notif_data.notification,
			hide_from_history = false,
		})
	elseif val.kind == "end" and notif_data then
		notif_data.notification = vim.notify(val.message and format_message(val.message) or "Complete", "info", {
			icon = "",
			replace = notif_data.notification,
			timeout = 100,
		})

		notif_data.spinner = nil
	end
end

rickalex21 avatar May 21 '24 22:05 rickalex21