vim + tmux visual mode not highlighting - vim

When I run vim in tmux, the syntax highlighting works fine except for the visual mode, it works but doesn't change the colors of the selected text, which I find quite annoying.
The problem stays the same even when I switch the colorscheme(I am currently using molokai)
I have the option set t_Co=256 on my vimrc
My .tmux.conf file is the same as the t-williams.conf example(just added the line "set -f default-terminal "xterm"")
I already tried some solutions to problems related to the 256 color support
any tips?

The recommended setting for tmux is
set -g default-terminal "screen-256color"
and you don't need
set t_Co=256
in your ~/.vimrc.

Make sure your terminal declares itself as a 256 color supported terminal (for example, xterm-256color). This will set the TERM in bash, which is read by tmux, and will automatically set the default-terminal setting to screen-256color.
For example, in the Terminal on OS X you can change this in the settings under the "Advanced" tab. The "Declare terminal as" option:

Related

Neovim colorscheme does not look right when using nvim inside tmux

I'm trying to use vim-material theme from https://github.com/kaicataldo/material.vim
Below is what happens when i run neovim in tmux
Below is what it should look like
What i've tried so far:
in my .tmux.conf
I tried both
set -g default-terminal "screen-256color"
and
set -g default-terminal "xterm-256color"
I also tried
TERM=screen-256color-bce tmux
I am able to echo $TERM with proper results here. but i've also tried setting them manually with export TERM=xterm-256color or export TERM=screen-256color before i open nvim
This is what I have in my init.vim
let g:material_theme_style = 'ocean'
colorscheme material
set background=dark
set t_Co=256
set termguicolors
i've tried setting and unsetting these.
unsetting termguicolors was the worst, the theme just didnt work and it gave me default vim look
I also run tmux as tmux -2 i should also mention i kill tmux sessions after changing anything in my tmux.conf to make sure it reflects
the versions of related apps and os
nvim v0.4.3
tmux 3.0a
iTerm2 3.3.9
macOS mojave 10.14.6
EDIT:
I've since tried clearing all tmux plugins and nvim plugins only leaving the default-terminal in my tmux config
Here's what's left on my init.vim file
call plug#begin('~/.config/nvim/plugged')
Plug 'kaicataldo/material.vim'
call plug#end()
set termguicolors
let g:material_theme_style = 'default'
colorscheme material
I also tried downloading an older version of tmux. 2.5, still no luck.
I deleted all my tmux plugins and nvim plugins and reinstalled material.vim so i'm sure nothing is conflicting in the plugins somehow
FOUND THE SOLUTION . this article helped me:
https://cyfyifanchen.com/neovim-true-color/
set-default colorset-option -ga terminal-overrides ",xterm-256color:Tc"
set-option -ga terminal-overrides ",xterm-256color:Tc" in .tmux.conf and alias tmux="TERM=screen-256color-bce tmux" in .bashrc worked for me in windows WSL2 using windows terminal. now I can use vim within tmux :)
I ran h: checkhealth in neovim and I was only getting an error message when I was using neovim inside a tmux session. The checkhealth message provided the only solution that worked for me.
This is what it said:
- WARNING: Neither Tc nor RGB capability set. True colors are disabled. |'termguicolors'| won't work properly.
- ADVICE:
- Put this in your ~/.tmux.conf and replace XXX by your $TERM outside of tmux:
set-option -sa terminal-overrides ',XXX:RGB'
- For older tmux versions use this instead:
set-option -ga terminal-overrides ',XXX:Tc'
Just change the TERM environment variable in your shell config file, in my case .zshrc, i.e:
# Path Variables
export TERM='xterm-256color'
export EDITOR='nvim'
export VISUAL='nvim'
Reload your terminal and reload tmux or kill tmux-server and check:
> echo $TERM
Since i use an old version of TMUX (that doesnt support all colors) this was my solution:
-- Set colorscheme
vim.o.termguicolors = false
vim.cmd [[colorscheme default]]

airline.vim does not work inside tmux

