Vetur: Please leave alone line wrapping

Created on 1 Feb 2018  路  12Comments  路  Source: vuejs/vetur

  • [x] I have searched through existing issues
  • [x] I have read through docs
  • [x] I have read FAQ

Info

  • Platform: Linux
  • Vetur version: 0.11.7
  • VS Code version: 1.19.2

Problem

VS code already has settings for line wrapping, and those work fine:

    "editor.wordWrap": "wordWrapColumn",
    "editor.wordWrapColumn": 120,

When vetur is enabled, it wraps lines around column 80. Please, let VS code handle that. Focus on areas not handled by VS code.

Reproducible Case

            if (typeof ar.applicability === "object" && ar.applicability) {
              if (typeof ar.applicability.when === "object" && ar.applicability.when) {
                if (typeof ar.applicability.when.months_since_last === "number" 
                && moment().diff(al.done_date, "months")  > ar.applicability.when.months_since_last) {
                  l("ar.applicability.when.months_since_last2", ar.applicability.when.months_since_last,
                    moment().diff(al.done_date, "months")
                  )
                }
              }
            }

question

Most helpful comment

@SandyGifford Please give a repro by forking https://github.com/octref/veturpack.

format

All 12 comments

Vetur uses prettier for <script> section, so you need to set its printWidth accordingly.

However, It doesn't seem to follow my "printWidth" under vscode's extension settings. I tested by setting it to 30, which affects all .js file but none of the .vue files.

Yeah, this issue should not have been closed so quickly. The provided solution does not fix it at all.

from my config

    "vetur.format.defaultFormatterOptions": {
        "prettier": {
            "tabWidth": 4,    // works
            "printWidth": 400 // does not work
        }
    },

Yeah - it doesn't seem to make a difference. I've tried both in .prettierrc and in the VSCode settings file.

@SandyGifford Please give a repro by forking https://github.com/octref/veturpack.

format

I have the same issue.

Having the same issue. I have code like this:

watch(() => Screen.width, () => setMiniState(undefined))

That gets formatted to this:

watch(
   () => Screen.width,
   () => setMiniState(undefined)
)

Even when adding printWidth to .prettierrc.js:

module.exports = {
    singleQuote: true,
    semi: false,
    trailingComma: "es5",
    arrowParens: "always",
    printWidth: 120
}

Although I know that the settings from the .prettierrc.js file are respected. Because semicolons are added/removed based on these settings. So I would expect Vetur to respect the printWidth line too.

I have the same ISSUE. This is such a weird and ugly behavior.

Please provide reproducible case and open a new issue.
https://github.com/vuejs/vetur/blob/master/.github/NO_REPRO_CASE.md

I'd like to thank this issue page and contributors here. I needed this:

"vetur.format.defaultFormatterOptions": {
        "prettier": {
            "tabWidth": 4,    // works
            "printWidth": 100 // does not work
        }
    },

I had an issue where Vetur would format in a way that it combines 2-6 lines into one line and that would cause me the max-len error of eslint. After setting the printWidth to 100 or less, everything becomes simple to solve eslint errors. Vetur will not deny Insertion of new lines any more upon formatting.
(I actually like to format my codes)

"vetur.format.defaultFormatterOptions": {
    "js-beautify-html": {
      "wrap_attributes": "auto"
    },
    "prettyhtml": {
      "wrapAttributes": false,
      "printWidth": 80
    },
    "prettier": {
      "semi": false,
      "singleQuote": true,
      "eslintIntegration": true,
      "trailingComma": "none",
      "printWidth": 80
    }
  },
Was this page helpful?
0 / 5 - 0 ratings

Related issues

octref picture octref  路  3Comments

shaunc picture shaunc  路  3Comments

gabrielboliveira picture gabrielboliveira  路  3Comments

yoyoys picture yoyoys  路  3Comments

Dealerpriest picture Dealerpriest  路  3Comments