Yeah, you need to load a buffer or implement everything from scratch if you want to operate on file. All the helper functions in neovim operate on buffers. If you’re dealing with response from a language server, you’re gonna get a uri, which can be converted to a buffer with the helper function vim.uri_to_bufnr, which will handle creating the buffer for you if it doesn’t exist.
I was searching for a while trying to find the uri_to_bufnr helper but could never figure out how to find it so thank you very much for telling me about the function.