Fork me on GitHub
#lsp
<
2022-12-26
>
didibus01:12:59

Is there a way to use clojure-lsp without files? Like in a Clojure buffer inside emacs, where there are no corresponding files.

ericdallo03:12:20

Theorycally, LSP servers and clients should handle URI as document identifiers and don't expect to files exists on disk, but TBH it's not that easy to support that. Clojure-lsp probably work for singles files but I don't think it will work for whole projects if no file is persisted

didibus02:12:22

My use is for a single buffer, I often open a new buffer and connect a REPL for one off sessions, where I never save, so there's no real file. But I could probably solve my use-case easily by having a playground project that I just erase/reuse instead, so I don't think it's a high priority.

ericdallo14:12:07

yeah, even so, for a single buffer, it should work, I didn't test extensively though

Carlo08:12:36

When I follow a definition for a function, I end up in .emacs.d/local/.cache/workspace/.cache/file.clj`` , and I can't evaluate the modifications I make in that buffer. Is there a way to evaluate some snippet in the dependency (I remember doing this before, but maybe it's because I was brought in ~/.m2/...?)

ericdallo15:12:00

that's a good question, TBH I never thought about that kind of workflow. If you go to a definition of a external deps you end up in that file indeed and lsp mark the buffer as read only, you can toggle the read-only mode though and make any changes you want. About the eval, I'm not sure why cider don't allow evaluating that buffer, with a error of:

No linked CIDER sessions
I suspect it doesn't know that file is linked to the existing session of your project, probably because they are not under the same project root :thinking_face:

ericdallo15:12:25

I found a workaround: • after changing the buffer, you can cider-connect and specify the nrepl port that is up and running for your project, then eval that buffer will work I know it's one more step but probably is not something you want to do all the time?

🙌 1
Carlo18:12:21

I'd say it's a good enough workaround, I'll try it next time I need something like that and report back!

👍 1
mpenet21:12:20

You can use sesman-link-with-buffer and link that file to a running repl

🙌 1
mpenet21:12:21

Then you can just eval stuff from there the normal way

mpenet22:12:06

There’s probably a way to automate this with sesman “friendly sessions” the same way cider does when navigating to var defs