lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
anonimitoraf 2021-03-21T07:54:05.054300Z

Update on this: I found the cause: β€’ I had treemacs sync mode on β€’ In treemacs I had an inner folder registered as a project. Treemacs doesn't allow projects that overlap. β€’ Removed it, now works fine

william 2021-03-21T12:12:55.057200Z

Hey @ericdallo, I have a question on tooling: I open the clojure-lsp project in emacs, then open the file clojure-lsp/test/clojure_lsp/features/call_hierarchy_test.clj (at which point my lsp server auto-starts), then I do cider-jack-in-clj (with clojure-cli). Then I try to evaluate the clojure-lsp.features.call-hierarchy-test namespace I'm in with M-x cider-eval-buffer , and I get:

2. Unhandled clojure.lang.Compiler$CompilerException
   Error compiling test/clojure_lsp/features/call_hierarchy_test.clj at (1:1)
   #:clojure.error{:phase :compile-syntax-check,
                   :line 1,
                   :column 1,
                   :source
                   "/home/carlo/code/clojure/clojure-lsp/test/clojure_lsp/features/call_hierarchy_test.clj"}
             Compiler.java: 7652  clojure.lang.Compiler/load
                      REPL:    1  user/eval22442
                      REPL:    1  user/eval22442
             Compiler.java: 7181  clojure.lang.Compiler/eval
             Compiler.java: 7136  clojure.lang.Compiler/eval
                  core.clj: 3202  clojure.core/eval
                  core.clj: 3198  clojure.core/eval
    interruptible_eval.clj:   87  nrepl.middleware.interruptible-eval/evaluate/fn/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj: 1977  clojure.core/with-bindings*
                  core.clj: 1977  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   87  nrepl.middleware.interruptible-eval/evaluate/fn
                  main.clj:  437  clojure.main/repl/read-eval-print/fn
                  main.clj:  437  clojure.main/repl/read-eval-print
                  main.clj:  458  clojure.main/repl/fn
                  main.clj:  458  clojure.main/repl
                  main.clj:  368  clojure.main/repl
               RestFn.java:  137  clojure.lang.RestFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj:  662  clojure.core/apply
                regrow.clj:   20  refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   84  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   56  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  152  nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
                  AFn.java:   22  clojure.lang.AFn/run
               session.clj:  202  nrepl.middleware.session/session-exec/main-loop/fn
               session.clj:  201  nrepl.middleware.session/session-exec/main-loop
                  AFn.java:   22  clojure.lang.AFn/run
               Thread.java:  834  java.lang.Thread/run

1. Caused by java.io.FileNotFoundException
   Could not locate clojure_lsp/test_helper__init.class,
   clojure_lsp/test_helper.clj or clojure_lsp/test_helper.cljc on classpath.
   Please check that namespaces with dashes use underscores in the Clojure file
   name.
Am I doing something wrong?

ericdallo 2021-03-21T12:34:02.057400Z

Could you try jack in as a lein project?

william 2021-03-21T12:57:58.057600Z

thanks @ericdallo, jack-in as lein works. Could you explain me why that's the case? Isn't the presence of a deps.edn file enough for clojure-clj?

ericdallo 2021-03-21T13:02:02.057800Z

the clojure-lsp is actually a lein project that read the dependencies from deps.edn file, we need to migrate to full dep.edn πŸ˜…

1πŸ™Œ
ericdallo 2021-03-21T13:08:21.058100Z

ref: https://github.com/clojure-lsp/clojure-lsp/tree/only-deps.edn

dpsutton 2021-03-21T13:35:33.059500Z

If you try using the clojure cli again does it work? It’s been a bit but I think there’s some Java that lein compiles that clj obviously doesn’t know about

ericdallo 2021-03-21T13:48:51.059700Z

yes, @dpsutton is correct, that branch I refered fix that, but we need to fix other things to that work as well

william 2021-03-21T14:31:21.062600Z

