You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
with Ada.Directories;
with Ada.Strings.Unbounded;
package Foo is
package AD renames Ada.Directories;
package ASU renames Ada.Strings.Unbounded;
type Site_Config is tagged limited record
Dry_Run : Boolean := True;
Site_Root : ASU.Unbounded_String;
end record;
function "+"(S : ASU.Unbounded_String) return String renames ASU.To_String;
function Root_Dir (Config : Site_Config) return String is (+Config.Site_Root & "/");
function Output_Dir (Config : Site_Config) return String is (+Config.Site_Root & "/html");
function Source_Dir (Config : Site_Config) return String is (+Config.Site_Root & "/md");
function Config_Dir (Config : Site_Config) return String is (+Config.Site_Root & "/config");
procedure Build_Site (Root : String);
end Foo;
The center lines with expression functions reformat split lines, even though I'd rather keep them together:
function Root_Dir (Config : Site_Config) return String
is (+Config.Site_Root & "/");
function Output_Dir (Config : Site_Config) return String
is (+Config.Site_Root & "/html");
function Source_Dir (Config : Site_Config) return String
is (+Config.Site_Root & "/md");
function Config_Dir (Config : Site_Config) return String
is (+Config.Site_Root & "/config");
This still occurs even with these Package settings:
package Format is
for Width ("Ada") use "120";
end Format;
This continuation of expression functions along the same line might not be wanted by everyone. With the old formatter, I could use --!pp off and --!pp on to ignore lines. While GnatFormat works great in a lot of situations, it'd be great if I could ignore lines to get the behavior I want.
The text was updated successfully, but these errors were encountered:
What you're observing is intentional, i.e., for expression functions, there is always a hard line break before the is keyword.
For GNATformat, we decided to have an opinionated formatter approach, therefore, in AdaCore, our goal for the coming months is to reach a consensus on a formatting style that most Ada developers (both from the community and customers) are happy to use. With that said, I'm afraid that this case has already been discussed and we decided to always have a hard line break before the is.
However, I encourage you to keep reporting possible style issues since they will taken into account.
We also realize that there might be some disagreement on the style chosen for certain constructs, so we will provide two work arounds:
As you mentioned, a way to deactivate formatting on certain ranges (using directives like --!pp off)
Allow overriding the formatting style configuration. GNATformat is an AST based formatter. There is a style configuration for each node, which you will be able to override. This requires getting familiar with the AST produced by Libadalang and with the configuration language. There will be proper documentation for those who would like to explore this feature. For a simple example like this one, it should not be difficult.
I'll leave the issue open until these two features are implemented.
Strange scenario here:
The center lines with expression functions reformat split lines, even though I'd rather keep them together:
This still occurs even with these
Package
settings:This continuation of expression functions along the same line might not be wanted by everyone. With the old formatter, I could use
--!pp off
and--!pp on
to ignore lines. While GnatFormat works great in a lot of situations, it'd be great if I could ignore lines to get the behavior I want.The text was updated successfully, but these errors were encountered: