Re: [vim/vim] Update runtime files (d2ea7cf)

32 views
Skip to first unread message

lacygoill

unread,
May 30, 2021, 3:22:27 PM5/30/21
to vim/vim, Subscribed

In runtime/doc/syntax.txt, line 4973 and 4974:

set -g default-terminal "xterm-256color"
set -ag terminal-overrides ",xterm-256color:Tc"

xterm-256color is wrong for default-terminal. It tells tmux to set $TERM to xterm-256color whenever the user opens a new window/pane; but in tmux, $TERM must be screen, tmux or a derivative, as documented at https://man.openbsd.org/tmux.1#default-terminal :

For tmux to work correctly, this must be set to ‘screen’, ‘tmux’ or a derivative of them.

There are several ways to set the options.  As a suggestion:

set -s default-terminal "tmux-256color"

set -as terminal-overrides ",*-256color:Tc"

This tells tmux to set $TERM to tmux-256color, and to enable its true color capability feature (Tc) if the name of the real outer terminal ends with the string -256color (e.g. xterm-256color, gnome-256color, ...).


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Dominique Pellé

unread,
May 30, 2021, 3:46:34 PM5/30/21
to vim/vim, Subscribed

I've been using tmux (latest in git, "next-3.3") with 256 colors without problems for a while.
My ~/.tmux-config contains (among other things):

set-option -g default-terminal "xterm"

I checked, this line alone in .tmux.conf is sufficient to have 256 colors.
And I use xfce4-terminal that comes with xubuntu-18.04.5.

In ~/.vimrc, I have:

set termguicolors`

lacygoill

unread,
May 30, 2021, 3:58:31 PM5/30/21
to vim/vim, Subscribed

My ~/.tmux-config contains (among other things):

set-option -g default-terminal "xterm"

Then it means that the programs that you are using are not asking for terminfo capabilities; or if they are asking, the values that they get are the same whether $TERM is xterm or screen, tmux, screen-256color, tmux-256color. But in the general case, we don't know which programs the user will be running, nor whether they'll ask for terminfo capabilities, nor how they'll use them; so it's best to respect tmux own documentation.

lacygoill

unread,
May 30, 2021, 4:01:43 PM5/30/21
to vim/vim, Subscribed

It's not just some minor nitpick. This is the cause of many subtle issues, to the point that the tmux devs have felt the need to include this in the CONTRIBUTING.md file which users having issues are expected to read before posting:

$TERM inside tmux is screen, screen-256color, tmux or tmux-256color. Check by running echo $TERM inside tmux.

lacygoill

unread,
May 30, 2021, 4:10:22 PM5/30/21
to vim/vim, Subscribed

I checked, this line alone in .tmux.conf is sufficient to have 256 colors.

Yes, with a recent tmux, you might not even need terminal-overrides. I think tmux is a bit smarter nowadays and auto-configure some options. In fact, if you need to set an option, you should use terminal-features, not terminal-overrides. But all of that is assuming that the user has a recent tmux. Again, we don't know that. They might be using 3.0; in which case, tmux won't auto-configure options, and terminal-features won't be available.

Bram Moolenaar

unread,
May 30, 2021, 4:18:37 PM5/30/21
to vim/vim, Subscribed


> In `runtime/doc/syntax.txt`, line 4973 and 4974:

>
> > set -g default-terminal "xterm-256color"
> > set -ag terminal-overrides ",xterm-256color:Tc"
>
> `xterm-256color` is wrong for `default-terminal`. It tells tmux to set `$TERM` to `xterm-256color` whenever the user opens a new window/pane; but in tmux, `$TERM` must be `screen`, `tmux` or a derivative, as documented at https://man.openbsd.org/tmux.1#default-terminal :

>
> > For tmux to work correctly, this must be set to ‘screen’, ‘tmux’ or a derivative of them.
>
> There are several ways to set the options.  As a suggestion:
>
> set -s default-terminal "tmux-256color"
> set -as terminal-overrides ",*-256color:Tc"
>
> This tells tmux to set `$TERM` to `tmux-256color`, and to enable its
> true color capability feature (`Tc`) if the name of the real outer
> terminal ends with the string `-256color` (e.g. `xterm-256color`,
> `gnome-256color`, ...).

OK, I was just putting there was was mentioned. I haven't tried any of
these.

Besides following the documentation, it would also be good if a few
users can try it out to check if it really works.

--
In Africa some of the native tribes have a custom of beating the ground
with clubs and uttering spine chilling cries. Anthropologists call
this a form of primitive self-expression. In America we call it golf.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages