Table Of Contents
Welcome back, my friends!
I know, I know, it’s been a while since we last delved into the wonderful world of LazyVim customization.
In Part 1, we laid the groundwork with LazyVim, establishing a solid foundation for our Neovim journey. Now, it’s time to take things to the next level β personalization!
In the next section, I want to express my gratitude to Takuya Matsuyama, who is a true inspiration to me. I have learned a great deal from his work, and I am deeply appreciative of his contributions to the field.
And now, let’s start cowboy π€ π€ π€ .
Folder Structure Tree of LazyVim
Before starting to customize anything, we need to quickly look through the default File Structure Diagram of Lazy.vim to get an overview of it.
For more information: General Settings
~/.config/nvim
βββ lua
β βββ config
β β βββ autocmds.lua
β β βββ keymaps.lua
β β βββ lazy.lua
β β βββ options.lua
β βββ plugins
β βββ spec1.lua
β βββ **
β βββ spec2.lua
βββ init.toml
-
autocmds.lua (auto commands): are used to automatically execute specific
commands
orfunctions
in response to certain events in the editors.
Greatly enhance your Vim workflow, it very wonderful π.
-
keymaps (key mappings): are configurations that define custom keyboard shortcuts. These mappings allow users to bind specific keys or combinations of keys to Vim
commands
,functions
, orscripts
, β¦ thereby streamlining their workflow and making repetitive tasks quicker and easier.
Suppose you donβt know about Key Mappings. In that case, I think this is a useful blog to get started with: Basic Vim Mapping.
Thanks for the great post!
lazy.lua: this is a place to set the default configuration of the Lazy.vim
options.lua (optional): you can set anything to custom your Vim if you want like:
autoindent
,smartindent
,hlsearch
,showcmd
,shiftwidth
, β¦ I will show my config later π«£
Overview of the bullet points
Now, we are an overview of the bullet points I will configure in the next section:
- Theme:
- Keymaps:
- keymaps
- autocmds
- options
- Plugins:
- ColorScheme (at above):
- coding:
- lsp:
- treesitters:
- ui:
- editors:
As you configure each plugin, it’s a good idea to save your changes and restart nvim quickly. This helps you catch any errors right away and makes troubleshooting smoother down the line. Think of it like a mini test drive after each tweak! π€ π€ π€
Solarized Osaka theme:
To change your theme create a file like colorscheme.lua
Create: lua/plugins/colorscheme.lua
and config:
return { { "craftzdog/solarized-osaka.nvim", branch = "osaka", lazy = true, priority = 1000, opts = function() return { transparent = true, } end, },
}
After config, you restart and see the theme:
Awesome π₯Έπ₯Έπ₯Έ!!!
Key Mappings
The LazyVim has already configured many things for me now, but I added some customizations like those in the file: lua/config/keymaps.lua
local keymap = vim.keymap
local opts = { noremap = true, silent = true } keymap.set("n", "x", '"_x') -- Increment/decrement
keymap.set("n", "+", "<C-a>")
keymap.set("n", "-", "<C-x>") -- Delete a word backwards
keymap.set("n", "dw", 'vb"_d') -- Select all
keymap.set("n", "<C-a>", "gg<S-v>G") -- Save with root permission (not working for now)
--vim.api.nvim_create_user_command('W', 'w !sudo tee > /dev/null %', {}) -- Disable continuations
keymap.set("n", "<Leader>o", "o<Esc>^Da", opts)
keymap.set("n", "<Leader>O", "O<Esc>^Da", opts) -- Jumplist
keymap.set("n", "<C-m>", "<C-i>", opts) -- New tab
keymap.set("n", "te", ":tabedit")
keymap.set("n", "<tab>", ":tabnext<Return>", opts)
keymap.set("n", "<s-tab>", ":tabprev<Return>", opts)
-- Split window
keymap.set("n", "ss", ":split<Return>", opts)
keymap.set("n", "sv", ":vsplit<Return>", opts)
-- Move window
keymap.set("n", "sh", "<C-w>h")
keymap.set("n", "sk", "<C-w>k")
keymap.set("n", "sj", "<C-w>j")
keymap.set("n", "sl", "<C-w>l") -- Resize window
keymap.set("n", "<C-w><left>", "<C-w><")
keymap.set("n", "<C-w><right>", "<C-w>>")
keymap.set("n", "<C-w><up>", "<C-w>+")
keymap.set("n", "<C-w><down>", "<C-w>-") -- Pick a buffer
keymap.set("n", "<Leader>1", "<Cmd>BufferLineGoToBuffer 1<CR>", {})
keymap.set("n", "<Leader>2", "<Cmd>BufferLineGoToBuffer 2<CR>", {})
keymap.set("n", "<Leader>3", "<Cmd>BufferLineGoToBuffer 3<CR>", {})
keymap.set("n", "<Leader>4", "<Cmd>BufferLineGoToBuffer 4<CR>", {})
keymap.set("n", "<Leader>5", "<Cmd>BufferLineGoToBuffer 5<CR>", {})
keymap.set("n", "<Leader>6", "<Cmd>BufferLineGoToBuffer 6<CR>", {})
keymap.set("n", "<Leader>9", "<Cmd>BufferLineGoToBuffer -1<CR>", {}) -- Moving text
-- Move text up and down
keymap.set("n", "<C-Down>", "<Esc>:m .+1<CR>", opts)
keymap.set("n", "<C-Up>", "<Esc>:m .-2<CR>", opts)
keymap.set("v", "<C-Down>", ":m .+1<CR>", opts)
keymap.set("v", "<C-Up>", ":m .-2<CR>", opts)
keymap.set("x", "<C-Down>", ":move '>+1<CR>gv-gv", opts)
keymap.set("x", "<C-Up>", ":move '<-2<CR>gv-gv", opts) -- Diagnostics
keymap.set("n", "<C-j>", function() vim.diagnostic.goto_next()
end, opts)
Auto Commands
lua/config/autocmds.lua
I donβt want to show concealing
when using json
and markdown
files and turn off paste mode when leaving insert. So, I set conceallevel
to 0 for json
files and turned off paste mode like below.
If you want to use them, you can skip this config file π
-- Turn off paste mode when leaving insert
vim.api.nvim_create_autocmd("InsertLeave", { pattern = "*", command = "set nopaste",
}) -- Disable the concealing in some file formats
-- The default conceallevel is 3 in LazyVim
vim.api.nvim_create_autocmd("FileType", { pattern = { "json", "jsonc", "markdown" }, callback = function() vim.opt.conceallevel = 0 end,
})
Awesome π₯Έπ₯Έπ₯Έ!!!
Options Configuration Vim
I have some config for default Vim, itβs only just an old config for normal nvim in the past: lua/config/options.lua
. I will omit to explain this file π«£
vim.g.mapleader = " " vim.opt.encoding = "utf-8"
vim.opt.fileencoding = "utf-8" vim.opt.spell = true
vim.opt.spelllang = { "en_us" } vim.opt.number = true vim.opt.title = true
vim.opt.autoindent = true
vim.opt.smartindent = true
vim.opt.hlsearch = true
vim.opt.backup = false
vim.opt.showcmd = true
vim.opt.cmdheight = 1
vim.opt.laststatus = 2
vim.opt.expandtab = true
vim.opt.scrolloff = 10
vim.opt.shell = "fish"
vim.opt.backupskip = { "/tmp/*", "/private/tmp/*" }
vim.opt.inccommand = "split"
vim.opt.ignorecase = true -- Case insensitive searching UNLESS /C or capital in search
vim.opt.smarttab = true
vim.opt.breakindent = true
vim.opt.shiftwidth = 2
vim.opt.tabstop = 2
vim.opt.wrap = false -- No Wrap lines
vim.opt.backspace = { "start", "eol", "indent" }
vim.opt.path:append({ "**" }) -- Finding files - Search down into subfolders
vim.opt.wildignore:append({ "*/node_modules/*" })
vim.opt.splitbelow = true -- Put new windows below current
vim.opt.splitright = true -- Put new windows right of current
vim.opt.splitkeep = "cursor"
vim.opt.mouse = ""
vim.g.deprecation_warnings = true -- Undercurl
vim.cmd([[let &t_Cs = "\e[4:3m"]])
vim.cmd([[let &t_Ce = "\e[4:0m"]]) -- Add asterisks in block comments
vim.opt.formatoptions:append({ "r" }) vim.cmd([[au BufNewFile,BufRead *.astro setf astro]])
vim.cmd([[au BufNewFile,BufRead Podfile setf ruby]]) if vim.fn.has("nvim-0.8") == 1 then vim.opt.cmdheight = 0
end
Honestly, I donβt want this post to be too long, so Iβll cover the Plugin configuration section in the next article.
My dotfiles configurations:
Configuration for nvim with lua
Warning: Donβt blindly use my settings unless you know what that entails. Use at your own risk!
- vim (NeoVim) config
- tmux config
- git config
- karabiner mapping
- fish config
Karabiner element application
I use Karabiner to customize some keys for my keyboard to make vim easier for me to use.
To install: brew install --cask karabiner-elements
Search in the registry:
Neovim setup
Requirements
- Neovim >= 0.9.0 (needs to be built with LuaJIT)
- Git >= 2.19.0 (for partial clones support)
- LazyVim
- a Nerd Font(v3.0 or greater) (optional, but needed to display some icons)
- lazygit (optional)
- a C compiler for
nvim-treesitter
. See here - for telescope.nvim (optional)
- a terminal that support true color and undercurl
π Connect with me on Linkedin
See you soon, comrades, in the next part.
Thanks for reading!
Discover more from Coursity
Subscribe to get the latest posts sent to your email.