nvim-config/lua/plugins/nvim-metals.lua

54 lines
1.8 KiB
Lua
Raw Normal View History

2023-02-11 11:16:16 -08:00
return {
"scalameta/nvim-metals",
2023-05-27 22:14:12 -07:00
lazy = false,
2023-02-11 11:16:16 -08:00
keys = {
{ "<leader>ws", "<cmd>lua require'metals'.hover_worksheet()<cr>", desc = "Metals Worksheet" },
{
"<leader>sm",
"<cmd>lua require'telescope'.extensions.metals.commands()<cr>",
desc = "Telescope Metals Commands",
},
2023-02-11 11:16:16 -08:00
},
config = function()
local metals_config = require("metals").bare_config()
2023-02-11 13:59:53 -08:00
metals_config.tvp = {
icons = {
enabled = true,
},
}
2023-02-11 11:16:16 -08:00
metals_config.settings = {
2023-02-11 11:59:44 -08:00
serverVersion = "latest.snapshot",
2023-12-17 15:17:14 -08:00
useGlobalExecutable = true,
2023-02-11 11:16:16 -08:00
showImplicitArguments = true,
2023-02-11 13:59:53 -08:00
showImplicitConversionsAndClasses = true,
2023-02-11 11:59:44 -08:00
showInferredType = true,
bloopSbtAlreadyInstalled = true,
2023-02-11 11:16:16 -08:00
excludedPackages = { "akka.actor.typed.javadsl", "com.github.swagger.akka.javadsl" },
2023-02-11 13:59:53 -08:00
-- fallbackScalaVersion = "2.13.8",
2023-02-11 11:59:44 -08:00
superMethodLensesEnabled = true,
2023-02-11 11:16:16 -08:00
}
2023-02-11 11:59:44 -08:00
metals_config.on_attach = function(client, bufnr)
2023-02-11 13:59:53 -08:00
vim.keymap.set("n", "<leader>tt", require("metals.tvp").toggle_tree_view)
vim.keymap.set("n", "<leader>tr", require("metals.tvp").reveal_in_tree)
2023-02-11 11:59:44 -08:00
vim.cmd([[autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()]])
vim.cmd([[autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()]])
vim.cmd([[autocmd BufEnter,CursorHold,InsertLeave <buffer> lua vim.lsp.codelens.refresh()]])
end
2023-02-11 11:16:16 -08:00
metals_config.init_options.statusBarProvider = "on"
metals_config.capabilities = require("cmp_nvim_lsp").default_capabilities()
local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
pattern = { "scala", "sbt", "java" },
callback = function()
require("metals").initialize_or_attach(metals_config)
end,
group = nvim_metals_group,
})
end,
}