toggle lsp with <leader>vt

This commit is contained in:
Anish L 2022-04-02 21:14:22 +10:00
parent b99aa1318e
commit 78e7bddc08

View file

@ -321,6 +321,27 @@ in
-- severity_limit = { "Error" }
-- }
-- })
vim.g.diagnostics_active = true
function _G.toggle_diagnostics()
if vim.g.diagnostics_active then
vim.g.diagnostics_active = false
vim.lsp.diagnostic.clear(0)
vim.lsp.handlers["textDocument/publishDiagnostics"] = function() end
else
vim.g.diagnostics_active = true
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = true,
signs = true,
underline = true,
update_in_insert = false,
}
)
end
end
vim.api.nvim_set_keymap('n', '<leader>vt', ':call v:lua.toggle_diagnostics()<CR>', {noremap = true, silent = true})
-- autopairs
require('nvim-autopairs').setup{}