I'm using Doom Emacs with (cc +tree-sitter +lsp), you can find my full config here: https://github.com/ZaneH/doom-emacs-config/blob/main/init.el
When editing this file:
// ./src/gui/ChatWindow.h
#pragma once
#include "../libs/Models/Message.h"
#include <QThread>
#include <QWidget>
class QTextEdit;
class QPushButton;
class ChatWindow : public QWidget {
Q_OBJECT
QThread consumerThread;
public:
ChatWindow(QWidget *parent = nullptr);
private slots:
void sendMessage();
void adjustTextEditHeight();
void addMessage(Message *message);
private:
QTextEdit *chatLog;
QTextEdit *messageBox;
QPushButton *sendButton;
};
If I put a newline after ChatWindow(QWidget *parent = nullptr); it indents all the way to the ; character from the previous line like so:
QThread consumerThread;
public:
ChatWindow(QWidget *parent = nullptr);
|
If I press C-c C-s it shows: ((inher-cont 247)).
Things I've tried:
- Add and configure the
google-c-stylepackage - Check that
Q_OBJECTis inc-macro-names-with-semicolon - Set
inher-contto 0 - Configure
clangd
Luckily, when I save the file, the formatter takes care of this awkward indention but it is something I'd like to fix without having to save.
foo<TAB>? Does it realign thefoowith theChatWindow? Also iselectric-indent-modeenabled? If so, try disabling it.foo<TAB>in the newline didn't react when pressing tab. When I turnelectric-indent-modeoff, pressing tab takes me back, but not exactly the correct indention level (still has 2 extra spaces)emacs -Q, which will bypass your init file. I suspect that the settings in your init file are partly to blame, but you need to start from a solid starting point. ATM, we don't have that.doomas set by thecc-mode, the other isgoogle-set-stylewhich cancel all fine tweaking made incc-mode- the culprit isgoogle-make-newline-indent- so remove that package and base your settings only on cc and clang-format; working with multiple projects is easier if you have a suitable.clang-formatfile in root folder of your projects.