Fork me on GitHub
#lsp
<
2021-03-05
>
practicalli-johnny06:03:09

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

borkdude09:03:45

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

practicalli-johnny10:03:19

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 πŸ™‚

ericdallo10:03:29

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

borkdude11:03:25

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

borkdude11:03:35

Can this be configured?

borkdude11:03:42

at the lsp server side

ericdallo11:03:13

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

ericdallo11:03:50

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

borkdude11:03:40

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

borkdude11:03:50

using the .lsp/config.edn

ericdallo11:03:12

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

borkdude11:03:24

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

ericdallo11:03:33

I think we can test it

ericdallo11:03:01

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

borkdude11:03:12

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

borkdude11:03:16

More uniform config

borkdude11:03:45

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

borkdude11:03:55

or rather linting

borkdude11:03:15

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

borkdude11:03:27

you would still get the analysis but not the warnings

borkdude11:03:38

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

ericdallo11:03:59

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

ericdallo11:03:13

I think it's easier and follow the same pattern

borkdude11:03:19

sorry, I missed that

ericdallo11:03:29

I can check this soon

borkdude12:03:06

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

borkdude12:03:45

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

ericdallo12:03:28

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

orestis09:03:54

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.

orestis09:03:14

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.

orestis09:03:11

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

πŸ‘ 3
ericdallo12:03:44

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?

borkdude12:03:37

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

borkdude12:03:56

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

borkdude12:03:03

but maybe the approach could work

borkdude12:03:53

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

ericdallo12:03:10

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

ericdallo12:03:40

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

borkdude12:03:28

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

borkdude12:03:02

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

ericdallo12:03:13

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?

borkdude12:03:44

of that file only, it ignores the deps.edn

ericdallo12:03:57

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

borkdude12:03:17

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

borkdude12:03:28

as a first experimentation

ericdallo14:03:01

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.

πŸ’― 9
catjam 3
orestis14:03:07

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.

ericdallo14:03:49

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

ericdallo14:03:02

but it works well

orestis14:03:53

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

orestis14:03:26

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

ericdallo14:03:47

like lsp-mode

orestis14:03:10

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

ericdallo14:03:02

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

orestis19:03:52

No worries, I'm doing some digging myself

orestis19:03:20

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

ericdallo20:03:10

What do you use on vim @U11EL3P9U?

dharrigan20:03:19

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

πŸ‘ 3
ericdallo20:03:39

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

borkdude14:03:06

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

ericdallo14:03:57

Yes, it should work

borkdude14:03:52

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)

borkdude14:03:03

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

ericdallo14:03:24

isn't that your clj-kondo flycheck check?

ericdallo14:03:18

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

ericdallo14:03:36

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

borkdude15:03:01

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

borkdude15:03:46

Meeting now, I'll check later

πŸ‘ 3
ericdallo22:03:17

We reached 200 people on this channel πŸŽ‰

πŸŽ‰ 33
catjam 15
2️⃣ 9
0️⃣ 9
πŸ…ΎοΈ 9
❀️ 6
jcsims23:03:20

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

clojure-lsp 3
πŸ˜‰ 3
devn01:03:18

well-deserved!

devn01:03:52

a testament to all of your hard work recently.

ericdallo01:03:05

Thanks ❀️

emilaasa18:03:06

Probably going conjure + lsp over cursive for work now.

πŸŽ‰ 3