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 auto formatting not working on .vue files until disabled and then re-enabled in preferences #2388

Closed
gorbypark opened this issue Oct 16, 2020 · 13 comments · Fixed by #2389 or #2436

Comments

@gorbypark
Copy link

  • [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 typescript@4.0.2.
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.

@yoyo930021 yoyo930021 added the bug label Oct 16, 2020
@yoyo930021
Copy link
Member

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.

@yoyo930021
Copy link
Member

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

yoyo930021 added a commit to yoyo930021/vuter that referenced this issue Oct 16, 2020
yoyo930021 added a commit to yoyo930021/vuter that referenced this issue Oct 16, 2020
@gorbypark
Copy link
Author

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 typescript@4.0.2.
[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.

@lloydjatkinson
Copy link

lloydjatkinson commented Oct 16, 2020

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

@yoyo930021
Copy link
Member

Not sure if it is relevant
microsoft/vscode#108447

@yoyo930021
Copy link
Member

Ref: microsoft/vscode#108447 (comment)

If anyone can try add this config?

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

It's supposed to solve the problem.

@Nisgrak
Copy link

Nisgrak commented Oct 26, 2020

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 pushed a commit to yoyo930021/vuter that referenced this issue Oct 30, 2020
octref added a commit that referenced this issue Oct 30, 2020
@Nisgrak
Copy link

Nisgrak commented Nov 2, 2020

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

@octref
Copy link
Member

octref commented Nov 2, 2020

@yoyo930021
Copy link
Member

@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.
microsoft/vscode#108447

@lloydjatkinson
Copy link

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

@rchl rchl reopened this Nov 5, 2020
@rchl
Copy link
Collaborator

rchl commented Nov 5, 2020

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

rchl added a commit to rchl/vetur that referenced this issue Nov 5, 2020
The documentSelector is a list of DocumentFilter and can not contain
a string as that is invalid per the LSP spec [1].

The types provided by https://github.com/microsoft/vscode-languageserver-node
are wrong: microsoft/vscode-languageserver-node#685

It would be an option to send registrationOptions in proper format but
it's not necessary to specify the documentSelector since vetur only runs
in vue files. So skipping it entirely is equivalent.

[1] https://microsoft.github.io/language-server-protocol/specification#documentFilter

Resolves vuejs#2388
rchl added a commit to rchl/vetur that referenced this issue Nov 5, 2020
Per current version of the spec [1], the "documentSelector" is a list of
DocumentFilter and can not contain a string.

It seems like it was allowed to have a string in the past [2] but it's
no longer the case and it doesn't work even in VSCode.

[1] https://microsoft.github.io/language-server-protocol/specification#documentFilter
[2] microsoft/vscode-languageserver-node#685

Resolves vuejs#2388
octref pushed a commit to rchl/vetur that referenced this issue Nov 6, 2020
Per current version of the spec [1], the "documentSelector" is a list of
DocumentFilter and can not contain a string.

It seems like it was allowed to have a string in the past [2] but it's
no longer the case and it doesn't work even in VSCode.

[1] https://microsoft.github.io/language-server-protocol/specification#documentFilter
[2] microsoft/vscode-languageserver-node#685

Resolves vuejs#2388
@trixie88
Copy link

Settings -> Text Editor -> Formatting -> Check "Format on Save".
After latest update this got unchecked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants