Lsp.buf.formatting() adds ^M to lines it touches

This happens in several LSPs (I’ve seen volar and rust-analyzer so far) and not in every file… I use a project that is checked out windows-style and committed unix-style with Git on Windows, and this seems to only happen with certain files.

Once I format once, formatting again garbles the file’s text and duplicates lines, so somehting’s definitely wrong…

I have this snippet in my vimrc long time ago, when I’m switching a lot between windows & *nix. Maybe you can give it a shot

" Remove the Windows ^M - when the encodings gets messed up
nnoremap <Leader>mm mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm

The problem is that this for me happens on save so unless I :noautocmd w this doesn’t help… Should I open an issue for this? It seems like this should be somehow handled on the lsp side…

Open an issue, using the minimal config from lspconfig on the neovim/neovim repo. I need a minimal reproduction. That means minimal config, the language server (and version) that cause the issue, and the specific file (preferably a small file) pre and post formatting (preferably all in a github repo).

This is fixed on master.