Full Neovim Setup from Scratch in 2024
4 min read
2 hours ago
Published on Dec 16, 2024
This response is partially generated with the help of AI. It may contain inaccuracies.
Table of Contents
Introduction
This tutorial provides a comprehensive guide to setting up Neovim from scratch in 2024 using kickstart.nvim. Whether you are a beginner or looking to refine your existing setup, this guide will walk you through the essential steps to create a personalized and efficient Neovim environment.
Step 1: Install Neovim
- Download the latest version of Neovim from the official website.
- Follow the installation instructions for your operating system (Windows, macOS, Linux).
- Verify the installation by running the command:
nvim --version
Step 2: Install kickstart.nvim
- Clone the kickstart.nvim repository into your Neovim configuration directory:
git clone https://github.com/hendrikmi/neovim-kickstart-config ~/.config/nvim
- This repository contains a basic configuration that you can customize later.
Step 3: Configure Neovim
- Open Neovim to edit your configuration file:
nvim ~/.config/nvim/init.lua
- Modify the configuration as needed. Key areas to customize include:
- Plugin settings
- Language Server Protocol (LSP) integration
- User preferences
Step 4: Setup Lazy Plugin Manager
- Install the Lazy plugin manager for managing your plugins efficiently.
- In your
init.lua
, add the following code to set up Lazy:require('lazy').setup('plugins')
- Create a
plugins.lua
file to define your plugins.
Step 5: Configure Neo-tree File Explorer
- Add Neo-tree to your plugin list in
plugins.lua
:use 'nvim-neo-tree/neo-tree.nvim'
- Configure Neo-tree to suit your workflow. Common settings include:
- Toggle keybindings
- Custom icons
Step 6: Choose a Color Theme
- Select a color theme by adding to your plugins:
use 'folke/tokyonight.nvim'
- Set the theme in your
init.lua
:vim.cmd 'colorscheme tokyonight'
Step 7: Set Global Vim Options
- In your
init.lua
, configure global options to enhance your editing experience:vim.opt.number = true vim.opt.relativenumber = true vim.opt.tabstop = 4 vim.opt.shiftwidth = 4 vim.opt.expandtab = true
Step 8: Create Custom Keymaps
- Define custom key mappings in your
init.lua
. For example:vim.api.nvim_set_keymap('n', '<leader>e', ':NeoTreeToggle<CR>', { noremap = true, silent = true })
Step 9: Modularize Your Configuration
- Break down your
init.lua
into multiple Lua modules for better organization. - Create a folder structure like
lua/config/
and load each module in yourinit.lua
:require('config.keymaps') require('config.plugins')
Step 10: Setup Bufferline
- Add Bufferline to your plugin list:
use 'akinsho/bufferline.nvim'
- Configure it in your
init.lua
for better navigation between buffers.
Step 11: Configure Statusline
- Use a plugin for a customizable statusline:
use 'nvim-lualine/lualine.nvim'
- Set it up to display useful information like current file type and position.
Step 12: Setup Treesitter
- Install Treesitter for better syntax highlighting:
use 'nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' }
- Configure Treesitter for the languages you work with.
Step 13: Integrate Telescope Fuzzy Finder
- Add Telescope to your plugins:
use 'nvim-telescope/telescope.nvim'
- Set up keybindings to invoke Telescope easily.
Step 14: Configure LSP
- Install LSP support for your preferred languages:
use 'neovim/nvim-lspconfig'
- Configure the LSP servers in your
init.lua
:require'lspconfig'.pyright.setup{}
Step 15: Enable Autocompletion
- Use a completion plugin like nvim-cmp:
use 'hrsh7th/nvim-cmp'
- Set it up in your configuration for improved coding speed.
Step 16: Autoformatting and Format on Save
- Enable autoformatting by adding the following to your LSP setup:
vim.lsp.buf.formatting_sync()
Step 17: Setup Git Integration
- Integrate Git features with Neovim using plugins like fugitive:
use 'tpope/vim-fugitive'
Step 18: Configure Greeter Screen
- Set up a welcome screen by using a plugin like alpha-nvim:
use 'goolord/alpha-nvim'
Step 19: Add Indent Guides
- Install a plugin for visualizing indentation levels:
use 'Yggdroot/indentLine'
Step 20: Explore Miscellaneous Plugins
- Consider additional plugins that enhance productivity, such as:
- Git signs
- Comment toggling
Conclusion
By following these steps, you will have a fully configured Neovim setup tailored to your preferences in 2024. Explore additional plugins and configurations to further enhance your coding experience. Happy coding!