Using Neovim snap as default editor

In order to run the current version of Neovim on Ubuntu 23.10 I installed version 0.9.4 as a snap package.

In zsh.rc I set the alias nv to snap run nvim and it works just fine, but my default editor is still set to the older version of Neovim and I can’t change that because the snap does not appear as an option when I run sudo update-alternatives --config editor.

When I do a git commit the old Neovim version pops up to write the commit message and complains that it can’t run the plugins (like TreeSitter) that run on the snap version. Not a big problem but annoying. Also, I use ZSH and when I type nv filena,,, (with a partial file name) I no longer get the autocomplete that I used to on a partial file name.

The snap version picks up the configuration in .config/nvim/ just like the older version of Neovim does.

Is there a way to get Linux to offer the snap version of Neovim as an option to set as my default editor?

My apologies if this is more of a Linux question than a Neovim question but I’m hoping some Neovim user who has dealt with this can help.

Thanks

In case someone is having the same issue it turns out this is a two-step process:

  1. To add the snap version of Neovim as a choice of editors
sudo update-alternatives --install /usr/bin/editor editor /snap/bin/nvim 1111

(thanks to StackExchange)

  1. Edit .gitconfig to set /var/snap/nvim as the editor for commits.