numToStr / FTerm.nvim

:fire: No-nonsense floating terminal plugin for neovim :fire:
MIT License
721 stars 24 forks source link

Reroute anything that opens in fterm window to another window #67

Closed utilyre closed 1 year ago

utilyre commented 1 year ago

One thing that I really like about nvim-tree.lua is that when ever I try to open a file inside its window, it'll open it up inside another window.

This behavior is extremely helpful especially in a terminal window. I have git setup to open the COMMIT buffer directly in neovim when it is a subprocess of another neovim process (rather than having a new instance of neovim nested in the integrated terminal) but my problem is that right after I run git commit to edit my commit message in neovim, the buffer will be opened inside the floating terminal window instead of a sensible window for example a window that contains a buffer with vim.bo.buftype equal to ""

numToStr commented 1 year ago

I understood your point but what about when you finish the gitcommit message, should the floating terminal reopen? Does this behavior only affect gitcommit buftype? There are bunch of cases that need to be handled. And TBH this doesn't bother me that much so I won't try to fix this, but I am happy If someone can start a PR so that we can talk about the implementation and some bike shedding.

utilyre commented 1 year ago

Since this project aims to be a minimal terminal wrapper I don't think the terminal should reopen so for example the user can have his own keymap to reopen the last terminal.

And no this isn't only useful for the gitcommit filetype. Another scenario is when someone prefers to have a telescope keymap in terminal mode so it makes it a little more convenient to access his files. In this case if fterm opens that file in another window becomes very nice.

In my point of view something like fterm which is a terminal wrapper should prevent any other kind of buffer from opening in its window, otherwise it is unexpected behavior.

numToStr commented 1 year ago

Since this project aims to be a minimal terminal wrapper I don't think the terminal should reopen so for example the user can have his own keymap to reopen the last terminal.

In my point of view something like fterm which is a terminal wrapper should prevent any other kind of buffer from opening in its window, otherwise it is unexpected behavior.

I would also argue that being a minimal terminal wrapper it doesn't make that much sense to control what happens inside the terminal.

Another scenario is when someone prefers to have a telescope keymap in terminal mode so it makes it a little more convenient to access his files. In this case if fterm opens that file in another window becomes very nice.

Well, you could make a mapping to close the terminal first and then open telescope.


Also, you could try https://github.com/akinsho/toggleterm.nvim which is more feature rich terminal plugin.

samjwill commented 1 year ago

Hi! I stumbled on this issue, and thought I might be able to provide some input, since it's been determined that the issue is mostly out of scope for FTerm.nvim itself.

I recently added a wiki page for a plugin I made called nvim-unception about how you can get it working with FTerm in order to achieve some of the desired behavior. Basically, any ordinary files opened from FTerm's floating terminal with Neovim can be opened in new tabs for the existing session.

It still will not work with git commit buffers however, since the commit is abandoned when the commit buffer closes initially in the nested terminal session. Edit: Works now!