vlime / vlime

A Common Lisp dev environment for Vim (and Neovim)
MIT License
441 stars 32 forks source link

Question: How to close connection from the server side? #47

Closed mwgkgk closed 4 years ago

mwgkgk commented 4 years ago

Problem: StumpWM restart (including forced one on certain errors) complains the (hardcoded) socket is busy and the whole thing hangs. A sane way of dealing with this would be to use some machinery that would pick a free socket when running vlime:main.

However, there's also a *restart-hook* that we could use to perhaps close the connection or, handle the situation more gracefully in some other way. The closest thing I've found is connection-close from vlime-connection.lisp, which requires a connection object, which however I'm not sure how to acquire: vlime:main seems to return nil.

Additionally, both these approaches would require handling the interrupted connection on the Vim side, which I'm also not sure how to best do.

Will be grateful for any suggestions :)

mwgkgk commented 4 years ago

This restart problem can be solved for both restart-hard and restart-soft by simply making sure vlime:main is only called once.

(ql:quickload :vlime)

(when (not (boundp '*vlime-loaded*))
  (vlime:main :interface #(127 0 0 1)
              ;; TODO pick a free port automatically and use :port-file
              :port 7002
              :backend :vlime-usocket)
  (defvar *vlime-loaded* t))

This lets the connection persist between restarts, so no additional Vim-side hackery is needed.

As such, closing the connection from the server side is not something that was needed. Closing the issue.