From d4fc16ef4b138a5c52fcb4abd20d44dbce1b7e43 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Fri, 2 Aug 2019 23:23:01 -0400 Subject: [PATCH] vim: more colorscheme fixes for detecting 256 colors I was previously checking $DISPLAY to determine if I was in an xterm or the Virtual Console (can't check $TERM =~ linux because of tmux). This breaks down over SSH, where $DISPLAY is not set. Solution: check $TERM =~ 256color and hope tmux set it properly. --- vim/vimrc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vim/vimrc b/vim/vimrc index 498f975..7f58199 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -90,7 +90,8 @@ set listchars=space:·,tab:>–,trail:~,eol:¬ " COLORSCHEME " Only gruv if you can handle it -if exists("$DISPLAY") && +" NOTE: for initial check, check $TERM, not &term, as nvim has &term=nvim +if $TERM =~# '256color' && \ (has("termguicolors") || has('gui_running')) && \ filereadable(s:vimdir . "/pack/mine/start/gruvbox/colors/gruvbox.vim") @@ -98,6 +99,7 @@ if exists("$DISPLAY") && colorscheme gruvbox " See :h xterm-true-color for tmux+termguicolors + " TODO: is this safe to blindly set always (in 256 color mode)? if &term =~# '^\(tmux\|st\|screen\)' let &t_8f = "\[38;2;%lu;%lu;%lum" let &t_8b = "\[48;2;%lu;%lu;%lum" @@ -110,6 +112,7 @@ if exists("$DISPLAY") && autocmd InsertEnter,InsertLeave * set cul! augroup END else + " Can't handle the gruv set background=light colorscheme vc endif -- libgit2 0.28.4