lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
dpsutton 2021-03-15T16:11:24.078300Z

things got a bit out of sync when i added a require to a namespace. is there a way to have lsp reparse the current file? I had to resort to restarting the workspace

borkdude 2021-03-15T16:15:09.078700Z

@dpsutton Making an edit in the relevant files will have the same effect probably

dpsutton 2021-03-15T16:16:09.079800Z

yeah. i edited and saved and it didn't like the state it ended up in. My evidence for that is the highlighting of words under point was nonsensical. Like it would highlight the third and fourth letters of a function and didn't recognize the other call sites

dpsutton 2021-03-15T16:16:29.080300Z

restarted the workspace and it got it right, highlighting the entire token and highlighting the other usages of the same

snoe 2021-03-15T16:39:19.084700Z

Yeah I've seen this too recently. I'm pretty suspicious of using this partial changes api @ericdallo https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/feature/file_management.clj#L107 I think there's a lot that can go wrong there.

borkdude 2021-03-15T16:40:13.085300Z

it sure is hard to get it right and since ericdallo didn't mention my name in that commit, I take no responsibility for it :P

borkdude 2021-03-15T16:40:29.085600Z

maybe it should be under an experimental flag in the config

snoe 2021-03-15T16:41:17.086300Z

i think so, I'd rather aim for stability by default and sacrifice speed of edge cases.

borkdude 2021-03-15T16:41:24.086500Z

agreed

dpsutton 2021-03-15T16:52:02.087200Z

is there a way to reanalyze current file? kinda just kick clojure-lsp? Or is the best workaround at the moment to restart the workspace?

borkdude 2021-03-15T16:53:03.087600Z

the current file should be re-analyzed on every edit, I think?

borkdude 2021-03-15T16:53:33.088Z

but it could be related to the problem discussed above with partial snippets that are sent over the wire

borkdude 2021-03-15T16:53:54.088500Z

if you edit files outside of your lsp environment, those edits might not be seen by lsp?

ericdallo 2021-03-15T16:54:47.089Z

@dpsutton kill the file buffer and reopen should fix it for now

dpsutton 2021-03-15T16:55:12.090Z

that makes sense. thanks @ericdallo

ericdallo 2021-03-15T16:55:17.090400Z

re-editing should not fix since if one edit go out of sync, all other probably will go wrong too

orestis 2021-03-15T16:55:27.090900Z

@snoe it was handling ranges for a long time, the change was to add full text support.

ericdallo 2021-03-15T16:55:47.091600Z

I could not reproduce the edit sync error, if you have a repro we could improve that

orestis 2021-03-15T16:56:05.092700Z

The neovim client is always sending the whole text. Perhaps the Emacs client could be configured to do the same?

borkdude 2021-03-15T16:56:08.092900Z

I think it might happen if you git pull some changes ?

ericdallo 2021-03-15T16:56:24.093600Z

@orestis actually we used to use the full text since the beginning, I changed recently with the help of @borkdude to use the range edit changes

borkdude 2021-03-15T16:56:40.094300Z

no no, I have nothing to do with it :P

snoe 2021-03-15T16:56:44.094500Z

there's a capabilities negotiation so the server can tell lsp-mode it only support full-text afaik

ericdallo 2021-03-15T16:56:45.094600Z

but it seems there is some corner cases that the doc goes out of sync

ericdallo 2021-03-15T16:56:58.094900Z

yes, but lsp-mode support both full and range edits

ericdallo 2021-03-15T16:57:29.096Z

full-text edit can end in a a really poor performance on large buffers

borkdude 2021-03-15T16:57:30.096100Z

@ericdallo I suggested above to make this feature experimental and opt-in using a flag in the .lsp/config.edn - thoughts?

ericdallo 2021-03-15T16:57:57.096600Z

yes, we could go this way, but that will probably make it hard to get the corner cases

ericdallo 2021-03-15T16:58:54.097700Z

Not sure if we should try to find the issue and fix it, We are already using it and it works for most cases (I use it daily and could not repro the out of sync issue yet)

ericdallo 2021-03-15T17:00:50.098900Z

the incremental didChanges increased the performance on medium/large buffers a lot, I think we should try to make that happen

borkdude 2021-03-15T17:01:15.099300Z

Wasn't that performance issue only manifesting when you had some delay set to 0?

ericdallo 2021-03-15T17:03:07.100900Z

That made the performance worst because of a lsp-mode limitation with completion, but besides that, with this feature, every change you do in a big buffer is more smooth

borkdude 2021-03-15T17:04:43.101300Z

ok

snoe 2021-03-15T18:50:04.108600Z

https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/feature/file_management.clj#L136 this seems suspicious - there's no check here that the current version is older than what's being applied and I can't reason through the async nature of analyze-changes but I would be surprised if there's no issue there. And I think debouncing with a change api is big no-no

ericdallo 2021-03-15T18:53:11.108800Z

