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

Missing indentation rules #35

Open
olafurpg opened this issue Jun 19, 2019 · 2 comments
Open

Missing indentation rules #35

olafurpg opened this issue Jun 19, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@olafurpg
Copy link
Contributor

olafurpg commented Jun 19, 2019

Language extensions can provide rules for increasing/decreasing indentation when writing new lines and copy-pasting code. The VS Code documentation for this feature is here https://code.visualstudio.com/updates/v1_14#_auto-indent-on-type-move-lines-and-paste

Some scenarios where the current indentation behavior can be improved, the | marker is the position of the cursor

-- obtained
++ expected

  val x =
- |
+   |

  val x = (n: Int) =>
- |
+   |

  1 match {
    case 1 =>
-   |
+     |

To play around with this feature, the language-configuration.json file needs to be updated with regex rules like this:

{
  "indentationRules": {
    "increaseIndentPattern": "^\\s*((begin|class|def|else|elsif|ensure|for|if|module|rescue|unless|until|when|while)|(.*\\sdo\\b))\\b[^\\{;]*$",
    "decreaseIndentPattern": "^\\s*([}\\]]([,)]?\\s*(#_|$)|\\.[a-zA-Z_]\\w*\\b)|(end|rescue|ensure|else|elsif|when)\\b)"
  }
}

https://github.com/scala/vscode-scala-syntax/blob/5211d13c231498d0ca4480a81e1e9cfa4741875b/language-configuration.json

@olafurpg olafurpg changed the title No indentation rules Missing indentation rules Jun 19, 2019
@olafurpg
Copy link
Contributor Author

A workaround to improve the current copy-paste behavior by a tiny bit is to disable the "auto indent" setting in VS Code

Screenshot 2019-06-19 at 18 07 49

@nicolasstucki
Copy link
Contributor

@odersky this feature might be interesting for the new syntax

@nicolasstucki nicolasstucki added the enhancement New feature or request label Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants