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

Vetur html format does not work with prettier-vscode > 1.0.1 #338

Closed
ericcirone opened this issue Jan 18, 2018 · 17 comments
Closed

Vetur html format does not work with prettier-vscode > 1.0.1 #338

ericcirone opened this issue Jan 18, 2018 · 17 comments
Labels
locked Please open a new issue and fill out the template instead of commenting.

Comments

@ericcirone
Copy link

All versions past 1.0.1 will not work with Vetur when setting Vetur to format html with js-beautify-html. Installing version 1.0.1 of prettier-vscode fixes this issue. Not sure if its a prettier-vscode issue or a Vetur issue.

Vetur issue here is: vuejs/vetur#658

@CiGit
Copy link
Member

CiGit commented Jan 18, 2018

Since prettier-vscode@1.1 we register a "vue" formatter for that language. The one provided by prettier. You can disable it with prettier.disableLanguages: ["vue"] and restart vscode

Currently prettier for vue does not format the template part of your vue SFC

@octref
Copy link

octref commented Jan 19, 2018

I suggest opt-in instead of opt-out for users to use prettier-vscode as formatter for Vue files.

Prettier's support for Vue is still very sparse: vuejs/vetur#658 (comment)

I do plan to help contribute to prettier for better Vue support. But at its current state I don't think it should be set as default formatter for Vue.

@azz
Copy link
Member

azz commented Jan 20, 2018

Any way we can do it dynamically, i.e. If vetur is installed and running, don't register the vue language?

@azz
Copy link
Member

azz commented Jan 20, 2018

@octref We'd love your help in improving Prettier's Vue support. Getting HTML support in Prettier completed is something that we've been super slow with.

@octref
Copy link

octref commented Jan 22, 2018

Any way we can do it dynamically, i.e. If vetur is installed and running, don't register the vue language?

Yes with vscode.extensions.getExtension('octref.vetur')

Getting HTML support in Prettier completed is something that we've been super slow with.

OK I'll start looking into it

@azz
Copy link
Member

azz commented Jan 22, 2018

Yes with vscode.extensions.getExtension('octref.vetur')

This sounds like the best avenue to me then, if someone is using this extension without vetur it will work as expected, and if they're using both they'll get vetur's formatting which is more feature-rich at the moment.

OK I'll start looking into it

❤️

@CiGit
Copy link
Member

CiGit commented Jan 25, 2018

Yes with vscode.extensions.getExtension('octref.vetur')

I'm not sure this is the best solution. If someone wanted to try prettier on vue files (for whatever reason), it would be hard to enable it. You would have to uninstall/disable vetur and install any other extension providing vue grammar (or at lease file association) to be able to use prettier.

I think we can simply disable it by default. Changing 1 option / reload seems easier to me. Maybe disable vetur's formatter if this is possible -> 2 options. This is maybe not easier, but certainly more common.

@octref
Copy link

octref commented Jan 25, 2018

Yeah, I agree having prettier.disableLanguages: ["vue"] seems to be better for now. Later when prettier has html formatter we can look into how we might collaborate.

Another quite popular need is to have initial indentation for style/script sections, but I don't know if that's something prettier wants to add.

@azz
Copy link
Member

azz commented Jan 27, 2018

If someone wanted to try prettier on vue files (for whatever reason), it would be hard to enable it.

vetur already runs Prettier, so you only need to use one extension at a time - I'm not sure I see the reasoning here.

@CiGit
Copy link
Member

CiGit commented Jan 27, 2018

If I understood vetur correctly, it doesn't run prettier in "vue" mode.
It splits SFC and sends each supported section to prettier

@azz
Copy link
Member

azz commented Jan 27, 2018

That's basically what Prettier 1.10 does anyway. They should be functionally identical with the exception of vetur handing the html to a different formatter.

@octref
Copy link

octref commented Jan 27, 2018

It also does a bunch of other things, some of which I don’t think it would make sense to add to prettier
vuejs/vetur#658 (comment)

@azz
Copy link
Member

azz commented Jan 27, 2018

Stylus is the only other lang missing? Doesn't seem unreasonable to make a prettier plugin for Stylus.

@octref
Copy link

octref commented Jan 28, 2018

Allow choice among multiple formatters might not be what prettier want to do. Many people prefer the TS formatter from TS language service instead of prettier's.

Another is initial indentation, like so

<script>
  // indent here
</script>
<style>
  // indent here
</style>

The community is half-half on this style choice, but I doubt adding Vue specific options here would be beneficial to prettier since it seems to be against prettier's philosophy.

@samburgers
Copy link

this comment got my .vue files formatting top to bottom in VSCode

vuejs/vetur#543 (comment)

@CiGit
Copy link
Member

CiGit commented Feb 15, 2018

"vue" is now disabled by default

@CiGit CiGit closed this as completed Feb 15, 2018
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot added the locked Please open a new issue and fill out the template instead of commenting. label Apr 13, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

5 participants