From 08d081f21d9b54ed0b20e9a94050e3b39c75de19 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 5 Dec 2022 22:30:02 +0100 Subject: [PATCH] fix(ui): open with noautocmd=true and close with vim.schedule to prevent weird errors by other plugins --- lua/lazy/view/init.lua | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lua/lazy/view/init.lua b/lua/lazy/view/init.lua index e9fd17b..cb0bb2b 100644 --- a/lua/lazy/view/init.lua +++ b/lua/lazy/view/init.lua @@ -57,6 +57,7 @@ function M.show(mode) border = Config.options.ui.border, width = math.min(vim.o.columns - hpad * 2, 200), height = math.min(vim.o.lines - vpad * 2, 70), + noautocmd = true, } opts.row = (vim.o.lines - opts.height) / 2 opts.col = (vim.o.columns - opts.width) / 2 @@ -75,16 +76,14 @@ function M.show(mode) local function close() M._buf = nil vim.diagnostic.reset(Config.ns, buf) - - if vim.api.nvim_buf_is_valid(buf) then - vim.api.nvim_buf_delete(buf, { - force = true, - }) - end - - if vim.api.nvim_win_is_valid(win) then - vim.api.nvim_win_close(win, true) - end + vim.schedule(function() + if vim.api.nvim_buf_is_valid(buf) then + vim.api.nvim_buf_delete(buf, { force = true }) + end + if vim.api.nvim_win_is_valid(win) then + vim.api.nvim_win_close(win, true) + end + end) end vim.keymap.set("n", "q", close, {