-
-
Notifications
You must be signed in to change notification settings - Fork 41
Don't change file if formatting doesn't change #81
Comments
I've done some digging on this; I don't think it would take much effort to make significant improvements to the way formatting is done. From what I can tell, the current formatting implementation simply sends the entire document through This section of Ideally, we could add another public function to |
Ok, I've done some tinkering here and here. The code is kinda messy right now and it only kind of works (it looks like some indentation changes are getting skipped so you have to reformat twice sometimes, and things occasionally get deleted), but it seems like it should be possible to fix those issues. When I have time I'll clean it up and open PRs on both repos. |
Fixing those issues has turned out to be much harder than anticipated. I'm going to keep working on it at some point, but if someone else wants to take over and give it a go, I'd be happy to give some pointers. |
I'd like to give it a go, but I don't know Rust. I might learn it this summer, but I have no chance to until July when my exams end. |
No worries, good luck with exams! I've actually finally managed to make some progress. I think I'm on the right track now, but there are still more bugs to work out. The problem is that |
Ok, I believe I've ironed out most of the bugs. All 77 of I'm still not entirely convinced it's bug-free though, so I'm going to use it myself for a little while before opening merge requests. I'm also not entirely sure where I should put the edit merging step (inside the In the meantime, if anyone wants to use these changes, use the |
I'm happy to take a look during the next days :) |
Ok, great! I'll try and get pull requests opened by tomorrow then. |
Description
I'm using the helix editor and when formatting a file with
:format
while usingrnix-lsp
, it will replace the entire content of the file even when the formatting doesn't change.Doing the same for a
.c/.cpp
file while usingclangd
doesn't replace the contents.I wonder whether this is because
rnix-lsp
doesn't check whether the formatting has actually changed. Perhaps it would take too much to check it? I'm not sure how this works as I'm not familiar with the code behind LSP servers.Considered alternatives
I noticed the code responsible for formatting is here and whether checking if the formatting changed is an option.
The text was updated successfully, but these errors were encountered: