81 lines
2.5 KiB
Lua
81 lines
2.5 KiB
Lua
-- NOTE: This setup does not define any lsp or dap specific key bindings
|
|
-- It is recommended that the LazyVim extras dap-core is imported "lazyvim.plugins.extras.dap.core"
|
|
-- If you like you can setup your own key bindings.
|
|
-- For minimalistic setup have a look at https://github.com/scalameta/nvim-metals/discussions/39
|
|
return {
|
|
recommended = function()
|
|
return LazyVim.extras.wants({
|
|
ft = "scala",
|
|
root = { "build.sbt", "build.sc", "build.gradle", "pom.xml" },
|
|
})
|
|
end,
|
|
{
|
|
"hrsh7th/nvim-cmp",
|
|
requires = {
|
|
{ "hrsh7th/cmp-nvim-lsp" },
|
|
{ "hrsh7th/cmp-vsnip" },
|
|
{ "hrsh7th/vim-vsnip" },
|
|
},
|
|
},
|
|
{
|
|
"scalameta/nvim-metals",
|
|
dependencies = {
|
|
"nvim-lua/plenary.nvim",
|
|
"mfussenegger/nvim-dap",
|
|
},
|
|
ft = { "scala", "sbt", "java" },
|
|
init = function()
|
|
local metals_config = require("metals").bare_config()
|
|
metals_config.init_options.statusBarProvider = "on"
|
|
metals_config.settings = {
|
|
showImplicitArguments = true,
|
|
excludedPackages = { "akka.actor.typed.javadsl", "com.github.swagger.akka.javadsl" },
|
|
}
|
|
metals_config.capabilities = require("cmp_nvim_lsp").default_capabilities()
|
|
metals_config.on_attach = function(client, bufnr)
|
|
require("metals").setup_dap()
|
|
end
|
|
|
|
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.
|
|
pattern = { "scala", "sbt", "java" },
|
|
callback = function()
|
|
require("metals").initialize_or_attach(metals_config)
|
|
end,
|
|
group = nvim_metals_group,
|
|
})
|
|
|
|
-- 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,
|
|
},
|
|
{
|
|
"nvim-treesitter/nvim-treesitter",
|
|
opts = function(_, opts)
|
|
vim.list_extend(opts.ensure_installed, { "scala" })
|
|
end,
|
|
},
|
|
}
|