question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change built-in HTML formatter from `prettyhtml` to `vscode-html-languageservice`

See original GitHub issue

In past I have chosen prettyhtml for Volar after comparing some HTML formatters, prettyhtml has always worked fine, but for some reasons I decided to replace the built-in HTML formatter with vscode-html-languageservice in 0.34.0.

  • It has only a few known bugs but the repo is not longer maintained so we can’t expect bugs to be fixed.
  • It is not supported for Namespace Components.
  • vscode-html-languageservice format result has been improved, much better than in the past in my experience.
  • vscode-html-languageservice is a built-in dependency of volar, so we don’t to add other dependencies for this change.
  • With vscode-html-languageservice volar can reuse vscode HTML format settings as much as possible.
  • prettyhtml depends on prettier, and prettier does not support on browser, so for Web IDE support I need to use solution other than prettyhtml.

prettyhtml will be migrated to an external plugin (#1027) and I will publish a package for it, for projects wishing to keep using prettyhtml, I will show how to do this. (Please keep an eye on the 0.34.0 changelog)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
johnsoncodehkcommented, Mar 20, 2022

@reslear The text edit range of prettyhtmlreturn is the entire html text, while the text edit range of vscode-html-languageservicereturn is only the actual changed range. In theory, the performance of vscode apply text edits will be improved after switching to vscode-html-languageservice.

But since volar finally merges all text edits into one text edit of the entire vue text, it cannot take advantage of this, maybe it can be improved in the future.

0reactions
Dazaercommented, Apr 16, 2022

@Dazaer see #1174.

Thanks! However that would be using prettier-html. I thought the point of this change was for us to use vscode-html-languageservice instead? If possible I’d like to use what’s built in but be able to configure it like before.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML Programming with Visual Studio Code
To improve the formatting of your HTML source code, you can use the Format Document command Ctrl+Shift+I to format the entire file or...
Read more >
Prettier not formatting HTML files in VS Code - Stack Overflow
Set the formatter in dropdown (esbenp.prettier-vscode) for prettier. this can change if you are using any other formatter. Share.
Read more >
VS Code Extensions for HTML | CSS-Tricks
Let's look at some extensions for VS Code that make writing and editing HTML (and languages that are basically HTML with extra powers) ......
Read more >
VS Code - You don't need a formatting ... - Rob O'Leary
You can use the built-in formatters for a number of languages. ... VS Code has builtin formatters for HTML, JavaScript, TypeScript, ...
Read more >
awesome-vscode | A curated list of delightful VS Code ...
Runs before the save action so you can still have a PHP formatter. Format HTML in PHP. Composer · PHP Debug - XDebug...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found