lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
devn 2021-03-05T01:59:46.441700Z

@ericdallo you rule!

ericdallo 2021-03-05T02:11:13.441900Z

Tomorrow morning I'll release it πŸ™‚

practicalli-john 2021-03-05T06:51:09.450200Z

Is there an LSP UI equivalent of the flycheck mode line display of errors/warnings. I'm using doom-gruvbox theme and if I have clj-kondo install as a binary on the OS execution path, then I get the flycheck mode line display of errors and warnings. If I remove clj-kondo binary, LSP package includes clj-kondo if not on the command line, but I don't see a visual on the mode-line about errors/warnings

borkdude 2021-03-05T09:51:45.453300Z

@jr0cket FWIW I'm still using clj-kondo flycheck and have disabled lsp diagnostics, but this is because I'm also developing clj-kondo

practicalli-john 2021-03-05T10:29:19.454100Z

That sounds an interesting approach. I use lsp mainly for seeing references for functions when doing archaeology on a code base. I 'need' flycheck to remind me not to commit things that clj-kondo will fail in the GitHub Action πŸ™‚

ericdallo 2021-03-05T10:59:29.454300Z

FYI We now have custom clijure-lsp linters like unused public vars, disabling diagnostics will remove these too. There is a built-in feature on lsp-mode that show the errors/warnings on the modeline, I think it is lsp-modeline-diagnostics-enable or something

borkdude 2021-03-05T11:00:25.454600Z

Hmm, I only want to disable the clj-kondo diagnostics, not the other ones

borkdude 2021-03-05T11:00:35.454800Z

Can this be configured?

borkdude 2021-03-05T11:00:42.455Z

at the lsp server side

ericdallo 2021-03-05T11:01:13.455200Z

No, this is a lsp-mode setting, not sure it makes sense to to add this kind of logic to the server

ericdallo 2021-03-05T11:02:50.455400Z

Also, not sure you could have both lsp and clj-kondo flycheck enable at the same time

borkdude 2021-03-05T11:04:40.455600Z

Why is it not possible to say at the server side: filter these diagnostics for me, before sending them over to the client.

borkdude 2021-03-05T11:04:50.455800Z

using the .lsp/config.edn

ericdallo 2021-03-05T11:06:12.456Z

It's possible, I just not sure it's good to add this kind of logic, I imagine users complaining about wrong linters but not using lsp linter or something

borkdude 2021-03-05T11:06:24.456200Z

This would also make it possible to not depend on any client side emacs config, but this would solve it for all clients

ericdallo 2021-03-05T11:06:33.456400Z

I think we can test it

ericdallo 2021-03-05T11:07:01.456600Z

Something like :linters :clj-kondo :level :off

borkdude 2021-03-05T11:07:12.456800Z

I think it would make sense to push more logic to the server than leave it on the client side

borkdude 2021-03-05T11:07:16.457Z

More uniform config

borkdude 2021-03-05T11:07:45.457200Z

