NeoVim tab size (shiftwidth, tabstop) constantly changing in Insert mode in Lua files

2.8k Views Asked by At

I am new to NeoVim (nvim 0.8.3) and started right away with AstoNvim config (astronvim 2.10.0). Tried to configure Tab and indentation size to be 2 spaces. It works at least in JavaScript files, but not in Lua files.

Initially, when I am opening lua file everything is ok. But as I switch to Insert mode shiftwidth and tabstop values are changed from 2 to 4. It impacts tab position markers and spaces placed when I am pressing Tab. It could also impact formatter (currently uninstalled any lua related lsp, linter, formatter).

Screen - Normal mode and shiftwidth value is 2
Screen - Insert mode and shiftwidth value now is 4

My config file location is ~/.config/astronvim/lua/user/init.lua. AstroNvim includes this path to make able save it e.g. in git repo.

Initially I changed this values:

vim.opt.smarttab = true
vim.opt.expandtab = true
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.softtabstop = 2

Then I've tried duplicate same values for buffer (vim.bo).

vim.bo.expandtab = true
vim.bo.shiftwidth = 2
vim.bo.tabstop = 2
vim.bo.softtabstop = 2

And later I added ftplugin for lua files with combination of above values. But none of these attempts made any effect on described behaviour.

Why it is redefined?
How to turn off or override this behaviour?

0

There are 0 best solutions below