2023-01-23 13:47:01 +00:00
|
|
|
local status, metals = pcall(require, "metals")
|
|
|
|
if (not status) then return function() end end
|
|
|
|
|
|
|
|
return function(on_attach)
|
2023-02-13 23:19:02 +00:00
|
|
|
metals_config = metals.bare_config()
|
|
|
|
metals_config.init_options.statusBarProvider = "on"
|
|
|
|
metals_config.settings = {
|
|
|
|
showImplicitArguments = true,
|
|
|
|
superMethodLensesEnabled = true,
|
|
|
|
}
|
|
|
|
metals_config.on_attach = function(client, bufnr)
|
|
|
|
require("metals").setup_dap()
|
|
|
|
on_attach(client, bufnr)
|
|
|
|
end
|
|
|
|
metals_config.capabilities = require("cmp_nvim_lsp").default_capabilities()
|
|
|
|
-- Debug settings if you're using nvim-dap
|
|
|
|
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
|
2023-02-13 15:04:35 +00:00
|
|
|
},
|
2023-02-13 23:19:02 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type = "scala",
|
|
|
|
request = "launch",
|
|
|
|
name = "Test Target",
|
|
|
|
metals = {
|
|
|
|
runType = "testTarget",
|
2023-02-13 15:04:35 +00:00
|
|
|
},
|
2023-02-13 23:19:02 +00:00
|
|
|
},
|
|
|
|
}
|
2023-01-23 13:47:01 +00:00
|
|
|
|
|
|
|
|
2023-02-13 23:19:02 +00:00
|
|
|
-- Autocmd that will actually be in charging of starting the whole thing
|
|
|
|
local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
|
|
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
|
|
-- NOTE: You may or may not want java included here. You will need it if you
|
|
|
|
-- want basic Java support but it may also conflict if you are using
|
|
|
|
-- something like nvim-jdtls which also works on a java filetype autocmd.
|
2023-02-26 21:07:32 +00:00
|
|
|
pattern = { "scala", "sbt" },
|
2023-02-13 23:19:02 +00:00
|
|
|
callback = function()
|
|
|
|
require("metals").initialize_or_attach(metals_config)
|
|
|
|
end,
|
|
|
|
group = nvim_metals_group,
|
|
|
|
})
|
2023-01-23 13:47:01 +00:00
|
|
|
|
2023-02-13 23:19:02 +00:00
|
|
|
return metals_config
|
2023-01-23 13:47:01 +00:00
|
|
|
end
|