filter by severity

I wish I could filter by severity like I do for virtualtext

  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

Assigned to
1 year, 8 months ago
4 months ago
No labels applied.

~whynothugo 1 year, 8 months ago

Sounds reasonable. Don't think I'll have time to implement it soon.

Regrettably, filter_by_severity is not exported from runtime/lua/vim/diagnostic.lua, so likely need to be either exported, or copy-pasted out.

~acksld 5 months ago

~whynothugo 4 months ago

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

Register here or Log in to comment, or comment via email.