mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-26 10:48:45 +02:00
fix(extra.lang.scala): Fix the always initializing regardless of file… (#3455)
* fix(extra.lang.scala): Fix the always initializing regardless of filetype * fix typo
This commit is contained in:
parent
452b70ad15
commit
c1f5fcf9c7
1 changed files with 60 additions and 60 deletions
|
@ -1,7 +1,3 @@
|
||||||
-- 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 {
|
return {
|
||||||
recommended = function()
|
recommended = function()
|
||||||
return LazyVim.extras.wants({
|
return LazyVim.extras.wants({
|
||||||
|
@ -10,44 +6,72 @@ return {
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
{
|
{
|
||||||
"hrsh7th/nvim-cmp",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
requires = {
|
opts = function(_, opts)
|
||||||
{ "hrsh7th/cmp-nvim-lsp" },
|
if type(opts.ensure_installed) == "table" then
|
||||||
{ "hrsh7th/cmp-vsnip" },
|
vim.list_extend(opts.ensure_installed, { "scala" })
|
||||||
{ "hrsh7th/vim-vsnip" },
|
end
|
||||||
},
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"scalameta/nvim-metals",
|
"scalameta/nvim-metals",
|
||||||
dependencies = {
|
ft = { "scala", "sbt" },
|
||||||
"nvim-lua/plenary.nvim",
|
config = function() end,
|
||||||
"mfussenegger/nvim-dap",
|
},
|
||||||
},
|
{
|
||||||
ft = { "scala", "sbt", "java" },
|
"neovim/nvim-lspconfig",
|
||||||
init = function()
|
opts = {
|
||||||
local metals_config = require("metals").bare_config()
|
servers = {
|
||||||
metals_config.init_options.statusBarProvider = "off"
|
metals = {
|
||||||
metals_config.settings = {
|
keys = {
|
||||||
showImplicitArguments = true,
|
{
|
||||||
excludedPackages = { "akka.actor.typed.javadsl", "com.github.swagger.akka.javadsl" },
|
"<leader>me",
|
||||||
}
|
function()
|
||||||
metals_config.capabilities = require("cmp_nvim_lsp").default_capabilities()
|
require("telescope").extensions.metals.commands()
|
||||||
metals_config.on_attach = function(client, bufnr)
|
end,
|
||||||
require("metals").setup_dap()
|
desc = "Metals commands",
|
||||||
end
|
},
|
||||||
|
{
|
||||||
|
"<leader>mc",
|
||||||
|
function()
|
||||||
|
require("metals").compile_cascade()
|
||||||
|
end,
|
||||||
|
desc = "Metals compile cascade",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
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 })
|
local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
-- NOTE: You may or may not want java included here. You will need it if you
|
pattern = { "scala", "sbt" },
|
||||||
-- want basic Java support but it may also conflict if you are using
|
callback = function()
|
||||||
-- something like nvim-jdtls which also works on a java filetype autocmd.
|
metals.initialize_or_attach(metals_config)
|
||||||
pattern = { "scala", "sbt", "java" },
|
end,
|
||||||
callback = function()
|
group = nvim_metals_group,
|
||||||
require("metals").initialize_or_attach(metals_config)
|
})
|
||||||
|
return true
|
||||||
end,
|
end,
|
||||||
group = nvim_metals_group,
|
},
|
||||||
})
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"mfussenegger/nvim-dap",
|
||||||
|
optional = true,
|
||||||
|
opts = function()
|
||||||
-- Debug settings
|
-- Debug settings
|
||||||
local dap = require("dap")
|
local dap = require("dap")
|
||||||
dap.configurations.scala = {
|
dap.configurations.scala = {
|
||||||
|
@ -70,29 +94,5 @@ return {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
keys = {
|
|
||||||
{
|
|
||||||
"<leader>me",
|
|
||||||
function()
|
|
||||||
require("telescope").extensions.metals.commands()
|
|
||||||
end,
|
|
||||||
desc = "Metals commands",
|
|
||||||
ft = { "scala", "sbt", "java" },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"<leader>mc",
|
|
||||||
function()
|
|
||||||
require("metals").compile_cascade()
|
|
||||||
end,
|
|
||||||
desc = "Metals compile cascade",
|
|
||||||
ft = { "scala", "sbt", "java" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"nvim-treesitter/nvim-treesitter",
|
|
||||||
opts = function(_, opts)
|
|
||||||
vim.list_extend(opts.ensure_installed, { "scala" })
|
|
||||||
end,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue