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

Error: `[telescope.builtin.lsp_*]: server does not support definitionProvider` #589

Closed mawkler closed 7 months ago

mawkler commented 7 months ago

LSP client configuration

-- Fetches Lazy if not present.
local function bootstrap_lazy()
  local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
  if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({
      "git",
      "clone",
      "--filter=blob:none",
      "https://github.com/folke/lazy.nvim.git",
      "--branch=stable",
      lazypath,
    })
  end
  vim.opt.rtp:prepend(lazypath)
end
bootstrap_lazy()

require('lazy').setup({
  {
    'williamboman/mason.nvim',
    opts = {},
  },
  {
    'mfussenegger/nvim-jdtls',
    dependencies = {
      'williamboman/mason.nvim',
      'neovim/nvim-lspconfig',
      { 'nvim-telescope/telescope.nvim', dependencies = 'nvim-lua/plenary.nvim' },
    },
    config = function()
      local function setup_jdtls()
        local mason_path = require('mason-core.path')
        local function get_install_path(package)
          return require('mason-registry').get_package(package):get_install_path()
        end

        local config = {
          cmd = { mason_path.concat({ get_install_path('jdtls'), 'jdtls' }) },
        }
        require('jdtls').start_or_attach(config)
      end

      local augroup = vim.api.nvim_create_augroup('jdtls', {})
      vim.api.nvim_create_autocmd('FileType', {
        pattern = 'java',
        group = augroup,
        callback = setup_jdtls,
      })
    end,
  },
})

Eclipse.jdt.ls version

v1.29.0

Steps to Reproduce

  1. :Telescope lsp_definitions
  2. Error: [telescope.builtin.lsp_*]: server does not support definitionProvider

Expected Result

(basically) the same behaviour as with vim.lsp.buf.definition() (which does work)

Actual Result

I get the errorr: [telescope.builtin.lsp_*]: server does not support definitionProvider

mawkler commented 7 months ago

I'm not sure if this is an issue with nvim-jdtls or if it's an issue with telescope.nvim, but I've been using Telescope for a while and I've never had this issue before. I just installed nvim-jdtls.

mfussenegger commented 7 months ago

That's very likely a telescope issue.

Since https://github.com/neovim/neovim/commit/ddd92a70d2aab5247895e89abaaa79c62ba7dbb4 neovim supports dynamic registration for definition, and eclipse.jdt.ls uses that, so the definitionProvider is not available in the server_capabilities.

They should adapt it to use client.supports_method('textDocument/definition') to check for the capability. It takes both - the static and dynamic capabilities into consideration.

fgheng commented 5 months ago

Whether you found a solution.