如何在neovim LSP中获取所有接口(或任何令牌)?

5
我正在尝试从给定的缓冲区中获取所有接口。为了做到这一点,我想获取所有令牌并过滤掉除接口以外的所有内容。然而,当我尝试调用 LSP 时,我没有得到任何返回信息。
local bufnr = vim.api.nvim_get_current_buf()
local params = vim.lsp.util.make_text_document_params()
local result = vim.lsp.buf_request_sync(bufnr, "textDocument/documentSymbol", params, 2000)
print(vim.inspect(result))

我只得到了一个空地图。显然,我漏掉了一些很明显的东西,但我弄不清楚是什么。
{
  [2] = {
    result = {}
  }
}
1个回答

1

你使用的语言服务器可能没有实现你要查找的方法。你可以尝试其他 LSPs 并进行比较。
请参阅 Neovim 的注意事项 docs

lsp-method
Methods are the names of requests and notifications as defined by the LSP specification. These LSP requests/notifications are defined by default:

callHierarchy/incomingCalls
callHierarchy/outgoingCalls
textDocument/codeAction
textDocument/completion
textDocument/declaration*
textDocument/definition
textDocument/documentHighlight
textDocument/documentSymbol
textDocument/formatting
textDocument/hover
textDocument/implementation*
textDocument/publishDiagnostics
textDocument/rangeFormatting
textDocument/references
textDocument/rename
textDocument/signatureHelp
textDocument/typeDefinition*
window/logMessage
window/showMessage
window/showDocument
window/showMessageRequest
workspace/applyEdit
workspace/symbol

NOTE: These are sometimes not implemented by servers.

此外,请确保您的 LSP 配置正确,以防万一。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接