Sep 302024
 

As someone who follows DHH on Twitter, I’ve seen a lot of posts around his switching to Linux as his daily driver. I’ve had Linux on my personal machine for a few years now, but never put a huge amount of effort into it since it’s not my “work” computer. Still, I try to poke around with some code when I can, so I do want to have it set up for development on personal projects. I’ve always had (at least some) co-workers who would code in Vim/Tmux exclusively (and swear by it), but it’s never been for me. I used Eclipse in college, bounced around a lot between VS Code and the IntelliJ community edition, briefly dabbled in Atom, and I even used regular vim (OK, gvim) for a bit…after I stumbled across a setting to use regular Windows keyboard shortcuts1. No editor ever really stuck as something I particularly liked using, but I could at least get VS Code (for front-end work) and then IntelliJ (for Java) “good enough” but that was it. So I decided to give Neovim a try, since the Vim people I worked with always seemed passionate about how they liked their editor and because..why not? This time, I decided to do it properly, with the real Vim keybindings, not replacing with Windows versions. After a few weeks, I see why Vim people are the way they are – this just feels like a better way of doing things.

First up, you need a good terminal emulator. I went with Alacritty. It’s really easy to customize, and can be configured to match the color scheme I’m using throughout the rest of my terminal applications. There’s not really a lot to say on that, so on to code editing in Neovim.

At a baseline install, Neovim is a very bare-bones editor. It’s designed to be customized through a (very large) library of plugins so you can configure it exactly how you like. Trying to get good introductions to that is a pretty time-consuming rabbit hole. Personally, I recommend getting started with the Typecraft.dev “Neovim for Noobs” playlist on YouTube. It starts from a fresh install, and walks you through turning it into a very nice, albeit minimal, IDE. By the time I finished I felt like I was about 90% of the way to making this a proper go-to dev environment. It was certainly good enough to code in (in fact, at this point I felt good enough with it to install Neovim on my work machine, copy over the configuration files, and start coding in it daily). Mostly I just felt like I was missing some little quality-of-life tweaks so that everything could be just right.

At this point, you can either continue tweaking your setup bit-by-bit to get it exactly the way you want it, researching plugins then picking, choosing, and configuring each one individually, or you can back your Neovim configuration up somewhere for reference, and then switch to a pre-made setup like Kickstart or Lazyvim and customize things from there, referring to your back-up configurations as needed. Because you started with a “by hand” process, you actually have the knowledge and ability to go in and play around to update these installations, and it won’t seem so intimidating. Personally, I felt I was close enough to “just right” that I decided to just keep going down the “by hand” route.

This brings us to the first problem I ran into – the projects I was currently working on for my job had introduced Lombok into our Java code, which takes a special plugin and set up on any IDE to keep from breaking things (side note, please don’t be the type of developer that uses Lombok – just write the getters and setters and actually put in logic around the operations). Java in Neovim is already tricky – the LSP (Language Server Protocol) for Java is already more painful to set up and use than pretty much any other language server I’ve pulled in, and now Lombok is dogpiling on to that frustration. It took several pretty concerted Googling efforts whenever I could sit down and dedicate time to it, but I finally found the configuration options needed to make Neovim play nicely with Lombok. A little more playing around to find where to insert them (because I worked very hard to exclusively manage all my LSPs via Mason), and I finally have Java files free of Lombok-related error notifications.

Another minor issue I ran into was with the Docker language server. I’ve actually been using Podman since the Docker Desktop licensing changes a while back, so I needed to make sure install podman-docker onto my system to get that to work. It’s a simple fix, but worth remembering that enabling some functionality in Neovim will require some programs to be available on the machine itself, like the aforementioned podman-docker and ripgrep for the ubiquitous Telescope plugin.

