Skip to content

nvim-java and failed integration with mason and mason-lspconfig #382

Closed as duplicate

Description

@DaniloMekic

I ensured that:

  • nvim-java is setup first
  • that mason is setup before nvim-lspconfig
  • that nvim-java/mason-registry is prioritized over mason-org/mason-registry
  • that mason-lspconfig is loaded last

But I still got error when I launch Neovim:

[mason-lspconfig.nvim] Server "jdtls" is not a valid entry in ensure_installed. Make sure to only provide lspconfig server names.

Here is my config. As you can see, I have mutilple LSPs loaded via mason-lspconfig, but I got error only for JDTLS.

return {
  {
    "nvim-java/nvim-java",
    opts = {
      jdk = { auto_install = false }
    }
  },
  {
    "neovim/nvim-lspconfig",
    dependencies = {
      {
        "mason-org/mason.nvim",
        opts = {
          registries = {
            "github:nvim-java/mason-registry",
            "github:mason-org/mason-registry"
          }
        }
      }
    },
    {
      "mason-org/mason-lspconfig.nvim",
      opts = {
        ensure_installed = {
          "jdtls",
          "lua_ls",
          "html",
          "cssls",
          "ts_ls",
          "basedpyright",
          "ruff"
        }
      }
    }
  }
}

Activity

  1. changed the title [-]`nvim-java` and failed integration with `mason` and `mason-lspconfig'[/-] [+]`nvim-java` and failed integration with `mason` and `mason-lspconfig`[/+] on May 16, 2025
  2. mathieurousseau commented on May 16, 2025

    @mathieurousseau

    This does not look like how it is supposed to be setup:
    https://github.com/nvim-java/nvim-java/wiki/Lazyvim#install-nvim-java-on-lazyvim

    return {
      'nvim-java/nvim-java',
      config = false,
      dependencies = {
        {
          'neovim/nvim-lspconfig',
          opts = {
            servers = {
              jdtls = {
                -- Your custom jdtls settings goes here
              },
            },
            setup = {
              jdtls = function()
                require('java').setup({
                  -- Your custom nvim-java configuration goes here
                })
              end,
            },
          },
        },
      },
    }
  3. mathieurousseau commented on May 16, 2025

    @mathieurousseau

    To be frank right now I can't have the play-lazyvim repo to work properly:
    #381

    So until this is fixed, I am not sure we can make nvim-java work at all 🤔

  4. DaniloMekic commented on May 17, 2025

    @DaniloMekic
    Author

    This does not look like how it is supposed to be setup: https://github.com/nvim-java/nvim-java/wiki/Lazyvim#install-nvim-java-on-lazyvim

    return {
    'nvim-java/nvim-java',
    config = false,
    dependencies = {
    {
    'neovim/nvim-lspconfig',
    opts = {
    servers = {
    jdtls = {
    -- Your custom jdtls settings goes here
    },
    },
    setup = {
    jdtls = function()
    require('java').setup({
    -- Your custom nvim-java configuration goes here
    })
    end,
    },
    },
    },
    },
    }

    Your solution give me this error:

    Failed to run config for nvim-lspconfig
    ... /local/nvim-data/lazy/lazy.nvim/lua/lazy/core/loader.lua:387: attempt to call field 'setup' (a table value)

  5. s1n7ax commented on May 17, 2025

    @s1n7ax
    Member

    @DaniloMekic What mason version are you using?

  6. DaniloMekic commented on May 18, 2025

    @DaniloMekic
    Author

    @DaniloMekic What mason version are you using?

    Latest, 2.0.

  7. mathieurousseau commented on May 18, 2025

    @mathieurousseau

    @DaniloMekic seems you need to downgrade to mason 1.x until the mason 2.0 enhancement issue is conplete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions