diff options
author | sumneko <sumneko@hotmail.com> | 2019-05-29 09:47:21 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-05-29 09:47:21 +0800 |
commit | 7af57e8d1416f8488ce778d7f3da10041bdf45b2 (patch) | |
tree | 0aabcdbcedfa599fba559fac4d75d4a8cabc9f68 /server/main.lua | |
parent | c6ad0a3d298d5eca968ae1835c566372b2b18c15 (diff) | |
download | lua-language-server-7af57e8d1416f8488ce778d7f3da10041bdf45b2.zip |
换个做法设置初始路径
Diffstat (limited to 'server/main.lua')
-rw-r--r-- | server/main.lua | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/server/main.lua b/server/main.lua index 9c258b22..681135d5 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,16 +1,12 @@ -local function findExe() - local n = 0 - while true do - if not arg[n-1] then - return arg[n] - end - n = n - 1 - end -end +local currentPath = debug.getinfo(1, 'S').source:sub(2) +local rootPath = currentPath:gsub('[/\\][^/\\]-$', '') +package.cpath = rootPath .. '/bin/?.dll' + .. ';' .. rootPath .. '/bin/?.so' +package.path = rootPath .. '/src/?.lua' + .. ';' .. rootPath .. '/src/?/init.lua' local fs = require 'bee.filesystem' - -ROOT = fs.path(findExe()):parent_path():parent_path() +ROOT = fs.path(rootPath) LANG = LANG or 'en-US' package.path = (ROOT / 'src' / '?.lua'):string() |