Fork me on GitHub
#lsp
<
2021-03-14
>
Carlo15:03:16

followup question from yesterday: I have a checkout of clojure-lsp, and I invoke lsp in emacs with:

(after! clojure-mode (setq lsp-clojure-custom-server-command '("bash" "-c" "cd /home/carlo/code/clojure/clojure-lsp && lein run")))
Then, I get the port via lsp-clojure-server-info, and cider-connect to localhost and that port. However, in the repl, I get this warning:
WARNING: CIDER requires cider-nrepl to be fully functional. Some features will not be available without it! (More information)
In the documentation for cider , I learnt that cider injects automatically the middleware in the case of cider-jack-in, but not in the case of cider-connect. So I modified clojure-lsp/deps.edn to have this section:
:aliases {:test {:extra-paths ["test"]}
           :debug {:extra-deps {nrepl/nrepl {:mvn/version "0.8.3"}
                                cider/cider-nrepl {:mvn/version "0.25.9"}}}
           :run {:main-opts ["-m" "clojure-lsp.main"]
                 :jvm-opts ["-Xmx2g" "-server"]}}
(note the cider-nrepl addition). However, nothing changed. I suspect that is because I'm not really using the debug version, so I'm trying setting the command to:
lein with-profile :debug run ;; doesn't work
or other variations, but can't get cider-nrepl to work properly. Ideas, @ericdallo?

ericdallo16:03:50

I think you can just inject the nrepl/nrepl in your lein profile

Carlo16:03:23

do you mean cider/cider-nrepl?

Carlo16:03:53

ok, now I have as my ~/.lein/profiles.clj:

{:user {:dependencies [[org.clojure/tools.namespace "0.2.3"]
                       [spyscope "0.1.3"]
                       [criterium "0.4.1"]
                       [cider/cider-nrepl "0.25.9"]
                       [nrepl/nrepl "0.8.3"]]}}
and the command is still
(after! clojure-mode (setq lsp-clojure-custom-server-command '("bash" "-c" "cd /home/carlo/code/clojure/clojure-lsp && lein run")))
but I still have:
WARNING: CIDER requires cider-nrepl to be fully functional. Some features will not be available without it! (More information)
is that because I need to inject them myself somehow?

ericdallo16:03:28

Hum, I have no idea, never faced this warning. Maybe https://github.com/clojure-emacs/cider-nrepl/issues/597 can help?

Carlo16:03:06

no, that's where I learned the difference in behavior between cider-connect and cider-jack-in. I'm starting to thing that maybe what I want to accomplish might be impossible in the current tooling

ericdallo16:03:29

Yeah, I never tried cider debug, and only used debug from DAP on other languages, and honestly the cider + clojure-lsp works pretty well to me to hack and code

ericdallo16:03:54

Did you ask about that on #cider?

Carlo16:03:58

yes, yesterday, but no response yet; I'll see if I have more luck during the week

Carlo16:03:34

I understand that it might seem strange that I insist in trying to get this workflow right, but it would be my dream workflow for a project like this, and I'm dabbling in clojure to see how well I can optimize for happiness 😂

ericdallo16:03:24

yes, I see your point 🙂

ericdallo16:03:33

well, let me know if you manage to make it work

🙌 3
💪 3
dpsutton19:03:27

You need to call ciders main not lsp

dpsutton19:03:06

Jack into a project that uses clojure cli and copy the jack in command printed at the top of the repl and modify it as you need

nmkip21:03:07

Hi. I noticied that sometimes I lose the arities of the the functions in the minibuffer, I think lsp errors override the minibuffer. Here's an example:

nmkip21:03:25

Is there a way to just underline the function and not the whole sexp?

nmkip21:03:37

For example, the first paren is underlined because I'm redifining the function and I get the warning when I move the point to that paren.

borkdude21:03:07

which editor is this? I found that VSCode did this too, so in the clj-kondo lsp server I worked around it like this: https://github.com/clj-kondo/clj-kondo.lsp/blob/90714f7d9a867110b003c24008c46ae4956c65c7/server/src/clj_kondo/lsp_server/impl/server.clj#L72

borkdude21:03:20

(note that this is not clojure-lsp)

😞 3
borkdude22:03:03

flycheck + pure clj-kondo does this better imo

borkdude22:03:54

yes. you can turn off linting with the lsp plugin, that's how I do it locally. you will need to install the clj-kondo binary though

nmkip22:03:06

I already have it 🙂

nmkip22:03:41

Do I lose lsp intelligence if I turn off linting?

nmkip22:03:44

btw, to turn it off I added this to my ~/.lsp/config.edn file, is that enough?

:linters {:clj-kondo {:level :off}}

borkdude22:03:04

@UJCC6CE9E You can do this on the client side

borkdude22:03:21

lsp-diagnostics-provider :none

borkdude22:03:39

I think it's best to do it there. clojure-lsp still uses clj-kondo for analysis and it will also use information from findings

nmkip22:03:18

good, I was afraid to lose that part!

nmkip22:03:23

Ill try that

nmkip22:03:05

works perfectly, thanks

nmkip22:03:39

The minibuffer blinking between the arity and the linting error was driving me crazy 😛 and I like the arity message

ericdallo22:03:25

Any tips how to improve this on clojure-lsp to avoid users need to disable that?

ericdallo22:03:03

I don't get lsp errors/warnings on minibiffer, I'm not sure what we should improve

borkdude22:03:26

The above is what I needed to do to "fix" this in vscode

borkdude22:03:06

My function is to avoid underlining the entire s-expression in case it's an expression with parens

borkdude22:03:21

even if it's on the same line (unlike your code, it seems)

ericdallo22:03:36

I see, so it'll underline only the function name?

borkdude22:03:57

only the first paren

borkdude22:03:18

pretty much how flycheck does it by default when you don't give an end location

borkdude22:03:24

it's just that lsp requires an end location

ericdallo22:03:28

yeah, I see the issue now

ericdallo22:03:51

looks a good fix for now, I'll try to make that happen for clojure-lsp as well, thanks for the tip @U04V15CAJ

borkdude22:03:32

yeah, not sure if kondo should do this by itself, the end locations may be used by some tools for other purposes

ericdallo22:03:52

yes, I agree

ericdallo23:03:42

Fixed on latest release @UJCC6CE9E 😄

nmkip23:03:43

Thanks @ericdallo! I'll try it after having dinner