the debouncing help us now call clj-kondo on every change if user input a lot of characters

ericdallo 2021-03-15T18:53:28.109Z

and AFAIK they come in a fixied order from client

ericdallo 2021-03-15T18:53:49.109200Z

you can try input multiple 1 s in a single line in a buffer to repro that

dpsutton 2021-03-15T19:05:53.109400Z

if you type "abc" does it coalesce all of the changes into "abc" or is it possible you'd see "ab" and then "c"?

ericdallo 2021-03-15T19:07:47.109600Z

it should join all changes to abc correctly with my tests, maybe is some specific corner case

ericdallo 2021-03-15T19:12:21.109800Z

my tests I inputed dozens of characters to check if any race condition could cause trouble, and everyting worked great

ericdallo 2021-03-15T19:12:49.110Z

I suspect you fell into some specific corner case

rafaeldelboni 2021-03-15T20:23:52.111100Z

Hey I dunno if is related to the issues being discussed today, but I'm getting a strange crash error after I updated today ๐Ÿงต

rafaeldelboni 2021-03-16T20:08:54.011500Z

Just a followup, using the previous version all is working fine here.

ericdallo 2021-03-16T20:09:33.011700Z

@rafaeldelboni I'll release a new version tonight rollingback the incremental text changes until we fix it, maybe it should fix your issue

๐ŸŽ‰ 1
ericdallo 2021-03-16T20:55:06.015400Z

@rafaeldelboni could you try latest release? https://clojurians.slack.com/archives/CPABC1H61/p1615928058014500

rafaeldelboni 2021-03-17T13:30:25.018200Z

Just installed this one right?

clojure-lsp 2021.03.16-20.28.06
clj-kondo 2021.03.03

๐Ÿ‘ 1
rafaeldelboni 2021-03-17T13:30:38.018400Z

I will use it today and report here

rafaeldelboni 2021-03-17T13:30:39.018600Z

thanks

rafaeldelboni 2021-03-17T22:02:25.018900Z

I worked all day with the new version and zero problems thanks

ericdallo 2021-03-17T22:02:36.019100Z

Glad to hear ๐Ÿ™‚

rafaeldelboni 2021-03-15T20:25:56.111200Z

After using a little bit the server crashes all functionalities stop working I need to force a lsp server restart.

ericdallo 2021-03-15T20:43:01.111600Z

It seems to be a issue indeed, do you have a code repro of when this exception happens?

rafaeldelboni 2021-03-15T20:44:32.111800Z

It happens randomly I was in a fixture test file with a lot of defs

ericdallo 2021-03-15T20:45:18.112Z

:thinking-face:

rafaeldelboni 2021-03-15T20:45:36.112200Z

Just editing the file and saving

rafaeldelboni 2021-03-15T20:46:48.112400Z

