chentoast / marks.nvim

A better user experience for viewing and interacting with Vim marks.
MIT License
848 stars 43 forks source link

vim.lsp.buf.format clears all the marks #105

Open dmtrKovalenko opened 7 months ago

dmtrKovalenko commented 7 months ago

I use vim lsp format on the simple markdown file and whenever it is called all the marks are lost. Do you know any reason it might happen seems like some kind of bug in the plugin to me, would be happy to help investigating it

https://github.com/chentoast/marks.nvim/assets/16926049/69646a55-10b2-492f-9b9b-034db830a167

swaroopanand10 commented 7 months ago

Hi, I am facing this same issue, Did you found some solution or workaround for this?

dmtrKovalenko commented 7 months ago

Yes, I used https://github.com/stevearc/conform.nvim for formatting which edits only specific parts and specifically saves marks m

swaroopanand10 commented 7 months ago

@dmtrKovalenko Thanks for the solution, its working.

chentoast commented 7 months ago

the main reason for this is because vim.lsp.buf.format (under the hood) deletes the entire buffer, and replaces it with new text. As such, there's no way for the plugin to retain marks - and the solution is to use workarounds like conform.nvim - or submit a PR to modify buf_set_lines in the neovim source code.

Darukutsu commented 4 months ago

other workaround suggested here https://github.com/neovim/neovim/issues/14307, was to use :wshada! before write and :rshada! after