Open sfsam opened 2 years ago
FWIW, I looked into this a bit. After chasing some dead ends (shell scripting, Applescript), I found a StackOverflow answer that described a solution using Apple Events:
https://stackoverflow.com/a/62134037/111418
The answer was written by the guy who made BBEdit, a popular Mac code editor. Based on his answer, I put together a small tool, nvmm, for invoking Neovim.app with file arguments. The tool gets bundled with the app and can be symlinked to somewhere in your path:
ln -s /Applications/Neovim.app/Contents/Helpers/nvmm /usr/local/bin
Usage: nvmm [file ...]
Currently, it ignores flags, but that can be added if desired. For me, this is sufficient for now.
I don't want to clutter up your project more than I already have so I put it in my own fork so you can see if it is of any interest to you:
https://github.com/sfsam/neovim-mac/commit/aee467ba4bb841828387151fbb2be44aff89361e
Super interesting solution. This is definitely something that we should support. Thanks for doing all the legwork.
I had some rough plans in my head for implementing this. I was thinking we could define a URL scheme for the app. One that would allow you to open files, tabs, or a new window with any arbitrary command line options passed to the neovim subprocess.
Haven't had much time to work on this project lately, but when I do this is a top priority.
You might take a look at MacVim as they have also implemented a URL scheme (mvim://) in addition to their shell scripts. AFAIK, it only opens files and optionally positions the cursor.
I have implemented a subset of command-line options now. Perhaps some of this work will be useful for a URL scheme as well. I went this way because it seemed easiest for what I wanted to do.
https://github.com/sfsam/neovim-mac/commit/088fd8d78e483974c9f04b093c13b68c50ec13f8
MacVim provides a bundled
mvim
script to launch the app from the command line. There are also symlinked variants formview
,mvimdiff
, etc. That script seems to work by invoking the bundled Vim binary with the-g
flag plus whatever other flags as appropriate. Since neovim works differently (no-g
), I don't think that approach would work. I wonder if you have thought about this?