Vetur: Vetur auto formatting not working on .vue files until disabled and then re-enabled in preferences

Created on 16 Oct 2020  路  12Comments  路  Source: vuejs/vetur

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

Info

  • Platform: macOS Catalina
  • Vetur version: 0.28.0
  • VS Code version: 1.50.1

Problem

After launching VSCode, Vetur does not format .vue files until going into vscode preferences > extensions > vetur > toggle Enable/Disable the Vetur document formatter off and then on again. After toggling, it works as expected.
Output from panel, both before and after toggling the mentioned setting so it appears Vetur is loaded when VSCode launches:

Loaded bundled [email protected].
Vetur initialized

Reproducible Case

Unsure how I can reproduce this, but there is at least one other user on the Discord vueland eslint channel who has the same/similar problem.

bug need-more-info

All 12 comments

These steps may help us debug:

  1. Add "vetur.trace.server": "messages" config.
  2. Launching VSCode
  3. open a vue file in project.
  4. copy output from panel.
  5. paste message on it.

Although there's not enough information.
But by reading the code, I think I can see what the problem is.

These steps may help us debug:

  1. Add "vetur.trace.server": "messages" config.
  2. Launching VSCode
  3. open a vue file in project.
  4. copy output from panel.
  5. paste message on it.

Here is the output after adding "vetur.trace.server": "messages" to the config.

[Trace - 1:59:25 PM] Sending request 'initialize - (0)'.
[Trace - 1:59:30 PM] Received notification 'window/logMessage'.
Loaded bundled [email protected].
[Trace - 1:59:30 PM] Received notification 'window/logMessage'.
Vetur initialized
[Trace - 1:59:30 PM] Received response 'initialize - (0)' in 4168ms.
[Trace - 1:59:30 PM] Sending notification 'initialized'.
[Trace - 1:59:30 PM] Sending notification 'workspace/didChangeConfiguration'.
[Trace - 1:59:30 PM] Sending notification 'textDocument/didOpen'.
[Trace - 1:59:30 PM] Sending notification 'textDocument/didOpen'.
[Trace - 1:59:30 PM] Received request 'client/registerCapability - (0)'.
[Trace - 1:59:30 PM] Sending response 'client/registerCapability - (0)'. Processing request took 1ms
[Trace - 1:59:30 PM] Sending request 'textDocument/documentSymbol - (1)'.
[Trace - 1:59:30 PM] Sending request 'textDocument/documentLink - (2)'.
[Trace - 1:59:30 PM] Sending request 'textDocument/documentLink - (3)'.
[Trace - 1:59:30 PM] Sending request 'textDocument/documentColor - (4)'.
[Trace - 1:59:30 PM] Sending request 'textDocument/documentColor - (5)'.
[Trace - 1:59:32 PM] Sending notification '$/cancelRequest'.
[Trace - 1:59:32 PM] Sending request 'textDocument/documentSymbol - (6)'.
[Trace - 1:59:33 PM] Sending notification '$/cancelRequest'.
[Trace - 1:59:33 PM] Sending request 'textDocument/documentSymbol - (7)'.
[Trace - 1:59:34 PM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 1:59:34 PM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 1:59:35 PM] Received response 'textDocument/documentSymbol - (1)' in 4726ms.
[Trace - 1:59:35 PM] Received response 'textDocument/documentLink - (2)' in 4744ms.
[Trace - 1:59:35 PM] Received response 'textDocument/documentLink - (3)' in 4744ms.
[Trace - 1:59:35 PM] Received response 'textDocument/documentColor - (4)' in 4744ms.
[Trace - 1:59:35 PM] Received response 'textDocument/documentColor - (5)' in 4745ms.
[Trace - 1:59:35 PM] Received response 'textDocument/documentSymbol - (6)' in 2431ms.
[Trace - 1:59:35 PM] Received response 'textDocument/documentSymbol - (7)' in 1189ms.

I'm the user mentioned also having this problem, but unfortunately toggling the setting isn't working for me. I'm currently having to run npm run lint frequently...

This problem started for me when I updated VS Code, the release notes indicate they have changed ESLint settings: https://code.visualstudio.com/updates/v1_50#_eslint

Ref: https://github.com/microsoft/vscode/issues/108447#issuecomment-712641584

If anyone can try add this config?

"[vue]": {
     "editor.defaultFormatter": "octref.vetur"
}

It's supposed to solve the problem.

Ref: microsoft/vscode#108447 (comment)

If anyone can try add this config?

"[vue]": {
     "editor.defaultFormatter": "octref.vetur"
}

It's supposed to solve the problem.

Doesn't work for me

@octref The v0.29.0 didn't solve this, I have the same error, how can I give you logs?

@Nisgrak Open a new issue and follow https://github.com/vuejs/vetur/blob/master/.github/NO_REPRO_CASE.md#how-to-create-a-repro-case

@octref The v0.29.0 didn't solve this, I have the same error, how can I give you logs?

I think it is a VSCode bug.
https://github.com/microsoft/vscode/issues/108447

This problem started for me when I updated VS Code, the release notes indicate they have changed ESLint settings: https://code.visualstudio.com/updates/v1_50#_eslint

This wasn't fixed correctly. The format of the registerCapability message is invalid. I'll try to submit PR for this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AnnAngela picture AnnAngela  路  3Comments

shaunc picture shaunc  路  3Comments

gabrielboliveira picture gabrielboliveira  路  3Comments

OsterHuang picture OsterHuang  路  3Comments

deangoku picture deangoku  路  3Comments