Skip to content

Commit

Permalink
only skip alpha when listed buffers are associated with windows
Browse files Browse the repository at this point in the history
  • Loading branch information
goolord committed Sep 14, 2023
1 parent 712dc1d commit 2348221
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lua/alpha.lua
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,12 @@ local function should_skip_alpha()
if #lines > 1 or (#lines == 1 and lines[1]:len() > 0) then return true end

-- Skip when there are several listed buffers.
local listed_buffers = vim.tbl_filter(function (buf_id)
return vim.fn.buflisted(buf_id) == 1
end, vim.api.nvim_list_bufs())
if #listed_buffers > 1 then return true end
for _, buf_id in pairs(vim.api.nvim_list_bufs()) do
local bufinfo = vim.fn.getbufinfo(buf_id)
if bufinfo.listed == 1 and #bufinfo.windows > 0
then return true
end
end

-- Handle nvim -M
if not vim.o.modifiable then return true end
Expand Down

3 comments on commit 2348221

@JosefLitos
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please make this an option - now using % in shada shows alpha again, although I already have files opened.

@goolord
Copy link
Owner Author

@goolord goolord commented on 2348221 Sep 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused, alpha is opening while you would have buffers open and visible to you? or do you just not want alpha to open when % loads files in the background? I've now gotten 2 requests for conflicting behavior because of this setting and I'm not sure how to accommodate both, especially because I don't understand the use case of this neovim setting I think. when would alpha even ever open on startup with % in shada? @JosefLitos

@JosefLitos
Copy link

@JosefLitos JosefLitos commented on 2348221 Sep 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it always opened, no matter the settings. I never found a way to not show alpha upon require'alpha'.setup(...). In the last couple of commits, it stopped showing up when I had buffers previously opened, which was great. % is like a default session that automatically gets saved and loaded as you close or open neovim. I think the easiest would be to give a config option (fun(): boolean) for initial start that would determine the behaviour. Something like initial_open.

Please sign in to comment.