From b61d28ad4b8b1e2b66060c807aeb254e9b0df433 Mon Sep 17 00:00:00 2001 From: haorenW1025 Date: Tue, 15 Sep 2020 20:51:12 +0800 Subject: [PATCH] fix: not properly fix the overwriting issue --- lua/diagnostic.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/diagnostic.lua b/lua/diagnostic.lua index 667c380..85a6ab6 100644 --- a/lua/diagnostic.lua +++ b/lua/diagnostic.lua @@ -77,7 +77,6 @@ function M.publish_diagnostics(bufnr) local diagnostics = vim.lsp.util.diagnostics_by_buf[bufnr] if diagnostics == nil then return end util.align_diagnostic_indices(diagnostics) - vim.fn.setloclist(0, {}, 'r') if vim.api.nvim_get_var('diagnostic_enable_underline') == 1 then vim.lsp.util.buf_diagnostics_underline(bufnr, diagnostics) end @@ -87,7 +86,10 @@ function M.publish_diagnostics(bufnr) if vim.api.nvim_get_var('diagnostic_enable_virtual_text') == 1 then util.buf_diagnostics_virtual_text(bufnr, diagnostics) end - M.diagnostics_loclist(diagnostics) + if #vim.fn.getloclist(vim.fn.winnr()) == 0 then + vim.fn.setloclist(0, {}, 'r') + M.diagnostics_loclist(diagnostics) + end M.trigger_diagnostics_changed() end