<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Nicolas Medda</title>
    <description>The latest articles on Forem by Nicolas Medda (@b2l).</description>
    <link>https://forem.com/b2l</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3845088%2F635d5cc4-ebe8-42ab-873c-ef177bd0f9ca.jpeg</url>
      <title>Forem: Nicolas Medda</title>
      <link>https://forem.com/b2l</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/b2l"/>
    <language>en</language>
    <item>
      <title>Neovim + Java LSP on a Play Framework sbt Project — The Missing Guide</title>
      <dc:creator>Nicolas Medda</dc:creator>
      <pubDate>Thu, 26 Mar 2026 17:32:30 +0000</pubDate>
      <link>https://forem.com/b2l/neovim-java-lsp-on-a-play-framework-sbt-project-the-missing-guide-1749</link>
      <guid>https://forem.com/b2l/neovim-java-lsp-on-a-play-framework-sbt-project-the-missing-guide-1749</guid>
      <description>&lt;h2&gt;
  
  
  The short answer
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;sbt-eclipse&lt;/strong&gt; generates Eclipse project files, &lt;strong&gt;JDTLS&lt;/strong&gt; consumes them. That's the bridge. Everything else is configuration details.&lt;/p&gt;

&lt;p&gt;If you're here, you've probably already tried Metals, hit a wall, and googled your way to disappointment. Here's the setup that actually works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Context
&lt;/h2&gt;

&lt;p&gt;Our project: Play Framework 3.x, Java (not Scala), sbt, 7 submodules, ~3,000 source files, heavy code generation (OpenAPI, Avro, WSDL). The rest of the team uses IntelliJ. I use Neovim.&lt;/p&gt;

&lt;p&gt;There were exactly &lt;strong&gt;zero documented success stories&lt;/strong&gt; for this combination online. The closest I found was &lt;a href="https://github.com/scalameta/nvim-metals/discussions/503" rel="noopener noreferrer"&gt;a discussion on nvim-metals&lt;/a&gt; where people tried Metals and hit the same wall.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Metals won't work
&lt;/h2&gt;

&lt;p&gt;Metals understands sbt natively. Great. But its Java support is minimal — no completions, no hover, no organize imports. A Metals maintainer &lt;a href="https://github.com/scalameta/metals/issues/1815" rel="noopener noreferrer"&gt;explicitly stated&lt;/a&gt;: &lt;em&gt;"I can't imagine the case when somebody wants to use Metals on a full-java project."&lt;/em&gt; Fair enough.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why JDTLS doesn't work out of the box
&lt;/h2&gt;

