Skip to content

Commit

Permalink
fix(ui): open with noautocmd=true and close with vim.schedule to prev…
Browse files Browse the repository at this point in the history
…ent weird errors by other plugins
  • Loading branch information
folke committed Dec 5, 2022
1 parent 836cdb2 commit 08d081f
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lua/lazy/view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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, {
Expand Down

0 comments on commit 08d081f

Please sign in to comment.