vim-lsp
vim-lsp copied to clipboard
Something keeps setting shiftwidth=8, when I set it to 4
After installing this plugin, seemingly at random when I work on a c++ file and I hit tab, I get \t\t instead of \t. Whenever this happens, I do :shiftwidth
and it says shiftwidth=8
.
My shiftwidth is 4, set in my vimrc. Something in this plugin is changing it, for whatever reason. The issue has only started happening since installing this plugin.
Very annoying!
That's because your LSP server specifies indent size. Check format options of your C++ LSP server to modify the size to your favorite one.
https://github.com/prabirshrestha/vim-lsp/blob/296fb98d198cbbb5c5c937c09b84c8c7a9605a16/autoload/lsp/utils/buffer.vim#L68
You can check where the option was set:
:verbose set shiftwidth
It seems to be getting set by various old syntax files that I haven't used or looked at in years, such as syntax/make.vim and syntax/vb.vim. However, I'm not editing a makefile or vb file. These files shouldn't have been sourced...
I just split a window to a new hpp file, discovered the shiftwidth set to 2, tried :verbose set shiftwidth
(thank you for that!) and it told me the source was my syntax/vb.vim. Which is very weird.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.