r/neovim•
calamari81

LazyVim swapping tab indentation to spaces on save, and I can't figure out how to stop it

Need Help

I'm working on some .ts files in a project, and the files are indented with tabs. When I save the file, it swaps all of my indentations to spaces. VS Code does not have this problem.

I have tried adding the following to my options.lua, with no effect:

vim.opt.tabstop = 2 
vim.opt.expandtab = false
vim.opt.softtabstop = 4

I have also tried adding some lines to my .editorconfig, also with no effect:

[*.{mjs,cjs,js,jsx,mts,cts,ts,tsx}]
max_line_length = 80
indent_size = 4
indent_style = tab

This is what the small .prettierrc.json looks like:

export default {
  useTabs: true,
  singleQuote: true,
  endOfLine: 'lf',
}

And I've also followed a few suggestions to add code to lsp.lua to try and prevent the LSP from auto-formatting. Nothing is working. Does anyone have any idea what could be causing my config to apply this formatting?

I have confirmed it doesn't do anything to any other file type (scss, html, etc.)

Thanks!

Posted Dec 1, 2025, 6:54 PM UTC

13
Loading comments…