trouble.nvim
trouble.nvim copied to clipboard
bug: `use_diagnostic_signs = true` no longer works due to a recent Neovim change (0.10+)
Did you check docs and existing issues?
- [X] I have read all the trouble.nvim docs
- [X] I have searched the existing issues of trouble.nvim
- [X] I have searched the existing issues of plugins related to this issue
Neovim version (nvim -v)
NVIM v0.10.0-dev-1856+gf4f7e2946-dirty
Operating system/version
Gentoo Linux
Describe the bug
Due to a recent change in Neovim (https://github.com/neovim/neovim/pull/26193 I believe), diagnostics signs are now configured differently.
As a result, trouble displays "E" ; "W" ; "H" ; "I" letters instead of respective configured signs, despite using use_diagnostic_signs = true
.
Steps To Reproduce
- trouble config:
return {
"folke/trouble.nvim",
cmd = { "Trouble", "TroubleToggle" },
dependencies = "nvim-tree/nvim-web-devicons",
opts = {
use_diagnostic_signs = true, -- Use the signs already defined in LSP
},
}
-
neovim/nvim-lspconfig
config:
return {
"neovim/nvim-lspconfig",
event = { "BufReadPre", "BufNewFile" },
config = function()
vim.diagnostic.config({
signs = {
text = {
[vim.diagnostic.severity.ERROR] = " ",
[vim.diagnostic.severity.WARN] = " ",
[vim.diagnostic.severity.INFO] = " ",
[vim.diagnostic.severity.HINT] = " ",
},
},
})
end,
}
- Using Neovim nightly, trigger a diagnostic in any file
- The diagnostic sign is correctly displayed in the SignColumn
- Open trouble with
:Trouble
- The default letter is displayed in trouble instead of the configured sign:
Expected Behavior
trouble displays signs instead of letters
Repro
No response
Note that with https://github.com/neovim/neovim/pull/26618, https://github.com/neovim/neovim/pull/26193 is no longer a breaking change. Plugins should still migrate to the new configuration format, but there is no immediate need to do so.
I have a neovim config only using the new way to define diagnostic signs, so I decided to fix this by myself. You can see my pr above. Feel free to checkout and give your feedback.
I have a neovim config only using the new way to define diagnostic signs, so I decided to fix this by myself. You can see my pr above. Feel free to checkout and give your feedback.
Thanks for the PR. I've just tried it, works fine here:
% nvim --version
NVIM v0.10.0-dev-2678+g3d9c028a4-dirty
Development on the main branch is EOL.
Trouble has been rewritten and will be merged in main soon.
This issue/feature either no longer exists or has been implemented on dev.
For more info, see https://github.com/folke/trouble.nvim/tree/dev
Dear @folke is it possible that it is not yet enabled on dev
branch? (I still see the E/W letters instead of icons).
Thanks
Trouble now always uses the configured Neovim diagnostic signs.
I configured neovim diagnostics, but somehow they are not picked up (just moved to dev
today)
Did you use vim.diagnostic.config
? And not sign_define
? sign_define is deprecated
No, could find that in the dev docs. Could you point me there?
In the lsp handlers I have
vim.diagnostic.config(lsp.diagnostic)
Can you show me the exact table you pass to diagnostics config?
Interestingly, everything works on NVIM v0.9.5 Build type: Release LuaJIT 2.1.1713773202,
but it fails on NVIM v0.10.0-dev Build type: RelWithDebInfo, LuaJIT 2.1.0-beta3.
The table you asked for:
local M = {}
function M.setup()
-- LSP handlers configuration
local lsp = {
float = {
focusable = true,
style = "minimal",
border = "rounded",
},
diagnostic = {
-- virtual_text = true,
virtual_text = { spacing = 4, prefix = "●" },
underline = true,
update_in_insert = false,
severity_sort = true,
float = {
focusable = true,
style = "minimal",
border = "rounded",
},
},
}
-- Diagnostic signs
local diagnostic_signs = {
{
name = "DiagnosticSignError",
text = ""
},
{
name = "DiagnosticSignWarn",
-- text = ""
text = ""
},
{
name = "DiagnosticSignHint",
text = ""
},
{
name = "DiagnosticSignInfo",
text = ""
},
}
for _, sign in ipairs(diagnostic_signs) do
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = sign.name })
end
-- Diagnostic configuration
vim.diagnostic.config(lsp.diagnostic)
-- Hover configuration
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, lsp.float)
-- Signature help configuration
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, lsp.float)
end
return M
like I said, on 0.10
, you need to pass signs
as an option to vim.diagnostic.config
. Please check the docs.
So no sign_define