0

I figured out there is some sort of a bug with Suckless's ST terminal emulator (0.8.2) regarding VIM. If I download ST's source files and open a configuration file config.h I can find a setting:

char *termname = "st-256color";

I keep this default setting and build the ST binary. Then I start the built ST binary and I noticed this:

  • keys DEL and HOME work fine inside the ST terminal,
  • VIM if executed from within ST terminal will display no syntax highlighting.

On the other hand, if I change the default setting to:

char *termname = "xterm-color";

I notice this:

  • keys DEL and HOME do not work inside ST terminal - they both print tilde ~
  • VIM if executed from within ST terminal will display proper syntax highlighting.

In both cases I had a file ~/.inputrc with only one line:

set enable-keypad on

Which was supposed to make DEL work accordingly to Arch Wiki. But if I remove it in the second case, keys DEL and HOME work, but DEL does not.

So it is like I can't have it all. One or the other... Does anyone have any ideas, how to overcome this? I would perfer a solution without ~/.inputrc.

skink
  • 5,133
  • 6
  • 37
  • 58
71GA
  • 1,132
  • 6
  • 36
  • 69
  • I found out that if I put `tput smkx` command in `.bashrc` **DEL** works and I can remove `.inputrc`. But this is not the solution that I want. Does anyone know if there is a fix that I can do in source code to make **DEL** work. – 71GA Apr 07 '20 at 15:41
  • I also found out that in my previous comment I was wrong! `tput smkx` makes **DEL** work only until I use `vim` for the first time and then it *DEL* stops working again... That is until I enter `tput smkx` in the terminal again. And then it works again... So `vim` changes something... – 71GA Apr 10 '20 at 08:36

1 Answers1

3

I have this setting in my ~/.vimrc and with the term name as st-256color, and colors just work fine.

Add this before you set the colorscheme:

" set Vim-specific sequences for RGB colors
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"

Source: https://github.com/vim/vim/issues/993#issuecomment-255651605

I cannot tell for the home button now, as I don't have my arch machine with me right now, but del surely works for me with the above setting.

Harish
  • 1,433
  • 9
  • 21
  • 1
    Your answer was a crutial part of the solution. Key here was to (a) use `char *termname = "st-256color";` in the source code to get a proper `TERM=st-256color` enviromental variable *(at this point colors inside `vim` and keyboard keys don't work)*. (b) Then I used your solution which made sure that I got colors inside `vim`. (c) At the end I made sure that all the keys are working by putting `set enable-keypad on ` inside `~/.inputrc`. – 71GA Apr 10 '20 at 09:33
  • 1
    Well it looks like this is not yet solved! To rely on a `~/.inputrc` was not a good idea, because this script is only executed on my local machine! If I open ST and within execute SSH to connect to a remote computer, *keyboard keys* stop working (!) because `~/.inputrc` is not present on the remote computer... So I need a better solution... – 71GA May 08 '20 at 07:56