Skip to main content
14 events
when toggle format what by license comment
Nov 18, 2021 at 6:45 comment added apoorv569 Ok so I found this issue on emacs-lsp github, looks like I have to set lsp-enable-on-type-formatting to nil and it worked. It no longer formats the code. The doom c-style is kind of working, but not exactly as it does in doom. When I type for example void func() and press RET to go to next line and create {} and my cursor is between the 2 braces i.e {|} and I press RET in doom it automatically create new line, indents 4 spaces and take the closing brace to new line. I want to achieve that same behavior.
Nov 18, 2021 at 6:09 comment added phils Should be easy to test that by disabling LSP. Looks like a good lead; hopefully you can figure out from here how to make it behave how you want.
Nov 18, 2021 at 6:04 comment added apoorv569 Looking at the *Message* buffer I saw these messages when the reformatting happens, LSP :: Applying 3 edits to 'MainFrame.cpp' ... Applying 3 edits to 'MainFrame.cpp' ...done I think its LSP that is re formatting the code.
Nov 18, 2021 at 5:51 comment added apoorv569 @phils I think you are correct, some other package or settings is changing the brace position automatically when I hit RET. BTW I found the doom-emacs c-style here is the link. Now the question is how do I see what package is causing this. I don't have any package that formats the code. I only have LSP and ccls for c/c++. I do have a lot of other packages as well. Here is my emacs config.
Nov 17, 2021 at 23:41 comment added phils If you are still having problems with the indentation levels, though, that's definitely fixable.
Nov 17, 2021 at 23:40 comment added phils Indentation can certainly happen automatically, but the "move a bracket from the start of the current line to end of the previous line" issue is not something that I've ever experienced with Emacs, so regardless of the chosen style I don't think that particular kind of reformatting is standard behaviour.
Nov 17, 2021 at 22:53 comment added apoorv569 @phils I think the default c-default-style is set to "gnu" which indents the braces, as stated here - EmacsWiki I have now switched to linux style, but I don't see any difference. At this point I am mostly manually editing brace position every time. I like how doom-emacs has the perfect c-style that I prefer, wish they had a package to set it up.
Nov 16, 2021 at 14:14 comment added phils The "sometimes re-formats the brackets position" issue is not a thing that Emacs does by default (to my knowledge). Although you say "As far as I know, I did not install any formatting package." I can only presume that you have unknowingly done exactly this. It's pretty easy to confirm -- just run emacs -Q and confirm the standard behaviour. Assuming it's your own config, you can use the recursive bisection technique to quickly narrow down which piece of your config is responsible.
Nov 16, 2021 at 14:02 history bumped CommunityBot This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Jul 19, 2021 at 14:01 history bumped CommunityBot This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Jun 19, 2021 at 13:38 comment added Drew I'm guessing this question is a duplicate, but I don't have time to look for it now. Hopefully someone will find it, if so, and then close this as a dup.
Jun 19, 2021 at 13:35 history edited Drew
edited tags
Jun 19, 2021 at 9:29 answer added db48x timeline score: 3
Jun 19, 2021 at 9:20 history asked apoorv569 CC BY-SA 4.0