Categories
Software vim

Opening files in Neovide from the shell or Finder

Another nvim howto, to remind myself how to do this when I want to set up Neovide on a new machine …

I previously (ie up until last week) used MacVim, and was able to open files using the mvim command. By default, Neovide is a bit clunkier, running a new instance in the foreground whenever you open it (this might be improved soon). Fortunately someone else has done the hard work for me, so it’s pretty easy to fix.

Firstly, save this script to somewhere in your path (I put it in /usr/local/bin/nv), and make it executable (chmod u+x /usr/local/bin/nv). This gives you an nv command in the shell, which will either open Neovide if it’s not running, or open the files you give it in a running instance.

If you want to be able to open a file at a specific line with nv path:lineno (or by command-clicking on a stack trace entry etc), I created a fork of the above script which sends the command to jump to the specified line after opening the file.

Secondly, fire up Automator, and create a new application. Add a Run Shell Script action, set it to pass input as arguments, and change the content to the following:

/usr/local/bin/nv "$@"

Save it somewhere (eg in /Applications), then you can tell the Finder to open any files/file types you want to edit in Neovide to open with this application. This also gives you command-click editing in iTerm.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.