Neovim from Scratch - Part 1: lazy.nvim, kanagawa.nvim, oil.nvim, Statusline & Essential Settings
Table of Contents
Introduction
This tutorial guides you through the process of setting up a robust Neovim configuration from scratch, focusing on essential features for an efficient development environment. We will cover the installation of a package manager, configuration of themes, file management, and custom settings to enhance your Neovim experience.
Step 1: Install lazy.nvim Package Manager
- Open your terminal and navigate to your Neovim configuration directory, typically
~/.config/nvim/
. - Create a new file called
init.lua
if it doesn't exist. - Add the following code to install lazy.nvim:
-- Bootstrap lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath, }) end vim.opt.rtp:prepend(lazypath)
Step 2: Configure Essential Settings
-
Add basic settings to your
init.lua
to enhance usability:-- Basic settings vim.opt.number = true vim.opt.relativenumber = true vim.opt.mouse = "a" -- Enable mouse support vim.opt.splitbelow = true -- Split windows below vim.opt.splitright = true -- Split windows to the right
-
Setup automatic indentation detection:
vim.opt.autoindent = true vim.opt.smartindent = true
Step 3: Install and Configure kanagawa.nvim Theme
-
Add kanagawa.nvim to your plugins in
init.lua
:require("lazy").setup({ { "rebelot/kanagawa.nvim" } })
-
Set the theme after loading the plugins:
require("kanagawa").setup() vim.cmd("colorscheme kanagawa")
Step 4: Install and Configure oil.nvim File Manager
-
Add oil.nvim to your plugins:
require("lazy").setup({ { "stevearc/oil.nvim" } })
-
Replace the default file explorer:
vim.keymap.set("n", "-", require("oil").open, { desc = "Open parent directory" })
Step 5: Customize Statusline
-
Install a statusline plugin (e.g., lualine):
require("lazy").setup({ { "nvim-lualine/lualine.nvim" } })
-
Set up the statusline:
require("lualine").setup({ options = { theme = "kanagawa", section_separators = '', component_separators = '', } })
Step 6: Configure Git Integration in Sign Columns
-
Add Git signs for better visibility:
require("lazy").setup({ { "lewis6991/gitsigns.nvim" } })
-
Enable Git signs:
require("gitsigns").setup()
Conclusion
You have successfully set up a foundational Neovim configuration with lazy.nvim as your package manager, implemented the kanagawa.nvim theme, replaced netrw with oil.nvim, and customized your statusline. This configuration enhances your development environment, making it more user-friendly and efficient.
For further enhancements, consider exploring advanced features like Treesitter for syntax highlighting and LSP for code intelligence in upcoming episodes of this series. Your next steps could include diving into those features or refining your current setup to better suit your workflow.