From 408111c60c5f5e02d582e0453d2e07d31b83b558 Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Thu, 19 Sep 2024 13:39:29 -0400 Subject: [PATCH] refactor(scala): use new `patch_func` helper function --- lua/astrocommunity/pack/scala/init.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lua/astrocommunity/pack/scala/init.lua b/lua/astrocommunity/pack/scala/init.lua index 44675c03e..84e94d2dd 100644 --- a/lua/astrocommunity/pack/scala/init.lua +++ b/lua/astrocommunity/pack/scala/init.lua @@ -23,17 +23,16 @@ return { }, }, opts = function() - local metals = require "metals" + local metals, astrocore = require "metals", require "astrocore" local astrolsp_avail, astrolsp = pcall(require, "astrolsp") local user_config = astrolsp_avail and astrolsp.lsp_opts "metals" or {} - if require("astrocore").is_available "nvim-dap" then - local on_attach = user_config.on_attach - user_config.on_attach = function(...) - if type(on_attach) == "function" then on_attach(...) end + if astrocore.is_available "nvim-dap" then + user_config.on_attach = astrocore.patch_func(user_config.on_attach, function(orig, ...) + orig(...) metals.setup_dap() - end + end) end - return require("astrocore").extend_tbl(metals.bare_config(), user_config) + return astrocore.extend_tbl(metals.bare_config(), user_config) end, config = function(self, opts) vim.api.nvim_create_autocmd("FileType", {