0

On the first file I created, I had tabs set to 4 spaces and wasn't using the LSP yet. Then I enabled the LSP, and on all subsequently created files tabs are 2 spaces, yet on the original file, it keeps to 4 spaces. I'd prefer to have everything be 4 spaces, but I'd even be fine with everything being 2 spaces, as long as it's consistent. This inconsistent formatting is driving me insane.

1 Answer 1

1

lsp-mode documentation states the following:

settings that are controlled on lsp-mode level are indent size and whether the server should use tabs or spaces. Refer to lsp--formatting-indent-alist to find out what is the variable that is used for the current major mode.

Hence, looking at lsp--formatting-indent-alist, for the major-mode typescript-mode (for instance), set typescript-indent-level to the value you need/want, this way:

(setq typescript-indent-level 2) 

But this may differ depending on the actual setup you have (major-mode, package manager, etc). See the following lsp-mode discussions for additional examples:

As another approach, try setting lsp-enable-indentation to nil. This should disable lsp-mode-caused indentation fully.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.