nvim-ide icon indicating copy to clipboard operation
nvim-ide copied to clipboard

method textDocument/documentSymbol is not supported by any of the servers registered for the current buffer

Open sboesebeck opened this issue 3 years ago • 12 comments

I get this error when opening a lua file. It is not shown when nvim-ide not loaded or setup not called.

sboesebeck avatar Nov 27 '22 17:11 sboesebeck

This also happens when the LSP server is not yet initialized. I am guessing the component is trying to grab the outline, but it isn't available yet.

mrjones2014 avatar Nov 27 '22 17:11 mrjones2014

if so, we'd have to change the call order. This is not really easy to accomplish, right?

sboesebeck avatar Nov 27 '22 17:11 sboesebeck

Yeah, this is most likely this just means your LSP didnt start yet. Does it work after LSP is attached?

ldelossa avatar Nov 27 '22 18:11 ldelossa

It does. You just get the notification right when the buffer opens, because the LSP hasn’t initialized yet.

mrjones2014 avatar Nov 27 '22 20:11 mrjones2014

Hmm, i suppose the autocmds and component code could check if an LSP is attached to the buffer and just not perform any action if its not.

ldelossa avatar Nov 27 '22 20:11 ldelossa

I ran into this too. The LSPs I'm using are ruby-ls and sumoneko, which seem to take a bit of time to start up.

I tried removing outline from the panel group used at startup, as well as not including a default panel group at startup, but get the same error.

Here's the full error in case it's useful:

CleanShot 2022-11-27 at 19 45 07@2x

technicalpickles avatar Nov 28 '22 00:11 technicalpickles

Does anyone have suggestions for working around this? I'm seeing LSP-related warnings and errors anytime I'm switching buffers because of this.

technicalpickles avatar Nov 29 '22 14:11 technicalpickles

We could do something like this in the plugin, before trying to call the textDocument/documentSymbol endpoint:

local supports_method = #(vim.tbl_filter(function(client)
  return client.supports_method('textDocument/documentSymbol')
end, vim.lsp.buf_get_clients(bufnr))) > 0

if supports_method then
  -- call it and populate the component
end

mrjones2014 avatar Nov 29 '22 14:11 mrjones2014

We would need to re-check periodically as the server will probably report that it doesn't support the method until it is finished initializing.

mrjones2014 avatar Nov 29 '22 14:11 mrjones2014

hmm, it looks like we do actually check if an LSP is attached:

    function self.create_outline()
        local log = self.logger.logger_from(nil, "Component.create_outline")
        local cur_buf = vim.api.nvim_get_current_buf()
        local cur_win = vim.api.nvim_get_current_win()

        log.debug("creating outline for workspace %d buffer %d %s", self.workspace.tab, cur_buf,
            vim.api.nvim_buf_get_name(cur_buf))
        if #vim.lsp.get_active_clients({ bufnr = cur_buf }) == 0 then
            log.debug("buffer had no LSP client attached, returning.")
            return
        end

So its not that an LSP is not attached, its maybe that its not initialized.

ldelossa avatar Nov 29 '22 16:11 ldelossa

Yeah, the issue is that it is not initialized, so before actually getting the outline data, we would need to check if any attached clients support the method. I think servers will report they don't support it until fully initialized.

mrjones2014 avatar Nov 29 '22 17:11 mrjones2014

cool, we can def try that.

ldelossa avatar Nov 29 '22 17:11 ldelossa