You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently support for textDocument/codeLens was added into NeoVim. This unlocks a couple neat Metals features that we've been unable to use so far in nvim-metals. To give a quick primer, code lenses are just virtual text displayed at the end of the line that hold some sort of action that you can do when selecting the code lens. In order to make code lenses work in NeoVim you'll need to do one of two things:
Have an autocmd similiar to this: autocmd BufEnter,CursorHold,InsertLeave <buffer> lua vim.lsp.codelens.refresh() which will call refresh() and request the code lenses from the server.
Have a local mapping that you can trigger on command that calls vim.lsp.codelens.refresh().
nvim-metals makes the opinionated choice and actually just automatically adds the autocomd for you to not make you add another line in your config to make this work. We do this for a few different autocmds actually that can be seen here. Again, this is an opinionated choice, but one I feel rather strongly about. I believe that most people just want a feature to work ™️ without having to add extra stuff to their configs.
What features does this bring nvim-metals
This brings two great new features to nvim-metals.
metals.goto-super-method which allows you to jump to the overridden member:
NOTE: These are somewhat expensive to compute, so we have them disabled by default in Metals. In order to enable them, add the following to your config settings:
You can find out more about by checking out :h lsp-codelens.
You need to update everything
⚠️ If you are trying out the analyze stacktrace functionality and you see:
Error executing vim.schedule lua callback: ...neovim/HEAD-f76f72a_2/share/nvim/runtime/lua/vim/uri.lua:116: URI must contain a scheme: /Users/ckipp/Documents/scala-workspace/sanity/.metals/stacktrace.scala
You'll need to switch to the latest snapshot of Metals. There was a small issue that was fixed here that you'll need.
Also if you see a warning about calling a code lens method that doesn't exist, make sure you're on the latest nightly of NeoVim. You need to have the code lens commits included in neovim/neovim#13165 for this to work.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
What are they
Recently support for
textDocument/codeLens
was added into NeoVim. This unlocks a couple neat Metals features that we've been unable to use so far innvim-metals
. To give a quick primer, code lenses are just virtual text displayed at the end of the line that hold some sort of action that you can do when selecting the code lens. In order to make code lenses work in NeoVim you'll need to do one of two things:autocmd BufEnter,CursorHold,InsertLeave <buffer> lua vim.lsp.codelens.refresh()
which will callrefresh()
and request the code lenses from the server.vim.lsp.codelens.refresh()
.nvim-metals
makes the opinionated choice and actually just automatically adds the autocomd for you to not make you add another line in your config to make this work. We do this for a few different autocmds actually that can be seen here. Again, this is an opinionated choice, but one I feel rather strongly about. I believe that most people just want a feature to work ™️ without having to add extra stuff to their configs.What features does this bring nvim-metals
This brings two great new features to nvim-metals.
metals.goto-super-method
which allows you to jump to the overridden member:NOTE: These are somewhat expensive to compute, so we have them disabled by default in Metals. In order to enable them, add the following to your config settings:
metals.analyze-stacktrace
which allows you to analyze stacktraces and jump to the trace positionScreen.Recording.2021-06-13.at.15.17.02.mov
How to trigger the code lens
To actually trigger the code lens you'll want some sort of mapping tied to
vim.lsp.codelens.run()
. For example I use:You can find out more about by checking out
:h lsp-codelens
.You need to update everything
You'll need to switch to the latest snapshot of Metals. There was a small issue that was fixed here that you'll need.
Also if you see a warning about calling a code lens method that doesn't exist, make sure you're on the latest nightly of NeoVim. You need to have the code lens commits included in neovim/neovim#13165 for this to work.
Beta Was this translation helpful? Give feedback.
All reactions