LazyVim.LazyVim/lua/lazyvim/plugins/extras/lang/scala.lua
Watson Dinh e510a4a2ce 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
2025-03-04 13:35:58 -06:00

105 lines
2.6 KiB
Lua

return {
recommended = function()
return LazyVim.extras.wants({
ft = "scala",
root = { "build.sbt", "build.sc", "build.gradle", "pom.xml" },
})
end,
{
"nvim-treesitter/nvim-treesitter",
opts = { ensure_installed = { "scala" } },
},
{
"scalameta/nvim-metals",
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,
opts = function()
-- Debug settings
local dap = require("dap")
dap.configurations.scala = {
{
type = "scala",
request = "launch",
name = "RunOrTest",
metals = {
runType = "runOrTestFile",
--args = { "firstArg", "secondArg", "thirdArg" }, -- here just as an example
},
},
{
type = "scala",
request = "launch",
name = "Test Target",
metals = {
runType = "testTarget",
},
},
}
end,
},
}