altercation / vim-colors-solarized

precision colorscheme for the vim text editor
http://ethanschoonover.com/solarized
6.58k stars 1.75k forks source link

Background colors not fully covering tmux vim screen #149

Closed paanvaannd closed 8 years ago

paanvaannd commented 8 years ago

Using vim through either zsh or bash with these themes works like a charm, and since I am beginning to use tmux, I would like to use these themes while working in tmux as well. However, once a newline character is present at the end of a line, the background theme color does not continue past that character but rather stops at it, exposing the underlying theme used in tmux for the remainder of the line. I have taken an image of what this looks like and uploaded it below, using the light theme to make the issue more noticeable though the issue persists with the dark theme as well.

tmux vim_solarized-issue

I am using iTerm2 and, as mentioned before, this issue only pops up while using vim with this theme within a tmux session. Other vim themes that do not change the background of the editor do not suffer from the same issue, and the text is properly colored while using the Solarized themes as well. The tmux theme I am using is maglev, but even after disabling that, the issue persists. I have made sure to enable 256 color mode in tmux, vim, and iTerm2. Below are my .vimrc and .tmux.conf files, should you need to look through them: vimrc.txt tmux_conf.txt

Note: This may be a problem with tmux and vim compatibility in general, at least with the settings I have. I am not aware of any conflicting settings, but there are some settings within my .vimrc file that are ignored within a tmux session. For example, I have a setting in my .vimrc that wraps text within a file past 80 characters in a line and this function works fine within a zsh+vim session, but does not work at all within a tmux+vim session on my computer. Are there any settings that seem to be conflicting between these two files that would cause any incompatibility in general, leading to the distortion of the Solarized theme and other such oddities between tmux and vim?

Edit: found out that the wrapping problem was mine and not some bad behavior on tmux's part. Also, I found that the text and theme wrapping issues were related to an extent. I had wrapmargin=0, formatoptions=qt, and formatoptions=qrn1 all declared within my .vimrc file. After commenting out the latter formatoptions code, changing the former to formatoptions=cqt, and changing wrapmargin to 80, the problem with automatic wrapping and the weird background wrapping ceased.

But alas, a few quirks exist! After the aforementioned edits to my .vimrc file and some more tinkering with vim, I found that while the file initially looks like the picture I presented at the beginning of this issue, upon scanning over each line of text using navigation keys in command mode, vim will start "filling in" the theme until the wrap-around area at character 80. For example, a file edited in vim that looks like so:

vim-issue1

Will look like so:

temp-fix1

After I have passed over each fully highlighted line using the navigation keys, leaving un-highlighted rows untouched and messy still.

Furthermore, if I have passed over all lines of a file using navigation keys in command mode and "fixed" the background issue as mentioned above, creating a new tmux partition within the same window will cause the "fixed" vim partition to revert to how the former picture looks, with the theme background "highlighting" only up until the last character of the line rather than the whole line or even up until the wrap-around character.

So: 1) Can you think of anything that will fix the need for me to continually "scan over" the file and highlight each line before allowing the theme to fill at least until the wrap-around line? 2) Is there a way for the theme to fully populate the editor rather than only extending until the wrap-around line?

nelsyeung commented 8 years ago

I have this problem as well for over SSH vim session. Are those Vim sessions over SSH? For my problem I used this to fix the problem:

if $SSH_CONNECTION
    let g:solarized_termtrans = 1
endif

Don't know if it helps though.

nelsyeung commented 8 years ago

I realised that this solution won't fix the problem where you ssh into a client then attach a tmux session. Hmmm...

paanvaannd commented 8 years ago

@nelsyeung No, I'm just using this locally. I haven't used this in a while and wanted to check it out again, to see if there have been fixes in the meantime but it's still the same issue. I was thinking of just using the Solarized theme throughout iTerm as is suggested in the readme but every source online points me to the Solarized website for the iTerm theme link yet there is no theme link here...

If I find that using the iTerm theme globally works to fix this problem, I'll let you know. That way, I suppose it should work over an SSH session as well, right?

nelsyeung commented 8 years ago

@paanvaannd I realised I can reproduce this problem with just tmux and with other themes. I've fixed this by making sure that the TERM variable is set to screen-256color. I had an override in my .bash_profile file where I had export TERM=xterm-256color. I've removed that and it seems to work.

Take a look at this link: http://superuser.com/questions/399296/256-color-support-for-vim-background-in-tmux

paanvaannd commented 8 years ago

@nelsyeung THANK YOU THANK YOU THANK YOU THANK YOU 😃

I had my .zshrc TERM variable set as export TERM=xterm-256color and changing that to export TERM=screen-256color resolved the issue. I changed the TERM variable to reflect this same change in my .bash_profile as well just to be certain 😆

I was searching pretty heavily a couple months back to find related issue threads like the one you linked... maybe I just wasn't using the correct search terms. That helps clarify things a lot, thank you so much once again.

Have an awesome week!

cluxter commented 7 years ago

@nelsyeung Your setting fixed my problem! Thank you so much!

erikscarlatescu commented 7 years ago

@nelsyeung I know everyone else already thanked you, but I'm so happy it works that I want to thank you anyways