vim-anywhere icon indicating copy to clipboard operation
vim-anywhere copied to clipboard

Support without gvim.

Open hobbestigrou opened this issue 6 years ago • 9 comments

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.

hobbestigrou avatar Mar 07 '18 09:03 hobbestigrou

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 gvim isn't installed
  • .vim-anywhere/config should not be versioned, but the install script should create it from a default-config file, or the like

I may have some time to open a pull request this weekend...

austinglaser avatar Mar 09 '18 23:03 austinglaser

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.

hobbestigrou avatar Mar 13 '18 21:03 hobbestigrou

@austinglaser, that would be great since that would allow me to easily use nvim.

malob avatar May 28 '18 20:05 malob

And regular vim for folks like me

Dbz avatar May 29 '18 01:05 Dbz

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

austinglaser avatar May 29 '18 01:05 austinglaser

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

Dbz avatar Jun 01 '18 20:06 Dbz

I updated the above script to work fully. I also forked and committed it here: https://github.com/Dbz/vim-anywhere

Dbz avatar Jun 12 '18 02:06 Dbz

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 avatar Jun 11 '22 18:06 tthkbw

@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.

nnnell avatar Oct 26 '23 19:10 nnnell