I just caused a random typo error and now the server crashed with this error: [1;31mjava.lang.Exception[m: [3mUnexpected EOF. [at line 53, column 1][m

ericdallo 2021-03-15T20:47:17.112600Z

the issue happens during the parse of a clj-kondo lint findings, but I still not sure when it happens

ericdallo 2021-03-15T20:47:27.112800Z

a minimal repro would help a lot

ericdallo 2021-03-15T20:49:39.113Z

do you have the piece of code that caused the crash? including the typo

borkdude 2021-03-15T20:50:15.113200Z

also moving config aside .clj-kondo and .lsp/config.edn could help diagnose

rafaeldelboni 2021-03-15T20:50:28.113400Z

Just created a file and started typing random code and this error happened

ericdallo 2021-03-15T20:53:25.114Z

Odd, I can't reproduce it, I'll keep trying to understand it

ericdallo 2021-03-15T20:53:51.114200Z

what's you clojure-lsp --version ?

rafaeldelboni 2021-03-15T20:54:13.114400Z

clojure-lsp 2021.03.14-23.22.46
clj-kondo 2021.03.03

rafaeldelboni 2021-03-15T20:55:16.114600Z

oh wait maybe is my java version

rafaeldelboni 2021-03-15T20:55:29.114800Z

openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment (build 11.0.10+9)
OpenJDK 64-Bit Server VM (build 11.0.10+9, mixed mode)

ericdallo 2021-03-15T20:55:39.115Z

how did you install clojure-lsp?

rafaeldelboni 2021-03-15T20:55:45.115200Z

arch aur

ericdallo 2021-03-15T20:55:48.115400Z

the native versions don't depend on java

ericdallo 2021-03-15T20:56:09.115700Z

I don't think it's a related to java

borkdude 2021-03-15T20:56:32.115900Z

did you try to move your configs aside?

ericdallo 2021-03-15T20:58:19.116100Z

BTW the exception from the first log is different from the next log ๐Ÿคฏ

rafaeldelboni 2021-03-15T20:58:33.116300Z

yeah is random

rafaeldelboni 2021-03-15T20:58:38.116500Z

I will move now

rafaeldelboni 2021-03-15T21:03:52.116700Z

yeah still happening without the kondo files

rafaeldelboni 2021-03-15T21:04:08.116900Z

[1;31mjava.lang.Exception[m: [3mUnmatched delimiter: } [at line 40, column 1][m

ericdallo 2021-03-15T21:04:54.117100Z

@rafaeldelboni the second log, the issue happen on didOpen that is when client send to server that a new file was opened in the client editor, and we can see that is a StringIndexOutOfBoundsException https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/feature/file_management.clj#L25 when is parsing the uri -> namespace

ericdallo 2021-03-15T21:05:35.117400Z

could you send the json log between client and server to check what your client is sending? I supposed you use vim, not sure how to get that log in vim lsp clients

rafaeldelboni 2021-03-15T21:08:31.117800Z

@dharrigan knows, I never know how to do this

borkdude 2021-03-15T21:10:47.118Z

Maybe Rafael can try an older version from before the incremental diffing?

ericdallo 2021-03-15T21:11:33.118200Z

what was the previous version that it was working @rafaeldelboni?

dharrigan 2021-03-15T21:11:51.118400Z

CocCommand workspace.showOutput

ericdallo 2021-03-15T21:13:33.118600Z

@borkdude from that log the didChange incremental change is a consequence of the didOpen exception, not the cause

rafaeldelboni 2021-03-15T21:14:33.118800Z

I don't remember I can try rollback some versions

rafaeldelboni 2021-03-15T21:16:12.119Z

@ericdallo if you type (defn asdljkfjkasldfkjlsdaf) in a clojure file save and try to go to definition you don't get this error?

ericdallo 2021-03-15T21:18:25.119200Z

No, I don't. I'm starting to think that the client is sending some messy range? that's why the request and response log could help

rafaeldelboni 2021-03-15T21:19:33.119700Z

nothing relevant comming out

## versions

vim version: NVIM v0.4.4
node version: v14.15.3
coc.nvim version: 0.0.80-98a0c6db19
coc.nvim directory: /home/delboni/.local/share/nvim/plugged/coc.nvim
term: xterm-256color
platform: linux

## Log of coc.nvim

2021-03-15T18:15:33.518 INFO (pid:31644) [services] - registered service "languageserver.godot"
2021-03-15T18:15:33.520 INFO (pid:31644) [services] - registered service "languageserver.clojure-lsp"
2021-03-15T18:15:33.522 INFO (pid:31644) [services] - clojure-lsp state change: stopped => starting
2021-03-15T18:15:33.540 INFO (pid:31644) [services] - registered service "eslint"
2021-03-15T18:15:33.542 INFO (pid:31644) [plugin] - coc.nvim 0.0.80-98a0c6db19 initialized with node: v14.15.3 after 93ms
2021-03-15T18:15:33.547 INFO (pid:31644) [language-client-index] - Language server "languageserver.clojure-lsp" started with 31655
2021-03-15T18:15:44.639 INFO (pid:31644) [services] - clojure-lsp state change: starting => running
2021-03-15T18:15:44.644 INFO (pid:31644) [services] - service languageserver.clojure-lsp started
2021-03-15T18:15:45.105 INFO (pid:31644) [attach] - receive notification: showInfo []

ericdallo 2021-03-15T21:20:25.119900Z

this is not the correct log

ericdallo 2021-03-15T21:20:38.120100Z

It should be a log with the content of the request and response from client <-> server

ericdallo 2021-03-15T21:20:46.120300Z

with the json body

ericdallo 2021-03-15T21:21:47.120500Z

@dharrigan we could maybe document that on https://clojure-lsp.github.io/clojure-lsp/troubleshooting/

dharrigan 2021-03-15T21:22:06.120800Z

Good Idea

dharrigan 2021-03-15T21:22:11.121Z

I'll do a PR

1
ericdallo 2021-03-15T21:23:59.121300Z

@rafaeldelboni it'd be nice if you could test other versions until we find the version that introduced the issue And find the logs as well ๐Ÿ˜…

rafaeldelboni 2021-03-15T21:24:29.121500Z

Thanks for the help I will do some tests with older versions

๐Ÿ‘ 1
dharrigan 2021-03-15T21:34:55.121800Z

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

rafaeldelboni 2021-03-15T21:45:01.122100Z

2021.03.06-17.05.35 is working fine here, I will do some more tests tomorrow

ericdallo 2021-03-15T21:47:05.122300Z

Ok LGTM @dharrigan, it'd be better if it makes sense to another vim user, could you check that PR later @rafaeldelboni?

rafaeldelboni 2021-03-15T21:48:22.122500Z

LGTM

dpsutton 2021-03-15T22:42:09.123Z

does clojure-lsp watch for changes to .lsp/config.edn or require a restart?

ericdallo 2021-03-15T23:45:56.123300Z

It requires a restart