1
votes

The default colors of vim in the terminal (tmux) still do not match those of gvim. I am using the pantheon terminal in elementary OS freya. This in combination with the solarized theme: http://ethanschoonover.com/solarized

When I do "echo $TERM" in tmux the output is: screen-256color

So that seems okay. From what I understand the $TERM value has to be properly defined in .bashrc. Tmux uses that and vim uses the TERM value it finds in tmux?

The colors I get are as follows: enter image description here

Within GVIM the line numbering and comments are gray?? How can I change this. The other colors also do not match?

My gvim looks like this: enter image description here

I have been looking a this problem for hours...

My configuration is as follows:

.bashr

# set a fancy prompt (non-color, unless we know we "want" color)
#case "$TERM" in
    #xterm-color) color_prompt=yes;;
#esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
    # We have color support; assume it's compliant with Ecma-48
    # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
    # a case would tend to support setf rather than setaf.)
    color_prompt=yes
    else
    color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

export EDITOR='vim'

### Start Tmux when opening terminal
if [[ ! $TERM =~ screen ]]; then
    exec tmux -2
fi

.tmux.conf

# reload source file to enable settings
#$ tmux source-file ~/.tmux.conf
bind r source-file ~/.tmux.conf \; display-message "Config reloaded..."

# Enable vi mode
set-window-option -g mode-keys vi

# Enable mouse control (clickable windows, panes, resizable panes)
set -g mouse-select-window on
set -g mouse-select-pane on
set -g mouse-resize-pane on

# switch panes using Alt-arrow without prefix
bind -n M-h select-pane -L
bind -n M-l select-pane -R
bind -n M-k select-pane -U
bind -n M-j select-pane -D

.vimrc

set background=dark
colorscheme solarized

When using pantheon $TERM = xterm

I also tried the vim csapprox plugin. This fixes it for the large part but the comments remain unreadable.

enter image description here

3

3 Answers

3
votes

From vim solarized github page:

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.

1
votes

Use csapprox vim plugin. It works transparently and makes the colors look the same or almost the same in gvim and in 256-color terminal.

.vimrc

let g:solarized_termcolors=256
let g:solarized_bold=1
let g:solarized_italic=1
let g:solarized_underline=1
let g:solarized_contrast="high"
set background=dark
colorscheme solarized

tmux.conf

set -g default-terminal "screen-256color"
0
votes

I fixed it using elementary tweaks. This enables me to choose to use the solarized theme in pantheon. All the other settings in the terminal are NOT needed.

enter image description here

The rest of my config is as follows:

.bashrc

export EDITOR='vim'

### Start Tmux when opening terminal
if [[ ! $TERM =~ screen ]]; then
    exec tmux
fi

.tmux.conf

# reload source file to enable settings
#$ tmux source-file ~/.tmux.conf
bind r source-file ~/.tmux.conf \; display-message "Config reloaded..."

# Enable vi mode
set-window-option -g mode-keys vi

# Enable mouse control (clickable windows, panes, resizable panes)
set -g mouse-select-window on
set -g mouse-select-pane on
set -g mouse-resize-pane on

# switch panes using Alt-arrow without prefix
bind -n M-h select-pane -L
bind -n M-l select-pane -R
bind -n M-k select-pane -U
bind -n M-j select-pane -D

.vimrc

let g:solarized_bold=1
let g:solarized_italic=1
let g:solarized_underline=1
set background=dark
colorscheme solarized

When doing echo $TERM in tmux I get screen.

As you can see I removed all the color 256 mentions and stuff is working. The comments are still dark but readable.

Screen:

enter image description here