psc-ide-emacs icon indicating copy to clipboard operation
psc-ide-emacs copied to clipboard

No more global psc-ide-server

Open reactormonk opened this issue 6 years ago • 7 comments

Currently, the psc-ide-server is global per emacs instance. It should be per-project instead of per-emacs.

reactormonk avatar Jan 10 '19 15:01 reactormonk

Yep, I expect to tackle this one.

purcell avatar Jan 17 '19 08:01 purcell

Some prior art to look into is how the Atom and VSCode plugin as well as pscid handle it, they generate a .psc-ide-port file in the project root with a random port:

https://github.com/kRITZCREEK/purescript-psc-ide/blob/1e6f2f658b6344c505ce9eb7d6c6f6fdb6562c1f/src/PscIde/Server.purs#L104-L124

(Part of the idea here is that different tools can share the same server instance. Useful if you're doing pair programming with two editors, or if you like the pscid workflow but still want to have auto-import resolution in the editor)

kritzcreek avatar Jan 17 '19 08:01 kritzcreek

I don't think a temp file with the port is necessary. Once there's a server buffer for a certain directory, it's easy enough to go from any purescript buffer to the server buffer for a parent directory. intero would be a better example IMO.

purcell avatar Jan 17 '19 09:01 purcell

That's what I meant with:

Part of the idea here is that different tools can share the same server instance. Useful if you're doing pair programming with two editors, or if you like the pscid workflow but still want to have auto-import resolution in the editor

I'm sure it's easy enough to handle within Emacs, but then you're not interoperating with other tools.

kritzcreek avatar Jan 17 '19 10:01 kritzcreek

Part of the idea here is that different tools can share the same server instance. Useful if > you're doing pair programming with two editors, or if you like the pscid workflow but still > want to have auto-import resolution in the editor

Interesting. Do people currently use psc-ide-emacs to do that? I'm not sure it's possible right now. Generally I'd think that the way to go would be to first make Emacs able to start and communicate with several servers, and then after that, mechanisms for sharing (or re-using) servers with non-Emacs clients could be added.

purcell avatar Jan 17 '19 22:01 purcell

You can do it right now by just telling pscid to look at the same port that is configured in Emacs. I handle multiple projects by specifying a different psc-ide-port per project with .dir-locals.el. It works "well enough" that I haven't looked into anything more complicated.

Usually when I try to design a feature I don't use myself I do a bad job :D

kritzcreek avatar Jan 17 '19 22:01 kritzcreek

It works "well enough" that I haven't looked into anything more complicated.

Simple is good! Thanks for the explanation.

Usually when I try to design a feature I don't use myself I do a bad job

SAME

purcell avatar Jan 18 '19 09:01 purcell