DEV Community

Cover image for Vim theme + plugin manager!
Louis Bertin
Louis Bertin

Posted on • Edited on

Vim theme + plugin manager!

I am frequently watching tech/dev youtubers (DistroTube, Luke Smith..) and I've always asked myself how they have an Atom/Vs Code/Sublime Text-like Vim editor.
I have always wanted the same things because Vim is a must have and literally changed my life (as a software engineer..). I discover new features every day and each time this blows my mind.

So, I have done some research to improve my setup and here are few steps to have a better Vim experience.

⚠️ This tutorial is for macOS, on Linux systems you just have to deal with your own package manager.

Prerequisites

How to pimp your Vim

  • 1. Install Neovim

I advise you to install Neovim instead of the classic Vim. Neovim is a fork of Vim, developed in order to improve Vim.

On macOS, just install it with Brew : brew install neovim Then, you can access it with the nvim command line. Or, you can create and add an alias to your .bashrc or .zshrc : alias vim='/usr/local/bin/nvim'

  • 2. Install Vim-plug

Vim-plug is one of the best plugin managers for Vim. It simplifies the way to install new Vim features.

First, you have to create Vim config folder if it doesn't exist : cd ~/.config/ && mkdir nvim
Then, you can install Vim-plug : sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'

⚠️ Here is the command line coming from the Vim-plug repository, I advise you to get the latest one on the official repo.

  • 3. Vim plug configuration and plugin installation

Create a Neovim config file into the Neovim config folder (~/.config/neovim/) : touch init.vim

Now we need to configure Neovim to install the Onedark.vim theme (my favorite one), you can choose another theme but this tutorial is not covering this subject.

Here is my config file with a few plugins :

  • onedark.vim : neovim colorscheme
  • lightline.vim : colorscheme for vim mode (insert, normal, etc)
  • vim-polyglot : to handle multiple languages
"Specify a directory for plugins"
call plug#begin('~/.config/nvim/plugged')

"Neovim theme"
Plug 'joshdick/onedark.vim'
"Lightline vim"
Plug 'itchyny/lightline.vim'
"Multiple language support"
Plug 'sheerun/vim-polyglot'

"Initialize plugin system"
call plug#end()


"Use 24-bit (true-color) mode in Vim/Neovim when outside tmux.
"If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support
"(see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.)
if (empty($TMUX))
  if (has("nvim"))
    "For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
    let $NVIM_TUI_ENABLE_TRUE_COLOR=1
  endif
  "For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
  "Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
  " < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
  if (has("termguicolors"))
    set termguicolors
  endif
endif

"onedark theme"
syntax on
colorscheme onedark
Enter fullscreen mode Exit fullscreen mode

Now, you just have to install your plugins, into Neovim run the following command PlugInstall a window pops up and you can see your plugins installed.

Restart Neovim and appreciate your new theme! 🙂

  • 4. This is just the beginning!

I have intentionally talked about a simple configuration (Keep It Simple Stupid!), but you can create your own plugin or add another one to your Vim configuration.

Top comments (3)

Collapse
 
joshleong profile image
Josh Leong

I just completed these steps to configure after wading through a bunch of tutorials. Excellent quick to the point, wish I found this earlier! Good job!

Collapse
 
louisbertin profile image
Louis Bertin

Thank you! Have fun with your customised Vim 😉

Collapse
 
glydric22 profile image
Glydric22

This is pretty bad, seems a tutorial for who already knows all, also the folder ~/.config/neovim/ will not gonna work as it uses ~/.config/nvim/