Created
June 22, 2023 08:49
-
-
Save fayimora/18a0ee7e68d07a88f8ef7118f09eceff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- local M = {} | |
-- M.config = function() | |
-- local lvim_lsp = require("lvim.lsp") | |
-- local metals_config = require("metals").bare_config() | |
-- metals_config.on_init = lvim_lsp.common_on_init | |
-- metals_config.on_exit = lvim_lsp.common_on_exit | |
-- metals_config.capabilities = lvim_lsp.common_capabilities() | |
-- metals_config.on_attach = function(client, bufnr) | |
-- lvim_lsp.common_on_attach(client, bufnr) | |
-- require("metals").setup_dap() | |
-- end | |
-- metals_config.settings = { | |
-- superMethodLensesEnabled = true, | |
-- showImplicitArguments = true, | |
-- showInferredType = true, | |
-- showImplicitConversionsAndClasses = true, | |
-- excludedPackages = {}, | |
-- } | |
-- metals_config.init_options.statusBarProvider = false | |
-- vim.api.nvim_create_autocmd("FileType", { | |
-- pattern = { "scala", "sbt" }, | |
-- callback = function() require("metals").initialize_or_attach(metals_config) end, | |
-- group = vim.api.nvim_create_augroup("nvim-metals", { clear = true }), | |
-- }) | |
-- end | |
-- return M | |
local metals_config = require("metals").bare_config() | |
-- Example of settings | |
metals_config.settings = { | |
showImplicitArguments = true, | |
excludedPackages = { "akka.actor.typed.javadsl", "com.github.swagger.akka.javadsl" }, | |
} | |
-- *READ THIS* | |
-- I *highly* recommend setting statusBarProvider to true, however if you do, | |
-- you *have* to have a setting to display this in your statusline or else | |
-- you'll not see any messages from metals. There is more info in the help | |
-- docs about this | |
-- metals_config.init_options.statusBarProvider = "on" | |
-- Example if you are using cmp how to make sure the correct capabilities for snippets are set | |
metals_config.capabilities = require("cmp_nvim_lsp").default_capabilities() | |
-- Debug settings if you're using nvim-dap | |
-- 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", | |
-- }, | |
-- }, | |
-- } | |
-- metals_config.on_attach = function(client, bufnr) | |
-- require("metals").setup_dap() | |
-- end | |
vim.api.nvim_create_autocmd("BufEnter", { | |
pattern = { "*.scala", "*.sbt" }, | |
command = "lua require('custom.configs.metals').config()" | |
}) | |
-- Autocmd that will actually be in charging of starting the whole thing | |
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, | |
}) | |
return metals_config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment