From b1dfcabba1d24adc8d5575a5e1c96f1e59b6a994 Mon Sep 17 00:00:00 2001 From: Kiyan Date: Sun, 8 May 2022 11:40:53 +0200 Subject: [PATCH] chore(diagnostics): clear whole group instead of keeping a table (#1241) --- lua/nvim-tree/diagnostics.lua | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/lua/nvim-tree/diagnostics.lua b/lua/nvim-tree/diagnostics.lua index 68eca126..50f85140 100644 --- a/lua/nvim-tree/diagnostics.lua +++ b/lua/nvim-tree/diagnostics.lua @@ -6,6 +6,8 @@ local log = require "nvim-tree.log" local M = {} +local GROUP = "NvimTreeDiagnosticSigns" + local function get_lowest_severity(diagnostics) local severity = math.huge for _, v in ipairs(diagnostics) do @@ -24,15 +26,13 @@ local sign_names = { { "NvimTreeSignHint", "NvimTreeLspDiagnosticsHint" }, } -local signs = {} - local function add_sign(linenr, severity) local buf = view.get_bufnr() if not a.nvim_buf_is_valid(buf) or not a.nvim_buf_is_loaded(buf) then return end local sign_name = sign_names[severity][1] - table.insert(signs, vim.fn.sign_place(1, "NvimTreeDiagnosticSigns", sign_name, buf, { lnum = linenr + 1 })) + vim.fn.sign_place(1, GROUP, sign_name, buf, { lnum = linenr + 1 }) end local function from_nvim_lsp() @@ -109,16 +109,7 @@ function M.clear() return end - if #signs then - vim.fn.sign_unplacelist(vim.tbl_map(function(sign) - return { - buffer = view.get_bufnr(), - group = "NvimTreeDiagnosticSigns", - id = sign, - } - end, signs)) - signs = {} - end + vim.fn.sign_unplace(GROUP) end function M.update()