vim.lsp.buf.formatting()
messes up lines it fixes. It’s only lines where it fixes wrong indentation, where wrong number of tabs is used (works ok with spaces). Formatting deletes first X characters of those lines. After undo, and repeat, all consecutive runs are ok, with no error (until next indentation is changed).
Issue is consistent with all language servers I tried (TS, Go).
After stripping config to only nvim-lspconfig plugin, and a basic ‘set’ of variables, issue persisted. However, changing ‘set noexpandtab’ to ‘set expandtab’ fixed it! Relevant part of my config is here:
set tabstop=4 softtabstop=4
set shiftwidth=4
set expandtab
set smartindent
I changed my style of coding from tabs to spaces but still have many projects that use tabs. Haven’t really spent much time configuring this properly, but I feel (mis)configuration should not cause this behavior?