How2Nvim

A collection of mildly useful Neovim rituals. Because vimtutor is for cowards. - Alpha

A Basic development workflow

In this section I will talk about builtin tools that vim has to offer to make your workflow actually flow. Coming from an IDE with inline error messages, auto-completion and a big green “run” button this kind of workflow might seem weird to you, but I encourage you to give it a fair try. neovim can have all those fancy features too (with plugins), but they’re opt-in, and you should know both sides. I personally used neovim for a long time entirely relying on LSP and plugins to even be able to write code. But now that I’ve seen both perspectives, I developed my own personal workflow that includes LSP and semantic completion, but in a way less obvious way, leveraging neovim’s builtin tools as much as makes sense. ...

How to install neovim

Depending on your operating system this process will be different, so I will cover Linux, Windows, and MacOS. Linux Windows MacOS Linux There are a few ways of installing neovim on Linux, so I will touch on all the relevant ones. Your system’s package manager This is the canonical way of installing software on Linux and I encourage you to use it. However, considering how fast neovim is moving, many distributions will lag a version or two behind the latest stable release, or even a few. If you use Arch Linux or NixOS, you should have the latest version, but double-checking never hurts. As of writing this, the latest stable release of neovim is version 0.9.4. You can check the current stable release here. ...

How to install plugins

Plugins in vim and neovim are usually just collections of .vim (and in neovim’s case .lua) files which can be loaded or interacted with from your own config once you downloaded them. They are usually managed with git and cloned to your machine when you install them. There is a history of plugin managers in vim and neovim going back almost a decade, but nowadays the neovim community seems to have settled on lazy.nvim. Now, before you go and install it, I want to present you with other options, as well as my opinion on each one, and how plugins are “actually” implemented by these plugin managers. ...

Getting to know your editor

In this section I will cover more details about configuring and extending neovim as an editor. This will partially apply to vim as well, so I will explicitly mention anything that is neovim-exclusive. It’s also kind of over the place with random topics, as I don’t really see an order here, just pick and choose what you’re interested in :) As I already mentioned, neovim heavily invests into Lua. This means that you can write your entire configuration using Lua! (There are some exceptions to this, such as the autoload/ directory, but for the most part everything just works with Lua) ...

Completion

While most people use some sort of auto-completion plugin, vim and neovim actually have pretty decent completion functionality built-in. If you take a look at :help ins-completion you will see a list of various completion sources, like buffer words, entire lines, file paths, tags, dictionary words, and more. To be fair, some of these are pretty useless. When writing code you will probably not find yourself using a thesaurus very frequently. However, there are two completion mechanisms that stand out here: userfunc and omnifunc. Both work the exact same way, don’t ask me why there’s two of them; for simplicity’s sake I’m just going to say “omnifunc” from now on, but I mean both, technically. ...

Finding your way around

Now that you got to know vim and understand the basics of using and configuring it, you should start working on projects. You will only get better by doing, not by reading! However, I do admit that navigating between files can be quite unintuitive, so I will discuss different strategies here. netrw vim ships with a builtin plugin called netrw. It’s a file explorer, similar to the “file tree” you might be used to from VSCode or similar. You can open netrw using various commands, one of which is :Explore (or :Ex for short). It will open a buffer displaying the current directory structure. It has a pretty ugly and useless banner at the top and unintuitive keybindings, and now it’s your best friend. ...

Introduction to vim as an editor

If you’ve never used a terminal-based text editor, vim can be quite intimidating. I want to show you the basics of using it and explain some terminology I will be using throughout this repository. Everything I talk about here applies to neovim in the exact same way, but for simplicity I will just refer to both as “vim”. Anytime I run the vim command in a terminal, just think nvim instead if you use neovim. ...

LSP

This is a guide for neovim users who want to use the Language Server Protocol (LSP). What is LSP? The Language Server Protocol is a protocol which defines a standard way of how a code editor and a static analysis tool should communicate. The basic premise of the protocol is that you have a client and a server. The client is your text editor (neovim in this case) and the server is some external process that communicates with a client over RPC. A client can start a server as an external process and the two communicate with messages. This allows a server to analyze the current file you’re editing without having to care about how that information is represented. It’s your editor’s (client) job to interpret the response from the server and showing you the errors. ...

Getting started with vim motions

The best way to get started with vim motions is probably the vim tutor. It’s an interactive game that walks you through the most important vim motions and it takes ~30 minutes to complete. If you have vim installed, run vimtutor in your terminal. If you have neovim installed, run :Tutor after opening neovim. If you want to switch to neovim and don’t know the motions yet, I recommend you install a vim plugin for whatever editor you currently use. Some examples: ...

Why neovim over vim

I will list the most important reasons why I choose neovim over vim. There are many small things that are just “nicer” which on their own wouldn’t justify switching editor which I will not mention here. If none of these apply to you, you can use vim as well. A lot of what I cover in this repository will apply to vim in exactly the same way. If you want to get the most out of your editor though, I think neovim is the way to go. ...