only use nvim-metals plugin to config metal

from nvim-metals README.md: NOTE: This plugin works without needing to
install neovim/nvim-lspconfig. If you have it installed for other
languages, that's not a problem, but make sure you do not have Metals
configured through nvim-lspconfig while using this plugin
This commit is contained in:
Watson Dinh 2025-03-04 13:35:58 -06:00
parent ec5981dfb1
commit e510a4a2ce

View file

@ -11,66 +11,70 @@ return {
},
{
"scalameta/nvim-metals",
ft = { "scala", "sbt" },
config = function() end,
},
{
"neovim/nvim-lspconfig",
opts = {
servers = {
metals = {
keys = {
{
"<leader>me",
function()
require("telescope").extensions.metals.commands()
end,
desc = "Metals commands",
},
{
"<leader>mc",
function()
require("metals").compile_cascade()
end,
desc = "Metals compile cascade",
},
{
"<leader>mh",
function()
require("metals").hover_worksheet()
end,
desc = "Metals hover worksheet",
},
},
init_options = {
statusBarProvider = "off",
},
settings = {
showImplicitArguments = true,
excludedPackages = { "akka.actor.typed.javadsl", "com.github.swagger.akka.javadsl" },
},
},
},
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" },
callback = function()
metals.initialize_or_attach(metals_config)
end,
group = nvim_metals_group,
})
return true
dependencies = {
"nvim-lua/plenary.nvim",
},
keys = {
{
"<leader>me",
function()
require("telescope").extensions.metals.commands()
end,
desc = "Metals commands",
},
{
"<leader>mc",
function()
require("metals").compile_cascade()
end,
desc = "Metals compile cascade",
},
{
"<leader>mh",
function()
require("metals").hover_worksheet()
end,
desc = "Metals hover worksheet",
},
},
},
ft = { "scala", "sbt", "java" },
opts = function()
local metals_config = require("metals").bare_config()
metals_config.init_options.statusBarProvider = "off"
metals_config.settings = {
verboseCompilation = true,
showImplicitArguments = true,
showImplicitConversionsAndClasses = true,
showInferredType = true,
superMethodLensesEnabled = true,
excludedPackages = {
"akka.actor.typed.javadsl",
"org.apache.pekko.actor.typed.javadsl",
"com.github.swagger.akka.javadsl",
},
testUserInterface = "Test Explorer",
}
metals_config.on_attach = function(client, bufnr)
-- your on_attach function
require("metals").setup_dap()
end
return metals_config
end,
config = function(self, metals_config)
local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
pattern = self.ft,
callback = function()
require("metals").initialize_or_attach(metals_config)
end,
group = nvim_metals_group,
})
end,
},
{
"mfussenegger/nvim-dap",
optional = true,