From 6602eb6b45553f1480dd523f43554527d2f9554a Mon Sep 17 00:00:00 2001 From: Rafik Draoui Date: Thu, 4 Sep 2025 17:50:39 -0300 Subject: [PATCH] Add a delay before printing usage message Without this, the message is cleared before the UI is fully initialized. This also allows us to use the default INFO log level. Previously, using WARN level was required to make the message display. But now it seems like even WARN level is not enough to keep the message displayed. I'm not a fan of using those `time.sleep()`-type of "fixes". And it's possible that using a 100ms delay is not appropriate for all set ups, but just happens to work for me as of September 4 2025. But I don't have time right now to find a proper fix, let alone investigate and bisect when the behaviour changed in Neovim. This can be replicated with: $ nvim --clean --noplugin -c 'lua vim.notify("hello")' versus $ nvim --clean --noplugin -c 'lua vim.defer_fn(function() vim.notify("hello") end, 100)' The first one doesn't have any message in the `:messages` section, while the latter does (using Neovim v0.11.3). --- lua/jj-diffconflicts/init.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/jj-diffconflicts/init.lua b/lua/jj-diffconflicts/init.lua index eb4ff80..cd0bb84 100644 --- a/lua/jj-diffconflicts/init.lua +++ b/lua/jj-diffconflicts/init.lua @@ -295,9 +295,11 @@ h.setup_ui = function(conflicts, show_history, show_usage_message) -- Display usage message if show_usage_message then - vim.notify( - "Resolve conflicts leftward then save. Use :cq to abort.", - vim.log.levels.WARN + -- We defer printing the message by 100ms, otherwise it is cleared before + -- the UI is fully initialized + vim.defer_fn( + function() vim.notify("Resolve conflicts leftward then save. Use :cq to abort.") end, + 100 ) end end