Switching to Neovim from VS Code: Easier Than Expected

3 mins read

October 15, 2024

I finally decided to try using Neovim because of VS Code incapability to run multiple formatters sequentially. Suprisingly, I found Neovim to be a fun experience.

Chapter 1: Formatting .templ file

templ is a HTML templating engine written in Go. I use templ when making simple web apps in Go where I want to utilize reusable component. templ has its own tools for formatting, called with templ fmt, which at the time of writing doesn't support javascript formatting (see this issue).

Basically, the templ fmt messes up the javascript formatting inside the <script> tag, which to be fair you probably should seperate the javascript to another .js file, but I am too lazy to do that. Some suggest their janky way to handle the issue which involves running sequential formatting, go then javascript, using conform.nvim plugin. I try to mimic that behavior in VS Code, and to my suprise, is not easy to do sequential formatting in VS Code. With nothing better to do, I decided to try using neovim.

Chapter 2: Kickstart.nvim

All I knew about vim is:

  1. You quit with :q
  2. You move with h,j,k,l
  3. Nerd like to use vim

People also say that vim has a steep learning curve. While I do agree with that notion as neovim is fully configurable, I think its only steep when comparing to other IDE. People has made and written countless guide for beginner to start using vim which is perfect for me. One particularly useful guide is kickstart.nvim which is a neovim configuration that contains all the basic stuff an IDE should have. Kickstart served as a starting point for me to start configuring neovim while being able to use it as an IDE. I watched the getting started video, did the :Tutor, learn lua syntax, read init.lua, and I am all set. I did not understand some concept but I did not care as I can learn when I need to. I found learning neovim to be suprisingly fun and more fulfilling than learning another new javascript framework.

Chapter 3: Devcontainer

The more I learn about neovim, the more I consider myself to switch to neovim from VS Code. One thing that VS Code do great is containerizing your development environment by using Devcontainer. Most of my dev tools is inside a devcontainer (basically just a docker container) so I thought I was locked into using VS Code. To my suprise, devcontainer is an open specification and they have a cli for managing it. I am able to use the devcontainer-cli to make a devcontainer, install neovim inside, then copy local nvim configuration inside the devcontainer, which works great. I also found some nvim plugin which use devcontainer or devpod to make my life easier: devcontainer-cli.nvim, nvim-dev-container, remote-nvim.nvim (I currently use this).

Conclusion

With the help of kickstart, I was able to start using nvim as a daily IDE and started liking it. Thank you for reading, I hope you give neovim a try too. Or not.