laravel / pint

Laravel Pint is an opinionated PHP code style fixer for minimalists.
https://laravel.com/docs/pint
MIT License
2.8k stars 143 forks source link

Add Ability to Set Indentation Level #90

Closed secondmanveran closed 2 years ago

secondmanveran commented 2 years ago

This MUST have the ability to set the indentation level and type if it's to be useful at all.

I, along with a great many others, don't use 4 spaces to indent. PHP-CS-Fixer has the ability to set the indentation as referenced in #24

I would suggest implementing this as a rule just as StyleCI does:

tab-width: (int)
use-tabs: (bool)

Please add this as I'm not able to use your package until you do.

Thanks

nunomaduro commented 2 years ago

I am sorry, but we don't have plans for this.

iskrisis commented 2 years ago

If i understand correctly its not possible to choose indenting with tabs with Pint in any way? Because it "fixes" my project to spaces and from my test i can't even fallback to PHP-CS-Fixer setting the indentation https://stackoverflow.com/a/64495193

I mean yes i understand if i need these settings i should use PHP-CS-Fixer directly. But it would be exactly that kind of "minimalism" that makes this very common setting much easier to set than in PHP-CS-Fixer what i would Pint expect to do.

Because Pint becoming Laravel default it essentially forces everyone to spaces. Not sure why is that required.

secondmanveran commented 2 years ago

@iskrisis

EXACTLY! I use spaces, but only 2 ... and even this isn't possible. It's like saying, oh sorry we only support Pusher for broadcasting, or MySQL for database.

This is NOT the Laravel way.

camiant commented 2 years ago

I'd use

tab-width: 2
use-tabs: true

sadly... many of us will be forced to ignore laravel/pint unless @nunomaduro customize these settings, while admitting that this package is really useful for code formatting/standardization. it is a pity to be unable to use it.

camiant commented 2 years ago

after executing ./vendor/bin/pint, we may use another tool to only care about indentation. terrible hack, but at least we can benefit from pint in a (cumbersome) way... anyone knows what may be a good package? ... maybe PHP-CS-Fixer itself?

wischerdson commented 2 years ago

@camiant

I think then it's better to use a pure PHP-CS-fixer without pint.

secondmanveran commented 2 years ago

@wischerdson

Agreed. Or simply spring for StyleCI. For all it does it's extremely affordable and Graham is a good cat, easy to work with and great support.

iskrisis commented 2 years ago

I think everybody understands there are other solutions. It just seems like this very nice magic wrapper that would be far more useful if it wasn't so highly dogmatic. Pint supports every other crazy setting PHPCSFIXER does just not 2 main settings people are most likely change to their preference.

Logical conclusion is that that this is a feature and it's on purpose. Which is strange but sure totally your decision to make. It will probably force many people to 2 spaces. 🤷

secondmanveran commented 2 years ago

@iskrisis

The default is the typical 4 spaces I believe ... that's the issue. We'd like to be able to change the space count and the ability to use tabs or spaces.

There may be other configs that are missing as well. But yes, if you use the default "Laravel" preset, then this is very convenient.

I have forked it to make the changes for my own use, but I haven't had time to work on it yet.

bbprojectnet commented 2 years ago

I also went back to PHP CS Fixer after 5 minutes of using the Pint. There is no benefit to using the Pint other than a nice console output, only the downsides. Pint it's just a limited PHP CS Fixer wrapper.

bluehaoran commented 1 year ago

I know this issue is closed, and I know that this is religious, dogmatic issue for many, but this has become an important accessibility issue too. This hard-converted me to the tabs camp, and I'd encourage the Pint team to re-consider this.

secondmanveran commented 1 year ago

@bluehaoran @iskrisis @camiant @bbprojectnet

I've released a more configurable version called Pinte

If there's any further configuration options you'd like to see past setIndent and setLineEndings feel free to open an issue or PR.

camiant commented 1 year ago

have you implemented a key in pinte.json like indentSize (e.g. 2 / 4) ?

secondmanveran commented 1 year ago

@camiant

Yeah if you look at the usage section of the readme you'll see.

{
  "indent": "\t",
  "lineEnding": "/r/n"
}

Of course you can use any value you can in PHP-CS-Fixer.