
So I've had this request a couple of times now, a bit of a tutorial on how I set up my Neovim - This is designed around running on macOS using ZSH - but I'm sure most of the commands would work on Linux and/or Bash.
So why Neovim rather than regular Vim? Mainly because it's a more modern version of it. Neovim can run plugins written for both the standard Vim and Neovim specific. Config and plugins are written using Lua, which isn't a language I've had a LOT of experience with, but it's pretty easy to pick up. Plus learning the basics of this is much more useful than a domain specific language that Vim uses.
So for starters, you need Homebrew installed (this works both on macOS and Linux - you may need to install Git if you don't already have it).
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Next up, make sure you install Neovim and Fzf
brew install neovim fzf
I have used LazyVim as the base of my Neovim config. It has most of the plugins I'd want anyway, and some really good defaults. This is done by cloning the starter template (Into the standard .config
directory) then removing the .git
directory (so we can add it to our own repository if we like)
git clone https://github.com/LazyVim/starter ~/.config/nvim
rm -rf ~/.config/nvim/.git
Start up Neovim and wait for all the plugins to download and install
nvim
Now we get to the additional plugins I use and how I configure them. From LazyExtras :LazyExtras
these are the ones I have installed
- coding.mini-surround
- One of my most used addins, lets me surround text with quotes, brackets, slashes, etc. eg
gsaaw"
surrounds a word with quotes
- One of my most used addins, lets me surround text with quotes, brackets, slashes, etc. eg
- coding.yanky
- Adds history for yanking (copying)
- chezmoi.ui
- Automatically picks the Chezmoi managed version of my dot files (I have temporarily heavily customised this until the next version is released)
- dap.core
- Debugger
- editor.fzf
- FZF for picking files
- editor.inc-rename
- Renaming via LSP
- editor.refactoring
- Various refactoring tools
- formatting.prettier
- Prettier formatting (I'm mainly a Typescript developer these days)
- linting.eslint
- In editor linting
- lsp.none-ls
- Fallback LSP
- test.core
- Testing tools in editor
- ui.smearcursor
- Just a fun tool for bouncing the cursor around the screen as you move it
- util.dot
- LSP support for dotfiles
- util.mini-hipatterns
- Show colours directly in code (highlights the colour value with the actual colour)
Additionally, on my work laptop where the company pays for Github Copilot, I use
- ai.copilot
- AI auto completion
- ai.copilot-chat
- brings up a chat window to ask the LLM various questions about how to do things in code, etc
Beyond that I have a few I manually add. The beauty of LazyVim is that you just add it to your config and it'll automatically download it for you.
- codestats.nvim
- For my totally useless but fun stats about my coding (I've also added to this repository)
- markview.nvim
- Markdown support. I think this one is better than the supplied one with LazyVim. Plus, the majority of it was developed with a phone! 🤯
- mini.snippets
- Snippets for coding. You can customise these per language. One of my most used is
aaa
which adds ARRANGE, ACT & ASSERT comments while I'm writing my tests
- Snippets for coding. You can customise these per language. One of my most used is
- nvim-tmux-navigation
- Integrates Neovim to tmux, so you can move in and out of Neovim using standard change buffer controls
- nvim-coverage
- Shows test coverage in your editor based on LCOV outputs
- obsidian.nvim
- Extra Obsidian support in Neovim - I haven't really delved deeply into this one yet.
- nvim-surround
- Easily change surrounding marks, eg. changing a
"
to a'
. I use this one very frequently too.
- Easily change surrounding marks, eg. changing a
- neotest
- Actual integration of testing into Neovim - I just have this set up for Vitest currently
- undotree
- Easily visualize your undo history, including the ability to "go back" through previous edits. This works a lot like Git in that it branches changes off, so if you undo, and edit, you don't lose your redo history
I'm still looking for the ideal AI solution to run with Ollama. I really like the llama.cpp version but I don't like that it doesn't use Ollama like everything else does. So I'm evaluating various options. Currently minuet for autocomplete. I haven't started playing with chat options yet, but may look at avante.nvim as a starting point.
Configuring everything is a challenge in itself too. You can see my current config on github, but some callouts are as follows:
local codestats = require("codestats")
local xp = function()
return codestats.get_xp(0) .. "/" .. codestats.get_xp() -- current buf language xp
end
return {
{
"nvim-lualine/lualine.nvim",
opts = function(_, opts)
opts.sections.lualine_z = {}
opts.sections.lualine_z = {
"location",
"filetype",
{
xp,
fmt = function(s)
return s and (s ~= "0/0" or nil) and s .. "xp"
end,
},
}
end,
},
}
This is for disabling the clock in my Lualine (I have it in Tmux instead) and adds my experience points from Codestats
return {
"echasnovski/mini.snippets",
opts = function(_, opts)
local snippets, config_path = require("mini.snippets"), vim.fn.stdpath("config")
opts.snippets = {
snippets.gen_loader.from_file(config_path .. "/snippets/global.json"),
snippets.gen_loader.from_lang(),
}
end,
}
This is for setting up my snippets, pointing it at ~/.config/nvim/snippets
return {
"jiaoshijie/undotree",
dependencies = "nvim-lua/plenary.nvim",
config = true,
keys = { -- load the plugin only when using it's keybinding:
{
"<leader>U",
function()
require("undotree").toggle()
end,
desc = "Undotree",
},
},
}
This sets up undotree with a keybinding for opening it (Space, U).
If you're not used to moving around in Vim, this will take a while to get used to, but if you're comfortable in the standard Vim motions, you should be able to adapt to this quite easily, and dump any existing IDE you're currently using (I was a very heavy VSCode user, but now I can't remember the last time I deliberately opened it - and haven't even installed it on my latest client machine). If you want to learn, I highly recommend LazyVim for ambitious developers