From 8e0d7b2eeceed5399a71c51001f4e26bd9dc13bd Mon Sep 17 00:00:00 2001 From: hyzen Date: Wed, 1 Jul 2026 04:07:02 +0530 Subject: [PATCH] Fix: alpha not showed in new tabs if nvim started with a filename in command, i.e nvim file.txt --- lua/alpha_fix.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lua/alpha_fix.lua b/lua/alpha_fix.lua index 5d4bab0..aadb38a 100644 --- a/lua/alpha_fix.lua +++ b/lua/alpha_fix.lua @@ -1,9 +1,12 @@ -- Manages Alpha refresh when switching and preserves ASCII art +-- Temporarily unlist other buffers so alpha.start(true) isn't skipped +-- when other tabs have real files open, then restore them after. +-- Also bypass argc()>0, which alpha's own should_skip_alpha() checks +-- first -- this stays true for the whole session if nvim was launched +-- as `nvim file.txt`, blocking alpha.start(true) everywhere afterward. _G.alpha_tab_ascii = {} --- Temporarily unlist other buffers so alpha.start(true) isn't skipped --- when other tabs have real files open, then restore them after local function force_alpha_start() local alpha_loaded, alpha = pcall(require, 'alpha') if not alpha_loaded then @@ -19,7 +22,15 @@ local function force_alpha_start() end end - alpha.start(true) + local orig_argc = vim.fn.argc + vim.fn.argc = function(...) + return 0 + end + local ok = pcall(alpha.start, true) + vim.fn.argc = orig_argc + if not ok then + vim.notify('Failed to start Alpha', vim.log.levels.ERROR) + end for _, buf in ipairs(restore) do if vim.api.nvim_buf_is_valid(buf) then @@ -91,9 +102,6 @@ vim.api.nvim_create_autocmd('TabEnter', { }) -- Clean --- here is the tab's position number, not its handle, so we --- can't use it to key into alpha_tab_ascii directly. Prune any cached --- handle that's no longer a live tabpage instead. vim.api.nvim_create_autocmd('TabClosed', { pattern = '*', callback = function()