This is a Visual Studio Code extension with a language server that formats Scala source code. It uses Scalafmt (https://github.com/scalameta/scalafmt.git) to format the code directly from the editor. It can format code written for Dotty compiler including newly added Enum.
This projet was part of the semester project done during Computer science Bachelor by Samuel Chassot at EPFL.
This repository uses some submodules so clone it using the --recursive option or update them afterwards:
git clone --recursive git@github.com:samuelchassot/vscode-scala-formatter
or if already cloned:
git submodule update --init --recursive
First you need to publish locally Scalameta and Scalafmt. To do so just run the two following commands in this specific order:
cd trees && sbt publishLocal && cd ..
cd scalafmt && sbt publishLocal && cd ..
- Run the following command at the root of the project:
cd languageServer && sbt 'set assemblyOutputPath in assembly := new File("../vscode-extension-scala-formatter/server/languageServer-assembly.jar")' assembly && cd ..
- If you change the filename be sure to change it in the code in vscode-extension-scala-formatter/client/src/extension.ts
- Then run the following command:
cd vscode-extension-scala-formatter && vsce package
it will generate the .vsix file in vscode-extension-scala-formatter/ .See next section for installation instructions.
If the vsce
command is not available, install it using the following command:
npm install -g vsce
Run the following command in the folder where there is the .vsix file:
code --install-extension scala-formatter-x.x.x.vsix
replacing the x.x.x
by the version of the .vsix file.
You can also install it from Visual Studio Code:
- Go in the extensions tab
- Click on the 3 dots
- Install from vsix
- Select the .vsix you downloaded or built