summaryrefslogtreecommitdiff
path: root/platform.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-03-25 17:59:39 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-03-27 15:16:23 +0800
commit2e78c013df3bf1f05ec5da7c97506b8e62d5280b (patch)
tree64d4c8c7ff9baaff211a02df8e0cfb4a51bfeca1 /platform.lua
parent3ee51ba3bfc5d83791176e17801e7b86f1c2cebc (diff)
downloadlua-language-server-2e78c013df3bf1f05ec5da7c97506b8e62d5280b.zip
#462 use required name instead of full path
Diffstat (limited to 'platform.lua')
-rw-r--r--platform.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/platform.lua b/platform.lua
index 6c9d7c09..eb318a84 100644
--- a/platform.lua
+++ b/platform.lua
@@ -41,3 +41,18 @@ else
package.path = rootPath .. script .. '/?.lua'
.. ';' .. rootPath .. script .. '/?/init.lua'
end
+
+package.searchers[2] = function (name)
+ local filename, err = package.searchpath(name, package.path)
+ if not filename then
+ return err
+ end
+ local f = io.open(filename)
+ local buf = f:read '*a'
+ f:close()
+ local init, err = load(buf, '@' .. name)
+ if not init then
+ return err
+ end
+ return init, filename
+end