Example configuration · scalameta/nvim-metals · Discussion #39
-------------------------------------------------------------------------------
-- These are example settings to use with nvim-metals and the nvim built-in
-- LSP. Be sure to thoroughly read the `:help nvim-metals` docs to get an
-- idea of what everything does. Again, these are meant to serve as an example.
-- If you just copy pasta them, they should work, but hopefully after time
-- goes on you'll cater them to your own liking especially since some of the stuff
-- in here is just an example, not what you probably want your setup to be.
--
-- Unfamiliar with Lua and Neovim?
-- - Check out `:help lua-guide`
--
-- The below configuration also makes use of the following plugins besides
-- nvim-metals, and therefore is a bit opinionated:
--
-- - https://github.com/hrsh7th/nvim-cmp
-- - hrsh7th/cmp-nvim-lsp for lsp completion sources
-- - hrsh7th/cmp-vsnip for snippet sources
-- - hrsh7th/vim-vsnip for snippet sources
--
-- - https://github.com/folke/lazy.nvim for package management
-- - https://github.com/mfussenegger/nvim-dap for debugging
-- - https://github.com/j-hui/fidget.nvim for progress notifications
-------------------------------------------------------------------------------
local map = vim.keymap.set
local fn = vim.fn
----------------------------------
-- INSTALL LAZY ------------------
----------------------------------
local lazypath = fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
----------------------------------
-- PLUGINS -----------------------
----------------------------------
require("lazy").setup({
{
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
{ "hrsh7th/cmp-nvim-lsp" },
{ "hrsh7th/cmp-vsnip" },
{ "hrsh7th/vim-vsnip" }
},
opts = function()
local cmp = require("cmp")
local conf = {
sources = {
{ name = "nvim_lsp" },
{ name = "vsnip" },
},
snippet = {
expand = function(args)
-- Comes from vsnip
fn["vsnip#anonymous"](args.body)
end,
},
mapping = cmp.mapping.preset.insert({
-- None of this made sense to me when first looking into this since there
-- is no vim docs, but you can't have select = true here _unless_ you are
-- also using the snippet stuff. So keep in mind that if you remove
-- snippets you need to remove this select
["<CR>"] = cmp.mapping.confirm({ select = true })
})
}
return conf
end
},
{
"scalameta/nvim-metals",
dependencies = {
{
"j-hui/fidget.nvim",
opts = {},
},
{
"mfussenegger/nvim-dap",
config = function(self, opts)
-- 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",
},
},
}
end
},
},
ft = { "scala", "sbt", "java" },
opts = function()
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 either "off" or "on"
--
-- "off" will enable LSP progress notifications by Metals and you'll need
-- to ensure you have a plugin like fidget.nvim installed to handle them.
--
-- "on" will enable the custom Metals status extension and you *have* to have
-- a have settings to capture 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 = "off"
-- 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()
metals_config.on_attach = function(client, bufnr)
require("metals").setup_dap()
-- LSP mappings
map("n", "gD", vim.lsp.buf.definition)
map("n", "K", vim.lsp.buf.hover)
map("n", "gi", vim.lsp.buf.implementation)
map("n", "gr", vim.lsp.buf.references)
map("n", "gds", vim.lsp.buf.document_symbol)
map("n", "gws", vim.lsp.buf.workspace_symbol)
map("n", "<leader>cl", vim.lsp.codelens.run)
map("n", "<leader>sh", vim.lsp.buf.signature_help)
map("n", "<leader>rn", vim.lsp.buf.rename)
map("n", "<leader>f", vim.lsp.buf.format)
map("n", "<leader>ca", vim.lsp.buf.code_action)
map("n", "<leader>ws", function()
require("metals").hover_worksheet()
end)
-- all workspace diagnostics
map("n", "<leader>aa", vim.diagnostic.setqflist)
-- all workspace errors
map("n", "<leader>ae", function()
vim.diagnostic.setqflist({ severity = "E" })
end)
-- all workspace warnings
map("n", "<leader>aw", function()
vim.diagnostic.setqflist({ severity = "W" })
end)
-- buffer diagnostics only
map("n", "<leader>d", vim.diagnostic.setloclist)
map("n", "[c", function()
vim.diagnostic.goto_prev({ wrap = false })
end)
map("n", "]c", function()
vim.diagnostic.goto_next({ wrap = false })
end)
-- Example mappings for usage with nvim-dap. If you don't use that, you can
-- skip these
map("n", "<leader>dc", function()
require("dap").continue()
end)
map("n", "<leader>dr", function()
require("dap").repl.toggle()
end)
map("n", "<leader>dK", function()
require("dap.ui.widgets").hover()
end)
map("n", "<leader>dt", function()
require("dap").toggle_breakpoint()
end)
map("n", "<leader>dso", function()
require("dap").step_over()
end)
map("n", "<leader>dsi", function()
require("dap").step_into()
end)
map("n", "<leader>dl", function()
require("dap").run_last()
end)
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
}
})
----------------------------------
-- OPTIONS -----------------------
----------------------------------
-- global
vim.opt_global.completeopt = { "menuone", "noinsert", "noselect" }
NOTE THIS IS OUTDATED AND JUST A VIMSCRIPT EXAMPLE
Just an fyi, I've gone ahead and only kept the pure Lua example up above with some very minimal instructions if you are using a Vimscript based setup. This is mainly for my own sake not having to maintain multiple minimal examples in both Lua and Vimscript. I'll post the last Vimscript based one below with no intent to keep it updated unless something radically changes in the setup. However, it will at leaset give an example:
"=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
" These are example settings to use with nvim-metals and the nvim built in
" LSP. Be sure to thoroughly read the the help docs to get an idea of what
" everything does.
"
" The below configuration also makes use of the following plugins besides
" nvim-metals
" - https://github.com/nvim-lua/completion-nvim
"=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
"-----------------------------------------------------------------------------
" nvim-lsp Mappings
"-----------------------------------------------------------------------------
nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>
nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
nnoremap <silent> gds <cmd>lua vim.lsp.buf.document_symbol()<CR>
nnoremap <silent> gws <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
nnoremap <silent> <leader>rn <cmd>lua vim.lsp.buf.rename()<CR>
nnoremap <silent> <leader>f <cmd>lua vim.lsp.buf.formatting()<CR>
nnoremap <silent> <leader>ca <cmd>lua vim.lsp.buf.code_action()<CR>
nnoremap <silent> <leader>ws <cmd>lua require'metals'.worksheet_hover()<CR>
nnoremap <silent> <leader>a <cmd>lua require'metals'.open_all_diagnostics()<CR>
nnoremap <silent> <space>d <cmd>lua vim.lsp.diagnostic.set_loclist()<CR>
nnoremap <silent> [c <cmd>lua vim.lsp.diagnostic.goto_prev { wrap = false }<CR>
nnoremap <silent> ]c <cmd>lua vim.lsp.diagnostic.goto_next { wrap = false }<CR>
"-----------------------------------------------------------------------------
" nvim-lsp Settings
"-----------------------------------------------------------------------------
" If you just use the latest stable version, then setting this isn't necessary
let g:metals_server_version = '0.9.8+10-334e402e-SNAPSHOT'
"-----------------------------------------------------------------------------
" nvim-metals setup with a few additions such as nvim-completions
"-----------------------------------------------------------------------------
:lua << EOF
metals_config = require'metals'.bare_config()
metals_config.settings = {
showImplicitArguments = true,
excludedPackages = {
"akka.actor.typed.javadsl",
"com.github.swagger.akka.javadsl"
}
}
metals_config.on_attach = function()
require'completion'.on_attach();
end
metals_config.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = {
prefix = '',
}
}
)
EOF
if has('nvim-0.5')
augroup lsp
au!
au FileType scala,sbt lua require('metals').initialize_or_attach(metals_config)
augroup end
endif
"-----------------------------------------------------------------------------
" completion-nvim settings
"-----------------------------------------------------------------------------
" Use <Tab> and <S-Tab> to navigate through popup menu
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
"-----------------------------------------------------------------------------
" Helpful general settings
"-----------------------------------------------------------------------------
" Needed for compltions _only_ if you aren't using completion-nvim
autocmd FileType scala setlocal omnifunc=v:lua.vim.lsp.omnifunc
" Set completeopt to have a better completion experience
set completeopt=menuone,noinsert,noselect
" Avoid showing message extra message when using completion
set shortmess+=c
0 replies
Should:
map("n", "<leader>ws", '<cmd>lua require"metals".worksheet_hover()<CR>')
now be:
map("n", "<leader>ws", '<cmd>lua require"metals".hover_worksheet()<CR>')
?
1 reply
Most minimal example
Just as a reminder, if you're trying to reproduce a bug, the best way to do it is to start with the most minimal configuration possible. For that, don't use the full example configuration. The example configuration is meant to show how to set various settings, and even setup nvim-dap. The most minimal setup is just:
vim.cmd([[autocmd FileType scala,sbt lua require("metals").initialize_or_attach({})]])
Then any mappings you need to test stuff.
1 reply
For those wanting a minimal setup that "does something" when you're trying to install nvim-metals, you may consider the smallest snippet I found that displays some information when pressing 'K' over scala/java items.
Using lazy.nvim, in ~/.config/nvim/lua/plugins/nvim-metals.lua:
return {
{
"scalameta/nvim-metals",
dependencies = {
"hrsh7th/nvim-cmp",
"hrsh7th/cmp-nvim-lsp"
},
opts = function()
local metals_config = require("metals").bare_config()
metals_config.capabilities = require("cmp_nvim_lsp").default_capabilities()
metals_config.on_attach = function(client, bufnr)
vim.keymap.set("n", "K", vim.lsp.buf.hover)
end
return metals_config
end,
config = function(metals, metals_config)
vim.api.nvim_create_autocmd("FileType", {
callback = function()
require("metals").initialize_or_attach(metals_config)
end
})
end
}
}
That may help some people get started. And perform a sanity check on the rest of their setup.
P.S: do not forget to install the JDK sources. On Ubuntu, something like apt -y install openjdk-21-source.
Hey @ckipp01 , looks like there's a typo in hrsh7th/nvim-cmp in that it has a trailing e.
Thanks for the reference!
1 reply
Just started using neovim purely because of nvim-metals and ultimately went with proposed initial "minimal" config. One thing that I've noticed is that it breaks file completion (<C-x><C-f>) if there's only one match due to missing menuone (present in vimscript version).
1 reply
Tried the lua, cmp not found.
Tried the vim, metals not found.
2 replies
Hey @rakamoviz, you'll need to provide a bit more info in order for me to help at all. When you tried the Lua setup, did you install the plugins? What did you actually try? What steps did you take?
As for the vim example, it's no longer maintained, as it says on the top of it. It's just there for reference if someone doesn't want to go the lua route. So there's 0 guarantee that it will work. In fact it for sure won't.
Hi, cmp_nvim_lsp.update_capabilities is deprecated, should use cmp_nvim_lsp.default_capabilities instead.
Further more. I tried in nvim according to the minimum configuration. It seems that nvim-metals is not working properly.
0 replies
Hi, cmp_nvim_lsp.update_capabilities is deprecated, should use cmp_nvim_lsp.default_capabilities instead.
Just updated this. Thanks for pointing this out!
Further more. I tried in nvim according to the minimum configuration. It seems that nvim-metals is not working properly.
What does your full config look like? What sort of issues are you having?
4 replies
Sorry, it was my fault. It works fine now.
I should not follow the help document nvim +"h metals" +:76. I missed metals_config in the {}.
require("metals").initialize_or_attach({})
I'm getting this after recent update of nvim-metals to 8f838eb:
Error detected while processing FileType Autocommands for "sbt":
Error executing lua callback: .../site/pack/packer/start/nvim-metals/lua/metals/setup.lua:89: attempt to call field 'start' (a nil value)
stack traceback:
.../site/pack/packer/start/nvim-metals/lua/metals/setup.lua:89: in function 'initialize_or_attach'
/home/user/.config/nvim/lua/nvim-metals-orig.lua:188: in function </home/user/.config/nvim/lua/nvim-metals-orig.lua:187>
Press ENTER or type command to continue
I'm using example configuration provided in the first post.
The issue seems to be introduced with 6e63d43.
Hey @arbitrary-dev what version of Neovim are you using? If using the main branch you'll need to ensure you're on 0.8.x. Prior to this the lsp.start won't exist.
Is this a vimrc file? Where does this configuration file go, and how do I initialize it?
1 reply
The top chunk is lua configuration. It's not meant to be just a drop in, but meant to be part of your existing config. If you're unfamiliar with Neovim Lua configuration I recommend checking out https://github.com/nanotee/nvim-lua-guide.
1 reply
Hey @dannashirn that error indeed makes it sounds like nvim-metals is not installed. Did you add nvim-metals as a plugin? Did you run :PackerInstall? It's really to help further without seeing more of your config and knowing what steps you took.
I was able to get it working for other lsp's
Keep in mind that nvim-metals isn't like other services in nvim-lspconfig, it's a completely separate things.
5 replies
Totally. I have been using lazy myself for a while. When I get a sec I'll update the example to use lazy instead.
@ckipp01 Yes please. I'd like to see the lazy example.
Alright, I've gone ahead and replaced the default example using lazy. Give it a try!
Hey! The config key is only executed once when the plugin is loaded. So it will only attach on the first buffer 😅 So the config still needs something like this:
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
A little update on the default config. I used to use packer.nvim as the example as for a while it was the default choice for many Neovim users. Therefore I'll keep the example that used to be used down below as a reference for people still using packer. Please note that IT WILL NO LONGER BE KEPT UP TO DATE, so there is no guarantee it'll work anymore. The new example will be using lazy.nvim.
------------------------------------------------------------------------------- -- These are example settings to use with nvim-metals and the nvim built-in -- LSP. Be sure to thoroughly read the `:help nvim-metals` docs to get an -- idea of what everything does. Again, these are meant to serve as an example, -- if you just copy pasta them, then should work, but hopefully after time -- goes on you'll cater them to your own liking especially since some of the stuff -- in here is just an example, not what you probably want your setup to be. -- -- Unfamiliar with Lua and Neovim? -- - Check out https://github.com/nanotee/nvim-lua-guide -- -- The below configuration also makes use of the following plugins besides -- nvim-metals, and therefore is a bit opinionated: -- -- - https://github.com/hrsh7th/nvim-cmp -- - hrsh7th/cmp-nvim-lsp for lsp completion sources -- - hrsh7th/cmp-vsnip for snippet sources -- - hrsh7th/vim-vsnip for snippet sources -- -- - https://github.com/wbthomason/packer.nvim for package management -- - https://github.com/mfussenegger/nvim-dap (for debugging) ------------------------------------------------------------------------------- local api = vim.api local cmd = vim.cmd local map = vim.keymap.set ---------------------------------- -- PLUGINS ----------------------- ---------------------------------- cmd([[packadd packer.nvim]]) require("packer").startup(function(use) use({ "wbthomason/packer.nvim", opt = true }) use({ "hrsh7th/nvim-cmp", requires = { { "hrsh7th/cmp-nvim-lsp" }, { "hrsh7th/cmp-vsnip" }, { "hrsh7th/vim-vsnip" }, }, }) use({ "scalameta/nvim-metals", requires = { "nvim-lua/plenary.nvim", "mfussenegger/nvim-dap", }, }) end) ---------------------------------- -- OPTIONS ----------------------- ---------------------------------- -- global vim.opt_global.completeopt = { "menuone", "noinsert", "noselect" } -- LSP mappings map("n", "gD", vim.lsp.buf.definition) map("n", "K", vim.lsp.buf.hover) map("n", "gi", vim.lsp.buf.implementation) map("n", "gr", vim.lsp.buf.references) map("n", "gds", vim.lsp.buf.document_symbol) map("n", "gws", vim.lsp.buf.workspace_symbol) map("n", "<leader>cl", vim.lsp.codelens.run) map("n", "<leader>sh", vim.lsp.buf.signature_help) map("n", "<leader>rn", vim.lsp.buf.rename) map("n", "<leader>f", vim.lsp.buf.format) map("n", "<leader>ca", vim.lsp.buf.code_action) map("n", "<leader>ws", function() require("metals").hover_worksheet() end) -- all workspace diagnostics map("n", "<leader>aa", vim.diagnostic.setqflist) -- all workspace errors map("n", "<leader>ae", function() vim.diagnostic.setqflist({ severity = "E" }) end) -- all workspace warnings map("n", "<leader>aw", function() vim.diagnostic.setqflist({ severity = "W" }) end) -- buffer diagnostics only map("n", "<leader>d", vim.diagnostic.setloclist) map("n", "[c", function() vim.diagnostic.goto_prev({ wrap = false }) end) map("n", "]c", function() vim.diagnostic.goto_next({ wrap = false }) end) -- Example mappings for usage with nvim-dap. If you don't use that, you can -- skip these map("n", "<leader>dc", function() require("dap").continue() end) map("n", "<leader>dr", function() require("dap").repl.toggle() end) map("n", "<leader>dK", function() require("dap.ui.widgets").hover() end) map("n", "<leader>dt", function() require("dap").toggle_breakpoint() end) map("n", "<leader>dso", function() require("dap").step_over() end) map("n", "<leader>dsi", function() require("dap").step_into() end) map("n", "<leader>dl", function() require("dap").run_last() end) -- completion related settings -- This is similiar to what I use local cmp = require("cmp") cmp.setup({ sources = { { name = "nvim_lsp" }, { name = "vsnip" }, }, snippet = { expand = function(args) -- Comes from vsnip vim.fn["vsnip#anonymous"](args.body) end, }, mapping = cmp.mapping.preset.insert({ -- None of this made sense to me when first looking into this since there -- is no vim docs, but you can't have select = true here _unless_ you are -- also using the snippet stuff. So keep in mind that if you remove -- snippets you need to remove this select ["<CR>"] = cmp.mapping.confirm({ select = true }), -- I use tabs... some say you should stick to ins-completion but this is just here as an example ["<Tab>"] = function(fallback) if cmp.visible() then cmp.select_next_item() else fallback() end end, ["<S-Tab>"] = function(fallback) if cmp.visible() then cmp.select_prev_item() else fallback() end end, }), }) ---------------------------------- -- LSP Setup --------------------- ---------------------------------- 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 -- Autocmd that will actually be in charging of starting the whole thing local nvim_metals_group = api.nvim_create_augroup("nvim-metals", { clear = true }) 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, })
3 replies
Hi,
First, sorry if I lack some informations or if I post at the wrong place, I'm still in learning phase of vim and its configuration files.
I'm working in a project with scala as back-end (play framework) and react (typescript) as front end. My front-end config works fine and now I'm trying to make scala work properly too.
So I installed the plugin, and my config looks like this for now:
local map = vim.keymap.set
return {
"scalameta/nvim-metals",
ft = { "scala", "sbt", "java" },
opts = function()
local metals_config = require("metals").bare_config()
metals_config.capabilities = require("cmp_nvim_lsp").default_capabilities()
metals_config.on_attach = function(client, bufnr)
map("n", "<leader>ws", function()
require("metals").hover_worksheet()
end)
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
}
My keymappings for hovering and everything else are defined in an other file. When I hover one of the models I want to know the type, it displays the message: "No information available". I have done a :MetalsBuild, :MetalInstall, but it does not work neither, do you know why ? However, find references is working, so I am wondering if it's not related to my project, maybe I need to run a specific command ?
When I open a scala file in Vim, I see the message: LSP[metals][Info] Indexing complete!
Do you have any ideas ?
1 reply
:MetalsBuild doesn't exist, at least not with nvim-metals. Do you mean another command? If you're seeing the status message like Indexing complete! then you have it installed and working. If you do a :MetalsRunDoctor, what does it show you? It's a bit hard to tell in your case without knowing exactly what is happening. In a minimal hello world project is hovers working? Just to ensure your setup is correct?
I have been a long time vim user but never tweaked my configurations. I only really used it as a simple text editor. I've also been dabbling in Scala for a number of years.
Digging into this project from the start. I looked at the dependency list which stated I needed plenary.nvim installed as a prereq, among other things. From the plenary.nvim page it said to install Plug or Packer to install plenary.nvim .
I think we read that Packer is not maintained. Then last week I tried to install plug. The documentation was to me a little confusing. I was unable to install Plug last week.
Today I made more progress. With Plug, it seemed like I needed to apply "alll the configuration steps", which was not my first interpretation reading.
I've finally installed plenary.nvim and then also this configuration.
As a last step, then I think I need to install the configuration above. Should we install this in ~/.vimrc (underneath the plug configuration?)
Finally it's confusing what's required, etc. I had to read through this gitter to have some idea what's going on. I would suggest that if this project wants to be more inclusive to new users, that some effort needs to be made to improve the starting documentation.
2 replies
Hey @apple-corps, I'm glad you're giving nvim-metals a try. A couple things:
I have been a long time vim user but never tweaked my configurations
Keep in mind this is only a Neovim plugin, not a vim plugin. So if you're still using just Vim, this plugin won't work. If you have switched over to Neovim, then of course if you've never configured it much before modern Neovim will take a while to get used to. The entire ecosystem has shifted quite a bit over the past couple years. That's why I have this in the Readme
Unfamiliar with Lua and Neovim? Check out the great :h lua-guide.
I'd recommend you take a look at this.
Today I made more progress. With Plug, it seemed like I needed to apply "alll the configuration steps", which was not my first interpretation reading.
You're totally free to use whatever plugin manager you want here, but if you're targeting mainly Lua plugins, then Plug really isn't a great choice since you'll have to jump back and forth between Vimscript and Lua. That's why this plugin in the example uses Lazy.nvim.
As a last step, then I think I need to install the configuration above. Should we install this in ~/.vimrc (underneath the plug configuration?)
Check out the help docs I mentioned above. There is a section called lua-guide-config which can help you here.
Finally it's confusing what's required
I'm not fully sure what's confusing? The Readme has very explicit instructions about what is required. It does assume some Neovim config knowledge, which I think is where you're getting stuck. I try to focus on nvim-metals documention, not general Neovim documentation and instead guide people towards those docs.
We also have a Discord channel linked in the Readme, feel free to head on over there as there is a bunch of people that are willing to help.
"It does assume some Neovim config knowledge, which I think is where you're getting stuck."
Yes. People writing these plugins clearly do not attempt to write instructions for people having just a cursory exposure to neovim. That's just the point. It's indeed a frustrating experience to see so many README pages where they says "write this code" without ever telling you where to write it.
Oh well. At least, back in the days, we had texi2html manuals...
@ckipp01 do you use nvim-dap with tests? how could I configure it?
{
"mfussenegger/nvim-dap",
config = function(self, opts)
-- 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",
},
},
{
name = "Debug Attach (5005)",
type = "scala",
request = "attach",
hostName = "127.0.0.1",
port = 5005,
metals = { },
},
}
end,
}
Error executing vim.schedule lua callback: .../.local/share/nvim/lazy/nvim-metals/lua/metals/setup.lua:138: attempt to index field 'result' (a nil value) stack traceback: .../.local/share/nvim/lazy/nvim-metals/lua/metals/setup.lua:138: in function 'callback' ...fuerte/.local/share/nvim/lazy/nvim-metals/lua/metals.lua:35: in function 'handler' ...ovim-unwrapped-0.10.4/share/nvim/runtime/lua/vim/lsp.lua:936: in function 'handler' ...wrapped-0.10.4/share/nvim/runtime/lua/vim/lsp/client.lua:687: in function '' vim/_editor.lua: in function <vim/_editor.lua:0>
0 replies
