You need to tell Tmux how to translate the control sequences sent by Nvim to the outer terminal, here st.
This is done by setting the unofficial extensions to terminfo Ss
and Se
.
From man tmux
:
Ss, Se Set or reset the cursor style. If set, a sequence such as this
may be used to change the cursor to an underline:
$ printf '\033[4 q'
If Se is not set, Ss with argument 0 will be used to reset the
cursor style instead.
See also :h tui-cursor-tmux
.
The Nvim documentation suggests this setting:
set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q'
But it seems to contain 2 errors.
First terminal-overrides
is not a session option anymore, but a server option. So the -g
flag is useless; instead you should pass the -s
flag to set-option
. Although, in practice, it should not matter because Tmux is able to infer the type of an option from its name (except if it's a user option).
Second, the control sequence \E[ q
doesn't seem to match the Se
capability of st, nor the one of xterm.
At least on my machine, Se
contains the sequence \E[2 q
. You can check on yours by running the shell command:
$ infocmp -1x | grep Se
All in all, you could try to add this line to your tmux.conf
:
set -as terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[2 q'
# │ ├┘ ├────────┘ ├┘ ├────┘
# │ │ │ │ └ override with this control sequence;
# │ │ │ │ restore the cursor shape to a block
# │ │ │ │
# │ │ │ └ `Se` capability in the terminfo database
# │ │ │
# │ │ └ override the current value with this new one;
# │ │ set the cursor shape to the one specified by
# │ │ the digit `%d`
# │ │
# │ └ `Ss` capability in the terminfo database
# │
# └ for all terminals (no matter the value of `$TERM`)
You may need to change the control sequences assigned to the Ss
and Se
capabilities; make sure they match whatever $ infocmp -1x | grep 'S[se]'
outputs (ignore the trailing commas).
You may also want to limit the assignments to the st terminal; in that case, replace the leading *
terminal name pattern with something like st
, st-256color
or st-*
. Check the value of $TERM
in your st terminal, outside Tmux.
For the new value to take effect, you can:
- restart the Tmux server after killing the current one (
$ tmux kill-server
)
- start a new one (
$ tmux -Lx
)
- detach your tmux client (
$ tmux detach-client
) and re-attach it ($ tmux attach-session
)