Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support without gvim. #89

Open
hobbestigrou opened this issue Mar 7, 2018 · 9 comments
Open

Support without gvim. #89

hobbestigrou opened this issue Mar 7, 2018 · 9 comments

Comments

@hobbestigrou
Copy link

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.

@austinglaser
Copy link

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

@hobbestigrou
Copy link
Author

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.

@malob
Copy link

malob commented May 28, 2018

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

@Dbz
Copy link

Dbz commented May 29, 2018

And regular vim for folks like me

@austinglaser
Copy link

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

@Dbz
Copy link

Dbz commented Jun 1, 2018

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
Copy link

Dbz commented Jun 12, 2018

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

@tthkbw
Copy link

tthkbw commented Jun 11, 2022

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?

@nnnell
Copy link

nnnell commented Oct 26, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants