-
-
Notifications
You must be signed in to change notification settings - Fork 384
Description
Describe the bug
Starting with 2.5.0
, I noticed that the language server no longer loaded files that correspond to require()
-ed modules.
My neovim scripts generate the language server config at startup, which includes populating Lua.runtime.path
and Lua.workspace.library
with some custom locations, which includes the current working directory and/or workspace directory (repository root). It adds the following paths to Lua.runtime.path
:
/absolute/path/to/workspace/?.lua
/absolute/path/to/workspace/?/init.lua
./?.lua
./?/init.lua
I have discovered that having ?.lua
and ?/init.lua
(the defaults in the vscode plugin) makes things work properly, but It's odd that the other versions (absolute and relative paths) do not. Is this intended?
To Reproduce
Note: Lua.runtime.pathStrict
is set to false
~/git/scratch $ tree
.
├── mod.lua
├── subdir
│ └── sub_module.lua
└── test.lua
contents of subdir/sub_module.lua
:
--- my submodule
local _M = {
--- module name
name = "sub_module",
--- some important attribute
attr = 456,
}
return _M
contents of test.lua
:
local mod = require "mod"
print(mod.attr)
local submod = require "subdir.sub_module"
print(submod.attr)
local other = require "other.mod"
print(other.value)
With Lua.runtime.path
set to ["?.lua", "?/init.lua"]
, files are correctly located and loaded:
Using relative path (./?.lua
|./?/init.lua
) or absolute path (/path/to/git/scratch/?.lua
|/path/to/git/scratch/?/init.lua
) leads to the module not being resolved/loaded:
I've also noted that files outside the workspace cannot be loaded via Lua.runtime.path
. For instance, if a file exists at /path/to/other/mod.lua
, and I add /path/to/other/?.lua
to Lua.runtime.path
, it is not discovered. I understand that adding /path/to/other
to Lua.workspace.library
solves this, but all of this makes me wonder: what is the purpose of Lua.runtime.path
if only the default values (?.lua
|?/init.lua
) actually do anything?
Expected behavior
I expected ?.lua
, ./?.lua
, and /absolute/path/to/?.lua
to be equal/equivalent in behavior, but as of 2.5.0
it seems that only ?.lua
has any effect.
Ideally I would like to add certain paths to Lua.runtime.path
so that files will be discovered when require()
-ed but without adding them to Lua.workspace.library
(since that causes the full directory to be scanned and pre-loaded, which leads to a slower startup time).
Environment (please complete the following information):
- OS: Linux
Is WSL remote?- Client: VSCode and Neovim