diff --git a/modules/editor/vim/lua/plugins/lsp.lua b/modules/editor/vim/lua/plugins/lsp.lua index 2b8af8a..0d1643d 100644 --- a/modules/editor/vim/lua/plugins/lsp.lua +++ b/modules/editor/vim/lua/plugins/lsp.lua @@ -1,4 +1,15 @@ return { + recommended = function() + return LazyVim.extras.wants({ + ft = "scala", + root = { "build.sbt", "build.mill", "build.sc", "build.gradle", "pom.xml" }, + }) + end, + { + "scalameta/nvim-metals", + ft = { "scala", "sbt", "mill" }, + config = function() end, + }, { "neovim/nvim-lspconfig", opts = { @@ -12,6 +23,23 @@ return { cmd = { "elixir-ls" }, }, }, + setup = { + metals = function(_, opts) + local metals = require("metals") + local metals_config = vim.tbl_deep_extend("force", metals.bare_config(), opts) + metals_config.on_attach = LazyVim.has("nvim-dap") and metals.setup_dap or nil + + local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true }) + vim.api.nvim_create_autocmd("FileType", { + pattern = { "scala", "sbt", "mill" }, + callback = function() + metals.initialize_or_attach(metals_config) + end, + group = nvim_metals_group, + }) + return true + end, + }, }, }, }