Formatting destroys the buffer
I noticed that sometimes, when you format (in this case on save), it completely clobbers the text in the buffer.
Prior to this, i noticed I was reporting a diagnostic error that was not accurate (i'm pretty sure).
In this video, I save (nothing happens), then reload the buffer by doing :e, then save again and it destroys it.
https://github.com/user-attachments/assets/7e7ba459-2c55-4390-a3e6-3263a9e182a8
This is very annoying bug... I also have it with current elixir-ls... Sometimes I need to totally restart neovim or it will keep removing random chunks from the code forever whenever it saves and tries to format.
Maybe it's more related to the formatter or treesitter than the lsp itself... nevertheless, I'm sad to see that it is still present.
Are you seeing it be completely destroyed or just the parentheses problem that ElixirLS has had?
Completely destroys... I'll try to get some screenshot the next time it happens...
To illustrate: it's just like it adds a lot of indentation and random spaces between random characters...
Sometimes, to get back to normal I need to restart LSP 2 or 3 times in a row...
I don't know exactly what triggers it, but I observed that it probably has to do with some comments in locations that the formatter may get confused like between case statements; or just over some fn definitions. Stuff like that...
I am wondering if this is related to the introduction of GenLSP and the code Lexical used to translate the utf8 and utf16 code positions.
Possibly the same issue: In NeoVim, I just wrote alias GridPoint.Schedules.WeeklyScheduleFactory and saved, and it was changed to
alias GridPoint.Schedules.WeeklySchedu()leFactory. I undid and saved again and it happened again. I quit out of NeoVim and reopened the same file and it stopped doing that.
I've seen other such mangled text.
If it's helpful I've seen similar with ElixirLS in Emacs. But it goes away when run with (setq lsp-document-sync-method lsp--sync-full)
Possibly the same issue: In NeoVim, I just wrote
alias GridPoint.Schedules.WeeklyScheduleFactoryand saved, and it was changed toalias GridPoint.Schedules.WeeklySchedu()leFactory. I undid and saved again and it happened again. I quit out of NeoVim and reopened the same file and it stopped doing that.I've seen other such mangled text.
Experience report: I had 2 days of Zed usage, probably ran into this every hour to hour-and-a-half -- 'I save the file, its attempt to auto-format introduces broken syntax that it doesn't "see" as broken; restarting the language servers fixes it'.
Just ran into it now, so I tracked this down, since I see that this comment is what I've run into as well. I'm not sure if 'destroys the buffer' is the right description, from the point of view of a user it feels more like 'code occasionally gets mangled on save / format'
Yeah, happens to me quite often. I've turned off format-on-save and am only using mix format for now. Its happened to me in both zed and neovim.
I think the issue might be related to this https://github.com/elixir-lang/expert/issues/110#issuecomment-3260167953
Not sure if that issue is vim specific, but this particular thing has happened in vim and zed for me (maybe they do the same thing)
... Its happened to me in both zed and neovim.
Oh hey, that seems like a great find.
I'm kinda out of my depth here, but if that's true that makes it feel like 'wrong LSP messages, or wrong order' -- when/if we have time we could try to check in the LSP logs in Zed.
Edit: interesting, just read that issue, it does seem like it might be LSP-related, and someone has taken the next step on tracking it down, logging etc!
Just want to report that the same issue is present in Helix editor as well. Appreciate you taking a look!
Just want to report that the same issue is present in Helix editor as well. Appreciate you taking a look!
Can you confirm you're using the latest?