Closed kiyoon closed 3 weeks ago
If you do it like that then trouble can't intercept notifications, so yes, that's an error
Here's my proposal. Don't worry if it's not what you want.
M = {}
local status2, vscode = pcall(require, "vscode")
if status2 then
---@param message string|string[]
M.notify = function(message, level, opts)
if type(message) == "table" then
message = table.concat(message, "\n")
end
vscode.notify(message, level)
end
else
local status, nvim_notify = pcall(require, "notify")
if status then
---@param message string|string[]
M.notify = function(message, level, opts)
if type(message) == "string" then
message = vim.split(message, "\n")
end
nvim_notify(message, level, opts)
end
else
M.notify = vim.notify
end
end
return M
require("trouble.notify").notify("Now you can\ndo\nmultiline", "info")
I think vscode.notify can't handle tables and nvim-notify can't handle multiline strings.
Did you check docs and existing issues?
Neovim version (nvim -v)
NVIM v0.10.0
Operating system/version
MacOS 14.4.1
Describe the bug
In https://github.com/rcarriga/nvim-notify, it demonstrates that we can override
vim.notify
to theirs.However, if you set it like this, the trouble notifications result in an error. It's due to a slightly different interface they have. I know it's not ideal to remap such a command but it is a widely-used plugin so I thought others would be wondering about it, thus reporting it :)
To address this, maybe trouble.nvim can check
require("notify")
and send the notification via the plugin, otherwise usevim.notify
Steps To Reproduce
require("trouble.providers.telescope").open_with_trouble()
Expected Behavior
No error should be thrown.
Repro
No response