I'm trying to set the indentation in C++ files to be 4 spaces. To achieve this I have the following config:
(setq-default indent-tabs-mode nil) (setq-default tab-width 4) (defun init-c-cpp () (setq c-basic-offset 4) (setq indent-line-function 'c-indent-line) ) (add-hook 'c++-mode-hook 'lsp 'init-c-cpp '(lambda () (print "hello")))
I know there are already questions concerning this topic, but none of the answers worked for me.
The problem is that after opening a
.cpp file in C++ mode, indentation is still at 2 spaces. In fact,
C-h v c-basic-offset inside a C++ mode buffer shows that it is set to
"hello" is not printed to the minibuffer upon opening the C++ file, which I expected to happen. It seems like the hook is not being called at all. Why could this be? Thank you.