Documentation Index
Fetch the complete documentation index at: https://metals-lsp.org/llms.txt
Use this file to discover all available pages before exploring further.
Metals v2 works with Neovim through nvim-metals, a Lua plugin that integrates Metals with Neovim’s built-in LSP support.
The nvim-metals repository is the primary reference for installation and configuration. This page covers only the Metals v2-specific setup.
Prerequisites
- Neovim v0.11.x or newer
- Coursier installed locally
Configuration
Follow the nvim-metals installation guide, then add the serverVersion setting to use Metals v2:
metals_config.settings = {
serverVersion = "2.0.0-M2",
serverProperties = { "-Xmx4g" },
}
Required VM Options
Metals v2 requires JVM options for JDK internals access. If PR #767 has been merged, these are set automatically. Otherwise, add them manually:
metals_config.settings = {
serverVersion = "2.0.0-M2",
serverProperties = {
"-Djol.magicFieldOffset=true",
"-Djol.tryWithSudo=true",
"-Djdk.attach.allowAttachSelf",
"--add-opens=java.base/java.nio=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.resources=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-opens=java.base/sun.nio.ch=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"-XX:+DisplayVMOutputToStderr",
"-Xlog:disable",
"-Xlog:all=warning,gc=warning:stderr",
},
}
nvim-metals on GitHub
Full documentation, examples, and source code