mfussenegger / nvim-jdtls

Extensions for the built-in LSP support in Neovim for eclipse.jdt.ls
GNU General Public License v3.0
979 stars 62 forks source link

jdtls client per maven module is launched #641

Closed jeusdi closed 3 months ago

jeusdi commented 3 months ago

LSP client configuration

I'm using default lazyvim configuration you can find here.

Eclipse.jdt.ls version

v1.33.0

Steps to Reproduce

I'm using last lazyvim version.

Here LspInfo output:

 Press q or <Esc> to close this window. Press <Tab> to view server doc.

 Language client log: /home/jcabre/.local/state/nvim/lsp.log
 Detected filetype:   java

 2 client(s) attached to this buffer: 

 Client: jdtls (id: 1, bufnr: [338])
    filetypes:       
    autostart:       false
    root directory:  /home/jcabre/projects/gene/cultura/espaidoc/repositories/cloud
    cmd:             /home/jcabre/.local/share/nvim/mason/bin/jdtls --jvm-arg=-javaagent:/home/jcabre/.local/share/nvim/mason/packages/jdtls/lombok.jar

 Client: jdtls (id: 2, bufnr: [338, 357])
    filetypes:       
    autostart:       false
    root directory:  /home/jcabre/projects/gene/cultura/espaidoc/repositories/cloud/presentation/frontoffice/rest
    cmd:             /home/jcabre/.local/share/nvim/mason/bin/jdtls -configuration /home/jcabre/.cache/nvim/jdtls/rest/config -data /home/jcabre/.cache/nvim/jdtls/rest/workspace --jvm-arg=-javaagent:/home/jcabre/.local/share/nvim/mason/packages/jdtls/lombok.jar

 Configured servers list: lua_ls

As you can see two jdtls lsp clients are launched.

My project structure is:

.
├── pom.xml
├── application
│   ├── pom.xml
│   └── src
├── domain
│   ├── pom.xml
│   └── src
├── infrastructure
│   ├── pom.xml
│   └── src
├── presentation
│   ├── backoffice
│   │   ├── apigateway
│   │   │   ├── pom.xml
│   │   │   └── src
│   │   └── rest
│   │       ├── pom.xml
│   │       └── src
│   └── frontoffice
│       ├── apigateway
│       │   ├── pom.xml
│       │   └── src
│       └── rest
│           ├── pom.xml
│           └── src
└── README.md

My parent pom.xml is:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>net.gencat.transversal.espaidoc</groupId>
    <artifactId>espaidoc-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <name>espaidoc</name>
    <description>espaidoc parent</description>

    <properties>
        <maven.compiler.target>17</maven.compiler.target>
    <maven.compiler.source>17</maven.compiler.source>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <modules>
        <module>domain</module>
        <module>application</module>
        <module>infrastructure</module>
        <module>presentation/frontoffice/rest</module>
        <module>presentation/frontoffice/apigateway</module>
        <module>presentation/backoffice/rest</module>
        <module>presentation/backoffice/apigateway</module>
    </modules>

</project>

Any ideas about how to fix that behavior or how to debug it?

Expected Result

One single lsp client is launched

Actual Result

a jdtls client per module is launched.

mfussenegger commented 3 months ago

See the readme: https://github.com/mfussenegger/nvim-jdtls?tab=readme-ov-file#configuration-verbose

In particular:


  -- 💀
  -- This is the default if not provided, you can remove it. Or adjust as needed.
  -- One dedicated LSP server & client will be started per unique root_dir
  root_dir = require('jdtls.setup').find_root({'.git', 'mvnw', 'gradlew'}),

:help vim.lsp.start() also gives more information about this.