lsp 2021-07-21

Is it possible to use clj-kondo style ignore forms with lsp linters like so:

#_{:clj-lsp/ignore [:unused-public-var]}
(def some-api-var ...)

… I mean besides doing in config… I’d rather the ignore and code was in the same place

@donavan There is an open issue for this in clojure-lsp. We're going to implement #_:linter/ignore on both sides so you can just use one annotation for both tools

Actually I realized this would not be that easy on clojure-lsp :/

That could affect performance on that part of the code

We only have kondo analysis at that time

Parsing the document with rewrite would increase the processing time considerably

@ericdallo what about trying to port this linter to clj-kondo and trying to support all linting in clj-kondo in the future? I'm open to this, but it may take some time

Yes, IMO that would be the best but not sure what is required on clj-kondo side for that, like know the project root, the source paths etc

What would be needed is 1) lint clj-kondo with a set of code of which you know that is the entire project, perhaps with a --project flag or so 2) clj-kondo can then save a bucket of all public var usages or something 3) this bucket gets updated each time you lint a new file (or files) so the public var linter can read from this bucket each time and know it has a "whole project" knowledge of this

Made an issue here: https://github.com/clj-kondo/clj-kondo/issues/1321 I think it's about time that clj-kondo supported these project-wide linters

looks good! thanks for that!

I'd love to open an PR, but not sure if that is too much for what I know how to code in clj-kondo 😂

we could implement it in tiny steps at a time perhaps in a branch

I'm curious to know how you implemented it, the bucket, let's say

clojure-lsp has a atom with all analysis, clojure-lsp just query for all var-definitions of that file that doesn't have a reference, each time a file is changed or something, it has not a bad performance, but certainly on clj-kondo would be way better

👍 1

Awesome, sounds like you guys have this under control! Thanks both 🙂 … I’ll just use the global config for now.

👍 1

how do i know which LSP spec version does clojure-lsp use?

There is no such official way, clojure-lsp implement most 3.16 important features already

👍 1

Like call hierarchy

There are some missing ones like rename folder, linkedEditting

But most of them doesn't affect clojure that much

i’m reading through the lsp4j code (which is wild, lol, i’m not a big fan of xtend), and am trying to follow how the signature help stuff works

> i’m not a big fan of xtend neither I hehe I needed to open PR adding support for call hierarchy there and it was not cool haha

In VSCode IDE, when I run the clean NS Form command, it just sorts the namespace but it’s not removing the unused namespaces as shown here - https://clojure-lsp.github.io/clojure-lsp/features/#clean-namespace. Does it require any configurations from VSCode or is it an issue?

just to update, I have tried to reproduce it in a new project and it works as intended. So, it’s a problem with my work project settings, mostly clj-kondo settings as it’s not highlighting unused namespaces. Will try to figure that out. Thanks for the quick response.

good, not necessary clj-kondo issue, but misconfigured clojure-lsp settings

probably clojure-lsp is not being able to scan your project classpath via lein classpath or clj -Spath depending on your project

that's why we'd know checking the server log

sorry can you point me at the doc where I can see how to check the server logs?

Not sure how Calva handle calls it c/c @brandon.ringe

but the correct LSP method for that is Organize Imports

or the command clean-ns

oh, maybe you are calling it correctly, it is just not removing because of a wrong analyzed project?

maybe try remoing .lsp/sqlite.db , restarting vscode and checking if shows as unused

does the linter shows as unused vars?

no, linter is not showing that but if I find in a file there is no use of that namespace

so probably a bad scanned project

I’ll try removing .lsp/sqlite.db

checked, it’s still not removing unused namespaces after restarting vscode

it will not remove if the linter doesn't report any unused, so we need to fix that first

try removing .clj-kondo/.cache

and restart again

by linter, do you mean any specific linter or whatever is shipped by Calva?

shipped in Calva, which is clojure-lsp (that uses clj-kondo to get the lint)

hmm, so I added [clojure.set :as sset] which got a Unsorted namespace linter error, and clean NS sorted it but didn’t removed it

it should remove indeed, probably your project is not being correctly analyzed

Can you check clojure-lsp logs?

sure, I’ll have to refer docs on how to do that

will let you know tomorrow, will also try to reproduce it outside my project

👍 2

Given this output from my lsp-log emacs buffer

Found the following clients for /home/drewverlee/tomatto/backend/deps.edn: (server-id clojure-lsp, priority 0)
The following clients were selected based on priority: (server-id clojure-lsp, priority 0)
Found the following clients for /home/drewverlee/tomatto/frontend/src/main/tomatto/frontend/app.cljs: (server-id clojure-lsp, priority 0)
The following clients were selected based on priority: (server-id clojure-lsp, priority 0)
I assume lsp mode is able to find the binary, can someone confirm my understanding?

I think so 😅

you can configure that manually with lsp-clojure-server-command '("bash" "-c" "/path/to/clojure-lsp/binary") as well

seems to be starting

check clojure-lsp log

the log is what i posed above.

I meant the server log

the tmp file, ok

2021-07-21T19:34:09.044Z drewverlee INFO [clojure-lsp.main:386] - Starting server... 2021-07-21T19:34:09.047Z drewverlee DEBUG [clojure-lsp.nrepl:24] - nrepl not found, skipping nrepl server start..

hmm i'm starting nrepl in the normal way, via cider-jack-in-cljs

that is a debug log, just for debugging purposes, not related with your issue

i guess i hadn't started it yet.

that nrepl has nothing related with cider nrepl

it's used for debugging purposes on clojure-lsp side only

anything more on log?

there is nothing else.

odd, what is your clojure-lsp --version ?

backing up, it's telling me that "the connected server(s) doesn't support renaming". If i try to "lsp-find usage" i get "the connected servers does not support method textDocument/defination. and prompts for lsp-describe-session which outputs... nothing in messages buffer at least. Or at the bottom of the screen. clojure-lsp from emacs gives :LSP lsp-mode <tel:202107151320|20210715.1320>, Emacs 27.2, gnu/linux I don't have clojure-lsp aliased so i can check on the command line. I forget how i installed it, i guess i'm currently thinking it was part of a spacmacs layer. Or it seems i probably ran "lsp-install-server" as that option doesn't list clojure so i assume its already insatlled?

➜  Personal lsp
zsh: command not found: lsp

LSP Connected to [clojure-lsp:155532/starting].

oh I meant lsp emacs command

it seems that there is a loop during start

Not seeing it on the Clojure-LSP site, but is there a comment code/form/selection ability?

what do you mean with comment code ability?

I think you mean comment manipulation in your editor?

if so, it's not related with LSP, this belong to the editor/plugin you are using

What editor are you using?

wasn’t sure if there was a take this form and #_ it or something

know there were plugins, but wasn’t sure if that was a thing with Clojure-LSP

I don't use vim, but I bet there is some plugin or something else to manipulate those comments

figured I would use that vs going and adding a plugin if supported… 😉

maybe ask on #vim?

yeah, just wanted to make sure there was no code-action or something else already supported with the Clojure specific forms..

thank you for your quick response!