From 1fe43f3e294cf994a52d25e16dc630e66db2970c Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 19 Dec 2022 12:20:02 +0100 Subject: [PATCH] fix(ui): focus Lazy window when auto-installing plugins in `VimEnter` --- lua/lazy/view/init.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lua/lazy/view/init.lua b/lua/lazy/view/init.lua index df0d2a5a..04dd42dc 100644 --- a/lua/lazy/view/init.lua +++ b/lua/lazy/view/init.lua @@ -65,9 +65,19 @@ function M.show(mode) opts.col = (vim.o.columns - opts.width) / 2 local win = vim.api.nvim_open_win(buf, true, opts) M._win = win - vim.api.nvim_set_current_win(win) + -- it seems that setting the current win doesn't work before VimEnter, + -- so do that then + if vim.v.vim_did_enter ~= 1 then + vim.api.nvim_create_autocmd("VimEnter", { + once = true, + callback = function() + vim.api.nvim_set_current_win(win) + end, + }) + end + vim.bo[buf].buftype = "nofile" vim.bo[buf].bufhidden = "wipe" vim.wo[win].conceallevel = 3