An Actually Usable Vim Setup
How I configured my Vim setup to be a pleasure to use
Albin Groen
Posted 2021-05-26
Every time I've tried using Vim for a substantial amount of time, I always found myself longing back to Visual Studio Code. Mostly because of the lack of auto-completion, worse performance, or modernity of Vim. Now I think I have a pretty decent setup though, and I thought I'd share it with the world. This will probably be changed in a couple of weeks though, or I might as well have gone back to VScode.
Here are the 3 components that make up my setup:
- Terminal: Alacritty
- Vim: Neovim
- Shell: zsh
Alacritty
When it comes to the terminal, my experience is that the performance of running Vim in the terminal is far better in Alacritty, than say in something like iTerm2. Don't get me wrong, iTerm is a really great terminal, that has features like tabs and splits, that Alacritty lacks. Alacritty is a far more low-level terminal emulator but does take home the performance price in my experience. It's also very customizable, which is nice.
Here's what my configuration for Alacritty looks like right now:
import:
- "/Users/albin/.dotfiles/color.yml"
env:
TERM: xterm-256color
# Window Customization
window:
dynamic_title: true
padding:
x: 16
y: 16
draw_bold_text_with_bright_colors: true
scrolling:
# Maximum number of lines in the scrollback buffer.
# Specifying '0' will disable scrolling.
history: 10000
# Number of lines the viewport will move for every line scrolled when
# scrollback is enabled (history > 0).
multiplier: 3
# Font Customization
font:
normal:
family: Monaco
style: Regular
bold:
family: Monaco
style: Bold
italic:
family: Monaco
style: Regular Italic
size: 18.0
offset:
x: 0
y: 0
glyph_offset:
x: 0
y: 0
use_thin_strokes: false
debug:
persistent_logging: false
# Fixes opt+key not working on Mac
alt_send_esc: false
# Reload Alacritty if the configuration changes
live_config_reload: true
The configuration, as you can see, is fairly simple. It makes sure to add some padding to the window, changes the font family and ups the font size, as well as fixes a couple of annoyances that come with Alacritty. This created a very nice terminal experience, which for me works better than iTerm.
Neovim
I've tried to keep my Neovim configuration fairly simple, although not by compromising the editing experience. A couple of extensions that I find really necessary are coc.nvim, for intellisense, and vim-just-pretty and yats.vim to get React/Typescript syntax highlighting. I also don't use something like Tmux. I find that when using Tmux the editing performance inside of Vim is slightly worsened, and makes me focus more on which window, session, or pane I'm at all the time instead of focusing on writing the actual code. Instead, I run several instances of Alacritty. For example, if I'm working on a React.js project, I have one instance where I run the server, and then one where I run Vim and edit the code.
Here's what my configuration for Neovim looks like right now:
" Start plugin managemer
call plug#begin('~/.vim/plugged')
" Plugins
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'maxmellon/vim-jsx-pretty'
Plug 'HerringtonDarkholme/yats.vim'
Plug 'joshdick/onedark.vim'
Plug 'tomtom/tcomment_vim'
Plug 'tpope/vim-surround'
Plug 'ctrlpvim/ctrlp.vim'
" Initialize plugin manager
call plug#end()
" Basic settings
let mapleader = "\<Space>"
filetype plugin indent on
set relativenumber
set softtabstop=2
set numberwidth=2
set shiftwidth=2
set splitright
set splitbelow
set expandtab
set tabstop=2
set nowrap
set cursorline
set termguicolors
" Easier splitting
nnoremap vs :vs<CR>
nnoremap sp :sp<CR>
" Easier closing of buffers
nnoremap q :q<CR>
" Easier navigation between panes
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-J> <C-W><C-J>
" Make ctrlp ignore all files listed in .gitignore
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']
" Theming
syntax enable
set background=dark
colorscheme onedark
" COC configuration
so ./coc-config.vim
If you want to check out all my different configuration files for zsh, Alacritty, as well as Neovim, take a look at this GitHub repository albingroen/.dotfiles, and if you have any questions, don't hesitate to hit my up at Twitter @albingroen.
Thanks for reading!