language-tools
language-tools copied to clipboard
formatting results in invalid file modifications in neovim
Describe the bug
formatting files on other lsp is not resulting in modified files in neovim, this can be reviewed by looking at the output of :changes
while i don't know which side is causing the problem i have opened an issue there as well see: https://github.com/neovim/neovim/issues/25579
Reproduction
see mentioned issue
Expected behaviour
formatting files should only modifies the lines that has formatted by lsp
System Info
- OS: Archlinux
- IDE: NVIM v0.9.4
Which package is the issue about?
svelte-language-server
Additional Information, eg. Screenshots
No response
I don't understand what you meant by "resulting in modified files in neovim" and "results in invalid file modifications"? But judging by the "expected behaviour", maybe it's because the formatting is currently replacing the whole document. We didn't calculate the difference between before and after.
I meant this by modified files and invalid modification
my neovim output of :changes:
normally lsp formatter only makes changes to specific lines not the whole document
Correct me if I misunderstood because I don't fully understand what you want to address, so please explain your intention in detail. There seem to be two issues you want to address. One is the "invalid" in your changes. And the other is that the change doesn't list every single difference in the file.
For "invalid", I can't relate the result of formatting edits to this image. The edit the language server returns is a single replacement instead of two. What exactly is in line 108 before format and after format?
For replacing the whole file, We're using prettier for formatting. The result returned by Prettier is the whole file. It'll take extra effort to calculate the difference between before and after. It also does what it is supposed to do, formatting. So it doesn't make much sense for us to spend the extra time to calculate the difference. Why would you need to know what changes?
I try to explain with gopls
with a very basic program in go
before running formatter I have
:changes like this:
modifying line 3 to trigger formatter results in
so only line 3 is changed by lsp
in case of svelte lsp formatter replace the whole file as you said so invalid line remains in
:changes output
for example this file has 129 line before formatting and 137 lines after, and line 138 is marked as invalid for some reason
Why would you need to know what changes?
it's useful in neovim/vim for g; and g, key to bring back and forth to last changed line in a file
Thanks for bearing with me btw