My (Neo)Vim Setup

Updated 01.15.2024

4.20.2023

Update: I've recently updated the GitHub Repo With the latest version of the config.

I recently changed over to using NeoVim on my live streams as a sort of experiment. Since then, I've been asked to go over my setup, and how I use it, and most importantly, to post the all-important vim config file.

I could just post the file and call it a day, but I'd like to take a moment and detail some of the whats and whys of it as well.

But why vim? Isn't VSCode enough?

Sure, VS Code is excellent. It's great - it really is. But it isn't vim. I had tried some plugins in the past to emulate vim, but none of them (at the time) seemed to really work all that well.

I switched away from VS Code at work several months ago and have truthfully never looked back. I love everything about it - espectially the navigation - but even some of the aesthetic as well. While VS Code offers everything one needs, I just found myself always wanting to give vim another shot.

I figured that since I finally got it running for work purposes (which is using Typescript), there shouldn't be any reason I can't also get it working for my at-home stuff, which is 99% in C. I even managed to get a visual debugger up and running, which was my last real barrier-to-entry for swapping to vim.

Prerequisites

There are a few things I have setup outside of vim to make it look the way it does:

Neovim Setup

This setup requires a minimum version of 0.9. As of the time of writing, I am using 0.9.5. On Arch-based distributions, this may be installed with:

sudo pacman -S neovim
or, if on a debian-based distribution it might be something like:
sudo apt install neovim
Note that Ubuntu sometimes doesn't have the latest version in its repos and might require you to access a separate private repository. For macOS this can be installed using homebrew:
brew install neovim

Neovim allows configuration to be done using Lua files, which I have opted for here.

Plugins

Unless otherwise specified, all of these plugins are hosted on GitHub. Repos therefore have a prepended address of https://github.com/ and then the repo name as listed. NOTE: These plugins are all included in the vim config files.

Configuration file layout

All config files will be located in ~/.config/nvim. UPDATED! This layout has been drastically simplified:

.
├── init.lua
├── lua
│   ├── travis
│   │   ├── dap_config.lua
│   └── plugins-setup.lua
├── plugin
│   └── packer_compiled.lua
        

Obviously, when setting this up you would want to replace my name with yours. init.lua contains all setup for things like keybindings, plugin-specific configuration, colourscheme, vim options, etc.. It also load all other lua files. plugins-setup.lua contains the bootstrapping for all plugins, whereas plugin/packer_compiled.lua contains the installed plugin data managed by packer.
Note that lua/travis/dap_config.lua contains DAP-specific configuration to easily turn this on/off because I'm on the fence about whether or not I will continue using it.

If you drop these files in place as-is, it *mostly* should work. I do suggest renaming the user folder name to your own, and any references found in the files to that name as well.

A public version of the files I use may be found here, where any sensitive data has been removed.

Visual Debugger setup (C/CPP specific)

Once all the above plugins are installed, make sure to visit this page for configuring nvim-dap for visual debugging of C code.

Quick usage highlights

Explorer window

With the explorer window selected, you can do the following in NORMAL mode:

General Navigation Keybinds

Debugging Keybinds

TODO

So far, this article has taken quite a lot of time to write. I'd like to continue this in more detail, but don't have the time at the moment. Be sure to check back at some point in the future, as I will be updating this from time to time.

Back to home