falstro / ghost-text-vim

Ghost Text for VIm
MIT License
52 stars 9 forks source link

Error on MacOS X #1

Closed kyleskrinak closed 8 years ago

kyleskrinak commented 8 years ago

When running the tcl script on Mac, and trying to invoke the server, I see:

./ghost-text-server.tcl
bad option "decode": must be format or scan
    while executing
"binary decode hex [sha1::sha1 "$rq(Sec-WebSocket-Key:)$WSGUID"]"
    (procedure "accept" line 22)
    invoked from within
"accept sock8 127.0.0.1 57799"
falstro commented 8 years ago

Hey. Forgive my surprise, never thought anyone would actually bother to try this. :D Anyway, binary encode and decode were introduced in tcl 8.6, I'm guessing you're on tcl 8.5?

kyleskrinak commented 8 years ago

Yes, 8.5.9 is what's on MacOSX 10.11.5, though I can load 8.6.4 using brew, which I've done. I'll test again later, thanks! Oh, and you're gaining attention: http://superuser.com/q/261689/85141

falstro commented 8 years ago

Heh, that is so cool. Anyway, I don't have a mac so I can't really test it, but please let me know how it goes. I'll update the readme when I get home on Sunday, to note the 8.6 dependency.

kyleskrinak commented 8 years ago

Closer:

/usr/local/bin/tclsh8.6 ~/.vim/bundle/ghost-text-vim/ghost-text-server.tcl
Caught exception: VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 10 2016 09:02:28)
Unknown option argument: "--servername"
More info with: "vim -h"
falstro commented 8 years ago

From what I can tell, vim needs to be compiled with +clientserver, which appears to be standard on most platforms, but mac is a weird ecosystem w.r.t. vim.There's something called macvim, is that what you're using?

kyleskrinak commented 8 years ago

MacVim is what I mostly use. I tried removing and reinstalling vim/MacVim with the client-server option. I get further, but still no cigar. I now see:

Exception while closing VIm: No display: Send failed.
Caught exception: No display: Send expression failed.

As you've guessed gvim invokes macvim. If I change 'gvim' to 'vim' I can invoke vim but get the above message, anyhow. I can confirm with both vim and MacVim I see "+clientserver" after running ":version"

falstro commented 8 years ago

Right, what I gather from my research is that macvim supports clientserver if the GUI is running but not when running on the console. VIm traditionally uses a some X11 stuff to do the clientserver communication, and it appears macvim does it somehow differently. Out of curiosity, does

gvim --servername test

and/or

mvim --servername test

give you errors?

if the first one gives you the error (with the unknown option argument), and the second one works I'm guessing gvim is a wrapper of some sort, and we can probably use mvim.

I'm sorry for all the back and forth.

kyleskrinak commented 8 years ago

No apologies necessary! To be thorough, I first ensure there's no Vim/MacVim process running, i.e.,

ps aucx | grep -i vim

Returns an empty result. Then

gvim --servername test

Launches a process for Vim and MacVim, and no errors returned. Without quitting those, running

mvim --servername test

Launches a new Vim process. From the Mac UI side, it simply adds a new buffer/window to MacVim. Again, no CLI errors.

falstro commented 8 years ago

I think I'm onto something, with the macvim client/server stuff not working in the console version, I think the issue is the vim-send and vim-expr functions where I have assumed the cli version can send messages to the gui version. Could you change the two lines:

proc vim-send {name msg} { exec vim --servername $name --remote-send $msg }
proc vim-expr {name expr} { exec vim --servername $name --remote-expr $expr }

change exec vim to exec gvim, i.e. make them read:

proc vim-send {name msg} { exec gvim --servername $name --remote-send $msg }
proc vim-expr {name expr} { exec gvim --servername $name --remote-expr $expr }

And see if that helps?

kyleskrinak commented 8 years ago

That more than helps — that made all the difference. I am responding using your vim integration now to type my update into the comment field. Fantastic, thank you!

falstro commented 8 years ago

Excellent, I'll run a few tests to make sure it runs well on linux as well, and I can't see why it shouldn't, if that works I'll just use that instead.