neovim icon indicating copy to clipboard operation
neovim copied to clipboard

:terminal improvements

Open justinmk opened this issue 8 years ago • 12 comments

List of terminal improvements.

  • [ ] vim-patch 8.0.1804: using :normal in terminal window causes problems
  • [ ] vim-patch 8.0.1794: duplicate term options after renaming
  • [ ] vim-patch 8.0.1743: terminal window options are named inconsistently
  • [ ] vim-patch 8.0.1732: crash when terminal API call deletes the buffer
  • [ ] vim-patch 8.0.1592: terminal windows in a session are not properly restored
  • [ ] vim-patch 8.0.1744: on some systems /dev/stdout isn't writable
  • [ ] vim-patch 8.0.1300: file permissions may end up wrong when writing
  • [ ] Revisit https://github.com/neovim/neovim/pull/2570
  • [ ] :! should use :terminal internally. Doesn't affect :read !foo etc. See #5396. Use cases: #5580.

    by making terminal.c draw directly to the screen (instead of a buffer) https://github.com/neovim/neovim/issues/1496#issuecomment-144346925

    • [ ] :%term should work like :%!
    • [ ] :read :term foo should work like :read !foo
    • Related: vim-patch 8.0.1609: shell commands in the GUI use a dumb terminal (https://github.com/vim/vim/commit/135682517bc378cfdb63fe3a6e3553935f69f6ce)
  • [ ] :term buffers should setlocal bufhidden=hide by default. Fixes #3340 #3138 #5122
  • [ ] should respect all 'bufhidden' flags #2368
  • [x] :emenu in terminal mode #3393
  • [ ] :te should open in split, similar to :help. Or not?
    • [x] support <mods> (:vert, :tab) #15427
    • [ ] :0te suppresses the split? cf. https://github.com/tpope/vim-fugitive/commit/bf7f05e62b75570d2bde8cbc131bfe25dbcdb427
  • [ ] instead of :bdeleteing the buffer after process exit, switch to some other buffer? #5176
  • [ ] Do not auto-resize. There's no good choice about when to resize and it causes problems.
  • [ ] Allow folds https://github.com/neovim/neovim/issues/5682
    • https://github.com/neovim/neovim/pull/2683
  • [x] Follow terminal output in normal-mode if cursor is on last line #6142
  • [x] :term buffer should be 'modifiable'. #6142
  • [x] Enable user to manage 'scrollback' (buffer-local option) #2637 #6142
  • [x] handle FN keys #5014
  • [x] handle ctrl-space, ctrl-arrow #3101. Closed by #5014 ?

justinmk avatar Oct 05 '16 03:10 justinmk

I think it would be really cool if terminal could support cmdwin - c.f. https://github.com/brettanomyces/nvim-terminus/issues/7

In particular, this would be great for writing multi-line functions in REPLs.

AprilArcus avatar Nov 02 '16 00:11 AprilArcus

would it be possible to handle :set nowrap in terminal buffer ?

bew avatar Dec 02 '16 14:12 bew

~~Yes, by telling libvterm a very long width. I have a pending PR that helps with this.~~

edit: That hack isn't going to work, because it will confuse interactive applications, not to mention tools like pytest which center text based on the TTY width.

justinmk avatar Dec 02 '16 15:12 justinmk

for the following improvment :

User-initiated :! invocations should silently use :terminal instead

Which terminal should be used ? We could send a RequestTerminal event, and see if a particular variable is set. If it is, use the terminal from the variable, or create a new terminal (new tab ? h/v split ?)

bew avatar Jan 20 '17 10:01 bew

The details of each item can be discussed as PRs are proposed for them. But at least initially the goal is only to match the traditional semantics of :!, so some sort of long-lived scratch buffer would be used.

justinmk avatar Jan 20 '17 10:01 justinmk

Well, I see (the last line of) a terminal buffer could serve as a really flexible readline-like interface, if only we can enter Insert Mode on a terminal buffer.

bohrshaw avatar Feb 27 '17 12:02 bohrshaw

@bohrshaw See this thread: https://github.com/neovim/neovim/pull/6142#issuecomment-282690785

justinmk avatar Feb 27 '17 13:02 justinmk

Most of the items in the checklist have a PR of their own. Currently, there's no PR associated with this item:

  • :te should open in split, similar to :help

Could we create a PR for that (unless it already exists) and link to it from that item in the checklist? It would be good to have a designated place to discuss that item.

nelstrom avatar Jul 24 '17 10:07 nelstrom

I know that I may loose the argument here, but I think Neovim :terminal behaves the right way already, and I would whish :help and other "special" buffers (e.g. quick fix) behave like it. Here are the reasons:

  1. Vim tabs are actually the right design, each tab is a layout and the user can switch between them easily. When :help (and :copen and probably others that I don't know about) is run the whole point of having different layouts on each tab is lost.
  2. Most commands behave the same, with exceptions, so the user must remember those especial cases to avoid disrupting the layout. Even if something like :0te is implemented (I would prefer something like :current te if it happens), there would be a default behaviour and a bunch of special cases :( I prefer consistency.

One can argue that the user that the user could have custom commands with the desire behaviour, and that's what I do, but it would be awesome if Neovim where more consistent than Vim, so I wouldn't need to remember to use my custom commands instead of the default :help. I don't expect the behaviour of :help to be changed, I know compatibility with Vim is more important, but it would be nice if :terminal was kept as is (plus support for :vertical, :tab and others)

tssm avatar Mar 11 '20 09:03 tssm

Tossing my hat/plugin/angle into the ring, I wrote a small-ish plugin for how I like to use :terminal:

  • https://github.com/jcorbin/neovim-termhide
  • basically I live the "no more tmux, neovim is my root terminal app" lifestyle
  • and on top of that, I mostly only over use one, session-specific, terminal at a time
  • ... that I want to be able to effectively show/hide, but never really terminate
  • sometimes I want it in a "quake-style" top-N line pull down form ( using say winfixheight )
  • sometimes I want it in a vert-split when doing more involved things
  • either way, the missing atom that most of my plugin is oriented around, is "create or show existing" , and make sure that it doesn't get killed when hidden
  • ...very much in line with tmux (and screen before it)'s idiom of "create or attach to prior", but now pivoted internally towards "the one terminal"
  • uncommonly, one can also spawn alternate shells or REPLs as in :Term ipython or :Term node

One of my current hanging problems tho, is that I very much wish that I could exclude my terminal buffers from session saving and/or have that bufhidden setting restored ( https://github.com/jcorbin/neovim-termhide/issues/2 )

jcorbin avatar Mar 11 '20 17:03 jcorbin

@justinmk can you elaborate on the plan for :read !foo? In the original post you write, ":! should use :terminal internally. Doesn't affect :read !foo etc." and then say ":read :term foo should work like :read !foo" What does this mean? It sounds like :read !foo isn't going to be changed by any of the :! plans, and that :read :term foo is going to be a new supported syntax that will have identical semantics to the current :read !foo. Is that correct?

ddickstein avatar Aug 13 '21 15:08 ddickstein

terminal windows in a session are not properly restored

It'd be cool if there were the option (e.g. maybe something in 'sessionoptions') to have scrollback restored (or an api to be able to do this manually, like get and set scrollback functions). By default, manpages don't get restored correctly either last I checked.

tmillr avatar Sep 21 '23 22:09 tmillr