Fork me on GitHub
#lsp
<
2021-07-21
>
donavan11:07:00

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 ...)

donavan11:07:53

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

borkdude12:07:31

@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

ericdallo12:07:14

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

ericdallo12:07:29

That could affect performance on that part of the code

ericdallo12:07:43

We only have kondo analysis at that time

ericdallo12:07:15

Parsing the document with rewrite would increase the processing time considerably

borkdude12:07:17

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

ericdallo12:07:44

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

borkdude12:07:37

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

borkdude13:07:20

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

ericdallo13:07:53

looks good! thanks for that!

ericdallo13:07:39

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 😂

borkdude13:07:25

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

borkdude13:07:36

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

ericdallo13:07:00

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

👍 2
donavan15:07:33

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

👍 2
Noah Bogart14:07:58

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

ericdallo14:07:42

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

👍 2
ericdallo14:07:51

Like call hierarchy

ericdallo14:07:11

There are some missing ones like rename folder, linkedEditting

ericdallo14:07:25

But most of them doesn't affect clojure that much

Noah Bogart14:07:16

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

Noah Bogart14:07:28

thanks so much

ericdallo14:07:19

> 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

Pratik17:07:41

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?

ericdallo17:07:12

Not sure how Calva handle calls it c/c @U9A1RLFNV

ericdallo17:07:24

but the correct LSP method for that is Organize Imports

ericdallo17:07:36

or the command clean-ns

ericdallo17:07:28

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

ericdallo17:07:55

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

ericdallo17:07:07

does the linter shows as unused vars?

Pratik17:07:07

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

ericdallo17:07:22

so probably a bad scanned project

Pratik17:07:26

I’ll try removing .lsp/sqlite.db

Pratik17:07:08

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

ericdallo17:07:38

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

ericdallo17:07:50

try removing .clj-kondo/.cache

ericdallo17:07:54

and restart again

Pratik17:07:35

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

ericdallo17:07:41

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

Pratik17:07:15

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

ericdallo17:07:02

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

ericdallo17:07:09

Can you check clojure-lsp logs?

Pratik17:07:52

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

Pratik17:07:49

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

👍 4
Pratik16:07:51

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.

ericdallo16:07:43

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

ericdallo16:07:21

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

ericdallo16:07:31

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

Pratik16:07:29

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

Drew Verlee19:07:44

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?

ericdallo19:07:24

I think so 😅

ericdallo19:07:08

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

ericdallo19:07:53

seems to be starting

ericdallo19:07:59

check clojure-lsp log

Drew Verlee19:07:13

the log is what i posed above.

ericdallo19:07:38

I meant the server log

Drew Verlee19:07:39

the tmp file, ok

Drew Verlee19:07:48

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..

Drew Verlee19:07:48

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

ericdallo19:07:20

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

Drew Verlee19:07:26

i guess i hadn't started it yet.

ericdallo19:07:39

that nrepl has nothing related with cider nrepl

ericdallo19:07:52

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

ericdallo19:07:56

anything more on log?

Drew Verlee19:07:38

there is nothing else.

ericdallo19:07:00

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

Drew Verlee19:07:39

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?

Drew Verlee20:07:57

➜  Personal lsp
zsh: command not found: lsp

Drew Verlee20:07:24

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

ericdallo20:07:29

oh I meant lsp emacs command

ericdallo20:07:14

it seems that there is a loop during start

Proctor19:07:20

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

ericdallo19:07:34

what do you mean with comment code ability?

ericdallo19:07:05

I think you mean comment manipulation in your editor?

ericdallo19:07:29

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

ericdallo19:07:34

What editor are you using?

Proctor19:07:37

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

Proctor19:07:18

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

ericdallo19:07:29

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

Proctor19:07:33

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

ericdallo19:07:55

maybe ask on #vim?

Proctor19:07:33

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

Proctor19:07:43

thank you for your quick response!