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

Toggleable & spawnable terminal window buffer #6

Open
siduck opened this issue May 1, 2022 · 9 comments
Open

Toggleable & spawnable terminal window buffer #6

siduck opened this issue May 1, 2022 · 9 comments

Comments

@siduck
Copy link
Collaborator

siduck commented May 1, 2022

 mappings = {
    toggle = {
      float = "<A-i>",
      horizontal = "<A-h>",
      vertical = "<A-v>",
      window = "<A-w>"
    },
    new = {
      horizontal = "<C-h>",
      vertical = "<C-v>",
      window = "<C-w>",
    },
  },
@siduck
Copy link
Collaborator Author

siduck commented May 1, 2022

Spawnable term window could be like :

:execute 'terminal' | let b:term_type = 'wind' | startinsert <CR>"

idk if it would be possible to toggle a term window buffer

@zbirenbaum
Copy link
Owner

zbirenbaum commented May 12, 2022

this is functionally equivalent to just doing :term I can take a look at enabling this so things like sending commands to the term works after finals some time next week.

FYI: Buffers aren't windows. Neovim terminology is very specifc, this really confused me until I remembered you use bufferline....

@siduck
Copy link
Collaborator Author

siduck commented May 12, 2022

yes ik its :term, but it would be nice to toggle it and hide it too 🤔

image

@zbirenbaum
Copy link
Owner

zbirenbaum commented May 12, 2022

This is because it fundamentally is not how windows function. Buffers are not windows.

I know how to implement this, but both can't until next week, and am not sure I should given that functionally there's no difference between this and literally doing C-z running your command in the normal term, and then fg to resume.

In fact, doing suspend and resume strategy is actually much better since native term is much faster than neovim emulator.

@siduck
Copy link
Collaborator Author

siduck commented Jun 1, 2022

C-z exits nvim

image

@zbirenbaum
Copy link
Owner

zbirenbaum commented Jun 1, 2022

C-z exits nvim

image

This is not true. C-z suspends a program to the background. Run 'fg' (foreground) and it will come back up exactly where it left off.

It's equivalent to creating a new tab page or something which is what you refer to as a "window"

@faraazahmad
Copy link

Is this issue related to functionality where toggle opens a new terminal if not already open?

@siduck
Copy link
Collaborator Author

siduck commented Jul 28, 2022

Is this issue related to functionality where toggle opens a new terminal if not already open?

no, this is for toggling new terminal window ( listed ) if thats possible @zbirenbaum

@zbirenbaum
Copy link
Owner

zbirenbaum commented Jul 28, 2022

Is this issue related to functionality where toggle opens a new terminal if not already open?

no, this is for toggling new terminal window ( listed ) if thats possible @zbirenbaum

Again, what you are referring to here as a window is actually a buffer. The implementation of the behavior you are describing would be to replace the buffer in the current window with a terminal and then restore it on toggle. I just took some time to see how it would have to be implemented and came across a few problems.

  1. This leads to all sorts of messy stuff to save and restore the window options since things like eolchars, linenumbers, etc will all have to be changed when the terminal is opened, and then restored when it is closed.
  2. If the user does anything to close the terminal other than use the dedicated toggle function, it would make a mess of everything and cause tons of bugs.
  3. Due to 1 & 2, I would then have to write autocmd's and do a ton of state tracking that is currently unnecessary
  4. The only people who could feasibly have a use for this are those who use bufferline and plugins like it.

This would make much more sense if it opened in a new tabpage, which would actually provide the behavior you want and have none of the above issues, but would not integrate with the plugins that treat buffers as tabs. For that reason, while I am happy to implement this with a tabpage,

I don't want to do this the way you are thinking about it, as it:

  1. Encourages bad habits
  2. Exacerbates confusion between what a buffer and a window actually are
  3. It is about 10x more work than quite literally any other feature would require to implement due to the debugging I foresee it requiring.

It isn't undoable, so if it would really mean a lot to you to have this feature, I am willing to put in that effort to write it at some point, but I am going to have to give priority to some other features I am working on in other repos at the moment.

If you want the tabpage implementation, it would be extremely quick to write, and I can do it immediately.

@siduck Let me know your thoughts, and please read this carefully, as all of the above info is relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants