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

Auto indent does not work #1067

Open
tsewaiho opened this issue Jan 20, 2019 · 3 comments
Open

Auto indent does not work #1067

tsewaiho opened this issue Jan 20, 2019 · 3 comments
Labels
bug help-wanted language-config https://code.visualstudio.com/api/language-extensions/language-configuration-guide

Comments

@tsewaiho
Copy link

Info

  • Platform: Windows and Linux
  • Vetur version: 0.14.5
  • VS Code version: 1.30.2

Problem

Auto indent does not work. I googled about this issue for many times, but I cannot find a solution, can't even find a discussion about this issue.

Reproducible Case

copy
1

result
2

Description

I thought auto indent should work out of the box but it bothered me for long time.

Currently, I am relying on formatOnSave to correct the indentation.

Discovery

  1. Atom does not have this issue. Sublime works a little bit tricky, it's auto indent is run 1 second after paste, but at least it is correct.
  2. If I manually change the language mode from Vue to HTML on VSCode, auto indent works.
    3
  3. I guess that auto indent is implement by something like that. But I cannot find one in Vetur source code.
	languages.setLanguageConfiguration('html', {
		indentationRules: {
			increaseIndentPattern: /<(?!\?|(?:area|base|br|col|frame|hr|html|img|input|link|meta|param)\b|[^>]*\/>)([-_\.A-Za-z0-9]+)(?=\s|>)\b[^>]*>(?!.*<\/\1>)|<!--(?!.*-->)|\{[^}"']*$/,
			decreaseIndentPattern: /^\s*(<\/(?!html)[-_\.A-Za-z0-9]+\b[^>]*>|-->|\})/
		},
@octref octref added language-config https://code.visualstudio.com/api/language-extensions/language-configuration-guide bug labels Mar 14, 2019
@herrernst
Copy link

It would be nice if auto indent on paste would work out of the box.

@simongcc
Copy link

Would like to know if Auto Indent by moving up and down the code belongs to feature requests?
When I switch the doc type to HTML, Javascript, CSS/SCSS, the move up and down of the code will be indented automatically. Does it a feature belongs to extension of builtin nature of vscode?

What could we help to implement or enhance Vetur?
Many thanks.

@yoyo930021
Copy link
Member

yoyo930021 commented Nov 19, 2020

If anyone can help, we welcome any PR.
I have briefly researched this issue.
The above setting is difficult for us to use in multiple languages in one file.

This link may also be helpful.
https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/#textDocument_onTypeFormatting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help-wanted language-config https://code.visualstudio.com/api/language-extensions/language-configuration-guide
Projects
None yet
Development

No branches or pull requests

5 participants