Closed kanlukasz closed 4 years ago
The only config option is tabs/spaces and tab size as they are defined by the language server protocol. I'll leave this open but it's unlikely to happen any time soon if at all. The goal for now is to be ~PSR2~ PSR12 compliant.
Would love to see a minimal amount of configuration like Prettier has. For example, I prefer single quotes and others double quotes so an option to convert them would be awesome, the same for leading comma's and adding maybe adding semicolons where they are missing.
@muuvmuuv - I'm not sure if I understand you correctly, but what you are asking for, can be problematic (for example replacing quotes in sql queries in php file). Keep in mind that PSR-2 is coding standard and it's not the same as beautifying.
Honestly, after thinking deeply, I understand the author's point of view PSR-2 is PSR-2 - nothing more, nothing less. If we start to add non standard ideas one by one, then it will stop having a logical sense
I think it's good to keep this ticket open for a while (thanks for keep it open). We'll see what other users will publish here and what they think about it.
If the only configuration you add is disabling the Allman braces, I would be a happy man. K&R (1TBS) style is so prevalent across so many codebases I could see a lot of people preferring this disabled. I want strict adoption at my company, but this one is a deal breaker if I want everyone setup to format on autosave.
(I never understood why Allman was adopted with PSR-2/12 in the first place, it's not even consistent with if/for blocks.)
It would be nice if Intelephense could detect the user setting for HTML files and preserve that for PHP (PHTML) files.
For example, right now intellephense won't let me add newlines between the attributes of a <div>
, and the line length is excessively long. My HTML formatting settings are in force-aligned
witch would give me a nice and optimal style:
<div id="example"
class="isnt-this-more-readable"
data-answer="yes">
</div>
@AeonFr you can put a .jsbeautifyrc
file in your project root and it should obey these settings. Here's an example https://gist.github.com/wzup/fc3254562236c1ec3f69
The Allman braces are a real issue for me too. I think it's not really about whether they are preferable, but rather about that not being able to change it can be an enormous drawback. In my case, I love the intelephense extension, but if it's breaking the conventions in collaborative projects (so that's why it's not about what someone thinks of Allman braces personally), I won't be able to use it much longer. So I would be very grateful if there was any way...
In my case the .jsbeautifyrc
is not working. Put the example in the root but get no results from what I have configured in the config (set indent to 5 for a test). Got this someone to work and could please post his setup somewhere?
The only config option is tabs/spaces and tab size as they are defined by the language server protocol. I'll leave this open but it's unlikely to happen any time soon if at all. The goal for now is to be ~PSR2~ PSR12 compliant.
And for that we already have https://editorconfig.org/ (with its extension on VS Code)
Will be great to have PSR12 on php-cs-fixer so then that could be integrated
@muuvmuuv Did you try setting up the Document Root option on the extension settings? I mean, this one: "intelephense.environment.documentRoot": ""
@d8vjork so this should point to my current workspace? Why do I need to set this?
@muuvmuuv Just thinking maybe that's why the extension doesn't detect the workspace root for check the .jsbeautifyrc file
The only config option is tabs/spaces and tab size as they are defined by the language server protocol.
How do I define whether I want tabs or spaces via intelephpsense formatting?
How do I define whether I want tabs or spaces via intelephpsense formatting?
Intelephense uses editor.tabSize
and editor.insertSpaces
settings.
{
"[php]": {
// tab or space size
"editor.tabSize": 4,
// use spaces or tabs
"editor.insertSpaces": true,
// false to force above for existing files
"editor.detectIndentation": false
},
}
Aha! This was all I needed:
"[php]": {
"editor.detectIndentation": false
},
My editor.tabSize and editor.insertSpaces was already set to true globally
Thanks @KapitanOczywisty 😄
@fakhamatia I think Beautify is the one used by Intelephense (correct me if I'm wrong)
Hi guys, with all due respect, but this is a ticket for one specific issue.
Respect the addon author and stop making a mess which makes it difficult for him to keep issues
If you have another question, you can use stackoverflow
every day, you can, really just try it
Eventually please create another issue
Opened #729 to offer a choice of html formatter.
Braces seems to be one of the main issues with the php formatter. I'd rather not have a config option for braces usage in every possible context. I opened #730 with a proposal for this.
Due to the opening of two separate tickets by @bmewburn (formatter and brackets), I close this ticket (everything in this topic has been said)
Hello Great addon!
I have question about formatter config
I saw that a year ago you wrote that this is not possible, because the goal of the project is minimal configuration.
Has something changed in this topic? Maybe at least some basic configuration ( brackets, spaces/tabs, etc. ) ?