diff --git a/vim/vimrc b/vim/vimrc index 48ca5667..8eb13b0c 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -341,7 +341,11 @@ xnoremap ag y:Ag " nmap cd :cd %:p:h " r : screen sucks, redraw everything -nnoremap r :redraw! +function! Redraw() + redraw! + call s:auto_termguicolors() " re-detect true colors +endfunction +nnoremap r :call Redraw() " src : source ~/.vimrc nnoremap src :source ~/.vimrc @@ -429,9 +433,28 @@ if &term =~ '256color' endif " 24-bit true color: neovim 0.1.5+ / vim 7.4.1799+ -if (has("termguicolors")) && &term == 'xterm-256color' - set termguicolors -endif +" enable ONLY if TERM is set valid and it is NOT under mosh +function! s:is_mosh() + let output = system("is_mosh -v") + if v:shell_error + return 0 + endif + return !empty(l:output) +endfunction + +function s:auto_termguicolors() + if !(has("termguicolors")) + return + endif + + if &term == 'xterm-256color' && !s:is_mosh() + set termguicolors + else + set notermguicolors + endif +endfunction +call s:auto_termguicolors() + " apply base theme silent! colorscheme xoria256