Vim-Plugins: Part 3 - Sync Tmux and Vim Theme

There are generally two types of people in the IT world: those who accept whatever the defaults are on a particular system, and those that endlessly tweak their setup with config changes, new themes, and custom shortcuts. Both have their advantages and disadvantages of course. I’m of the opinion that an admin or developer’s primary tools and environment should be not just efficient, powerful, and easy to use but also beautiful. I will easily spend 8+ hours a day staring at a terminal window … why would I not want it to be as beautiful as possible?

Themes, themes and more themes

Most text editors have a variety of theme choices and vim is no exception. I often find myself browsing the newest additions on vimcolors.com, looking for something that catches my eye. But the terminal experience isn’t just about vim and its appearance: your terminal emulator itself likely supports themes. There are also terminal multi-plexers like tmux. I personally hate it when themes across my various tools clash.

I use the amazing alacritty terminal emulator. It’s written in rust, uses GPU rendering, is blazing fast and is fairly easy to customize. It has a number of themes available, which can be applied easily enough with this lovely python tool: alacritty-colorscheme. I’m currently using the one_dark theme.

Tmuxline: sync your vim and tmux statusline

tmuxline generates a tmux status line and syncs your vim theme to tmux. With the terminal colorscheme already set, we can now have the same theme across vim, tmux, and the terminal emulator itself. This gives a really polished and consistent look that is quite pleasing to the eyes. Everything just feels right.

vim-3-tmuxline-1

tmuxline can be installed with vim-plug by adding Plug 'chriskempson/base16-vim' to your ~/.config/nvim/init.vim and then running :PlugInstall.

Once installed, we’ll need to configure it. Add the following to your ~/.config/nvim/init.vim file:

" Theme
set termguicolors
let base16colorspace=256  " Access colors present in 256 colorspace
colorscheme base16-onedark
set showtabline=2
let g:airline_theme='base16'

" force transparent vim background, not needed if you dont use terminal transparency
hi Normal guibg=NONE ctermbg=NONE

let g:tmuxline_powerline_separators = 1
let g:tmuxline_preset = {
	\ 'a': '#S',
        \ 'win': '#I #W',
        \ 'cwin': '#I #W',
	\ 'y': '#(spotify status artist) - #(spotify status track)',
        \ 'z': '%d %b %H:%M',
        \ 'options': {
        \'status-justify': 'left'}
	\}

vim-airline

vim-airline is one of several statusline plugins available for vim. It’s lightweight, customizable, comes with built-in integration with a number of other vim plugins, and it has quite a few themes available: vim-airline-themes

tmux-spotify

I use the tmux-spotify plugin to display the current artist and track, as well as provide a pop-up menu in tmux for advancing to the next track, etc. If that’s not something you’re interested in, simply omit this line from the let g:tmuxline_preset = {} block: \ 'y': '#(spotify status artist) - #(spotify status track)',