LuaLS/LuaLS.github.io

Plugin ResolveRequire wrong description of URI?

Closed this issue · 3 comments

---@param  uri  string # The URI of file

Over the plugins page it seems to me like ResolveRequire first parameter is the current file the require is being typed at.

But in reality it seems to be the workspace URI, not the file. I am not sure if this is a bug and it should actually be the file URI, because actually I do need that and can't figure out how I would do it!

image

Seems like a documentation problem, the URI passed seems reasonable
https://github.com/LuaLS/lua-language-server/blob/master/script/workspace/require-path.lua#L175-L188

PS: I was able to get the URI of the current file with a bit of help from debug.getlocal. which queries back this code https://github.com/LuaLS/lua-language-server/blob/master/script/workspace/require-path.lua#L244-L250
image

Would very much appreciate simply having the full URI of the file that does the require. Or, at least, a relative path to the calling file - relative to the given URI.

This indeed seems more like a bug, where the full URI to the require-ing file should be given. Please open an issue for this on the language server instead.

As for how you would then get the URI of the workspace, I'm not positive, but I believe there is a function that could tell you that, given the file URI.