Code

Effective Neovim Setup Tutorial Guide

neovim lsp image

This is a blog on setting up neovim to be able to be at minimum, effective at coding something. I won’t go through each plugin in detail, but there is a plugin list with links to each plugin if you want to go in-depth.

Recently I borked my arch linux machine, and decided to wipe the partition and start from scratch. Along with the partition wipe was also my neovim configs, so I went and made a new neovim config from scratch. This time I went in with the mindset that I want to know how each part works and not just copy paste and call it a day. I think for the most part I understand what each one does now, and wanted to document this in a blog. Other blogs about neovim, like the movements I use and my neovim goals, are planned. So check back or follow me on socials to know when they come out.

I will need to somehow setup a way to check engagements, but if I see a lot of likes on m Twitter/BlueSky announcement of this blog post, I will work on another blog explaining my config settings. Drop me a comment/reply if you have any request or think something can be improved.

Config

My neovim config files are on my github .

Plugin List

I’ll be going through these plugins briefly below. For those that are just interested in what I am using, I’ll start this blog with the plugin list:

Plugin Manager

Lazy.nvim

I used to use packer plugin manager, but since it’s unmaintained now, I am using lazy.nvim. It has async execution for performance, and is able to lazy load specific plugins you want to lazy load. An example of this is in my init.lua:

{
    "windwp/nvim-autopairs",
    event = "InsertEnter",
    opts = {
        disable_filetype = { "TelescopePrompt" }
    }
},

The event value here is indicating that nvim-autopairs should load when we press insert or enter, so our startup time will be improved by not loading in this plugin until we are active in the file.

General Stuff

Nvimspectre

This is a decent search and replace tool that has a good interface, I like how much control you have with it. Sometimes you will just need to do an old fashion ripgrep, but this plugin will cover most of what you need.

The above video shows that I can hand select which search I want to replace, maybe all my functions have the same parameter name, but I only need to change the parameter name in only test3().

Comment

This helps with commenting and uncommenting bulk lines quickly.

Telescope

If we needed bread and butter, this is your bread. A powerful search tool to be able to navigate to a file fast. I would say your butter is the LSP setup, since that completes your flow of quickly navigating references and stuff.

telescope finder image

Autopairs

This helps with creating full brackets after pressing the start of the bracket. I also have a keybind that encloses words in brackets here (The link might be bad in the future, just look for remaps with autopair comment)

Nvim Ts Autotag

This helps with closing html element tags.

Nvim Treesitter

Syntax highlighter, more colors, better for the eyes.

Catppucchin

My theme is Catpucchin, but with background disabled. Since I am using a semi-opaque blurred terminal background.

catppucchin theme example

Lualine

This is just mostly eyecandy, it styles the bottom statusbar nicely.

lualine theme example

Bufferline

This is also just mostly eyecandy, it styles buffer tabs nicely.

bufferline example

LSP (you might call it intellisense)

nvim-lspconfig, mason, mason-lspconfig

To setup the LSP and server installer and manager, check mason-lspconfig#installation plugin. This has info on all 3 plugins you need to setup.

Mason is the server installer/manager, and lspconfig is your LSP.

LSP Completion Sources

nvim-cmp, cmp-nvim-lsp, cmp-buffer, cmp-path, cmp-cmdline, cmp-nvim-lsp-signature-help

These are needed for completion to know sources to draw from, so like cmp-path will detect a path like string and will try to help you complete a directory path on your pc.

Your browser doesn't support HTML video. Here is a link to the video instead.

Code Formatter

Conform

I put this below Mason and the LSP stuff because Mason helps you install the formatters you need to use this plugin. I’ve bound it for manual formatting on <leader>F, since I like to control when I want to format.

Snippets

I haven’t played around with snippets much, but I have it in place for when I do.


Ending Thoughts

In my opinion, having LSP completion, file finder, search and replace, and a code formatter is all you need to be effective at coding stuff. I think this setup should check those boxes, but the journey of editing your config never ends. So I will be updating my config and settings on occasions. If there are several major changes to my dotfiles, I think I might make another blog post revisiting my neovim setup again.

kokopi
neovim guide

Comments

Go to post