rescript-mode icon indicating copy to clipboard operation
rescript-mode copied to clipboard

Issue with `lsp-format-buffer` with other lsp servers

Open Zeta611 opened this issue 3 years ago • 2 comments

Hi, I'm using rescript-mode with lsp-tailwindcss. When using lsp-tailwindcss as an add-on mode, lsp-format-buffer resets every changes I made on the buffer (since I opened the file?). Is there a workaround for this issue?

Zeta611 avatar Aug 21 '22 14:08 Zeta611

Hi, thanks

Did you see this? https://github.com/jjlee/rescript-mode#formatting

Mind you, I think when I tried it lsp-format-buffer resulted in an error (I think because of some huge integer out of range for the size of the buffer, used by the server to mean "end of buffer"). So what you're describing sounds like a different issue than I had -- perhaps upstream lsp fixed the problem I saw then, revealing some other issue.

When you say "resets" changes since you opened the file, I think you're saying it reverts the buffer (to its current state on disk, as in revert-buffer)?

I guess the ideal behaviour is to operate just on the buffer, not on the file on disk. The obvious way to do that is to write a temporary file, but I'm not sure right now whether that's what the LSP server expects / supports... If you know how VS code handles this, let me know.

jjlee avatar Aug 22 '22 09:08 jjlee

I did read the warning, but because it worked very well before I installed the lsp-tailwindcss, I just guessed it was fixed :)

When you say "resets" changes since you opened the file, I think you're saying it reverts the buffer (to its current state on disk, as in revert-buffer)? Yes, that's correct.

I simply worked around this issue by executing yarn run rescript format %s using a hook!

Zeta611 avatar Aug 22 '22 12:08 Zeta611