Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

24-bit true color support #9

Merged
merged 8 commits into from
Oct 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
[submodule "zsh/zplug"]
path = zsh/zplug
url = https://github.com/zplug/zplug
[submodule "zsh/is_mosh"]
path = zsh/is_mosh
url = https://github.com/wookayin/is_mosh
1 change: 1 addition & 0 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
# Bins
'~/.local/bin/dotfiles' : 'bin/dotfiles',
'~/.local/bin/fasd' : 'zsh/fasd/fasd',
'~/.local/bin/is_mosh' : 'zsh/is_mosh/is_mosh',
'~/.local/bin/imgcat' : 'bin/imgcat',
'~/.local/bin/imgls' : 'bin/imgls',
'~/.local/bin/fzf' : '~/.fzf/bin/fzf', # fzf is at $HOME/.fzf
Expand Down
3 changes: 2 additions & 1 deletion tmux/tmux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ set-window-option -g display-panes-time 1500
set -g focus-events on

# Color and Themes
set-option -g default-terminal "screen-256color"
set-option -g default-terminal "xterm-256color"
set-option -ga terminal-overrides ",xterm-256color:Tc" # True-color (24bit)

# let pane/window numbers be 1-indexed
set-option -g base-index 1
Expand Down
56 changes: 52 additions & 4 deletions vim/vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,11 @@ xnoremap <silent> <leader>ag y:Ag <C-R>"<CR>
nmap <leader>cd :cd %:p:h<CR>

" <leader>r : screen sucks, redraw everything
nnoremap <leader>r :redraw!<CR>
function! Redraw()
redraw!
call s:auto_termguicolors() " re-detect true colors
endfunction
nnoremap <leader>r :call Redraw()<CR>

" <leader>src : source ~/.vimrc
nnoremap <leader>src :source ~/.vimrc<CR>
Expand Down Expand Up @@ -428,9 +432,41 @@ if &term =~ '256color'
set t_ut=
endif

" 24-bit true color: neovim 0.1.5+ / vim 7.4.1799+
" 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' || &term == 'nvim') && !s:is_mosh()
set termguicolors
else
set notermguicolors
endif
endfunction
call s:auto_termguicolors()


" apply base theme
silent! colorscheme xoria256

" airline theme: status line and tab line
if &termguicolors
let g:airline_theme='deus'
else
let g:airline_theme='bubblegum'
endif


" override more customized colors
highlight StatusLine ctermfg=LightGreen
highlight ColorColumn ctermbg=52 guibg=#5f0000
Expand All @@ -444,6 +480,18 @@ highlight Constant ctermfg=204 guifg=#ff5f87
highlight PreProc ctermfg=219 guifg=#ffafff
highlight SpecialKey ctermfg=242 guifg=#666666

" colors for gui/24bit mode {{
" DiffAdd - inserted lines (dark green)
highlight DiffAdd guibg=#102a05 guifg=NONE
" DiffDelete - deleted/filler lines (gray 246)
highlight DiffDelete guibg=#949494
" DiffChange - changed lines (dark red)
highlight DiffChange guibg=#471515 guifg=NONE
" DiffChange - changed 'text'(brighter red)
highlight DiffText guibg=#721b1b guifg=NONE
" }}


" no underline, current cursor line
highlight CursorLine cterm=none

Expand Down Expand Up @@ -489,8 +537,8 @@ autocmd BufWinLeave * call clearmatches()
autocmd InsertLeave * silent! set nopaste

" better popup menu colors (instead of dark black)
highlight Pmenu ctermfg=black ctermbg=yellow
highlight PmenuSel ctermfg=red ctermbg=white gui=bold
highlight Pmenu ctermfg=black ctermbg=yellow guifg=black guibg=#ffec99
highlight PmenuSel ctermfg=red ctermbg=white guifg=red guibg=white gui=bold

" http://vim.wikia.com/wiki/Identify_the_syntax_highlighting_group_used_at_the_cursor
function! ShowSyntaxGroup()
Expand Down Expand Up @@ -626,9 +674,9 @@ let g:EditorConfig_core_mode = 'python_external'

" ---------------------------------------------------------------- }}}
" Airline {{{
" Note: for airline theme, see the 'appearance' section

" use airline, with powerline-ish theme
let g:airline_theme='bubblegum'
let g:airline_powerline_fonts=1

" enable tabline feature
Expand Down
1 change: 1 addition & 0 deletions zsh/is_mosh
Submodule is_mosh added at 6cde1c
8 changes: 2 additions & 6 deletions zsh/zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,8 @@ zplug load #--verbose
for config_file (${ZDOTDIR:-$HOME}/.zsh/zsh.d/*.zsh(N)) source $config_file

# Terminal
# screen-256color if inside tmux, xterm-256color otherwise
if [[ -n "$TMUX" ]]; then
export TERM="screen-256color"
else
export TERM="xterm-256color"
fi
# Use xterm-256color (for tmux, too)
export TERM="xterm-256color"

# iTerm integration (for OS X iTerm2)
# @see https://iterm2.com/shell_integration.html
Expand Down