My next change was less about fixing a problem I was having and more about improving my quality of life – updating my Telescope plugin (used for finding files and grepping files in your project – if you have ripgrep on your machine) to ignore lock files (lazy-lock.json for Neovim plugins and package-lock.json for front-end projects) so when I’m searching for a file in my projects I only see project files. It’s an easy change (add this to your setup: defaults = {file_ignore_patterns = {"lazy%-lock.json","package%-lock.json",},} – if you followed the Typecraft guide, you’ll have a formatter that can clean up the formatting), largely because changing settings is just editing a text file on my machine. You can do stuff like this in other IDEs, but you’re relying on the options they expose to the UI which could be hidden and hard to get to, versus running something like cd ~/.config/nvim ; nvim and just manually setting up the plugin specifics myself if I want to stray from the defaults. By the way, I’ve realized that just explicitly pulling in the default settings for plugins makes my life so much easier when I decide I want to tweak them – I can see what the options are right there and go ahead and make whatever change I need.

Since my initial setup, I played around with a few different color schemes, but I had settled on Kanagawa (Dragon) pretty early on and never found a better option. I also changed out the debugger and linter and just replaced it with conform for formatting (I’ll probably set a linter back up at some point, but I’m not in a huge rush to do that right now), incremental renaming for renaming things throughout my codebase, FTerm for popping into a terminal for quick commands (like rebuilding and restarting my containers), added Dadbod (probably the best plugin name ever) for running database queries in a Neovim session (so now I don’t need a separate application or command-line window), and Lazygit (along with the Neovim plugin) for visualizing changes and getting them checked in without leaving my editor.

Right now I’m looking for a good terminal client (ideally with Neovim plugin) to replace Postman – specifically it’s collection management and ability to export curl. I tried out Arguably a Terminal API Client, and it’s nice, but the inability to export a curl command is inevitably going to be a deal breaker since curl commands are what get copied over to QA for back-end testing. Next up may be rest.nvim to see how that goes, but I’ll still use Postman for now, at least until I find something that let’s me manage and edit curl commands easily.

I found Typecraft’s Zellij video and wound up liking it better than trying to make Tmux work. Mostly because Zellij just has a much lower learning curve than TMux. Remember – I was committing to learning vim properly, so I really didn’t want to spend brain cycles on Tmux too. Zeillij labels options in the UI so I can pick up what I want to do much easier. Also, Zellij is easier to theme to match my color scheme in both Neovim and my terminal. There is a plugin that let’s you navigate Neovim buffers similar to how you can in Tmux, you just need to prefix the navigation command with “<C-w>” (control-w).

This gets me to the point where the main apps I “need” are a browser, the terminal, and communication apps for my job, and Postman (and I’m trying to find a replacement for that). The list of apps that run from the terminal is pretty impressive, including proper file managers (I haven’t gone that far down the terminal rabbit hole, but I’m tempted).

Now, all of this means dotfile configurations, so I also started using stow to manage those, which is nice because I can make a tweak to my Neovim setup at work, check it into a private Github repo, and then pull it into my home computer, and vice versa. This starts to look like it should be possible to automate setting up my machine largely from scratch to how I like it, which now has me considering trying out the Nix package manager and dotfile manager. I haven’t been able to dig into that yet, but it’s something I want to explore.

For years I’d ignored people’s desire to live in the terminal instead of proper apps with actual user interfaces as people doing weird things, but seeing some of the hype, and trying it out made me realize just how good terminal UIs can be, not to mention just how simple working on a computer can be. I only run a handful of applications for work (fewer once I find a good replacement for Postman). Outside the terminal (for development), the browser (because I work on a web application, and use a lot of web tools), all I generally need are a VPN client and communications apps (email, and chat apps – don’t ask). At home I just run my browser, terminal, and Signal if I need to send a message, and that’s it. It’s really an amazing look at how “simple” (yes – learning how to Vim takes work) computing can be. The realization of how good applications installed in the terminal can be is coming at a point where I’m increasingly interested in various decentralized web projects (like Solid, IndieWeb, and ActivityPub). The installable and pluggable world of terminal applications just confirms not everything needs to turn into a subscription-based (or ad-supported) cloud application, but that there still is a place for installed software, even if you don’t write code for a living. Apparently, the best things just need a little prompting.

  1. Just add source $VIMRUNTIME/mswin.vim to your vimrc file and reload it. ↩︎

 Posted by at 11:45 AM