Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make line length configurable #83

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Make line length configurable #83

wants to merge 6 commits into from

Conversation

sthiele
Copy link
Member

@sthiele sthiele commented Oct 2, 2022

Hey @MaxOstrowski, this PR makes the maximal line length configurable.
clingofmt will read/create a .clingofmt file in TOML format, in this file you can define line_length = 20.
Would be nice if you give it a test round. 💞

@florianfischer91
Copy link

Nice feature. Would be cool if you could also support configuration via pyproject.toml too. For some "inspiration" you can take a look at https://github.com/charliermarsh/ruff. It's a python linter written in rust.

@MaxOstrowski
Copy link
Member

I tested, and at least for my style-feeling this looks much better.
I'm still a bit puzzled about the newline after the head of a rule. Things like:

is_a(V, common) :- type(V). 

come out as:

is_a(V, common) :-
    type(V).

which I think doesn't look as good.

Also:

a :- something_longer(X), foo(X).

with a long linelength will come out as:

a :-
    something_longer(X), foo(X).

@sthiele
Copy link
Member Author

sthiele commented Oct 6, 2022

.. I'm still a bit puzzled about the newline after the head of a rule. Things like:

is_a(V, common) :- type(V). 

come out as:

is_a(V, common) :-
    type(V).

In most cases I prefer to separate head and body that is why the line break after the :- is a hard one. Otherwise it would allow things like that:

a(x) :- a_somehow_longer_predicate(X),
    short(X).

Which I think looks ugly too.

I'm not happy with the feature .. while it allows to have multiple body atoms on one line, it also often disallows having them on separate lines.
I tend to prefer the style with one atom per line also because it is more consistent .. I guess i prefer vertical reading .. one could also argue that the vertical style makes reading diffs easier.

Maybe you are interested in the feature discussed here PR #86

@MaxOstrowski
Copy link
Member

You are right, I guess this is a game of preference.
I still think that it could be a useful feature, and I also think that it should be extended to the head of the rule. Simply because of the fact that with '--linelenght=0' you will always have your head separated from the body and conserve your vertical reading.

With the diffs, I agree that your method is superior.

Base automatically changed from next to main April 30, 2024 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants