changeset 364:f300ef1bc475

Do not run LSP diagnostics while in insert mode Should help keeping the load down
author Zeger Van de Vannet <zegervdv@me.com>
date Fri, 19 Mar 2021 17:55:02 +0100
parents db80c8ac727d
children d8216ea00ad1
files dot_config/nvim/config.lua
diffstat 1 files changed, 18 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/dot_config/nvim/config.lua	Tue Mar 16 12:23:12 2021 +0100
+++ b/dot_config/nvim/config.lua	Fri Mar 19 17:55:02 2021 +0100
@@ -454,20 +454,27 @@
 
 
 vim.lsp.handlers["textDocument/formatting"] = function(err, _, result, _, bufnr)
-    if err ~= nil or result == nil then
-        return
-    end
-    if not vim.api.nvim_buf_get_option(bufnr, "modified") then
-        local view = vim.fn.winsaveview()
-        vim.lsp.util.apply_text_edits(result, bufnr)
-        -- Fix to reload Treesitter
-        -- vim.api.nvim_command("edit")
-        vim.fn.winrestview(view)
-    end
+  if err ~= nil or result == nil then
+    return
+  end
+  if not vim.api.nvim_buf_get_option(bufnr, "modified") then
+    local view = vim.fn.winsaveview()
+    vim.lsp.util.apply_text_edits(result, bufnr)
+    -- Fix to reload Treesitter
+    -- vim.api.nvim_command("edit")
+    vim.fn.winrestview(view)
+  end
+end
+
+vim.lsp.handlers["textDocument/publishDiagnostics"] = function(...)
+  vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
+    underline = true,
+    update_in_insert = false
+  })(...)
 end
 
 lsp.pyright.setup{
-    on_attach = on_attach;
+  on_attach = on_attach;
 }
 
 if (vim.fn.executable('efm-langserver') == 1) then