bhrgunatha 路 2022-09-24 07:39
I use emacssclient and the emacs server.
I've configured emacs to use `lsp-mode` for several languages e.g. haskell when visiting a .hs file, python for a .py file.
These all work as expected according to my configuration.
What happens often to me though is:
1. Open up such a file
1. `lsp-mode` fires up and connects (correctly) to the appropriate language server.
1. Edit other files of the same kind - all use the same languages server instance. Happy. 馃憤馃徏
1. Kill the buffers using `lsp-mode` and connected to the languages server, one by one over time.
1. Close emacsclient (emacs server continues running as it should)
1. Language server is also still running despite having no more clients connected.
Is it possible to have `lsp-mode` kill the language server automatically when there are no more clients?
Icommentedtoday 路 2022-09-24 09:00
Maybe try to set "lsp-keep-workspace-alive" to nil and see if that helps?
bhrgunatha 路 2022-09-24 12:44
Thanks, I believe that's working. I swear I went through all the items in lsp-mode config group.
Although the `*<servername>*` buffers still linger `(get-buffer-process (current-buffer))` returns `nil` in those buffers and the processes are definitely gone.
Thaodan 路 2022-09-24 15:44
Interesting, how did you do it?
I wonder if a systemd socket might work good, socket activation would make handling of this services much easier.
bhrgunatha 路 2022-09-24 17:13
I literally just added `(setq lsp-keep-workspace-alive nil)` to my emacs config. `lsp-mode` takes care of the server activation - and now I've learned termination too.
I'm not sure about systemd, I haven't tried it. Maybe if you're hacking on c or c++ all day it might make sense for systemd to manage.