You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- instead of deps, we can call it `lua_modules` :cry:---- TODO: Add `deps` stuff to `package.path` so then you could drop all of this in deps/-- deps/-- myplugin__plenary__commit-- Could also add:-- $ROOT/deps/-- $ROOT/lua/deps/...-- For now this works with $ROOT/lua/deps since then `require` bits get to work for free.-- if we add a new searcher, then it would probably work fine either way.localuv=vim.loop-- YOU CAN ONLY CALL THIS FUNCTION FROM THE APPROPRIATE LEVEL OF NESTEDNESS-- OTHERWISE YOU GET THE WRONG PATH. CAREFUL OF THIS ONE!localfunctionget_script_path()
localpath=debug.getinfo(3, "S").source:sub(2):match"(.*/)"returnuv.fs_realpath(path)
endlocalfunctionfind_plugin_root(path)
-- TODO: Windows Sadgelocalparts=vim.split(path, "/")
while#parts>0dolocalsubpath=table.concat(parts, "/")
ifuv.fs_stat(subpath.."/plugin.lua") thenreturnsubpathendtable.remove(parts, #parts)
endreturnnilendlocalfunctionget_dep_name(name)
name=string.gsub(name, "/", ".")
returnvim.split(name, "%.")[1]
endlocalfunctionmake_dep_path(plug_name, dep_name, version, name)
returnstring.format("deps.%s__%s__%s.lua.%s", plug_name, dep_name, version, name)
endlocaldep=function(name)
localplugin_script=get_script_path()
localdep_name=get_dep_name(name)
localplugin_root=find_plugin_root(plugin_script)
ifplugin_rootthenlocalplugin_config=loadfile(plugin_root.."/plugin.lua")()
localplugin_deps=plugin_config.dependenciesifnotplugin_deps[dep_name] thenerror(string.format("Could not find dependency: %s // %s", dep_name, name))
end-- TODO: This is a bit goofy, but it makes it so that we can-- still use require easily.localdep_version=string.gsub(plugin_deps[dep_name], "%.", "-")
localdep_path=make_dep_path(plugin_config.name, dep_name, dep_version, name)
NESTED_REQUIRE=truelocalok, mod=pcall(require, dep_path)
NESTED_REQUIRE=falseifnotokthenerror(mod)
endreturnmod-- return setfenv(require, {-- require = function(req_name)-- error(req_name)-- end,-- })(dep_path)enderror(string.format("Unable to find plugin root: %s // %s", name, plugin_script))
endvim.dep=dep
The text was updated successfully, but these errors were encountered:
The idea is to have multiple versions of the same package? I think in order for that to be a thing, dependencies would have to explicitly declare that they promise not to modify the global state in any way, so you don't have multiple versions fighting over the same global variable or something like that.
mjlbach
changed the title
vim.dep
Per package dependency versioning via vim.depMar 29, 2022
Implementation:
The text was updated successfully, but these errors were encountered: