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

Add option to define a minimal indentation #2138

Open
Angelisium opened this issue Jan 26, 2023 · 2 comments
Open

Add option to define a minimal indentation #2138

Angelisium opened this issue Jan 26, 2023 · 2 comments

Comments

@Angelisium
Copy link

Hi 👋
I don't know if many people would be interested, I think it would be nice to have an option to define a minimal indentation. like :

--minimal-tab-indent: <Number> (default = 0)

Who, according to --tab-width and --use-tabs would give :
Input:

<?php

array_map(function($arg1,$arg2) use ( $var1, $var2 ) {
    return $arg1+$arg2/($var+$var2);
}, array("complex"=>"code","with"=>
    function() {return "inconsistent";}
,"formatting"=>"is", "hard" => "to", "maintain"=>true));

Output:

// With --tab-width=4, --use-tabs=false and --minimal-tab-indent=1
<?php

    array_map(
        function ($arg1, $arg2) use ($var1, $var2) {
            return $arg1 + $arg2 / ($var + $var2);
        },
        [
            "complex" => "code",
            "with" => function () {
                return "inconsistent";
            },
            "formatting" => "is",
            "hard" => "to",
            "maintain" => true,
        ]
    );

I know it's a really marginal addition but it makes me anxious not to have this indentation that I always use in all my projects 😭

@czosel
Copy link
Collaborator

czosel commented Jan 26, 2023

Hi @Angelisium, does this mean the entire source code would be indented by the given amount of tabs? Personally, I've never seen code formatted that way. What's the benefit of doing this?

@Angelisium
Copy link
Author

Sorry for the delay in responding, I did not see the notification.
Yes, it's to indent of +1 the whole document ; I don't think it has some benefit, personally I think it's just prettier.

I learned PHP a few years ago and it always seemed logical to me to indent the code between tag <?php ... ?> ; and it stayed even after I stopped using the ?> tag.

E.G. :

<?php
    // some stuff
    // foo bar
?>

As it is the case when I add CSS or JS between HTML tags.

E.G. :

<!DOCTYPE html>
<html lang="en">
    <!--  head -->
    <body>
        <style>
            body {
                /* some stuff */
            }
        </style>
    </body>
</html>

I know it's rare. I myself only do it when I'm working on solo projects (or personal projects of which I am the leader 😈) ; otherwise, I follow the formatting rule established beforehand (generally PSR-2/12 for simplicity)

I don't have many public examples... I found that in my gitlab code snippets: Time and Sql ; and this in my gitlab repo : Octave
there is not much code but it gives an idea of what it looks like with a +1 indentation everywhere.

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

No branches or pull requests

2 participants