From c3fe4cdc58e13bfe85f53daf959bca059a1e13a5 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 15 Nov 2023 13:22:19 +0100 Subject: [PATCH] nvim: Add mapping to toggle buffer diagnostics If you want to hide buffer diagnostics for any reason, there is now a quick mapping reachable through the usual lsp submenu: `lo` (I suppose the mnemonic would be 'lsp off'). It toggles them enabled and disabled and only affects the current buffer. --- nvim/.config/nvim/lua/plugins/config/lsp.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nvim/.config/nvim/lua/plugins/config/lsp.lua b/nvim/.config/nvim/lua/plugins/config/lsp.lua index b537c7f..cb75d7d 100644 --- a/nvim/.config/nvim/lua/plugins/config/lsp.lua +++ b/nvim/.config/nvim/lua/plugins/config/lsp.lua @@ -109,6 +109,13 @@ local function on_attach(client, bufnr) "lua vim.lsp.buf.signature_help()", { buffer = bufnr, desc = "Signature help" } ) + map("n", "lo", function() + if vim.diagnostic.is_disabled(0) then + vim.diagnostic.enable(0) + else + vim.diagnostic.disable(0) + end + end, { buffer = bufnr, desc = "Disable buffer diagnostics" }) if vim.g.format_on_save then require("lsp-setup.utils").format_on_save(client)