{:features {:clj-kondo {:disabled true}}

borkdude 2021-03-05T11:07:55.457400Z

or rather linting

borkdude 2021-03-05T11:08:15.457600Z

{:disable-features #{:clj-kondo-linting}} or something

borkdude 2021-03-05T11:08:27.457800Z

you would still get the analysis but not the warnings

borkdude 2021-03-05T11:08:38.458Z

and I would like to opt in to the add-on linters that lsp provides based on the project-wide analysis

ericdallo 2021-03-05T11:08:59.458200Z

That's why I added to the :linters config block

ericdallo 2021-03-05T11:09:13.458500Z

I think it's easier and follow the same pattern

borkdude 2021-03-05T11:09:14.458700Z

oh right

borkdude 2021-03-05T11:09:19.458900Z

sorry, I missed that

ericdallo 2021-03-05T11:09:23.459100Z

Np

ericdallo 2021-03-05T11:09:29.459300Z

I can check this soon

borkdude 2021-03-05T11:10:15.459500Z

Amazing

borkdude 2021-03-05T12:05:06.460800Z

@ericdallo To be honest, I think the lens-mode is sufficient for me for showing unused vars

borkdude 2021-03-05T12:05:45.461Z

it's pretty much the same as an info-lint warning to me personally

ericdallo 2021-03-05T12:09:28.461600Z

Ok, I'll release the new feature without this, we can see if that flag would be really necessary then

orestis 2021-03-05T09:21:54.452Z

I'm seeing a weird issue. I'm running a local version of clojure-lsp. When I am attaching a client to the clojure-lsp source itself, everything works fine. When I attach to my work project, I see that the clojure LSP process has started, but no LSP server logs. In the client logs, I see a ton of: "stderr" "Syntax error reading source at (REPL:1:16).\nInvalid token: Content-Length:\n" and similar looking things.

orestis 2021-03-05T09:28:14.452900Z

It seems like neovim is sending the correct handshake to clojure-lsp but for some reason it's interpreted wrong? I'm not sure why it works though with clojure-lsp's source code and with the work project.

orestis 2021-03-05T09:30:11.453200Z

ooooh it's the way I start the process. Never mind.

πŸ‘ 1
borkdude 2021-03-05T10:04:22.453800Z

@devn @ericdallo About automatically inferring deps from a random script: https://github.com/babashka/babashka/issues/733#issuecomment-791314599

ericdallo 2021-03-05T12:00:44.459700Z

We could use that I think, but we still don't know if the file is a bb one, so your idea is to have a flag that if enable we always use deps infer?

borkdude 2021-03-05T12:01:37.459900Z

Yeah, from LSP it doesn't matter if this is a bb script, or other script, as long as it comes up with the correct list of deps

borkdude 2021-03-05T12:01:56.460100Z

I'm not suggesting you use this right now, it first needs some polishing

borkdude 2021-03-05T12:02:03.460300Z

but maybe the approach could work

borkdude 2021-03-05T12:02:53.460500Z

The same approach could also work for people who make use of add-lib (dynamically adding libs to the classpath)

ericdallo 2021-03-05T12:08:10.461200Z

I see, do you know if that works for lein projects, deps edn, shadow-cljs and etc? I wonder if we could replace all that logic with just deps infer in the future

ericdallo 2021-03-05T12:08:40.461400Z

I don't know also if I'd need to call deps infer in a specific file on a whole project to get the correct classpath

borkdude 2021-03-05T12:10:28.461800Z

@ericdallo The idea of deps-infer is that it is agnostic about your project tools, it only looks at source

borkdude 2021-03-05T12:11:02.462Z

So you can infer deps from code that doesn't have a deps.edn, project.clj, etc, that is the idea

ericdallo 2021-03-05T12:12:13.462200Z

Got it, but what happens if I call it in a specific file of a deps.edn project? It'll bring me all the dependencies of that file only or the correct deps.edn deps?

borkdude 2021-03-05T12:12:44.462400Z

of that file only, it ignores the deps.edn

ericdallo 2021-03-05T12:18:57.462600Z

I see, so we would't be able to replace all clojure-lsp logic to only use deps infer

borkdude 2021-03-05T12:19:09.462800Z

nope

borkdude 2021-03-05T12:20:17.463Z

Maybe this can be first used to update your existing deps.edn or to create one which lsp can then pick up on

borkdude 2021-03-05T12:20:28.463200Z

as a first experimentation

ericdallo 2021-03-05T14:19:01.465200Z

:clojure-lsp: Released https://github.com/clojure-lsp/clojure-lsp/releases/tag/2021.03.05-13.35.47 πŸŽ‰ β€’ Fix clojure-lsp lint crash when analyzing specific macros with clj-kondo hooks. β€’ Fix didChange for Neovim client - thanks to @orestis β€’ Add new clojure-lsp linter: unused-public-var - FixesΒ https://github.com/clojure-lsp/clojure-lsp/issues/359 β€’ Add option to disable clj-kondo linter, check https://clojure-lsp.github.io/clojure-lsp/settings/#unused-public-var for more details.

πŸ’― 3
1
orestis 2021-03-05T14:20:07.466100Z

I've seen another instance of neovim asking something that clojure-lsp can't deliver, something about watching workspace files? I'll investigate more and report back next week.

ericdallo 2021-03-05T14:20:49.466200Z

we have this on emacs, it's called lsp-mode file watchers

ericdallo 2021-03-05T14:21:02.466400Z

but it works well

orestis 2021-03-05T14:21:53.466700Z

I mean, neovim is asking clojure-lsp to do something and clojure-lsp reports back that it lacks the capability.

orestis 2021-03-05T14:22:26.466900Z

Things seem to work without it, apparently, so perhaps neovim can also do client-side watching?

ericdallo 2021-03-05T14:22:44.467100Z

yes

ericdallo 2021-03-05T14:22:47.467300Z

like lsp-mode

orestis 2021-03-05T14:23:10.467500Z

Would you be interested in doing this watching also server-side?

ericdallo 2021-03-05T14:26:02.467800Z

Need to check the spec but AFAIK this should be handled on client side

borkdude 2021-03-05T14:31:06.468500Z

@ericdallo Are config in ~/.lsp and the project .lsp merged? I.e. can I set that linter config my home dir while overriding it in my project?

ericdallo 2021-03-05T14:33:57.468600Z

Yes, it should work

borkdude 2021-03-05T14:52:52.469600Z

Excellent. So to have flycheck clj-kondo work with lsp I have:

{:auto-add-ns-to-new-files? false
 :linters {:clj-kondo {:level :off}
           :unused-public-var {:level :info}}}
in ~.lsp/config.edn and:
(dolist (checker '(clj-kondo-clj clj-kondo-cljs clj-kondo-cljc clj-kondo-edn))
  (setq flycheck-checkers (cons checker (delq checker flycheck-checkers))))
;; clj-kondo calls lsp after linting, even if there are errors
(dolist (checkers '((clj-kondo-clj . lsp)
                    (clj-kondo-cljs . lsp)
                    (clj-kondo-cljc . lsp)
                    (clj-kondo-edn . lsp)))
  (flycheck-add-next-checker (car checkers) (cons 'error (cdr checkers))))
in my init.el (after loading flycheck-clj-kondo and lsp-mode)

borkdude 2021-03-05T14:55:41.470100Z

hmm

borkdude 2021-03-05T14:56:03.470400Z

It seems I'm still getting linting from lsp...

borkdude 2021-03-05T14:56:14.470500Z

ericdallo 2021-03-05T14:57:24.470800Z

isn't that your clj-kondo flycheck check?

ericdallo 2021-03-05T14:58:18.471Z

Just to make things simple, test it with your local project .lsp/config.edn

ericdallo 2021-03-05T14:58:36.471200Z

if it works, probably it's some config merge issue

borkdude 2021-03-05T15:00:01.471400Z

no, because clj-kondo flycheck doesn't add the linter name in the square brackets

ericdallo 2021-03-05T15:00:22.471600Z

I see

borkdude 2021-03-05T15:00:46.471800Z

Meeting now, I'll check later

πŸ‘ 1
orestis 2021-03-05T19:46:52.472800Z

No worries, I'm doing some digging myself

orestis 2021-03-05T19:47:20.473Z

Seems like the NeoVim lsp client isn't as mature as I hoped. Still works but quite a lot of capabilities missing...

ericdallo 2021-03-05T20:00:10.473200Z

What do you use on vim @dharrigan?

dharrigan 2021-03-05T20:51:12.473400Z

CoC

dharrigan 2021-03-05T20:51:19.473600Z

Plug 'neoclide/coc.nvim', {'branch': 'release'}

πŸ‘ 1
ericdallo 2021-03-05T20:53:39.473900Z

Yeah, it's not the first time that I heard that Neovim has some issues

ericdallo 2021-03-05T22:56:17.475100Z

We reached 200 people on this channel πŸŽ‰

5
❀️ 2
πŸ…ΎοΈ 3
πŸŽ‰ 11
2️⃣ 3
0️⃣ 3
emilaasa 2021-03-06T18:00:06.479900Z

Probably going conjure + lsp over cursive for work now.

πŸŽ‰ 1
ericdallo 2021-03-05T22:56:49.475200Z

thanks @jcsims you can claim you prize installing https://clojure-lsp.github.io/clojure-lsp/installation/ πŸ˜›

jcsims 2021-03-05T23:00:37.475500Z

done :awesome:

jcsims 2021-03-05T23:01:20.475700Z

I came back to it recently (had used just cider previously, and cursive for a bit), and was really impressed!

1
πŸ˜‰ 1