Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Zen mode is closed upon toggling the terminal #398

Closed
4 tasks done
mohammad-amin-khajeh opened this issue Dec 27, 2024 · 5 comments
Closed
4 tasks done

bug: Zen mode is closed upon toggling the terminal #398

mohammad-amin-khajeh opened this issue Dec 27, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@mohammad-amin-khajeh
Copy link

Did you check docs and existing issues?

  • I have read all the snacks.nvim docs
  • I have updated the plugin to the latest version before submitting this issue
  • I have searched the existing issues of snacks.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM 0.10.2

Operating system/version

Arch linux kernel 6.12.4-zen1-1-zen

Describe the bug

opening the snacks terminal closes the zen mode.

demonstration

out.mp4

Steps To Reproduce

  1. go into zen mode
  2. open snacks terminal
  3. zen mode is closed

Expected Behavior

snacks terminal does nothing to zen mode and it is kept open.

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    { "folke/snacks.nvim", opts = {} },
    -- add any other plugins here
  },
})
@mohammad-amin-khajeh mohammad-amin-khajeh added the bug Something isn't working label Dec 27, 2024
@dpetka2001
Copy link
Contributor

That is intended behavior as the code here indicates. Whenever you enter another window such as a terminal and it's not a floating window then zen mode exits.

@mohammad-amin-khajeh
Copy link
Author

mohammad-amin-khajeh commented Dec 27, 2024

I see.

I can see how this would be helpful in some contexts like opening nvim-tree; but in this case isn't there a way to get around this behavior?
or at least some hacky way to get the job done?

In my workflow I tend to open and close the terminal a lot and so having to turn on zen mode every single time pretty much defeats the whole purpose of it.

@dpetka2001
Copy link
Contributor

Just open your terminal as a float window instead, since that doesn't seem to quit zen mode?

@mohammad-amin-khajeh
Copy link
Author

Yes I ended up doing that thanks for the suggestion.

For anyone wondering how to do it, your snacks config should look something like this:

opts = {
    terminal = {
      ---@class snacks.terminal.Config
      ---@field win? snacks.win.Config
      ---@field override? fun(cmd?: string|string[], opts?: snacks.terminal.Opts) Use this to use a different terminal implementation

      win = { position = "float" },
    },
  }

@dpetka2001
Copy link
Contributor

By doing it this way, you're changing the behavior for all terminal windows that are created with Snacks. This might be the behavior you want or might not. For example lazygit also opens in a terminal window but it's opened in a float window either way by default.

Personally I prefer to put these custom changes into styles myself, because that way only the windows with the selected style will be affected. So, I do

opts = {
  styles = {
    terminal = {
      position = "float",
    },
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants