Phosphorus15 / intellij-prolog

Prolog plugin for Intellij IDEA
Apache License 2.0
26 stars 5 forks source link

advances in code formatting #122

Open javatlacati opened 1 year ago

javatlacati commented 1 year ago

The documentation for formatting is a little outdated, so here are some advances for it.

Still no custom indentation configuration but it starts applying some formatting in certain circumstances, probably we can discuss on several ways to indent the code based on the tokens you have defined.

Phosphorus15 commented 1 year ago

Is it possible to introduce an indentation configuration based on this PR? maybe there'd be a global configuration hosted in the IDEA platform that we can read from it and apply.

javatlacati commented 1 year ago

that depends totally in the tokens you have declared.

I personally tend to use two indentation styles:

my_rule( Param1, Param2 ) :-
      number( Param1 ),
      between( 1, 10, Param2 ).

That's the one I've seen in many books.

And the other I use is:

my_rule(
        Param1
        , Param2
      ) :-
        number( Param1 )
      , between( 1, 10, Param2 )
      .

This is more SQL inspired and is more practical when you need to comment a whole line yet less readable.

According to documentation the options that we have are:

Phosphorus15 commented 1 year ago

Strangely enough, in my local testing environment, the code formatting hardly does anything on most of the code I've provided (I've also tried to add blank space manually and see if the formatting eliminates it, but nothing happened). Do you have any example that works with the formatting function introduced by this PR?

Phosphorus15 commented 1 year ago

Strangely enough, in my local testing environment, the code formatting hardly does anything on most of the code I've provided (I've also tried to add blank space manually and see if the formatting eliminates it, but nothing happened). Do you have any example that works with the formatting function introduced by this PR?

@javatlacati have you got any working example for me to test on? The behavior of the formatter seems wrong to me.

javatlacati commented 1 year ago

not yet, I need to get trough all of your tokens to see what can be done