noice.nvim icon indicating copy to clipboard operation
noice.nvim copied to clipboard

bug: todo-comments causes false error notifications

Open jackwoodside opened this issue 1 year ago • 4 comments

Did you check docs and existing issues?

  • [X] I have read all the noice.nvim docs
  • [X] I have searched the existing issues of noice.nvim
  • [X] I have searched the exsiting issues of plugins related to this issue

Neovim version (nvim -v)

0.8.1

Operating system/version

Ubuntu 18.04.6

Describe the bug

When todo-comments is installed, the first notification sent after writing a file is always an error. This doesn't happen without todo-comments installed, and it doesn't happen if todo-comments is installed but noice isn't.

As a side note, the prefilled repro.lua given in the issue template is different from the wiki, and is missing the dependencies.

Steps To Reproduce

  1. Save the repro.lua below and open it with nvim -u repro.lua repro.lua.
  2. Write the file with :w.
  3. Press d10d to delete 10 lines and then u to bring them back, giving notifications that are marked as messages.
  4. Press :w to write the buffer.
  5. Repeat step 3, noticing that the notification is now marked as an error.
  6. Repeating step 3 again without writing, the notifications are again marked as messages.
  7. Remove todo-comments from repro.lua and repeat the above, the issue will disappear.

Expected Behavior

I'd expect notifications to behave as they do normally, such as if todo-comments is removed from the repro.lua below.

Repro

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
	vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
	vim.fn.system({
		"git",
		"clone",
		"--filter=blob:none",
		"--single-branch",
		"https://github.com/folke/lazy.nvim.git",
		lazypath,
	})
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
	"folke/tokyonight.nvim",
	{
		"folke/noice.nvim",
		dependencies = {
			"MunifTanjim/nui.nvim",
			"rcarriga/nvim-notify",
		},
	},
	{
		"folke/todo-comments.nvim",
		config = function()
			require("todo-comments").setup()
		end,
	},
}
require("lazy").setup(plugins, {
	root = root .. "/plugins",
})

-- add anything else here
vim.opt.termguicolors = true
vim.cmd([[colorscheme tokyonight]])
require("noice").setup()

jackwoodside avatar Feb 13 '23 10:02 jackwoodside

was just about opening an issue for this before i saw yours and it helped me figure out the problem i have been trying to solve. i get the same error message whenever i write into the same file for the second time. The error message is identical to the message you get whenever you write into a file. i just disabled todo and the error disappeared. noice

oyinbra avatar Feb 28 '23 18:02 oyinbra

I'm getting the same error

haru02w avatar May 23 '23 21:05 haru02w

Met the same issue. The first notification will always be "ERROR", but actually the notification should be "INFO".

tan-wei avatar Dec 23 '23 08:12 tan-wei

I'm getting the same error local opts = { noremap = true, -- non-recursive silent = true, -- do not show message } vim.keymap.set('n', "S", ':w<CR>', opts)

But I changed the write file mapping as follows and got the solution

vim.keymap.set('n', "S", ':w<CR>') But every time the shortcut key is written to a file, the cmd command will flash, which is not perfect.

xiaozhang1990 avatar May 13 '24 08:05 xiaozhang1990