Another question: in my emacs setup I have (setq lsp-clojure-custom-server-command '("bash" "-c" "cd /home/carlo/code/clojure/clojure-lsp && lein run")). I open emacs, visit the file clojure-lsp/src/clojure_lsp/feature/call_hierarchy.clj , jack-in using lein, use cider-eval-defun-at-point with an universal argument to toggle the debugging on the function incoming, then I call M-x lsp-treemacs-call-hierarchy on element-by-uri->incoming-usage-by-uri , expecting the call to be intercepted and debugged via cider (it has to pass via the incoming function). But that doesn't happen. What am I missing?

ericdallo 2021-03-21T14:33:25.062700Z

I never used that as (setq lsp-clojure-custom-server-command '("bash" "-c" "cd /home/carlo/code/clojure/clojure-lsp && lein run"))`` not sure why you need that. these are the steps I do to work:

ericdallo 2021-03-21T14:37:11.062900Z

1. I generate a local release to test with lein with-profile :debug bin 2. I point emacs to use that release: (setq lsp-clojure-custom-server-command '("bash" "-c" "~/dev/clojure-lsp/target/clojure-lsp")) 3. I open the https://github.com/ericdallo/clojure-sample, (could be any clojure project) and and wait until LSP starts. 4. I get the port of the running clojure-lsp on the project with lsp-clojure-server-info , it should print a :port xyz 5. I go to clojure-lsp and use cider-connect-clj and pass the port xyz 6. Now every function I eval on clojure-lsp project, it will affect the running session of clojure-lsp on my sample project

william 2021-03-21T14:40:46.063300Z

let me try this again then. I seem to remember that the problem with this approach is that if you use cider-connect-clj you won't have cider-nrepl middleware automatically injected, and so you won't be able to flag functions for debugging in cider. Is there a workaround for that? @dpsutton mentioned connecting to the repl the way clojure-clj does it (which, as I understand, injects the appropriate middlewares) which is what brought me to the previous question

william 2021-03-21T14:41:10.063500Z

so, in your method, does universal-argument M-x cider-eval-defun-at-point work?

ericdallo 2021-03-21T14:48:38.063800Z

Good question, never tried that, but you could add the middleware manually I think via some cider variable?

william 2021-03-21T14:50:22.064Z

that's the thing, from my admittedly little experience, I think a middleware has to be injected in the nrepl initialization, and I didn't find a way to do it only from the emacs side

ericdallo 2021-03-21T14:55:07.064400Z

or cider-jack-in-nrepl-middlewares

william 2021-03-21T15:29:15.064600Z

the documentation for lein you linked suggests to add something like

{:repl {:plugins [[cider/cider-nrepl "0.25.2"]]}}
to the project.clj . I modified the :debug section (since it seems to be the one I'm invoking:
:debug ^:leaky {:dependencies [[nrepl/nrepl "0.8.3"]
                                            [cider/cider-nrepl "0.25.9"]]}

ericdallo 2021-03-21T15:29:48.064900Z

that worked?

william 2021-03-21T15:29:56.065100Z

but I'm not sure on the invocation:

$ lein with-profile :debug bin
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
Performing task 'bin' with profile(s): ''
Warning: profile : not found.
WARNING: seqable? already refers to: #'clojure.core/seqable? in namespace: clojure.core.incubator, being replaced by: #'clojure.core.incubator/seqable?
WARNING: seqable? already refers to: #'clojure.core/seqable? in namespace: clostache.parser, being replaced by: #'clojure.core.incubator/seqable?
Warning: profile : not found.
Warning: profile : not found.
Warning: profile : not found.

ericdallo 2021-03-21T15:30:16.065400Z

try with: lein with-profiles +debug bin

william 2021-03-21T15:30:59.065600Z

ok that eliminates the warning, why does +debug work instead of :debug which is what's written in project-clj?

ericdallo 2021-03-21T15:32:18.065800Z

when you +profile , lein add that profile to the existing instead of using only the one you provided

ericdallo 2021-03-21T15:32:32.066Z

I don't know why that removes the warning though

ericdallo 2021-03-21T17:11:28.066200Z

Still need some corner cases fixes though, but it's working nice πŸ™‚

borkdude 2021-03-21T17:12:18.066600Z

you might also want to add clj-kondo.lint-as/def-catch-all to this list

borkdude 2021-03-21T17:12:26.066800Z

which works for weirder def-like macros

ericdallo 2021-03-21T17:12:42.067Z

yes!

borkdude 2021-03-21T17:12:55.067200Z

and I would probably remove -> since I have almost never encountered this in lint-as

borkdude 2021-03-21T17:13:08.067400Z

oh you have, well, then leave it :)

ericdallo 2021-03-21T17:13:22.067600Z

Cursive thas that, I don't see any harm keep it, right?

borkdude 2021-03-21T17:13:33.067900Z

no harm. good job!

ericdallo 2021-03-21T17:13:44.068100Z

Thank you for the help! I'm glad this worked πŸ™‚

borkdude 2021-03-21T17:15:25.068300Z

LSP is quickly becoming the most complete IDE after Cursive

borkdude 2021-03-21T17:15:45.068500Z

I hope you get funding by CT

1☝️
ericdallo 2021-03-21T17:16:22.068700Z

Yeah πŸ˜„ That'd be really good πŸ™‚

borkdude 2021-03-21T17:17:29.068900Z

Was there a survey announcement recently? Haven't seen one

ericdallo 2021-03-21T17:17:51.069100Z

No, I think they will start the voting on april

ericdallo 2021-03-21T17:18:25.069300Z

they were closing the members register this month

borkdude 2021-03-21T17:18:35.069500Z

So how did it end with the incremental diffing? reverted it?

borkdude 2021-03-21T17:18:51.069700Z

yeah, but usually they send out a survey to the sponsors before this

borkdude 2021-03-21T17:19:19.070Z

to see which projects should get funded by the opinion of the sponsors

borkdude 2021-03-21T17:20:31.070200Z

I will ask Daniel

ericdallo 2021-03-21T17:21:31.070400Z

> So how did it end with the incremental diffing? reverted it? I still need to find the out-of-sync corner case issue, it's behind a feature-flag

ericdallo 2021-03-21T17:21:47.070600Z

Oh, got it

borkdude 2021-03-21T17:22:22.070800Z

I was thinking, maybe generative testing could be used to find this corner case

ericdallo 2021-03-21T17:23:34.071Z

yes, it could help indeed, I think we could improve the integration tests to be able to do that

ericdallo 2021-03-21T17:23:46.071200Z

the clojure-lsp integration tests base is working good

borkdude 2021-03-21T17:24:13.071400Z

is it a problem with the async stuff, or with the diff function?

ericdallo 2021-03-21T17:24:42.071600Z

Probably the async stuff

ericdallo 2021-03-21T17:24:54.071800Z

the diff function seems to work good

ericdallo 2021-03-21T17:25:15.072Z

also it seems to happen with medium/big buffers

borkdude 2021-03-21T17:25:48.072200Z

Maybe you can test it by putting some random Thread/sleeps into the async handlers

ericdallo 2021-03-21T17:26:00.072400Z

hum, good idea indeed

borkdude 2021-03-21T17:54:12.072600Z

Btw, I will probably make a new clj-kondo release tonight with a bunch of bug fixes in it

ericdallo 2021-03-21T17:54:51.072800Z

good to know! I'll include in this feature release if don't find any issues with that bump 🀞

ericdallo 2021-03-21T17:55:08.073Z

thanks for telling me

borkdude 2021-03-21T17:56:20.073200Z

I will push one more fix to master within the next two hours

1πŸ‘
borkdude 2021-03-21T18:55:19.073500Z

Pushing 2021.03.21, will be on clojars in a few minutes hopefully

ericdallo 2021-03-21T18:58:51.073800Z

Nice, I'm finishing the resolve macro as, then I'll bump clj-kondo, if everything goes fine, I'll release it later tonight

ericdallo 2021-03-21T19:12:30.074Z

I love this bot πŸ™‚ https://github.com/clojure-lsp/clojure-lsp/pull/375

borkdude 2021-03-21T19:44:28.074300Z

Hmm, I found one more edge. I will do another release tonight

ericdallo 2021-03-21T19:47:53.074500Z

πŸ‘ , I'll wait for clojure-lsp release so

borkdude 2021-03-21T20:47:25.074800Z

2πŸ‘1
ericdallo 2021-03-21T23:51:14.075100Z

:clojure-lsp:Β ReleasedΒ https://github.com/clojure-lsp/clojure-lsp/releases/tag/2021.03.21-23.29.19Β version: β€’ Bump a lot of libs: rewrite-clj (v1), lsp4j, guava, data.json β€’ Add new code action: Resolve macro as... πŸŽ‰ : The Resolve macro as feature asks to user how clj-kondo should lint that macro from common used macros only (for now), and on what clj-kondo config file it should save the :lint-as map. Thanks to @borkdude and @lee for the help to make that happen. This feature was something that since I started programming Clojure I missed on other editors than Cursive and now that is possible starting from Emacs editor (make sure to update lsp-mode package) πŸ˜„

4613πŸŽ‰
snoe 2021-03-22T14:48:02.080200Z

amazing

nmkip 2021-03-22T22:20:07.080900Z

Thanks! Just updated πŸ™‚

2πŸš€
ericdallo 2021-03-21T23:57:37.075500Z

@brandon.ringe LMK if need any help setting up that new action on Calva, it will need to code something for that work

1πŸ‘