lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
snoe 2021-03-14T06:27:52.056Z

sure, i dont know lsp-mode; i use this in vim https://github.com/snoe/dotfiles/blob/master/home/.vim/coc-settings.json#L9-L10

william 2021-03-14T15:58:16.061400Z

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?

ericdallo 2021-03-14T16:01:50.061500Z

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

ericdallo 2021-03-14T16:02:22.061900Z

Example: https://gist.github.com/arnaudsj/9731521#file-profiles-clj-L2

william 2021-03-14T16:02:23.062100Z

do you mean cider/cider-nrepl?

ericdallo 2021-03-14T16:02:33.062300Z

yeah

william 2021-03-14T16:08:53.062500Z

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?

ericdallo 2021-03-14T16:15:28.062700Z

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

william 2021-03-14T16:21:06.063100Z

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

ericdallo 2021-03-14T16:25:29.063300Z

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

ericdallo 2021-03-14T16:25:54.063500Z

Did you ask about that on #cider?

william 2021-03-14T16:28:58.063700Z

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

william 2021-03-14T16:30:34.063900Z

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 😂

ericdallo 2021-03-14T16:32:24.064100Z

yes, I see your point 🙂

ericdallo 2021-03-14T16:32:33.064300Z

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

💪 1
🙌 1
dpsutton 2021-03-14T19:21:27.065Z

You need to call ciders main not lsp

dpsutton 2021-03-14T19:22:06.066200Z

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

nmkip 2021-03-14T21:50:07.069300Z

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:

nmkip 2021-03-14T21:50:25.069600Z

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

nmkip 2021-03-14T21:51:37.069800Z

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.

borkdude 2021-03-14T21:53:07.070Z

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

borkdude 2021-03-14T21:53:20.070400Z

(note that this is not clojure-lsp)

😞 1
nmkip 2021-03-14T21:54:13.070600Z

emacs

borkdude 2021-03-14T22:03:03.070900Z

flycheck + pure clj-kondo does this better imo

nmkip 2021-03-14T22:04:17.071100Z

https://github.com/borkdude/flycheck-clj-kondo this one, right?

borkdude 2021-03-14T22:04:54.071500Z

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

nmkip 2021-03-14T22:05:06.071700Z

I already have it 🙂

nmkip 2021-03-14T22:12:41.071900Z

Do I lose lsp intelligence if I turn off linting?

nmkip 2021-03-14T22:13:44.072100Z

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

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

borkdude 2021-03-14T22:14:04.072300Z

@juan.ignacio848 You can do this on the client side

borkdude 2021-03-14T22:14:21.072500Z

lsp-diagnostics-provider :none

borkdude 2021-03-14T22:14:39.072700Z

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

nmkip 2021-03-14T22:15:18.073Z

good, I was afraid to lose that part!

nmkip 2021-03-14T22:15:23.073200Z

Ill try that

nmkip 2021-03-14T22:17:05.073400Z

works perfectly, thanks

nmkip 2021-03-14T22:17:39.073600Z

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

ericdallo 2021-03-14T22:34:25.073900Z

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

ericdallo 2021-03-14T22:35:03.074300Z

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

borkdude 2021-03-14T22:35:26.074700Z

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

ericdallo 2021-03-14T22:37:22.074900Z

Could you elaborate? we have a pretty similar function in clojure-lsp: https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/feature/diagnostics.clj#L10

borkdude 2021-03-14T22:40:06.075200Z

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

borkdude 2021-03-14T22:40:21.075400Z

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

ericdallo 2021-03-14T22:40:36.075600Z

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

borkdude 2021-03-14T22:40:57.075800Z

only the first paren

borkdude 2021-03-14T22:41:18.076100Z

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

borkdude 2021-03-14T22:41:24.076300Z

it's just that lsp requires an end location

ericdallo 2021-03-14T22:41:28.076500Z

yeah, I see the issue now

ericdallo 2021-03-14T22:41:51.076700Z

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

borkdude 2021-03-14T22:42:32.076900Z

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

ericdallo 2021-03-14T22:42:52.077100Z

yes, I agree

ericdallo 2021-03-14T23:42:42.077300Z

Fixed on latest release @juan.ignacio848 😄

nmkip 2021-03-14T23:44:43.077500Z

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