I wish I could filter by severity like I do for virtualtext
vim.diagnostic.config({
virtual_text = {
severity = { min = vim.diagnostic.severity.WARN }
},
})
Actually maybe lsp_lines could read its filter from the virtual_text one. Right now I've hardcoded the change as:
diff --git a/lua/lsp_lines/init.lua b/lua/lsp_lines/init.lua
index 50a2ff3..c305920 100644
--- a/lua/lsp_lines/init.lua
+++ b/lua/lsp_lines/init.lua
@@ -45,7 +45,9 @@ M.register_lsp_virtual_lines = function()
vim.api.nvim_buf_clear_namespace(bufnr, virt_lines_ns, 0, -1)
- for i, diagnostic in ipairs(diagnostics) do
+ -- local filter_by_severity = filter_by_severity(
+ local diagnostics2 = vim.tbl_filter(function(t) return t.severity <= vim.diagnostic.severity.WARN end, diagnostics)
+ for i, diagnostic in ipairs(diagnostics2) do
vim.api.nvim_buf_set_extmark(bufnr, virt_lines_ns, diagnostic.lnum, 0, {
id = i,
virt_lines = {
to get rid of the annoying hints from pyright
Sounds reasonable. Don't think I'll have time to implement it soon.
Regrettably,
filter_by_severity
is not exported fromruntime/lua/vim/diagnostic.lua
, so likely need to be either exported, or copy-pasted out.
I opened https://lists.sr.ht/~whynothugo/lsp_lines.nvim/patches/40180 to support this
This is likely best implemented in neovim itself before it hands over diagnostics to handlers. See https://github.com/neovim/neovim/pull/23751#issuecomment-1563498953