Last Updated on March 27, 2023 by mishou
I. Let’s learn Neovim Configuration
Configuring Neovim can be a time-consuming task, but I believe that practicing is the best way to master it. In this post, I’ll share some tips for creating a better environment for practicing.
Managing Configurations
Backing up your current configuration and saving a new configuration file in the appropriate directory every time you try a new one can be a hassle. However, you don’t need to back up anything if you open Neovim with the “-u” flag. For example, to open Neovim with your custom configuration file named “custom.lua”, run the following command:
nvim -u ~/.config/nvim/custom.lua
Managing Versions
Another issue with Neovim configuration is encountering errors caused by differences between Neovim versions. When using sample configurations found online, you may need to switch between Neovim versions. Bob is a tool that allows for easy switching between versions right from the command line.
You can learn how to install and use Bob by reading my post, which is available at this link:
http://www.mishou.be/2023/02/21/neovim-get-started-with-bob-ver-1/
II. Selecting configurations and configurations
The following is the folder structures of my Neovim configurations. You can see three configuration files and four Neovim executable files of different versions shown in the following diagram:

“You can choose any combination of configurations and versions by using Bob and the -u flag.”
When you select 0.9.0 + init.lua, that is, default combination:
./nvim.appimage
When you select 0.8.0 + journal.vim
bob use 0.8.0
~/.local/share/bob/nvim-bin/nvim -u ~/.config/nvim/journal.vim
III. My configurations
Default configuration
I have set up the Default Neovim configuration by following the tutorial:
Turning Neovim into a Full-Fledged Code Editor with Lua
jounal.vim
See my previous post: Journaling using a separate Neovim configuration, vimwiki
sample_conf1.lua
I have created a sample configuration file written in Lua for learning basic Neovim configuration:
-- init.lua
vim.cmd([[packadd packer.nvim]])
-- General settings
vim.cmd("syntax enable")
vim.cmd("filetype plugin indent on")
vim.opt.clipboard = "unnamedplus"
vim.opt.number = true
vim.opt.expandtab = true
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.autoindent = true
vim.opt.smartindent = true
-- Plugin management with Packer
require("packer").startup(function()
use("nvim-lua/plenary.nvim")
use("wbthomason/packer.nvim")
use("neovim/nvim-lspconfig")
use("nvim-treesitter/nvim-treesitter")
use("nvim-telescope/telescope.nvim")
use("kyazdani42/nvim-web-devicons")
use("akinsho/nvim-bufferline.lua")
use("mhinz/vim-startify")
end)
-- LSP settings
local lspconfig = require("lspconfig")
lspconfig.clangd.setup({})
-- Telescope settings
require("telescope").setup({
defaults = {
prompt_prefix = "> ",
selection_caret = "> ",
layout_strategy = "horizontal",
layout_config = {
horizontal = {
mirror = false,
},
vertical = {
mirror = false,
},
},
},
})
-- Treesitter settings
require("nvim-treesitter.configs").setup({
ensure_installed = {"python", "c", "lua"},
highlight = {
enable = true,
},
})
-- Startify settings
vim.g.startify_lists = {
{ type = 'files', header = {' Recent Files'}},
{ type = 'sessions', header = {' Sessions'}},
{ type = 'bookmarks', header = {' Bookmarks'}}
}
vim.g.startify_session_dir = '~/.config/nvim/session'
vim.g.startify_session_persistence = 1
-- Bufferline settings
require("bufferline").setup({
options = {
numbers = function(opts)
return string.format("%s.", opts.ordinal)
end,
mappings = true,
close_command = "bdelete! %d",
right_mouse_command = "bdelete! %d",
left_mouse_command = "buffer %d",
middle_mouse_command = nil,
},
})
return -- return nil to ensure no values are returned
Open Nightly configured with sample_conf1.lua:
bob use nightly
~/.local/share/bob/nvim-bin/nvim -u ~/.config/nvim/sample_conf1.lua

“Of course, you can set the following aliases for convenience by adding the following lines to the .bashrc file.”
alias nvbob="~/.local/share/bob/nvim-bin/nvim"
alias nvsample1="nvbob -u ~/.config/nvim/sample_conf.lua"
Now you can open Nightly configured with sample_conf1.lua:
bob use nightly
nvsample1