Scala
info
You can enable the extra with the :LazyExtras
command.
Plugins marked as optional will only be configured if they are installed.
Alternatively, you can add it to your lazy.nvim
imports
lua/config/lazy.lua
require("lazy").setup({
spec = {
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
{ import = "lazyvim.plugins.extras.lang.scala" },
{ import = "plugins" },
},
})
Below you can find a list of included plugins and their default settings.
caution
You don't need to copy the default settings to your config. They are only shown here for reference.
nvim-treesitter
- Options
- Full Spec
opts = { ensure_installed = { "scala" } }
{
"nvim-treesitter/nvim-treesitter",
opts = { ensure_installed = { "scala" } },
}
nvim-metals
- Options
- Full Spec
opts = {}
{
"scalameta/nvim-metals",
ft = { "scala", "sbt" },
config = function() end,
}
nvim-lspconfig
- Options
- Full Spec
opts = {
servers = {
metals = {
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",
},
},
init_options = {
statusBarProvider = "off",
},
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
local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
pattern = { "scala", "sbt" },
callback = function()
metals.initialize_or_attach(metals_config)
end,
group = nvim_metals_group,
})
return true
end,
},
}
{
"neovim/nvim-lspconfig",
opts = {
servers = {
metals = {
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",
},
},
init_options = {
statusBarProvider = "off",
},
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
local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
pattern = { "scala", "sbt" },
callback = function()
metals.initialize_or_attach(metals_config)
end,
group = nvim_metals_group,
})
return true
end,
},
},
}
nvim-dap (optional)
- Options
- Full Spec
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
{
"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,
}