I am new to tmux and also not an expert on VIM, I tried to use tmux these days, but seems that airline disappeared when I used vim inside tmux. I would like to show you the screen shots and hopefully anyone can help me solve this problem.
airline in vim
airline inside tmux
You need to correctly set $TERM environment variable to make vim properly detect 256 colors support by doing the following before opening vim:
export TERM=screen-256color
While the accepted answer works, it is not cheap. Manually setting the value of the $TERM variable will usually be set correctly by itself.
It is usually a good a idea to force tmux to assume the terminal supports 256 colors.
In your ~/.bash_aliases, add:
tmux='tmux -2'
Answer based on the following posts:
What is the difference between screen-256 color and xterm-256color
tmux vim colorscheme background is not showing
Add the following line in your .tmux.conf
set -g default-terminal screen-256color
In my case, using ubuntu 20.04 inside windows with WSL2, the accepted answer (export TERM=screen-256color), just freeze the tmux pane.
The fix for me was add to ~/.vim/vimrc:
set t_Co=256

Setting VIM for 256 colors

I've googled it for hours but I can't find a solution.
I use raspian, on a raspberry pi and I want to have colorscheems work on it.
Default terminal in raspian seems to be set at 8 colors as when I enter
tput colors
I get 8.
I'm sure there must be a way to have the term work with 256 colors but I don't know how. Anyway I set tmux in the config file to support 256 colors, so I created a .tmux.conf file in my home directory and have
set -g default-terminal "screen-256color"
now if I check with tput within tmux I get 256.
Anyway I know you can set VIM to force think you support 256 color by adding
set t_Co=256
but this seems to make no actual change.
If I run this color test
:runtime syntax/colortest.vim
in normal terminal from raspian I get only 8 different colors. If I do this on tmux I get more but not all of them because some of them (red and lightred for example) still look the same.
did you add set t_Co=256 after the line colorscheme <yourColourScheme>? That was a problem I had early on.
Let me know if you're still having trouble, because I managed to solve a similar problem (only I'm using MobaXterm and GNU screen), and wouldn't mind the excuse to dig into this a bit more.
I was having a similar problem and have solved it with the following setup. .zshrc on my OSX laptop contains:
TERM=xterm-256color
after I ssh into raspbian, tput colors returns 256. On raspbian, I don't have TERM explicitly set (which means it pulls it from ssh), and have the following in .tmux.conf:
set -g default-terminal "xterm-256color"
Then after I do tmux (and I don't even need the -2), tputs colors still reports 256 colors and vim looks right. I am using vanilla solarized with no edits in .vimrc or elsewhere in the vim configs.

Bad colorscheme in Vim running on Putty+tmux

I'm trying to set up base16-tomorrow colorscheme in my Vim, which runs on top of tmux+Putty. I exausted nearly every link on Google to get it working, but nothing happens =S
This is how the colorscheme looks like now:
How it was supposed to be:
The odd part is, no matter which base16 colorscheme I chose, it still looks the same.
Some informations about my shell:
$ echo $TERM # on Putty
xterm-256color # I configured putty to 256 colors and use this identifier
$ tmux
$ echo $TERM
screen-256color
Also, in Vim, t_Co variable is set with 256.
How can I solve this problem?
Despite having this in my .tmux.conf file, it didn't help: set -g default-terminal "screen-256color"
However, this from #xthrd helped me:
Have you tried running tmux with tmux -2 to force 256-color mode?
I had a simular issue with displaying colorschemes in tmux.
Have you tried adding set -g default-terminal "screen-256color" to your .tmux.conf

Ubuntu, Vim, and the solarized color palette

I'd really like to get in on all the colorful goodness of the solarized colorscheme, but I can't seem to get it configured just right.
I have the main solarized file in my .vim/colors folder, I've set my terminal profile colors to what is listed on the site, and I've added the lines
set background=dark
let g:solarized_termcolors=16
colorscheme solarized
to my .vimrc file, but Vim looks greyed out and is using a bright green color as the default. How can I do it?
Here's my recommendation for things to try:
ensure syntax on is in your .vimrc file
Check what t_Co Vim has picked up from your term emulator (a quick :echo &t_Co). If it's 8, you'll want to se t_Co=16. You might also try se t_Co=256 though without let g:solarized_termcolors=16 this will use the 256 fallback mode, which isn't quite the correct color scheme.
set t_Co=16 and let g:solarized_termcolors=16 did not work for me. This is what worked:
syntax on
let g:solarized_termcolors=256
set t_Co=256
set background=dark
colorscheme solarized
I found out how do do it from this article.
I wrote the following script to do the gnome-terminal stuff.
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_background" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_colors" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/palette" --type string "#070736364242:#D3D301010202:#858599990000:#B5B589890000:#26268B8BD2D2:#D3D336368282:#2A2AA1A19898:#EEEEE8E8D5D5:#00002B2B3636:#CBCB4B4B1616:#58586E6E7575:#65657B7B8383:#838394949696:#6C6C7171C4C4:#9393A1A1A1A1:#FDFDF6F6E3E3"
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/background_color" --type string "#00002B2B3636"
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/foreground_color" --type string "#838394949696"
If you are trying to use Vim with solarized inside of tmux, this is the fix for your issue:
Fix solarized theme in tmux
Trying it out myself, it seems to work better without the
let g:solarized_termcolors=16
Setting it to 16, I get the bright green color you seem to describe. Maybe try leaving it at the default of 256?
This doesn't, however, perfectly mimic the colors from the screenshots (although the light version looks fairly close). I only get the colors with the screenshot if I use gVim.
I didn't use the terminal profile colors provided, however, so you may get a different result.
For the copy and paste lovers, this is how you install the solarized Vim colorscheme on Ubuntu:
sudo apt-get install wget unzip curl
cd
wget http://ethanschoonover.com/solarized/files/solarized.zip
unzip solarized.zip
mkdir .vim
mkdir .vim/colors/
mv solarized/vim-colors-solarized/colors/solarized.vim ~/.vim/colors/
cp .vimrc .vimrc.old
echo "syntax enable" > .vimrc
echo "set background=dark" >> .vimrc
echo "colorscheme solarized" >> .vimrc
curl https://raw.github.com/seebi/dircolors-solarized/master/dircolors.256dark > ~/.dircolors
source .bashrc
rm -r solarized
rm solarized.zip
And presto.
From the README (emphasis mine):
IMPORTANT NOTE FOR TERMINAL USERS:
If you are going to use Solarized in Terminal mode (i.e. not in a GUI
version like gvim or macvim), please please please consider
setting your terminal emulator's colorscheme to used the Solarized
palette. I've included palettes for some popular terminal emulator as
well as Xdefaults in the official Solarized download available from
[Solarized homepage]. If you use Solarized without these colors,
Solarized will need to be told to degrade its colorscheme to a set
compatible with the limited 256 terminal palette (whereas by using
the terminal's 16 ansi color values, you can set the correct, specific
values for the Solarized palette).
If you do use the custom terminal colors, solarized.vim should work
out of the box for you. If you are using a terminal emulator that
supports 256 colors and don't want to use the custom Solarized
terminal colors, you will need to use the degraded 256 colorscheme.
To do so, simply add the following line before the colorschem solarized line:
let g:solarized_termcolors=256
Again, I recommend just changing your terminal colors to Solarized
values either manually or via one of the many terminal schemes
available for import.
Simply selecting Solarized for both "Text and Background Color" (choose light or dark) and "Palette" in Terminal → Preferences → Profiles → (select yours) → Edit → Colors worked for me on Ubuntu 16.04 (Xenial Xerus) with the included Terminal application.
Some other answers recommend choosing a 256 color palette but, as mentioned in the documentation, this gives you a degraded (and visibly worse in my opinion) color scheme.
This worked for me for exherbo
git clone https://github.com/sigurdga/gnome-terminal-colors-solarized
cd gnome-terminal-colors-solarized
sh install.sh -s dark -p <my_current_profile>
256 colors in vim may also help

Resources