lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
2021-03-04T09:57:29.416800Z

has anyone here found that clojure-lsp / lsp-mode in emacs significantly slows down slurping and barfing expressions with smartparens?

borkdude 2021-03-04T09:59:07.417500Z

@rickmoynihan This can be related to

company-idle-delay 0.5
If you set that to 0 things slowed down for me

2021-03-04T10:01:18.418Z

@borkdude what do you have it to set to?

borkdude 2021-03-04T10:01:56.418200Z

0.5

borkdude 2021-03-04T10:02:20.418600Z

Also update to the newest, there might have been some improvements around this

2021-03-04T10:06:41.419Z

ahh great upgrading seems to have made a big difference!

2021-03-04T10:06:45.419200Z

thanks! ๐Ÿ™‡

2021-03-04T10:12:52.419600Z

ah it could also be that lsp-mode is no longer connecting hmmmm

2021-03-04T10:26:33.420Z

anyone here know how to debug lsp not connecting anymore after an upgrade?!

2021-03-04T10:27:09.420700Z

Running

$ clojure-lsp
{}
appears to error like troubleshooting says it should

2021-03-04T10:27:47.421300Z

however nothing appears in the log

ericdallo 2021-03-04T11:47:17.421900Z

@rickmoynihan the troubleshooting should be self explanatory otherwise we can improve it, but if the executable is working we need to understand why it's crashsing

ericdallo 2021-03-04T11:47:50.422100Z

check the *clojure-lsp-stderr* buffer if has any thing relevant

ericdallo 2021-03-04T11:47:57.422300Z

otherwise we need to check the log

ericdallo 2021-03-04T11:48:17.422500Z

usually it's on /tmp/clojure-lsp.*.out

2021-03-04T11:48:36.422700Z

Yeah I went through the troubleshooting section but nothing seemed to help

2021-03-04T11:48:45.422900Z

the emacs buffers for logs etc didnโ€™t seem to exist either

ericdallo 2021-03-04T11:49:00.423200Z

what is the error you receive on emacs?

2021-03-04T11:49:54.423400Z

no visible error โ€” just LSP[Disconnected] in the mode line

2021-03-04T11:50:15.423700Z

and no lsp features

ericdallo 2021-03-04T11:50:28.423900Z

what happens when you M-x lsp

2021-03-04T11:50:53.424100Z

aha! lsp--path-to-uri: Symbol's function definition is void: -compose

2021-03-04T11:51:32.424300Z

(I was running M-x lsp-mode)

ericdallo 2021-03-04T11:51:46.424500Z

https://github.com/emacs-lsp/lsp-mode/issues/2615

ericdallo 2021-03-04T11:51:58.424800Z

TLDR update your dash.el package and everything should work

2021-03-04T11:54:28.425Z

ok that seems to work

2021-03-04T11:54:36.425200Z

thanks a million! ๐Ÿ™‡

ericdallo 2021-03-04T11:56:54.425400Z

You're welcome ๐Ÿ˜‰

2021-03-04T11:57:40.425600Z

hmm now get apply: Cannot open load file: No such file or directory, lsp-ui

ericdallo 2021-03-04T11:58:09.425800Z

I suggest you re install your packages

2021-03-04T11:58:26.426Z

Thatโ€™s what got me here ๐Ÿ˜†

2021-03-04T11:58:33.426200Z

but yeah Iโ€™ll try reinstall againโ€ฆ

2021-03-04T12:01:42.426400Z

ok seems to be working

2021-03-04T12:01:45.426600Z

๐Ÿ™‡

1
orestis 2021-03-04T12:14:50.426900Z

Hi, I think https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/feature/file_management.clj#L119 might be the piece of code in charge, it expects a range of changed characters. I will see if I can get LSP running locally so that I can confirm and submit a PR, it might be tomorrow though.

ericdallo 2021-03-04T12:16:08.427200Z

Yes, it is, that was changed recently, probably we are having some race condition on there, we need to check how vim is sending the didChange texts

orestis 2021-03-04T14:32:48.427400Z

