Neovim: Now in Lua!

This article was written in 2024, looking back at my previous home lab projects and where my journey into IT began.

This article is part of a series on Other Projects.


Neovim banner

Introduction

This article tells the story of how I wrote my own Neovim configuration from scratch – this project can be accessed by following the link to my GitHub.


“You Can Go Your Own Way”

While I was working on my debian-dwm project (links: to article; to GitHub), I began to notice that my Neovim experience wasn’t exactly where I wanted it to be. I had been using Luke Smith’s Vim config file for about a year now, and it was an excellent way to get started with Neovim. However, I was beginning to use Neovim for everything I did on my machine, and I was starting to realize that there were more features that I wanted. After watching enough of thePrimeagen’s content, I knew that I wanted some additional plugins that would take my experience to the next level. Fortunately, I had recently come across a video of his, where he starts with the bare-bones Neovim experience and builds it from scratch to suit his needs. And, I thought, “hey, why not do it with him?” In the worst case scenario, I could always revert back to using Luke’s Vim config file.

So, I sat down one day in late August 2023, and wrote my own Neovim configs alongside Prime. The first thing that I had to get used to was Lua. While Luke Smith’s Vim config was written in Vimscript, so it would be backwards compatible with the original Vim, Prime was writing configs for Neovim alone, and so he opted to use Lua in order to have greater control over the code he wrote. By doing this, I learned a ton about how my favorite text editor functioned. I learned:

I was also introduced to some awesome new plugins!

Neovim

An image of my Neovim configuration directory, in Neovim, using the Telescope plugin to view files.

Plugins

These tools have greatly improved my ability to use Neovim. Especially when working on code projects, I can’t work without them.

Telescope

One of my favorite additions to my Neovim is Telescope: a fuzzy finder. While Luke’s configs also had a fuzzy finder, Telescope enabled me to also have a file preview for any file that I was searching over. Because of Telescope, I massively increased my use of the fuzzy finder within Neovim – where I almost never used fzf, I constantly use Telescope. With Prime’s help, I also added some custom keymaps, including one that allows me to use grep through the entire working directory to search for a file, and then displays that output in Telescope. This has been a great help when working within a repository, as I can now quickly find files I’m working on.

Harpoon

As Prime accurately describes it, Harpoon is truly “a glorious way to navigate files”. Basically, what Harpoon allows the user to do is to use the same set of keymaps for switching between files. What does that mean? It means that I know that “Ctrl-J” is always my #1 file in a project, “Ctrl-K” is my #2 file, and “Ctrl-L” is my #3 file. Then, no matter what project I’m working on, I can use those same keymaps to always hit the most important files. I can readily change those files out; if another file needs to be moved in, or the positions need to change, I can do that with no effort required. In addition, the marks are set on a “per repo” basis. If I’m working on my debian-dwm project, those keymaps will access the marks for that project; if I switch over to the library repo, then I have access to the marks for that repo. So, I now have the muscle memory to very effortlessly flip through the most accessed files in any one of my repos/directories/projects. And, if I want to add something that’s not in my Harpoon just yet, I use Telescope to navigate to it, add it to Harpoon, and then set it as whichever mark I need it to be. Harpoon is incredibly useful.

LSP

The last thing I want to shout out in particular are Language Server Protocols (LSPs) in Neovim. While I wasn’t coding much besides Bash scripts at the time, setting up LSPs paid dividends in the future. Once I started coding in Rust, having rust-analyzer built into Neovim made life so easy, as I was able to have my code actively assessed by the Rust compiler while I was programming. I also got some auto-complete features and function descriptions built into my Neovim. It’s not something I needed up until this point, but now that I have them, I don’t know what I’d do without them.

I Use Vim, BTW

While I was using Vim a lot before this, creating my own custom configuration caused me to love Vim even more. I now use Vim for everything I can, whether it’s coding, writing documentation in Markdown, or even my daily to-do lists. The more I use it, the more I become comfortable with using Vim motions and navigating using Harpoon and Telescope. Since creating these config files, I have become a bit obsessed with using Vim for everything I can. I even have a version of my Neovim configs written in Vimscript; that way, when I’m working on servers, I can quickly deploy a more lean version of my setup using just Vim (as opposed to Neovim).

It’s kinda become a way of life. 🤣

Helpful Videos

Related
Home Lab · Other