Build your custom Vim from scratch

VIM

We have been there… We have done that… Kinda.
After an update my config kinda broke. So I thought it was time for a long overdue Neovim config from scratch.
I will try to stay as minimalistic as possible while (probably) still using a plugin manager.

Initial Setup

We will use vim, nvim, neovim indifferently in this article.
If you like to play around and try different configurations, I would suggest adding the following aliases in your .zshrc. The “custom-nvim” here refers to a folder using that name in .config.

alias vim=nvim
alias vv='NVIM_APPNAME=custom-nvim nvim'

For more information on switching configs, I would recommend this website.

sudo pacman -S neovim

Once nvim is installed, open an empty document type the following command to know where vim is looking for its configuration.

:echo stdpath('config')

Config

First draft for minimalist init.lua

vim.pack.add {
    { src = 'https://github.com/nvim-treesitter/nvim-treesitter', version = 'main' },
    'https://github.com/neovim/nvim-lspconfig',
    'https://github.com/catppuccin/nvim',
}

vim.cmd.packadd('cfilter')
vim.cmd.packadd('nvim.undotree')
vim.cmd.packadd('nvim.difftool')

vim.cmd.colorscheme('catppuccin')

vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.ignorecase = true
vim.opt.smartcase = true
-- vim.opt.colorcolumn = '80'
-- vim.opt.textwidth = 80

-- disable mouse popup yet keep mouse enabled
-- vim.cmd [[
--  aunmenu PopUp
--   autocmd! nvim.popupmenu
--]]

-- Only highlight with treesitter
--vim.cmd('syntax off')

vim.api.nvim_create_autocmd('TextYankPost', {
    callback = function() vim.highlight.on_yank() end,
})

require('nvim-treesitter').setup {
    ensure_installed = { 'python', 'rust', 'go', 'lua', 'vim', 'vimdoc' },
    highlight = {
        enable = true,
    },
}

Motions

  • comment code
  • comment multiple lines