vim-anywhere
vim-anywhere copied to clipboard
Support without gvim.
First thanks for your project it's great. Just know if it possible to add a support without gvim. I don't want to need install gvim for use your project.
Totally on the same page.
What about a .vim-anywhere/config file which allows you to specify the command to start vim, among other future things? This could default to just gvim, but could also be set to something like (in my case), termite -e nvim.
Other things that would have to change:
- The install script should warn rather than fail when
gvimisn't installed .vim-anywhere/configshould not be versioned, but the install script should create it from adefault-configfile, or the like
I may have some time to open a pull request this weekend...
I'm happy to see I'm not alone. If you have the time to make that is awesome, I have not the time at the moment.
@austinglaser, that would be great since that would allow me to easily use nvim.
And regular vim for folks like me
Never got around to adding features properly. However, I've been using the following patch, which seems to work reasonably:
bin/run | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bin/run b/bin/run
index 804a137037a3..2c5abf1f77ec 100755
--- a/bin/run
+++ b/bin/run
@@ -38,7 +38,7 @@ done
AW_PATH=$HOME/.vim-anywhere
TMPFILE_DIR=/tmp/vim-anywhere
TMPFILE=$TMPFILE_DIR/doc-$(date +"%y%m%d%H%M%S")
-VIM_OPTS=--nofork
+#VIM_OPTS=--nofork
# Use ~/.gvimrc.min or ~/.vimrc.min if one exists
VIMRC_PATH=($HOME/.gvimrc.min $HOME/.vimrc.min)
@@ -56,7 +56,7 @@ touch $TMPFILE
# Linux
if [[ $OSTYPE == "linux-gnu" ]]; then
chmod o-r $TMPFILE # Make file only readable by you
- gvim $VIM_OPTS $TMPFILE
+ termite -e "nvim $TMPFILE"
cat $TMPFILE | xclip -selection clipboard
# OSX
Do you have an idea on how to do this with OSX+iterm2?. I've been experimenting with osascript, and I have a workable solution:
bin/run
frontmost_app="~/.vim-anywhere/script/set_frontmost_app.scpt"
osascript <<EOF
tell application "iTerm"
create window with default profile
tell current session of current window
activate
write text "vim -c 'execute \"au VimLeave * !pbcopy < \" . expand(\"%\") | execute \"au VimLeave * !osascript $frontmost_app $app\"' $TMPFILE"
end tell
end tell
EOF
script/set_frontmost_app.scpt
on run argv
tell application "System Events"
set frontmost of the first process whose unix id is (item 1 of argv) to true
end tell
end run
script/current_app.scpt
-- vim-anywhere - use Vim whenever, wherever
-- Author: Chris Knadler
-- Homepage: https://www.github.com/cknadler/vim-anywhere
--
-- Get the current application's name
tell application "System Events"
copy (unix id of application processes whose frontmost is true) to stdout
end tell
I updated the above script to work fully. I also forked and committed it here: https://github.com/Dbz/vim-anywhere
When I use these scripts, the iterm window is left open after running vim (or nvim, which I use). Is there a way to close the iterm window when vim is done?
@tthkbw I ran into the same thing, and setting up one last VimLeave autocommand to exit the window does the trick!
write text "xnvim -c 'execute \"au VimLeave * !pbcopy < \" . expand(\"%\") | execute \"au VimLeave * !osascript $frontmost_app $app\" | execute \"au VimLeave * !exit\"' $TMPFILE"
(it kind of feels like one of those things that shouldn't work, and yet)
Edit: The feeling was true. This no longer works for me.