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
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.
I never saw 4, but with larger displays, who knows, 8, 12, 15? Some prime number, I guess.
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.
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.