diff --git a/lua/astrocommunity/pack/scala/init.lua b/lua/astrocommunity/pack/scala/init.lua index 9d68e7baa..03276c914 100644 --- a/lua/astrocommunity/pack/scala/init.lua +++ b/lua/astrocommunity/pack/scala/init.lua @@ -38,7 +38,12 @@ return { pattern = self.ft, group = vim.api.nvim_create_augroup("nvim-metals", { clear = true }), desc = "Initialize and attach nvim-metals", - callback = function() require("metals").initialize_or_attach(opts) end, + callback = function(args) + if not vim.b[args.buf].metals_initialized then + require("metals").initialize_or_attach(opts) + vim.b[args.buf].metals_initialized = true + end + end, }) end, },