Skip to content

vscode-dotty: Improve auto-indentation #7278

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

Merged
merged 4 commits into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ object Build {
lazy val `vscode-dotty` = project.in(file("vscode-dotty")).
settings(commonSettings).
settings(
version := "0.1.16-snapshot", // Keep in sync with package.json
version := "0.1.17-snapshot", // Keep in sync with package.json
autoScalaLibrary := false,
publishArtifact := false,
includeFilter in unmanagedSources := NothingFilter | "*.ts" | "**.json",
Expand Down
2 changes: 1 addition & 1 deletion vscode-dotty/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vscode-dotty/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dotty",
"displayName": "Dotty Language Server",
"description": "IDE integration for Dotty, the experimental Scala compiler",
"version": "0.1.16-snapshot",
"version": "0.1.17-snapshot",
"license": "BSD-3-Clause",
"publisher": "lampepfl",
"repository": {
Expand Down
13 changes: 8 additions & 5 deletions vscode-dotty/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@ export function activate(context: ExtensionContext) {
// package.json does not work)
vscode.languages.setLanguageConfiguration("scala", {
"indentationRules": {
// Auto-indent when pressing enter on a line matching this regexp
"increaseIndentPattern": /(((\b(then|else|do|catch|finally|yield|match|while|try|for|if|case)\b)|\bif\s*\(.*\)|=|=>|<-|=>>)\s*$)/,
// Auto-unindent disabled, because it doesn't work well with all
// indentation styles
"decreaseIndentPattern": /^.$/
// Auto-indent when pressing enter on a line matching this regexp, in details:
// 1. If they're not preceded by `end`, auto-indent after `while`, `for`, `match`, `try`, `if`
// 2. Auto-indent after `if ...` as long as it doesn't match `if ... then ...`
// 3. Auto-indent after `then`, `else`, `do`, `catch`, `finally`, `yield`, `case`, `=`, `=>`, `<-`, `=>>`x
"increaseIndentPattern":
/(((?<!\bend\b\s*?)\b(if|while|for|match|try))|(\bif\s+(?!.*?\bthen\b.*?$)[^\s]*?)|(\b(then|else|do|catch|finally|yield|case))|=|=>|<-|=>>)\s*?$/,
// Only auto-unindent completed `end` folowed by `while`, `for`, `match`, `try`, `if`
"decreaseIndentPattern": /(^\s*end\b\s*)\b(if|while|for|match|try)$/
}
})

Expand Down