willothy / flatten.nvim

Open files and command output from wezterm, kitty, and neovim terminals in your current neovim instance
https://luarocks.org/modules/willothy/flatten.nvim
MIT License
473 stars 13 forks source link

Doesn't seem to work when using tmux inside of the nested terminal #97

Open brandonpollack23 opened 5 months ago

brandonpollack23 commented 5 months ago

Describe the bug I like to use tmux to save sessions for workspaces in neovim so it functions a bit more like vscode in that way with toggleterm.

When I do this the nesting doesnt work, even though vim.env.NVIM is set...not certain why. When I exit tmux it works just fine.

To Reproduce Steps to reproduce the behavior:

  1. open a toggle term
  2. start tmux
  3. try to open a file with the nvim command
  4. observer that vim.env.NVIM is set, but it didn't open in the 'alternate' window instead it just opened inside the terminal.

Expected behavior Works just like without tmux

willothy commented 4 months ago

Hmm I'm not a big tmux user so haven't run into this, but i'll look into it! It would definitely be good to have tmux integration equivalent to the kitty and wezterm integrations.

brandonpollack23 commented 4 months ago

Appreciated! Let me know if there is anything I can do to help

willothy commented 4 months ago

This actually seems to work just fine for me... mind sharing your config?

brandonpollack23 commented 4 months ago

Narrowwed it down some, I am getting a failed pcall to vim.fn.sockconnect in guest.lua it seems.

My config is here: github.com/brandonpollack23/rcfiles under ".config/nvim"

It is a total mess so sorry in advance.

brandonpollack23 commented 4 months ago

I have a theory, I think it is because I automatically generate the session name in a way that causes conflicts if I have multiple sessions created by neovim, so I need a more unique name (I'm trying to open the file in the wrong socket)

brandonpollack23 commented 4 months ago

Ok so it had something to do with that...at least something that fixed it for me was explicitly setting NVIM to vim.v.servername

I think my session was getting revived with old env vars or something? some Tmux thing I dont understand

willothy commented 4 months ago

Hmm interesting, $NVIM should always be set to vim.v.servername, but if that works then it works lol. I'll take a look at your config.

willothy commented 4 months ago

Can't really see anything wrong with your config and this works fine for me in tmux sessions... not quite sure what's going on. What exactly isn't working / what is the behavior you would expect?

brandonpollack23 commented 4 months ago

Yeah my config is updated now. The issue I think was the way I was creating sessions and not closing them and it kept the NVIM env var in the session I think. I think there should be guidance to ensure it is set like I do in my setup.

You can reproduce the issue if you don't do that,open a terminal, close nvim, reopen and open a terminal that connects to the same tmux session, then try

On Tue, Apr 16, 2024, 23:58 Will Hopkins @.***> wrote:

Can't really see anything wrong with your config and this works fine for me in tmux sessions... not quite sure what's going on. What exactly isn't working / what is the behavior you would expect?

— Reply to this email directly, view it on GitHub https://github.com/willothy/flatten.nvim/issues/97#issuecomment-2059985185, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBR327MBQEK2JEKPYXNBULY5WNIDAVCNFSM6AAAAABGCFV2NCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJZHE4DKMJYGU . You are receiving this because you authored the thread.Message ID: @.***>