Code Monkey home page Code Monkey logo

Comments (5)

kovisoft avatar kovisoft commented on July 21, 2024

Slimv does not have any built-in support for encrypted communication between vim and the swank server. I think tunneling may work, but TBH I have never tried it. By default the swank server is using port 4005 (see slime/start-swank.lisp). So I think if you:

  • manually start the swank server on the remote machine (e.g. sbcl --load start-swank.lisp for sbcl)
  • create an ssh tunnel on your local machine that forwards remote port 4005 (or whatever port you configured for the remote swank)
  • configure your local port used by the ssh tunnelling in your .vimrc (see g:swank_port)

then slimv might be able to connect to the remote swank server.

from slimv.

Jach avatar Jach commented on July 21, 2024

At least for Common Lisp, SSH forwarding works. It's partially documented on the CL cookbook: https://lispcookbook.github.io/cl-cookbook/debugging.html#remote-debugging

In one of my experimental use cases, I ship a binary exe to my server and it serves some web pages with hunchentoot. In its loader I make sure to load and init swank (I don't think this is needed if instead you're using ASDF and specify :swank as a dependency)

(load "~/.vim/bundle/slimv/slime/swank-loader.lisp")
(swank-loader:init :delete nil
                   :reload nil
                   :load-contribs nil)

and I start it at the same time as I start my hunchentoot server:

(defvar *acceptor*) ; hunchentoot handle
(defun start-server (port)
  ; sorry, I don't remember why I initially included these and then commented them out
  ;(setf swank:*use-dedicated-output-stream* nil)
  ;(setf swank:*communication-style* :fd-handler)

  ; the key line:
  (swank:create-server :dont-close t)

  ; hunchentoot only:
  (setf *acceptor*
        (start (make-instance 'easy-acceptor :port port))))

After that, I launch the exe on the server in a screen session, and I can later connect with ssh -C -L4005:127.0.0.1:4005 myserver and so long as I don't have anything locally slimv's ,c will connect to the remote program and I can inspect and recompile stuff and so on.

from slimv.

kwccoin avatar kwccoin commented on July 21, 2024

At least for Common Lisp, SSH forwarding works. It's partially documented on the CL cookbook: https://lispcookbook.github.io/cl-cookbook/debugging.html#remote-debugging

In one of my experimental use cases, I ship a binary exe to my server and it serves some web pages with hunchentoot. In its loader I make sure to load and init swank (I don't think this is needed if instead you're using ASDF and specify :swank as a dependency)

(load "~/.vim/bundle/slimv/slime/swank-loader.lisp")
(swank-loader:init :delete nil
                   :reload nil
                   :load-contribs nil)

and I start it at the same time as I start my hunchentoot server:

(defvar *acceptor*) ; hunchentoot handle
(defun start-server (port)
  ; sorry, I don't remember why I initially included these and then commented them out
  ;(setf swank:*use-dedicated-output-stream* nil)
  ;(setf swank:*communication-style* :fd-handler)

  ; the key line:
  (swank:create-server :dont-close t)

  ; hunchentoot only:
  (setf *acceptor*
        (start (make-instance 'easy-acceptor :port port))))

After that, I launch the exe on the server in a screen session, and I can later connect with ssh -C -L4005:127.0.0.1:4005 myserver and so long as I don't have anything locally slimv's ,c will connect to the remote program and I can inspect and recompile stuff and so on.

I am trying to run two sbcl and two image. The program use 4545 to isolate the two swank. I am using slimv and remote ssh ok. But can this be done in two images with different port. In particular how can my gvim found the right swank.

the advice is to use .vimrc but there is only one per vim, wonder how and whether one can use two swank ports for two different sbcl images.

Thank in advance again for any advice.

from slimv.

kovisoft avatar kovisoft commented on July 21, 2024

Maybe this approach could work: override the g:swank_port option before opening the REPL buffer.
Define two separate key mappings (e.g. ,1 and ,2) for opening the swank server on two different ports:

:noremap <silent> ,1 :let g:swank_port=4545 <bar> call SlimvConnectServer()<CR>
:noremap <silent> ,2 :let g:swank_port=4546 <bar> call SlimvConnectServer()<CR>

Then open swank on port 4545 by pressing ,1 and open swank on port 4546 by pressing ,2.

from slimv.

kwccoin avatar kwccoin commented on July 21, 2024

Thanks. Thanks and thanks. All goods!!!!!!


TL;dr

All good, except I use nmap. (I know nothing about vim but somehow the as the command noremap just not working; I check this https://stackoverflow.com/questions/3776117/what-is-the-difference-between-the-remap-noremap-nnoremap-and-vnoremap-mapping and as there is something call nmap I just try that. I guess I need to investigate a bit more; but it is not my focus).

That do the job and may I as a novice to this, add some conceptual and operational note. In particular, the key is your note on "before the REPL"

Let us concentrate on the second part
:let g:swank_port=4545 call SlimvConnectServer()

vim will use that to connect to a different swank server by a different sbcl image. Hence, one has to do the in-package etc. anew.

The nmap is to map the keyboard using the lead-character "," in slimv case. It map ,1 to 4545 port (and you can see a message in the real to reflect this).

Typing this down as this is so far of my conceptual scope that I really ensure I can understand this a few months later. I think I need to re-fresh my understanding of load-compile-executive plus vim-repl-image ...

(P.S. It is like "ssh -C -L4005:127.0.0.1:4005 myserver" is so strange it is only last week I aware that I do not need to expose my web server on the Internet for my testing. I can just tunnel my SSH to 8080 from local host to AWS! I only aware the similarity, after re-reading this post. )

Sorry for such a long post. Just to say my gratitude if you read to here. Just to say again all thanks!!!!

from slimv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.