Modify to communicate with Vim via client-server functionality
See: http://vimdoc.sourceforge.net/htmldoc/remote.html
Currently it seems that PeepOpen is shelling vim/macvim to get it to open the file. That is why they always open in a new window/tab.
Using the client-server functionality of Vim (the server name could be sent to PeepOpen when it is launched from Vim) it should be possible to call a function in Vim with the path of the file to be opened.
Once that change is done then many other Vim related issues/feature requests could be implemented:
- Open in current buffer
- Open in split
- Open in new tab
The launching command would send a hint to PeepOpen, and when PeepOpen calls back it could provide that hint back, allowing the appropriate dispatch.
This script can be used to help ensure that a reasonable server name is set:
#!/bin/bash
mvim --servername "${PWD##*/}" .
Here is a simple example of sending a command to a running instance:
mvim --servername VIM --remote-send ":echo 'hello from the outside'<CR>"
Looks like this was requested many times (even patch provided) but unfortunately was never implemented :( That's sad.
I've experimented with this in the past and wasn't able to get it to work reliably.
Would everyone need to launch vim or mvim with the script that sets the name of the server? I'd like to make this work without changing developers' existing workflows.
However, this could make a way for PeepOpen to work with terminal vim, which would be really cool. It could be enough to make me switch from Emacs to Vim. ;-)
Also, MacVim already has a setting that basically fixes the main problem by opening files in the current window:
https://peepcode.com/system/uploads/2010/PeepOpen-Help/editors%20-%20macvim.html