LSP formatting deletes characters when `set expandtab`

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?

Which version of neovim? Tim Pope fixed some things around tabstop for 0.7. If it’s in 0.7 file a GH issue following the minimal reproduction steps so I can reproduce and I can look into it.

It’s latest 0.7, just updated all before posting. I’ll post GH issue.