&lt;p&gt;JDTLS (Eclipse's Java language server) has full Java support, but only speaks Maven, Gradle, and Eclipse project formats. It has no idea what &lt;code&gt;build.sbt&lt;/code&gt; is.&lt;/p&gt;

&lt;h2&gt;
  
  
  The solution
&lt;/h2&gt;

&lt;p&gt;Make sbt produce what JDTLS expects: &lt;code&gt;.classpath&lt;/code&gt; and &lt;code&gt;.project&lt;/code&gt; files.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Install sbt-eclipse — without touching the repo
&lt;/h3&gt;

&lt;p&gt;You're probably the only Neovim user on your team. No reason to commit IDE-specific build config. sbt supports user-level configuration:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;~/.sbt/1.0/plugins/plugins.sbt&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scala"&gt;&lt;code&gt;&lt;span class="nf"&gt;addSbtPlugin&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"com.github.sbt"&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="s"&gt;"sbt-eclipse"&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="s"&gt;"6.2.0"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;code&gt;~/.sbt/1.0/global.sbt&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scala"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;com.typesafe.sbteclipse.core.EclipsePlugin.EclipseKeys&lt;/span&gt;

&lt;span class="nv"&gt;EclipseKeys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="py"&gt;projectFlavor&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nv"&gt;EclipseProjectFlavor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="py"&gt;Java&lt;/span&gt;
&lt;span class="nv"&gt;EclipseKeys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="py"&gt;skipParents&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;span class="nv"&gt;EclipseKeys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="py"&gt;withSource&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="nv"&gt;EclipseKeys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="py"&gt;preTasks&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nc"&gt;Seq&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Compile&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;compile&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;EclipseKeys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="py"&gt;createSrc&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nv"&gt;EclipseCreateSrc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="py"&gt;ValueSet&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
  &lt;span class="nv"&gt;EclipseCreateSrc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="py"&gt;Unmanaged&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
  &lt;span class="nv"&gt;EclipseCreateSrc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="py"&gt;Source&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
  &lt;span class="nv"&gt;EclipseCreateSrc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="py"&gt;Resource&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
  &lt;span class="nv"&gt;EclipseCreateSrc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="py"&gt;ManagedSrc&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
  &lt;span class="nv"&gt;EclipseCreateSrc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="py"&gt;ManagedClasses&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
  &lt;span class="nv"&gt;EclipseCreateSrc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="py"&gt;ManagedResources&lt;/span&gt;
&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three things I learned the hard way:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Gotcha&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Don't use &lt;code&gt;ThisBuild /&lt;/code&gt; scope&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;sbt-eclipse reads keys at project level, not &lt;code&gt;ThisBuild&lt;/code&gt;. The settings silently do nothing.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;ManagedSrc&lt;/code&gt; is critical&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Without it, generated sources (Play routes, OpenAPI codegen, Avro) don't appear in &lt;code&gt;.classpath&lt;/code&gt;. &lt;code&gt;ManagedClasses&lt;/code&gt; and &lt;code&gt;ManagedResources&lt;/code&gt; alone are not enough.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;preTasks := Seq(Compile / compile)&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Code generation must run before Eclipse files are created, otherwise the managed source directories don't exist on disk yet.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  2. Generate Eclipse project files
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sbt eclipse
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This compiles first (triggering codegen), then generates &lt;code&gt;.classpath&lt;/code&gt; and &lt;code&gt;.project&lt;/code&gt; in root and every submodule. Add to &lt;code&gt;.gitignore&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.classpath
.project
.settings/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Install and configure JDTLS
&lt;/h3&gt;

&lt;p&gt;Install via &lt;a href="https://github.com/williamboman/mason.nvim" rel="noopener noreferrer"&gt;Mason&lt;/a&gt;: &lt;code&gt;:MasonInstall jdtls&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then configure root detection. &lt;strong&gt;This is the part that cost me the most time.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In a multi-module sbt project, every submodule has its own &lt;code&gt;build.sbt&lt;/code&gt; and &lt;code&gt;.project&lt;/code&gt;. If either of these is in your &lt;code&gt;root_markers&lt;/code&gt;, JDTLS will root at the submodule instead of the repository root. It won't discover sibling modules. Cross-module imports silently fail.&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;.git&lt;/code&gt; as the primary anchor:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lua"&gt;&lt;code&gt;&lt;span class="n"&gt;vim&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lsp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"jdtls"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;root_markers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;"mvnw"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"gradlew"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"settings.gradle"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"settings.gradle.kts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;".git"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;"pom.xml"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"build.gradle"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"build.gradle.kts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"build.xml"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="n"&gt;vim&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lsp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;enable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"jdtls"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nested arrays require Neovim 0.11.3+. First group that matches wins.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. When things break: wipe the cache
&lt;/h3&gt;

&lt;p&gt;JDTLS caches workspace data aggressively. If you change root detection config, or if projects aren't being discovered:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-rf&lt;/span&gt; ~/.cache/nvim/jdtls/workspace/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restart Neovim. JDTLS re-imports everything from scratch.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you get
&lt;/h2&gt;

&lt;p&gt;Full Java IDE features on a Play Framework sbt project in Neovim:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Code completion&lt;/li&gt;
&lt;li&gt;Go-to-definition (across modules)&lt;/li&gt;
&lt;li&gt;Find references&lt;/li&gt;
&lt;li&gt;Diagnostics&lt;/li&gt;
&lt;li&gt;Organize imports&lt;/li&gt;
&lt;li&gt;Rename refactoring&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What you don't get
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Running/debugging Play&lt;/strong&gt; through JDTLS. Play's dev mode doesn't use a standard main method — &lt;code&gt;sbt run&lt;/code&gt; in a terminal, as usual.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic classpath updates.&lt;/strong&gt; After dependency changes in &lt;code&gt;build.sbt&lt;/code&gt;, you need to re-run &lt;code&gt;sbt eclipse&lt;/code&gt; and restart JDTLS. In practice this is a few times a month.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Normal coding, generated code changes, and branch switches (with same deps) need no action.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not just use IntelliJ?
&lt;/h2&gt;

&lt;p&gt;IntelliJ handles Play + sbt out of the box. If that works for you, stay there. This guide exists because some of us prefer Neovim and, until now, there was no documented path to a working Java LSP for sbt projects.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Sources and tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/sbt/sbt-eclipse" rel="noopener noreferrer"&gt;sbt-eclipse&lt;/a&gt; — the bridge that makes this possible&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/neovim/nvim-lspconfig" rel="noopener noreferrer"&gt;nvim-lspconfig&lt;/a&gt; — JDTLS configuration for Neovim&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/williamboman/mason.nvim" rel="noopener noreferrer"&gt;Mason.nvim&lt;/a&gt; — LSP server installer&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/scalameta/nvim-metals/discussions/503" rel="noopener noreferrer"&gt;nvim-metals#503&lt;/a&gt; — the discussion that confirms Metals won't work for this&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/scalameta/metals/issues/1815" rel="noopener noreferrer"&gt;metals#1815&lt;/a&gt; — Metals team on Java-only project support&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>neovim</category>
      <category>java</category>
      <category>playframework</category>
      <category>sbt</category>
    </item>
  </channel>
</rss>
