fwcd / kotlin-language-server

Kotlin code completion, diagnostics and more for any editor/IDE using the Language Server Protocol
MIT License
1.58k stars 202 forks source link

Support for multi-module project #559

Closed AlexandrosAlexiou closed 4 months ago

AlexandrosAlexiou commented 5 months ago

I have a multimoduled maven project and it seems that if the cwd points to the root of the repo (parent module) the LSP server does not work properly. (eg. Cannot resolve libraries only declared in the pom files of some modules and not in the parent one).

In case I am not doing something wrong with the setup, how difficult would it be to add this kind of feature?

Thanks :)

AlexandrosAlexiou commented 4 months ago

I can see that using the VSCode extension for this LSP my issues are alleviated. Any thoughts why the LSP misbehaves in Neovim?

AlexandrosAlexiou commented 4 months ago

The issue is because of this line in nvim-lspconfig.

Fixed by adding a custom root_dir function in my Neovim configuration to start indexing from the current working directory all files like so:

  kotlin_language_server = {
      filetypes = {
          "kotlin",
      },
      root_dir = function()
          return vim.fn.getcwd()
      end,
      settings = {
          kotlin = { compiler = { jvm = { target = "19" } } },
          hints = {
              typeHints = true,
              parameterHints = true,
              chainedHints = true,
          },
      },
  },
franckrasolo commented 4 months ago

@AlexandrosAlexiou is your Neovim configuration on GitHub?

AlexandrosAlexiou commented 4 months ago

@AlexandrosAlexiou is your Neovim configuration on GitHub?

Sure you can take a look here