patch 8.2.0858: not easy to require Lua modules
Problem: Not easy to require Lua modules.
Solution: Improve use of Lua path. (Prabir Shrestha, closes #6098)
diff --git a/src/testdir/test_lua.vim b/src/testdir/test_lua.vim
index f92208c..bd50bce 100644
--- a/src/testdir/test_lua.vim
+++ b/src/testdir/test_lua.vim
@@ -536,6 +536,11 @@
%bwipe!
endfunc
+func Test_update_package_paths()
+ set runtimepath+=./testluaplugin
+ call assert_equal("hello from lua", luaeval("require('testluaplugin').hello()"))
+endfunc
+
" Test vim.line()
func Test_lua_line()
new
diff --git a/src/testdir/testluaplugin/lua/testluaplugin/hello.lua b/src/testdir/testluaplugin/lua/testluaplugin/hello.lua
new file mode 100644
index 0000000..7c90552
--- /dev/null
+++ b/src/testdir/testluaplugin/lua/testluaplugin/hello.lua
@@ -0,0 +1,7 @@
+local function hello()
+ return "hello from lua"
+end
+
+return {
+ hello = hello
+}
diff --git a/src/testdir/testluaplugin/lua/testluaplugin/init.lua b/src/testdir/testluaplugin/lua/testluaplugin/init.lua
new file mode 100644
index 0000000..1e6c474
--- /dev/null
+++ b/src/testdir/testluaplugin/lua/testluaplugin/init.lua
@@ -0,0 +1,5 @@
+local hello = require('testluaplugin/hello').hello
+
+return {
+ hello = hello
+}