Fork me on GitHub

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 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,
    7652  clojure.lang.Compiler/load
                      REPL:    1  user/eval22442
                      REPL:    1  user/eval22442
    7181  clojure.lang.Compiler/eval
    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
          152  clojure.lang.AFn/applyToHelper
          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*
       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
       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
      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
           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
           22  clojure.lang.AFn/run
       834  java.lang.Thread/run

1. Caused by
   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
Am I doing something wrong?


Could you try jack in as a lein project?


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?


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

🙌 3

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


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


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?


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:


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, (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


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? @U11BV7MTK 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


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


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


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


or cider-jack-in-nrepl-middlewares


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"]]}


that worked?


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.


try with: lein with-profiles +debug bin


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


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


I don't know why that removes the warning though


clojure-lsp Released 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) 😄

🎉 39
clojure-lsp 18
clj-kondo 12

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

👍 3

how does it work, code actions should be editor agnostic right?


Will it be available in AUR?


@U0BUV7XSA this action uses a lsp-mode feature called action-handler, it's used on lsp-java, rust and other LSP, it's useful to when you need user input before applying the action, But yeah, the editor needs to handle that as well


@UJCC6CE9E yes, probably @U11EL3P9U will release it tomorrow


It's there now 🙂


Thanks! Just updated 🙂

🚀 6