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)
|
|
|
|
metals_config = metals.bare_config()
|
|
|
|
metals_config.init_options.statusBarProvider = "on"
|
2023-02-13 15:04:35 +00:00
|
|
|
metals_config.settings = {
|
|
|
|
showImplicitArguments = true,
|
|
|
|
superMethodLensesEnabled = true,
|
|
|
|
}
|
|
|
|
metals_config.on_attach = function(client, bufnr)
|
|
|
|
require("metals").setup_dap()
|
|
|
|
on_attach(client, bufnr)
|
|
|
|
end
|
2023-01-23 13:47:01 +00:00
|
|
|
metals_config.capabilities = require("cmp_nvim_lsp").default_capabilities()
|
2023-02-13 15:04:35 +00:00
|
|
|
-- 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
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type = "scala",
|
|
|
|
request = "launch",
|
|
|
|
name = "Test Target",
|
|
|
|
metals = {
|
|
|
|
runType = "testTarget",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2023-01-23 13:47:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
vim.cmd [[augroup lsp]]
|
|
|
|
vim.cmd [[au!]]
|
|
|
|
vim.cmd([[autocmd FileType scala setlocal omnifunc=v:lua.vim.lsp.omnifunc]])
|
|
|
|
vim.cmd [[au FileType scala,sbt lua require("metals").initialize_or_attach(metals_config)]]
|
|
|
|
vim.cmd [[augroup end]]
|
|
|
|
|
|
|
|
return metals_config
|
|
|
|
end
|