Eclipse/nsight formatter doesn't respect function body indentation policy - eclipse

I use CUDA 8.0's version of nsight (Eclipse platform 4.4.0, CDT 8.4.0). My Eclipse C/++ formatter is configured to indent as follows (image is from the Formatter config prev:
but if I have this code:
and I press enter, get to the next line (the cursor is placed under the span), and type in an opening brace, it is not placed at the beginning of the line, but is rather kept indented:
Is this a bug or have I misconfigured something?
Notes:
I tried both the built-in formatter and the "CUDA C" formatter; they behave the same in this case

I see this behaviour in stock CDT as well. It looks like a bug. Please file a bug report.

Related

IntelliJ + Scalafmt: Incorrect docstring indentation

For some reason, when using IntelliJ and Scalafmt 2.7.5, typing /** followed by [ENTER] results in the following sort of docstring:
As you can see, the first asterisk has no indentation... Since I have "format on save" enabled, hitting [CTRL]+[S] results in a correctly formatted docstring:
It doesn't surprise me that the initial format wouldn't match up with scalafmt's, and that the formatting isn't really applied until saving or compiling (if that's enabled). However, the lack of indentation on the first asterisk -- even if it's only present until I save or compile -- is driving me mad.
Does anyone know how to resolve this without using the built-in IntelliJ formatter? This is actually tempting me to scrap scalafmt and just use the IntelliJ formatter for my team's project. Thanks :)
Here's the .scalafmt.conf for reference:
version = 2.7.5
project.git = true
preset = IntelliJ

How to make Eclipse format according to template when typing

I'm using eclipse Version: 2019-09 R (4.13.0) on mac High Sierra.
I didn't like the default formatting. For example when I write a method, it puts a space before the brace like this myMethod() { instead of myMethod(){ which I prefer.
So I changed the formatting template in Preferences -> Java -> Code Style -> Formatter
Now when I do CMD+shift+F it formats it how I want without the whitespace.
However, it STILL adds the white space as I type in the method! I can't figure out how to stop it doing that. When I type CMD+shift+F it corrects it, so it knows what I want, but retains the old behaviour when I type. Please save my sanity!
(Yes I've tried restarting eclipse!)
Thanks!
In Preferences: Java > Editor > Typing in section Automatically insert at correct position uncheck the checkbox Braces.

Eclipse C/C++ Formatter Line Wrapping or Indentation Problem When a Macro is a Function Parameter

I am having problem when I try to format C code in Atollic TrueSTUDIO for STM32 9.3.0. When a macro is a parameter of a function, line wrapping doesn't work. It is a bug or I couldn't find the correct setting in Formatter.
#define GPIO_PIN_7 ((uint16_t)0x0080U)
GPIO_InitAsOutput(&LED_D, GPIOC,
GPIO_PIN_7,
GPIO_OutputType_PushPull, GPIO_Pull_None,
GPIO_Speed_Low);
In the code above, GPIO_PIN_7 is the problem here. Line wrapping width is 80. When I press "CTRL+SHIFT+F", It should be look like this:
PIO_InitAsOutput(&LED_D, GPIOC, GPIO_PIN_7,
GPIO_OutputType_PushPull, GPIO_Pull_None,
GPIO_Speed_Low);
However, It doesn't change the format.
One other odd thing is that If I replace GPIO_PIN_7 with ((uint16_t)0x0080U), It is working and code becomes like below:
PIO_InitAsOutput(&LED_D, GPIOC, ((uint16_t)0x0080U),
GPIO_OutputType_PushPull, GPIO_Pull_None,
GPIO_Speed_Low);
What should I do to correct this behavior?
You just hit the Eclipse bug 459301. Until it's fixed you can just use formatter tags if you can use Eclipse 2019-03 with CDT 9.7.
//#formatter:off
PIO_InitAsOutput(&LED_D, GPIOC, GPIO_PIN_7, GPIO_OutputType_PushPull,
GPIO_Pull_None, GPIO_Speed_Low);
//#formatter:on

Unexpected 'INDENT' in CoffeeScript Example Code

As I was playing around for the first time with CoffeeScript, I ran in to a problem. In order to debug my problem, I tried replacing my whole file with one of the example bits of code from the coffee script site:
kids =
brother:
name: "Max"
age: 11
sister:
name: "Ida"
age: 9
However, when I try to compile that code, I get:
Error: In coffee/main.coffee, Parse error on line 3: Unexpected 'INDENT'
at Object.parseError (/usr/lib/coffeescript/parser.js:501:11)
at Object.parse (/usr/lib/coffeescript/parser.js:573:32)
at Object.compile (/usr/lib/coffeescript/coffee-script.js:23:22)
at /usr/lib/coffeescript/command.js:99:27
at /usr/lib/coffeescript/command.js:72:28
at fs:84:13
at node.js:773:9
In coffee/main.coffee, Parse error on line 3: Unexpected 'INDENT'
Since this is code from the CoffeeScript site, I assume the code itself isn't the problem. However, the compiler also seems to be working properly; if I compile:
a = 2
it generates a file with:
(function(){
var a;
a = 2;
})();
as expected. So in other words, the code is good, the compiler is good, and yet somehow I'm getting this Unexpected 'IDENT' error ... can anyone help me understand what is going on?
I am pretty sure this is a tabs-vs-spaces issue. Tell your editor not to convert spaces to tabs if it does that. Also, go through your code with the cursor and make sure it doesn't jump over blank areas.
The issue is that while normal editors see a tab as equivalent to two or four spaces, coffeescript sees it as one space, so the indentation gets messed up.
If this all doesn't help, make sure you have a recent coffeescript version, e.g. 1.1.0 or newer.
If you are using a JetBrains IDE (IntelliJ, PHPStorm, etc) the change of setting that worked for me is:
File > Settings > Project Settings > Code Style > CoffeeScript > Tabs
and Indents
Tick "Use tab character" & "Smart tabs"
Code is fine. Make sure you haven't messed up the whitespace (strange control chars showing as blanks, tabs or similar).
If you have the same problem, but your indentation is okay,
then you must be suffering from bug 2868.
Basically, the error is misleading. Check for indentation
errors in the required files.
When in Atom you can automatically convert tabs to spaces:
Packages > Whitespace > Convert Tabs to Spaces
You can resolve this two ways
1. IF using webstorm File->Default Settings as said above
2. Other workaround, is to use a different editor like Sublime, there u can press enter on earlier line and it will auto tab it for you with spaces

Eclipse code formatter: spacing in empty blocks

i configured the eclipse code formatter to display an empty block's brackets in one line. Now my projects checkstyle configuration requires spacing between these brackets. Is it possible to tell Eclipse to do this.
e.g.: emptyMethod() { }
Thanks for any help.
As far as I know there is no way to put a space between the braces with the Eclipse formatter.
As a workaround I removed the "WhitespaceAround" rule from the checkStyle plugin configuration.