fix(extras.lang): fix Scala extra by using nvimMetals only (#5726)

## Description
Scala lang Extra should NOT be configured via `neovim/nvim-lspconfig`.
This PR removes `neovim/nvim-lspconfig` config and replace it by
`nvim-metals` only. From [nvim-metals
README.md](https://github.com/scalameta/nvim-metals): _"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"_

## Related Issue(s)

No specific issue, this is attempt to follow users guide of Scala nvim
plugin : https://github.com/scalameta/nvim-metals

## Screenshots

## Checklist

- [x] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
This commit is contained in:
Watson Dinh
2025-10-20 02:04:35 -05:00
committed by GitHub
parent 8c5cc77107
commit f118dca334

View File

@@ -11,14 +11,9 @@ return {
}, },
{ {
"scalameta/nvim-metals", "scalameta/nvim-metals",
ft = { "scala", "sbt" }, dependencies = {
config = function() end, "nvim-lua/plenary.nvim",
}, },
{
"neovim/nvim-lspconfig",
opts = {
servers = {
metals = {
keys = { keys = {
{ {
"<leader>me", "<leader>me",
@@ -42,35 +37,44 @@ return {
desc = "Metals hover worksheet", desc = "Metals hover worksheet",
}, },
}, },
init_options = { ft = { "scala", "sbt", "java" },
statusBarProvider = "off", opts = function()
}, local metals_config = require("metals").bare_config()
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
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 }) local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = { "scala", "sbt" }, pattern = self.ft,
callback = function() callback = function()
metals.initialize_or_attach(metals_config) require("metals").initialize_or_attach(metals_config)
end, end,
group = nvim_metals_group, group = nvim_metals_group,
}) })
return true
end, end,
}, },
},
},
{ {
"mfussenegger/nvim-dap", "mfussenegger/nvim-dap",
optional = true, optional = true,