kovisoft / slimv

Official mirror of Slimv versions released on vim.org
454 stars 60 forks source link

SLIMV opening swank in a new window instead of buffer #74

Open theblacksquid opened 5 years ago

theblacksquid commented 5 years ago

I just installed SLIMV and tried following the tutorial, but I couldn't get the slimv-repl to run inside Vim. ,c opens up the Swank server just fine, although it opens in a new (non-Vim) window as opposed to a split window buffer inside Vim.

I also checked if the SLIMV menu was present (I'm using Vim from urxvt) by enabling menu.vim from Vim's console-menu help article, but it wasn't there either.

I'm running Vim 8.0 on Ubuntu 18.04 Minimal with i3wm and urxvt.

kovisoft commented 5 years ago

Normally when you press ,c then two things happen: (1) The swank server is opened in a separate process (a new xterm window by default). (2) A new vim buffer is opened for the REPL, by default this is opened in a split window inside vim.

Now what you describe is something like the swank server was opened (1) and this is normal to be in a separate non-vim window. And it seems that (2) is missing for you. Is there anything printed in the vim message line after ,c was pressed? An error message maybe? Is there a new vim buffer or split window created? Please check the buffers by typing :ls.

Slimv builds an OS command for opening the swank server (this can be overridden by setting g:slimv_swank_cmd). The command can be printed this way:

:echo SlimvSwankCommand()

What does it print for you?

theblacksquid commented 5 years ago

Apologies about how long it took:

So i tried doing ,c again on a "hello world" lisp file, and now nothing happens. Running :ls on the file only gives me the following:

1 %a "hello.lisp line 2"

While running :echo SlimvSwankCommand() gives me errors, saying it's both an unknown function and an invalid expression.

And just to check, i ran :help slimv and got at least the help files for it.

PS: By the way, I'm using Pathogen to add Slimv, and my directory structure is as follows:

.vim
    | autoload
    | bundle
        | slimv
            ... slimv files and directories...
kovisoft commented 5 years ago

What is the output of :scriptnames when you execute it in a .lisp file buffer? You should see somewhere the ftplugin/slimv.vim file. Slimv files are structured in various directories inside vimfiles, the core script is ftplugins/slimv.vim, this should be loaded only for .lisp (or .scm, .clj, etc) files, but there are also indent/ and syntax/ files in the package. I don't know how Pathogen structures the bundles, so maybe there is a problem that slimv.vim is not loaded at all.

For a list of the slimv files please check the help file on slimv-installation.

theblacksquid commented 5 years ago

Thank you for your patience with me.

:scriptnames does show ftplugins/slimv.vim along with the syntax files for .lisp.

kovisoft commented 5 years ago

Is it possible that there was a typo in entering the :echo SlimvSwankCommand statement? What if try this: type :echo Sli, press Tab for autocomplete (it should complete to Slimv), continue typing with Sw and again press Tab (this should complete to SlimvSwank, continue typing with C and press Tab (this should complete to SlimvSwankCommand(). If the autocompletion fails then the body of slimv.vim was not loaded even if the script itself is present in the :scriptnames output. In this case it must be caused by the very first condition if &cp || exists( 'g:slimv_loaded' ). Is it possible that you have compatible set? Please check it with :set cp?. Also please check this value: :echo g:slimv_loaded. Thanks for the assistance.

theblacksquid commented 5 years ago

Trying to get autocomplete to get :echo SlimvSwankCommand() failed, and I have nocompatible set in my .vimrc. In saying that though, that did remind me that messed around with some settings there before opening this issue thinking it would help (I tried to set g:slimv_disable_lisp to 0). I commented out the offending line and restarted Vim, and ,c works again, although still no internal Vim buffer like in the tutorial.

So going back to your original troubleshooting:

Pressing ,c opens up a separate xterm window, and on Vim itself, it prints

xterm: unable to open font "", trying "fixed"...

And after a while, it goes back to my regular Vim buffer with an error printed on the status line:

SWANK server is not running. Press ENTER to continue.

:ls outputs the same result, just my single hello.lisp buffer, and :echo SlimvSwankCommand now returns:

! SWANK_PORT=4005 xterm -iconic -e "gcl" -i "~/.vim/bundle/slimv/slime/start-swank.lisp" &

That's all I could find right now, and thank you again for your patience.

kovisoft commented 5 years ago

OK, thanks. As I mentioned, Slimv tries to build an OS command that would start the swank server. This command should start a new terminal window and load start-swank.lisp inside that window. It seems that in your system the xterm command is not working for some reason, For such situations you can define your version of the swank starter command by setting variable g:slimv_swank_cmd in your .vimrc. You can find some examples in the help on g:slimv_swank_cmd. The main idea is that you need a command that would start the swank server, then you need to pass that command to whatever that would open a new terminal window for you.

So first please open a new terminal window manually and make sure that the following command really starts the swank server:

gcl -i ~/.vim/bundle/slimv/slime/start-swank.lisp

BTW, if the swank server is started manually and running then Slimv should be able to connect to it via ,c. Now the next step is to make it automatic. For this you need another command that opens a new terminal window. If xterm does not work then it can be any other command if it has a switch for passing a startup command (as -e does for xterm). I suppose you use urxvt, please check the manpage for such options. If everything is ready then you can build and set the swank starter command for Slimv:

let g:slimv_swank_cmd='! urxvt -e gcl -i ~/.vim/bundle/slimv/slime/start-swank.lisp &'

This is just an example, I'm not sure urxvt has a -e switch. The ! tells Vim that this is an external OS command. Also please note the & at the end, this is needed to start the command in the background and not locking Vim.

theblacksquid commented 5 years ago

Awesome, the new swank starter code works! It starts in a new urxvt window. How do we get the new buffer for the REPL, though? :ls still lists only one buffer.

EDIT: ,c causes the Vim screen to go completely blank for about 30 secs after the new window with the lisp REPL. Afterwards, it just goes back to the buffer with an error saying that the swank server isn't running.

kovisoft commented 5 years ago

Great! Now the question is whether the swank server is really running or exited with some error? What can you see in the other terminal window? Is there any indication of an error? Or an indication that it is running on a given port? By default the swank server uses port number 4005. You can also check if there is a listener running on port 4005 (e.g. netstat -apn | grep 4005). Or you can try to telnet to that port (telnet localhost 4005).

aoeuaoeu commented 3 years ago

imma bump this for other newbies, had the same problem, firewall rules were blocking connection to swank.