From b11cf10e31efc24a1957bc68a21be14f180871aa Mon Sep 17 00:00:00 2001 From: Stevan Freeborn Date: Tue, 21 Jul 2026 09:31:54 -0500 Subject: [PATCH] feat: add keymap for copying diagnostics for buffer --- lua/plugins/lsp.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index a060036..e5ede24 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -452,6 +452,29 @@ return { { desc = "Display errors for current buffer", buffer = ev.buf } ) + vim.keymap.set("n", "eca", function() + local diagnostics = vim.diagnostic.get(0) + + if #diagnostics == 0 then + vim.notify("No diagnostics in buffer", vim.log.levels.INFO) + return + end + + local lines = vim.tbl_map(function(d) + return string.format( + "%s:%d %s", + vim.fs.basename(vim.api.nvim_buf_get_name(d.bufnr)), + d.lnum + 1, + d.message + ) + end, diagnostics) + + vim.fn.setreg("+", table.concat(lines, "\n")) + + vim.notify(string.format("Copied %d diagnostics to clipboard", #diagnostics)) + + end, { desc = "Copy buffer diagnostics to clipboard", buffer = ev.buf }) + vim.keymap.set("n", "K", vim.lsp.buf.hover, { desc = "Display symbol info", buffer = ev.buf }) end, })