From 47786bf89e15f4a8963ce4136c0dc87478dd8c6a Mon Sep 17 00:00:00 2001 From: Elias Almqvist Date: Thu, 16 Jan 2025 13:24:23 +0100 Subject: [PATCH] fixed nvim-metals --- nvchad/.config/nvim/lua/configs/lspconfig.lua | 24 ++++++++--------- nvchad/.config/nvim/lua/plugins/init.lua | 26 +++++++++++++++++++ 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/nvchad/.config/nvim/lua/configs/lspconfig.lua b/nvchad/.config/nvim/lua/configs/lspconfig.lua index 325bc81..3d4f76e 100644 --- a/nvchad/.config/nvim/lua/configs/lspconfig.lua +++ b/nvchad/.config/nvim/lua/configs/lspconfig.lua @@ -25,16 +25,16 @@ for _, lsp in ipairs(servers) do }) end -lspconfig.metals.setup({ - settings = { - showImplicitArguments = true, - excludedPackages = { "akka.actor.typed.javadsl", "com.github.swagger.akka.javadsl" }, - }, - init_options = { - statusBarProvider = "on", - }, - -- on_attach = function(client, bufnr) - -- -- Add your keybindings and other on_attach functions here - -- end, -}) +-- lspconfig.metals.setup({ +-- settings = { +-- showImplicitArguments = true, +-- excludedPackages = { "akka.actor.typed.javadsl", "com.github.swagger.akka.javadsl" }, +-- }, +-- init_options = { +-- statusBarProvider = "on", +-- }, +-- -- on_attach = function(client, bufnr) +-- -- -- Add your keybindings and other on_attach functions here +-- -- end, +-- }) diff --git a/nvchad/.config/nvim/lua/plugins/init.lua b/nvchad/.config/nvim/lua/plugins/init.lua index 93d498b..9a8edf8 100644 --- a/nvchad/.config/nvim/lua/plugins/init.lua +++ b/nvchad/.config/nvim/lua/plugins/init.lua @@ -158,6 +158,32 @@ local plugins = { -- end, }, + { + "scalameta/nvim-metals", + dependencies = { + "nvim-lua/plenary.nvim", + }, + ft = { "scala", "sbt", "java" }, + opts = function() + local metals_config = require("metals").bare_config() + metals_config.on_attach = function(client, bufnr) + -- your on_attach function + end + + return metals_config + end, + config = function(self, metals_config) + local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true }) + vim.api.nvim_create_autocmd("FileType", { + pattern = self.ft, + callback = function() + require("metals").initialize_or_attach(metals_config) + end, + group = nvim_metals_group, + }) + end + }, + { "NvChad/nvim-colorizer.lua", enabled = true