I think the issue might be simpler: NeoVim doesn't send a start/range at all because it's sending the entire text. So replace-text is getting nil values in line, col, end-line, end-coland throws the NPE

ericdallo 2021-03-04T14:33:48.427600Z

It could be indeed, but even so I think it should send the position according to the LSP spec

orestis 2021-03-04T14:34:16.427800Z

I did a small POC locally and indeed it throws an NPE, and of course the fix is trivial -- I will try tomorrow to run LSP locally so I can verify that this is indeed happening and add a test.

orestis 2021-03-04T14:35:24.428Z

/**
 * An event describing a change to a text document. If range and rangeLength are
 * omitted the new text is considered to be the full content of the document.
 */

orestis 2021-03-04T14:35:26.428200Z

from the spec

orestis 2021-03-04T14:38:03.428400Z

Seems like a NeoVim bug though.

ericdallo 2021-03-04T14:38:57.428600Z

Oh, missed that, cool ๐Ÿ™‚

orestis 2021-03-04T14:40:00.428800Z

The client should respect the incremental sync but it seems like it doesn't... but I guess that yeah supporting that on the server is easy enough...

orestis 2021-03-04T14:40:02.429Z

Thanks!

ericdallo 2021-03-04T14:41:21.429200Z

yes, probably handling the didChange as full text when the range is not present seems a valid approach

devn 2021-03-04T17:38:14.430100Z

recently updated lsp, and it seems like unused vars no longer highlight, but if i do a lsp-lens-show i can see it has 0 references

devn 2021-03-04T17:38:28.430600Z

am i missing something config-wise?

ericdallo 2021-03-04T17:39:29.430900Z

We didn't change anything related to that, check this section to see if it works for you: https://clojure-lsp.github.io/clojure-lsp/troubleshooting/#wrong-diagnosticslint

devn 2021-03-04T17:53:33.431300Z

hm, no diceโ€ฆ :thinking_face:

devn 2021-03-04T18:03:49.431500Z

pretty sure this is just me misunderstanding how the unused checking works

devn 2021-03-04T18:05:01.431700Z

clj-kondo will look for private unused vars, and this wasnโ€™t a private var. unfortunately whoever wrote the code im working on was not very judicious in their application of adding private metadata

ericdallo 2021-03-04T18:06:12.431900Z

I don't get it the error, do you have a small sample?

devn 2021-03-04T18:23:56.432100Z

sure,

(ns foo)
(defn bar [])
(defn- baz [])

ericdallo 2021-03-04T18:24:29.432300Z

So clj-kondo should report only the unused private function baz, right?

devn 2021-03-04T18:24:36.432500Z

yes

devn 2021-03-04T18:24:47.432700Z

but i could swear globally unused publics highlighted awhile back

devn 2021-03-04T18:24:54.432900Z

i may be mistaken

ericdallo 2021-03-04T18:25:12.433100Z

oh yeah

ericdallo 2021-03-04T18:25:26.433300Z

we used to have those for public functions before clj-kondo integration (2020 december)

devn 2021-03-04T18:33:52.433500Z

i guess i understand why itโ€™s not a clj-kondo thing, but it is useful when removing dead code

devn 2021-03-04T18:34:35.433700Z

for instance, of course you donโ€™t want your public API fns highlighted, but then again, i would assume those have a testโ€ฆ

1๐Ÿ‘
ericdallo 2021-03-04T18:34:47.433900Z

yeah, for sure, it's something we lost when using clj-kondo, but I think we could implement it

ericdallo 2021-03-04T18:34:53.434100Z

need some hammock time though how to do it

orestis 2021-03-04T19:14:34.434400Z

https://github.com/clojure-lsp/clojure-lsp/pull/357

ericdallo 2021-03-04T19:20:49.434700Z

Thanks! I added some suggestions, looks good though

orestis 2021-03-04T19:27:17.434900Z

Thanks for the suggestions, they look obvious in retrospect ๐Ÿ™‚

1๐Ÿ˜…
orestis 2021-03-04T19:28:07.435200Z

If you could capture somewhere the format that the emacs lsp client sends the changes I might be able to provide a test that covers both cases... But not tonight.

orestis 2021-03-04T19:29:17.435400Z

Any more action needed on my part? I think testing on Emacs is the blocker here. I've setup NeoVim to run my local fork of clojure-lsp so if something like this comes up again it'll be easy to validate.

ericdallo 2021-03-04T19:31:14.435600Z

Sure, for a range this is a sample:

(ns foo)

(let [a 1
      b 2]
  (+ a b))
[Trace - 04:30:39 PM] Sending notification 'textDocument/didChange'.
Params: {
  "textDocument": {
    "uri": "file:///home/greg/dev/nu/zakarum/postman/integration/aux/init.clj",
    "version": 55
  },
  "contentChanges": [
    {
      "range": {
        "start": {
          "line": 4,
          "character": 7
        },
        "end": {
          "line": 4,
          "character": 8
        }
      },
      "rangeLength": 1,
      "text": "c"
    }
  ]
}
changing it to
(ns foo)

(let [a 1
      b 2]
  (+ a c))

ericdallo 2021-03-04T19:32:03.435900Z

I can test manually the PR tonight (couple of hours), if everything ok, I can merge it

1๐Ÿ‘
ericdallo 2021-03-04T21:20:58.436500Z

@borkdude lsp already supports info lint, green color

borkdude 2021-03-04T21:21:26.436700Z

nice. how does it do the local highlighting?

ericdallo 2021-03-04T21:21:30.436900Z

But I think we don't use on clojure-lsp for any feature

ericdallo 2021-03-04T21:21:41.437100Z

the local highlighting is a custom thing for highlighting on lsp-mode side

borkdude 2021-03-04T21:21:54.437300Z

ok, we could do an info-level "warning" maybe

borkdude 2021-03-04T21:22:08.437500Z

enable it by default, and if people complain offer a way to disable it

ericdallo 2021-03-04T21:22:11.437700Z

yes, I think it's the best option

devn 2021-03-04T21:23:22.437900Z

continuing the convo from #clj-kondo: eh, iโ€™m not 100% sure on highlight v warn. iโ€™ll say iโ€™m biased because i was used to a warning-like indicator in the old clojure-lsp. I think lens is neat, but where I found the previous underline helpful was when i was cruising around in a file and it was like โ€œoh look, someone left some dead code hereโ€ฆโ€

ericdallo 2021-03-04T21:23:58.438100Z

the info lint is just like the warn lint but green not yellow

devn 2021-03-04T21:24:17.438300Z

oh, that sounds great

ericdallo 2021-03-04T21:25:42.438500Z

https://github.com/clojure-lsp/clojure-lsp/issues/359

devn 2021-03-04T21:26:26.438800Z

yay! big thanks!

1๐Ÿ˜ƒ
borkdude 2021-03-04T21:28:26.439100Z

maybe a better name {:unused-public-var {:level :info}}

borkdude 2021-03-04T21:28:41.439300Z

so you can add more stuff to it and also :exclude stuff

borkdude 2021-03-04T21:28:52.439500Z

maybe using a regex, namespace, fully qualified var

ericdallo 2021-03-04T21:28:59.439700Z

yeah, that looks perfect ๐Ÿ™‚

ericdallo 2021-03-04T21:29:23.439900Z

I think I saw that pattern somewhere ๐Ÿ˜›

borkdude 2021-03-04T21:29:33.440100Z

;)

borkdude 2021-03-04T21:29:52.440300Z

carve has a .carve/ignore file: https://github.com/borkdude/carve so you can interactively add it to the list of ignored vars

ericdallo 2021-03-04T22:15:03.440700Z

@devn ๐Ÿ™‚

1๐Ÿ‘
borkdude 2021-03-04T22:15:43.441100Z

I would put "var" instead of "variable", that is the proper name or clojure vars

2๐Ÿ‘
borkdude 2021-03-04T22:15:58.441300Z

but looks nice!

1