@ericdallo you rule!
Tomorrow morning I'll release it π
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
@jr0cket FWIW I'm still using clj-kondo flycheck and have disabled lsp diagnostics, but this is because I'm also developing clj-kondo
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 π
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
Hmm, I only want to disable the clj-kondo diagnostics, not the other ones
Can this be configured?
at the lsp server side
No, this is a lsp-mode setting, not sure it makes sense to to add this kind of logic to the server
Also, not sure you could have both lsp and clj-kondo flycheck enable at the same time
Why is it not possible to say at the server side: filter these diagnostics for me, before sending them over to the client.
using the .lsp/config.edn
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
This would also make it possible to not depend on any client side emacs config, but this would solve it for all clients
I think we can test it
Something like :linters :clj-kondo :level :off
I think it would make sense to push more logic to the server than leave it on the client side
More uniform config
{:features {:clj-kondo {:disabled true}}
or rather linting
{:disable-features #{:clj-kondo-linting}}
or something
you would still get the analysis but not the warnings
and I would like to opt in to the add-on linters that lsp provides based on the project-wide analysis
That's why I added to the :linters config block
I think it's easier and follow the same pattern
oh right
sorry, I missed that
Np
I can check this soon
Amazing
@ericdallo To be honest, I think the lens-mode is sufficient for me for showing unused vars
it's pretty much the same as an info-lint warning to me personally
Ok, I'll release the new feature without this, we can see if that flag would be really necessary then
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.
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.
ooooh it's the way I start the process. Never mind.
@devn @ericdallo About automatically inferring deps from a random script: https://github.com/babashka/babashka/issues/733#issuecomment-791314599
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?
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
I'm not suggesting you use this right now, it first needs some polishing
but maybe the approach could work
The same approach could also work for people who make use of add-lib (dynamically adding libs to the classpath)
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
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
@ericdallo The idea of deps-infer is that it is agnostic about your project tools, it only looks at source
So you can infer deps from code that doesn't have a deps.edn, project.clj, etc, that is the idea
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?
of that file only, it ignores the deps.edn
I see, so we would't be able to replace all clojure-lsp logic to only use deps infer
nope
Maybe this can be first used to update your existing deps.edn or to create one which lsp can then pick up on
as a first experimentation
: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.
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.
we have this on emacs, it's called lsp-mode file watchers
but it works well
I mean, neovim is asking clojure-lsp to do something and clojure-lsp reports back that it lacks the capability.
Things seem to work without it, apparently, so perhaps neovim can also do client-side watching?
yes
like lsp-mode
Would you be interested in doing this watching also server-side?
Need to check the spec but AFAIK this should be handled on client side
@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?
Yes, it should work
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)hmm
It seems I'm still getting linting from lsp...
isn't that your clj-kondo flycheck check?
Just to make things simple, test it with your local project .lsp/config.edn
if it works, probably it's some config merge issue
no, because clj-kondo flycheck doesn't add the linter name in the square brackets
I see
Meeting now, I'll check later
No worries, I'm doing some digging myself
Seems like the NeoVim lsp client isn't as mature as I hoped. Still works but quite a lot of capabilities missing...
What do you use on vim @dharrigan?
CoC
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Yeah, it's not the first time that I heard that Neovim has some issues
We reached 200 people on this channel π
Probably going conjure + lsp over cursive for work now.
thanks @jcsims you can claim you prize installing https://clojure-lsp.github.io/clojure-lsp/installation/ π
done :awesome:
I came back to it recently (had used just cider previously, and cursive for a bit), and was really impressed!