-
Notifications
You must be signed in to change notification settings - Fork 25.5k
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
Angular 17: visual studio code doesn't format control flow #52720
Comments
Formatting is not controlled by our extension. Closing as out of scope. The Prettier teams is working on formatting with control flow in Angular. |
Reopening until investigation into exploration of a language contribution for the extension is complete. language configuration allows for defining indentation rules https://code.visualstudio.com/api/language-extensions/language-configuration-guide#indentation-rules |
Closing again. Contributing a language does not affect the formatting command, which is controlled by the formatting provider. This is out of scope for our extension. That said, we have been in contact with Prettier to support them in making this work in their extension. |
Hello, this is a bit gibberish to me :-) I'm using vscode without any specific extension for formatting HTML template of Angular. |
You need to install the extension and use its formatter ! |
Prettier is a formatting library that has extensions for various editors. You can find the one for VSCode here. |
Then I guess I'm missing something. I don't have this extension installed, however, everything works as expected in vscode (except control flow). This issue is about control flow formatting in vscode and the given solution is to install an extension. According to me, it does not answer the original question. Who is responsible to implement control flow in vscode without using Prettier then? vscode itself then? (I'm not saying it's not a good solution, I'm just trying to understand who is responsible for what :-)) |
VScode has a default formatter for several filetypes. The new control flow syntax introduces a new flavor that VSCode isn't able to "prettity". So it will format it as standard HTML. This is why prettier is important here, because it provide a formatter that is able to pretity HTML which has the new control flow syntax. |
Ok now it makes sense to me :-) Thanks for the explanation. |
A slight correction to what @JeanMeche said - formatting is controlled by extensions which register as formatting providers. VSCode ships with a built-in "HTML Language Features" extension. If you disable that (and any other formatting extensions you might have in addition to that one) and try to format an HTML document, it will not work. Getting into the formatting game is out of scope for the Angular extension at the moment. We could consider adding prettier as a dependency to our extension, registering ours as a formatting provider for HTML, and delegating to prettier (see extensionDependencies here). |
Unfortunately prettier has a TON of extra html formatting rules which, to me, are garbage. We just want default vscode html formatting + angular control flow, and I don't want to spend hours configuring prettier to ignore 90% of it's rules just so we can get indentation on |
Exact same situation here. I don't like prettier but then I guess an issue should be created on the vscode GitHub repo, but I fear they'll say that they can implement that as it is not standard html. |
VSCode uses the |
Still seems to be no indentations, but after using the new control flow for a while, I've got used to it and I think it's much better without indents. Adding more tabs would just add unnecessary pyramidization because the control flow @-operators are very easy to spot anyway, as they are highlighted with different color :) |
Then I guess you never used an "if" in a "for" and ended up with something like
Wondering what is what ^^ |
Hi, pretty late in the perty.. I have noticed that Vscode doesn't highlight the new syntax. |
Did, and yeah that's ugly. Also |
when using prettier, update your prettierrc file
|
Couldn't make this work. |
Any working solutions? It has been a while |
@tsenguunchik see here the open issue mentioned by @gergely-gyorgy-both |
This comment was marked as off-topic.
This comment was marked as off-topic.
There's gotta be a more flexible solution for this. When the cyclomatic complexity starts growing, the template becomes unreadable. The lack of proper formatting is holding this great new feature back... |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Which @angular/* package(s) are the source of the bug?
language-service
Is this a regression?
No
Description
In visual studio code 1.84.1 with Angular Extension at version 17.0.0, indenting control flow like this:
after document format become
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: