method textDocument/documentSymbol is not supported by any of the servers registered for the current buffer
I get this error when opening a lua file. It is not shown when nvim-ide not loaded or setup not called.
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.
if so, we'd have to change the call order. This is not really easy to accomplish, right?
Yeah, this is most likely this just means your LSP didnt start yet. Does it work after LSP is attached?
It does. You just get the notification right when the buffer opens, because the LSP hasn’t initialized yet.
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.
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:
Does anyone have suggestions for working around this? I'm seeing LSP-related warnings and errors anytime I'm switching buffers because of this.
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
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.
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.
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.
cool, we can def try that.