5

I'm trying to get all the interfaces from a given buffer. To do so, I want to get all the tokens and filter out everything except the interfaces. However, when I try to make a call to the LSP: I get nothing back.

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))

All I'm getting is an empty map. I'm clearly missing something obvious, but I can't figure out what.

{
  [2] = {
    result = {}
  }
}
Tomasz Gałkowski
  • 1,841
  • 4
  • 24
  • 39

1 Answers1

0

Language server you're using probably didn't implement the method you're looking for. You can try other LSPs and compare.
See the NOTE from the 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.

Also, make sure your LSP is configured correctly, just in case.

inyourdream
  • 700
  • 4
  • 13