nvimdev / dashboard-nvim

vim dashboard
MIT License
2.19k stars 177 forks source link

Restore user's UI options when switching tabs #455

Closed jbarap closed 1 month ago

jbarap commented 1 month ago

Currently, if the user has opts.hide.statusline or opts.hide.tabline enabled, as long as a dashboard buffer exists, the user's UI components will stay hidden.

This results in the following workflow behaving strangely:

  1. Open neovim to show dashboard
    • If you chose to hide tabline/statusline, they will be hidden to get a clean look
  2. Run a command that creates a new tab (e.g. "DiffViewOpen"), or create a tab yourself
  3. Watch as contents are filled in the new tab, but you still have your tabline/statusline hidden

This PR stores the user's UI preferences when starting a dashboard, and restores the user's UI settings every time he/she switches to a tab where there's no dashboard buffer visible.

Before (no tabline/statusline after running DiffViewFileHistory): image

After (the expected tabline/statusline load when dashboard isn't visible): image

Feel free to close the PR if you have a nicer solution in mind or if you find edge cases with this approach.

folke commented 1 month ago

The result of this PR is now exactly what you're trying to prevent for LazyVim and others. We're now no longer seeing the statusline after exiting the dashboard.

glepnir commented 1 month ago

oh ..i don't look it carefully revert then.

jbarap commented 1 month ago

@folke can you elaborate? I'd like to find a way to change this behavior without breaking stuff and It'd be helpful to know how LazyVim breaks.

folke commented 1 month ago

In LazyVim we have hide.statusline = false, so hiding is disabled. We did that because it caused issues when opening a file from the cmdline.

See https://github.com/LazyVim/LazyVim/blob/ae381c91a1ec420cce082443501bace1ac7aaa3f/lua/lazyvim/plugins/ui.lua#L357

And

https://github.com/LazyVim/LazyVim/blob/ae381c91a1ec420cce082443501bace1ac7aaa3f/lua/lazyvim/plugins/ui.lua#L113-L129

folke commented 1 month ago

So for our use-case there's just nothing that should be restored?

folke commented 1 month ago

In LazyVim, lualine does already load, but we added dashboard to disabled filetypes. vim.o.laststatus = 3 still.

So again, I think the problem with this PR is that settings are supposedly restored, while I explicitely tell dashboard to not touch my statusline.

jbarap commented 1 month ago

Got it. I missed the check for the setting before attempting to restore the settings, sorry for breaking LazyVim! Can you check if #458 solves it?

folke commented 1 month ago

Yep, all good now!