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

Ability to turn off on-save compilation #278

Open
mikkka opened this issue Jun 9, 2022 · 11 comments
Open

Ability to turn off on-save compilation #278

mikkka opened this issue Jun 9, 2022 · 11 comments

Comments

@mikkka
Copy link

mikkka commented Jun 9, 2022

Is your feature request related to a problem? Please describe.

if I have big project and do refactoring, for example type moving this ends in infinite compilation turns in metals, and takes very long time. It would be great if I could do all my changes, save all files, and then request compilation.

Describe the solution you'd like

Command or option to turn off and on auto-compilation.

Describe alternatives you've considered

go to IntelliJ maybe, it can compile on demand through SBT

Additional contex

No response

Search terms

autosave, disable, compile, source, scan

@tgodzik
Copy link
Contributor

tgodzik commented Jun 10, 2022

Thanks for reporting! The compilation only occurs after you save the files, so an alternative would be to keep the changes unsaved until you are sure you want to compile them.

Getting a usability of this feature request might be a bit tricky.

@laughedelic
Copy link
Member

Would it be possible to add a command to "Disconnect from the build server" and some indicator of wher Metals is connected to a build server or not? Then the user can reconnect using an existing command.

@armanbilge
Copy link

Yes, apologies if it already exists, but I would appreciate a way to "turn off" metals sometimes.

@sjorn3
Copy link

sjorn3 commented May 2, 2024

Hey I'd appreciate this too and would like to add a motivating example.

Our codebase takes 25 minutes to compile from scratch. That's something we're working on but it probably won't get better overnight or anything and I don't think it will ever be super quick.

I have to be very careful whenever doing certain actions to try and prevent it from full recompiling, or I'm out another 25 minutes. In particular if I rebase on master and have a conflict partway through, metals will start recompiling things that would not have needed to be recompiled if the rebase had been successful, and then when the rebase is finished it has to compile it again. If I could temporarily disable the build server for the duration of a rebase, there would be significantly less compile time.

In my particular case I prefer to start the build server manually in a terminal and have metals connect to it. But if I disable that build server metals will just spin up another one. So actually a toggle to simply disable automatic build server generation would be sufficient to fix my issue.

My current solution means fully closing vscode and using some other tool to fix merge conflicts when they are sufficiently large that I start running into this issue.

Metals does have a "disconnect from build server without restarting" option, but this doesn't seem to do anything, possibly a bug?

Thanks,

Sean.

@vladimir-popov
Copy link

Any updates? I had to switch back to IDEA because I love using Neovim's autosave mode, but it causes 100% CPU load when paired with Metals. It would be great if there were an option to run compilation manually through Metals instead of it happening automatically.

@tgodzik
Copy link
Contributor

tgodzik commented Nov 14, 2024

Normally, compile happens on save, so if you turn off the autosave option you can get close to what you need.

Do you have an idea what gets recompiled that causes the CPU usage? Maybe we could optimize that too?

@vladimir-popov
Copy link

Honestly, I don't want to disable autosave because, for me, it represents a bigger shift in my workflow than switching to IDEA. Additionally, I prefer a manual compilation approach when working with Zig, as its LSP server is quite basic, and I like using Vim's compiler feature to collect diagnostics. I'd be happy to adopt the same approach for Scala (manually running compilation, I mean).

Regarding compilation, I'm working with a large monorepo on my work, and making changes to any projects near the root of the project hierarchy results in an extremely heavy compilation process.

@tgodzik
Copy link
Contributor

tgodzik commented Nov 14, 2024

By default we should not recompile downstream projects only the current one. There might be a bug in that logic then 🤔

We do try to recompile downstream projects if we know that they have errors which might be fixed the changes.

There is also this issues: scalameta/metals#6782 <- it might help especially in large projects

@vladimir-popov
Copy link

Thanks for sharing a related issue! But anyway, ability to run compilation manually may give us more control on resource consumption and save battery even in simple projects. Moreover, as was mentioned by @sjorn3 resolving merge conflict is one more reason to pause compilation.

@tgodzik
Copy link
Contributor

tgodzik commented Nov 14, 2024

Anyway, I might be able to work on it soon, but the change should simple enough. We can add a user setting to enable manual compilation on save and then ignore it in here

@vladimir-popov
Copy link

sounds awesome! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants