tonsky / Clojure-Sublimed

Clojure support for Sublime Text 4
MIT License
359 stars 22 forks source link

Allow connection through UNIX domain socket #80

Closed tribals closed 1 year ago

tribals commented 1 year ago

Closes #68

tonsky commented 1 year ago

Looks great! Can you make it so that relative paths would work as well as absolute ones when specifying socket path? Kind of like .nrepl-port is searched in all opened folders?

Also, status bar shows None now, it shouldn’t

Screenshot 2022-11-16 at 20 36 51
tribals commented 1 year ago

Can you make it so that relative paths would work as well as absolute ones when specifying socket path?

When you connect through TCP, you need to be precise about what you're connecting to. I think, this is useful semantic which we need to keep when connecting through UNIX domain sockets too. There is no "relative" IP-address:TCP-port.

Kind of like .nrepl-port is searched in all opened folders?

Personally I disagree with this style of configuration. If you want to save your users from typing too much, I think something like os.path.expanduser would be helpful, or even expanding common environment variables like $XDG_RUNTIME_DIR. As well as common "Sublime Dirs" like project location or so. The problem with "Sublime Dirs" is that it is not clear, which directory is "opened" at this time? But proper integration with REPL server depends on precise path. Or, REPL could not be able to load your sources.

Consider this Sublime project layout:

top-dir
`+ sub-project
`+ sub-project1

What if both sub-project and sub-project1 developed in Clojure? Both has .nrepl-port (which points to TCP socket port, or in case of unix domain sockets - absolute socket file path :grin: ). Which one try to connect to? This depends on context - in which directory you are right now? But, in Sublime, there is no such one. There is only "project directory" (top-dir in our case). Then, specifying relative path would connect to any of sub-project and sub-project1 servers. It is better to provide some variable expansion instead. Then, you could specify socket as ~/work/foo/nrepl.sock, or {project_directory}/sub-project/nrepl.sock. Or, even $XDG_RUNTIME_DIR/nrepl.sock - I prefer to keep only one instance of nREPL server.

This is why you need to be precise when initiating client connection.

tonsky commented 1 year ago

Thanks! Merged in 2df3bb213d081cf77bf3f40b343b8774a98c3cb8