MagicDuck / grug-far.nvim

Find And Replace plugin for neovim
MIT License
782 stars 23 forks source link

RPC[Error] code_name = InvalidParams, message = "Document for URI could not be found: ..." #93

Closed fredrikaverpil closed 4 months ago

fredrikaverpil commented 4 months ago

Hey @MagicDuck and thanks for this fantastic plugin! 👏 😄 I've always struggled a bit with nvim-spectre in terms of how you have to mix filters and flags, and your UI and keymaps just makes everything so much more intuitive to me. Instant replacement here! ⭐

I am however getting an RPC error for each character I type into the search field. This is me typing in hello into the search field:

08:35:31 msg_show RPC[Error] code_name = InvalidParams, message = "Document for URI could not be found: file:///Users/fredrik/code/dotfiles/Grug%20FAR%20-%201%3A%20he, URIs of the known document are: file:///Users/fredrik/code/dotfiles/Grug%20FAR%20-%201"
08:35:33 msg_show RPC[Error] code_name = InvalidParams, message = "Document for URI could not be found: file:///Users/fredrik/code/dotfiles/Grug%20FAR%20-%201%3A%20hel, URIs of the known document are: file:///Users/fredrik/code/dotfiles/Grug%20FAR%20-%201"
08:35:34 msg_show RPC[Error] code_name = InvalidParams, message = "Document for URI could not be found: file:///Users/fredrik/code/dotfiles/Grug%20FAR%20-%201%3A%20hell, URIs of the known document are: file:///Users/fredrik/code/dotfiles/Grug%20FAR%20-%201"
08:35:36 msg_show RPC[Error] code_name = InvalidParams, message = "Document for URI could not be found: file:///Users/fredrik/code/dotfiles/Grug%20FAR%20-%201%3A%20hello, URIs of the known document are: file:///Users/fredrik/code/dotfiles/Grug%20FAR%20-%201"

My current working directory is /Users/fredrik/code/dotfiles and it feels like grug-far is expecting (or looking for) a file in this location, matching the pattern Grug FAR - 1: <search term>.

This doesn't appear to affect functionality other than being annoying (as I get popups about this).

System:

MagicDuck commented 4 months ago

HI Frederik, thank you for the kind words and detailed info! 😄

That error message makes me suspicious that a language server is trying to attach to the buffer, but there is no backing file for it naturally. If you run :LspInfo while in the grug-far.nvim buffer, do you see any language server attached?

image
MagicDuck commented 4 months ago

could also be copilot / other AI related if you use that... (saw similar error in this emacs issue: https://github.com/copilot-emacs/copilot.el/issues/171)

If you use something like https://github.com/zbirenbaum/copilot.lua?tab=readme-ov-file#setup-and-configuration you can exclude the grug-far's filetypes (see https://github.com/MagicDuck/grug-far.nvim?tab=readme-ov-file#filetype)

fredrikaverpil commented 4 months ago

Ah yes, that was it - thank you! I have copilot.lua activated for public git repos, and I don't see this error in the non-public ones. 😄

I just noticed this didn't work well in Lua as it doesn't like the dash:

filetypes = {
  grug-far = false,
  grug-far-history = false,
}

I worked around it with opts.filetypes["grug-far"] = false. With this, no more rpc errors! 👍 Thanks again so much for the support and your work on the plugin! ⭐

MagicDuck commented 4 months ago

@fredrikaverpil glad that worked! 😄 Btw, small tip, I believe this should work if you want to add the filetypes config inline:

filetypes = {
  ["grug-far"] = false,
  ["grug-far-history"] = false,
}
fredrikaverpil commented 3 months ago

Awesome, thank you @MagicDuck, I didn't know this! 👍