Fork me on GitHub
#lsp
<
2021-07-17
>
ikitommi10:07:07

Is it possible to publish events to LSP/clj-kondo from a running application? my use case is that I know in my reply session that for example a Var has an invalid function schema defined: in-repl dev-toolong runs generative testing on background and could report "`var #'user/kikka has invalid function schema defined`". Would be great to be able to push that into LSP so it would end up in a warning-marker.

borkdude10:07:55

wouldn't a CIDER middleware/thing or so be a better fit for that?

ikitommi10:07:55

would that work with calva? or cursive?

ikitommi10:07:23

(never wrote CIDER middleware, so clueless here)

borkdude10:07:49

you talk about REPL session. I think it's more natural to inject something in that REPL session than into static analyzer tools

borkdude10:07:55

since REPL = runtime

borkdude10:07:12

perhaps throwing an exception with some stacktrace will do the right thing automatically

borkdude10:07:26

you could do trick using clj-kondo hooks where the hook generates errors

borkdude10:07:33

and you refresh the hook at runtime

borkdude10:07:47

and then clj-kondo will report it on the next lint (not sure in the case of clojure-lsp, it should refresh the config if one of the hook code has changed, which it should do anyway)

ikitommi10:07:13

:thinking_face: the flow is: 1. you call mallli.dev/start! in repl 2. you define function schemas 3. dev-toolong listens to registry changes and runs tests for that -> know if it's not right (var + error) 4. now, just prints that

borkdude10:07:58

ok in the case of 4, I think throwing an exception would probably be what triggers CIDER to render the error in the code

borkdude10:07:06

or whatever other tool, like socket REPL tooling

ikitommi10:07:26

thanks, need to test. The checking is done in background on var watcher, so not sure where the exception would end up.

borkdude11:07:15

Sometimes people have setup an uncaught exception handler which makes it log somewhere

pez12:07:30

With the right deps.edn alias Calva should support custom nrepl middleware, I think.

ericdallo16:07:52

For Nix users: Latest clojure-lsp is available on nixpkgs unstable channel. FYI @huxley @suskeyhose