metals
metals copied to clipboard
Formatting (i.e. using Scalafmt) is unnecessarily slow
Describe the bug
When using VSCode and doing the textDocument/formatting task, it is very slow on our large codebase. It should be super fast as it is when we run scalafmt from commandline.
Doing some investigation, it seems the issue lies on this call where the code is trying to obtain the projectRoot path, but it does a whole lot of (seemingly unecessary) processing like reading the database and determine builtools. In particular, it appears to perform the buildtool.digest() which is pretty slow on our large codebase. https://github.com/scalameta/metals/blob/b9b8c5b991f053cf54a00ef9a476570987290650/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala#L1070
Expected behavior
It seems like the projectRoot (and build tools) should have already been figured out and don't need to be recalculated during a Format routine.
Hopefully this can be fixed soon so we can have super fast formatting.
Operating system
Windows
Editor/Extension
VS Code
Version of Metals
v1.2.2
Extra context or search terms
No response