0

I have some trouble with my emacs indentation. Since I have enabled electric-pair-mode my indentation is screwed when I use hanging braces. Example (| is my cursor):

int main(int argc, char *argv[])
{
        if(true)|
        return 0;
}

If I now press { I get this:

int main(int argc, char *argv[])
{
  if (true) {
  }
        return 0;
}

Why is this if-block not correctly indented with my c-basic-offset of 8 like the return statement? My relevant config:

(electric-pair-mode 1)
(setq c-default-style "linux")
(setq-default indent-tabs-mode nil)
  • I've tried to repro this after starting from "emacs -q" and cannot. Can you try to do this? (Note that you need a "(require 'cc-mode) (setq c-basic-offset 8)" to be added to the elisp fragment you mention.) – Realraptor Dec 3 '19 at 9:51
  • I found the issue. I am using lsp-mode and i had to turn off lsp-enable-on-type-formatting. github.com/emacs-lsp/lsp-mode/issues/768 – guest356234 Dec 3 '19 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.