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

[Question] Is there any solutions to wrap attributes only when wrap automatic? #3587

Closed
s3xysteak opened this issue Sep 24, 2023 · 4 comments
Labels
question Further information is requested

Comments

@s3xysteak
Copy link

now:

<ExampleComponent class="test" @click="handleClick" :data="data"/>

request to be:

<ExampleComponent class="test" @click="handleClick" :data="data"/>

No need to wrap attributes when the code is not long enough to wrap automatic.

now:

<ExampleComponent class="test" @click="handleClick" :data="data" :data-source="dataSource" :loading="onLoading" :attr1="attr1" :attr2="attr2" />

request to be:

<ExampleComponent 
    class="test" 
    @click="handleClick"
    :data="data" 
   :data-source="dataSource"
    :loading="onLoading"
    :attr1="attr1"
    :attr2="attr2" 
   />

Wrap attributes when the code is long enough to wrap automatic.

@meguoe
Copy link

meguoe commented Oct 8, 2023

配合prettier使用

@so1ve
Copy link
Member

so1ve commented Oct 8, 2023

#1078 Volar now uses vscode-html-languageservice, which doesn't automatically wrap these attributes. Please use prettier if you want to wrap them.

@so1ve so1ve closed this as completed Oct 8, 2023
@so1ve so1ve added the question Further information is requested label Oct 8, 2023
@s3xysteak
Copy link
Author

#1078 Volar now uses vscode-html-languageservice, which doesn't automatically wrap these attributes. Please use prettier if you want to wrap them.

Could I format code in <template></template> by Prettier, but still use Volar to formatter other code? I really love the style of Volar.
I tried it in VsCode. Here is my setting.json

  "[vue]": {
    "editor.defaultFormatter": "Vue.volar"
  },
  "[html]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },

But it does not work. It seems to only work on the file with the .html suffix.

@so1ve
Copy link
Member

so1ve commented Oct 20, 2023

This currently impossible, but you can open a feature request for it (although I'm not sure if it's a good idea).

BTW could you please try https://github.com/volarjs/services/tree/master/packages/prettier?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants