I'm using nvim for Flutter development. From time to time, if I save a file with compilation errors, then the emulator still hotloads it and my PC hangs.
I use a custom key mapping to save my files. I'd like that to call a function which checks that (pseudo code)
if lua vim.lsp.diagnostic.get_count() > 0 echo an error, else do the save