GPS drives me nuts

I’ve got a new machine. I downloaded and installed GNAT CE 2021, the same as on the old machine, but GPS behaves differently.
In the project file, I set in package Pretty_Printer “-gnaty2” for indentation - GPS ignores.
I set in the project properties menu Default indentation to 2 - GPS ignores. It insists on 3.
I checked the old machine’s setting and am confused.
What I want: Just indentation 2 and no reformatting.

Documentation was no help. Can you help, please?
Christoph

Maybe I misunderstood your question but what has this all to do with pretty printer? IMO the relevant settings is here:


P.S. Indentation 2 is a blasphemy! :grinning:

I like it. (I highly estimate AdaCore, but it is not heaven. :wink:


)

GPS might use GNATFormat, which uses a different package block (package Format).

There’s also EditorConfig which some editors/IDEs can be set up indent conventions per file type, but I don’t know if GPS respects it.

Outside of Ada, I only see tabs (C++ or Go) or 4 space indents (also C++, Python, Rust, Ruby), with the exception of Ruby which sometimes uses 2 space indent. Ada’s usual three space convention just looked weird to me for the longest time.

My old Ada code used to enforce 4 spaces but I don’t care anymore, now I just enable “format on save” in the VS Code extension and let GNATformat do what it wants, like how I’d let gofmt, or clang-format or rustfmt do their jobs. Life’s too short for formatting wars.

3 Likes

I never saw 4, but with larger displays, who knows, 8, 12, 15? Some prime number, I guess. :grinning:

3 is an aesthetical choice because “if” is two letters long. So it looks better with if-the-else. Other keywords requiring indentation are long “begin”, “declare”, “for”, “case”, “when.”

Another thing about 3 is that if someone mixes spaces and tabs, tab width is typically an even number like 2, 4, or 8, so it’s usually obvious there’s an issue.

maybe i’m the only person to think this, but:

  • 2 seems too short to make out changes in indentation
  • 4 seems too long, and you’re more likely to hit 80 characters with just 2 or 3 levels of indentation
  • 3 makes a nice compromise

i came to this conclusion long before trying out Ada; i think i was using it back in my Java days, so i was pleased to see that Ada used it.

fwiw i’ve seen some javascript that indents by 2 spaces, but i have no idea how common that is. maybe just a weird but influential member of my team.

1 Like

If you use the 2025 xcommunityx continuous release instead of 2021 community edition then you will find a newer language server with better or with package pretty_printer support.

2021 was AdaCore’s last GNAT CE. Which newer one do you mean?

Oh, it’s actually called continuous release.