lazyvim and obsidian.nvim

2023.09.30
(tools) (obsidian) (neovim) (lazyvim)

Obsidian and obsidian.nvim

I’ve spent most of my software career editing text in vi or its successors, vim or neovim. Not only do I feel comfortable in vim, but I find myself missing its functionality when I use other editors. While I generally enjoy using obsidian’s UI, I still reach for vim when I want to refactor or perform complex operations.

My .vimrc has gotten quite crufty over the years, but it’s worked for me, so I haven’t bothered fixing it up. But last month I wanted to try obsidian.nvim, which allows for editing Obsidian markdown files in neovim. (Yes, you can edit markdown in any text file, but handy features Obsidian include wikilink autocompletion and listing backlinks to a given page. These features are available in neovim using obsidian.nvim.)

One issue I hit off the bat was that obsidian.nvim is written to be configured in init.lua, and my .vimrc was written in vimscript. It’s possible to straddle lua and vimscript in the same config, but it can get a little messy.

Enter LazyVim

One of the suggested methods of setting up obsidian.nvim is LazyVim, which handles a lot of the complexity for you. There’s a template repo to replace your ~/.config/nvim, and so many things Just Work.

I tried it and it’s definitely a lot more fancy than I need (I’ve spent years getting accustomed to bare bones setups so I can hack on mobile devices and remote servers relatively comfortably). I actually stopped using it for a while because I ran into some…

LazyVim drawbacks (and fixes)

There were two that stuck out at me:

  1. slow load times, since LazyVim updates all of the plugins on startup. This is probably fine for people who keep one vim window open all the time and open different files into it. By habit I exit and reopen vim all the time, since I prefer to use the shell directly, and
  2. the damn s button is remapped. I use that all the time to replace a single character. So I needed to find a way to remap it, remove the offending plugin, retrain my muscle memory, or not use LazyVim.

I tried using packer instead. It was pretty complex to set up but worked around the issues I was facing with LazyVim. But I found that my config slowed nvim down, and working in the configs was clunky. Back to LazyVim.

I solved the above two LazyVim issues with some configuration tweaks. I turned off automatic updates and was able to disable the offending flash plugin to get my s keymap back. I was also able to turn off the auto-quote-pairing feature I didn’t want.

Then I hit a couple issues in obsidian.nvim that the maintainer fixed super quick. Now obsidian.nvim is working pretty well for me. I’ve got a bit of lua experience too :)

Other plugins

I also set up vim-table-mode for easy and clean markdown tables in vim, set up tmux.nvim for improved tmux navigation, and configured vim-gnupg so I can edit gpg-encrypted text files directly in vim.

Was it worth it?

I spent maybe a few days’ worth of effort on my new, cleaner neovim config. It was probably past time that I revisited these, and I love the ease with which I can edit my Obsidian markdown in either vim or Obsidian. It feels easier for me to wrap my head around and edit dense Obsidian markdown files, so it was super worth it for me.