2021-05-27 13:46:51 +02:00
|
|
|
-- this file is used by lite-xl to setup the Lua environment when starting
|
2021-08-09 19:32:53 +02:00
|
|
|
VERSION = "@PROJECT_VERSION@"
|
2022-03-24 16:57:26 +01:00
|
|
|
MOD_VERSION = "3"
|
2021-02-24 16:29:39 +01:00
|
|
|
|
2021-11-24 04:30:35 +01:00
|
|
|
SCALE = tonumber(os.getenv("LITE_SCALE") or os.getenv("GDK_SCALE") or os.getenv("QT_SCALE_FACTOR")) or SCALE
|
2021-02-24 16:29:39 +01:00
|
|
|
PATHSEP = package.config:sub(1, 1)
|
|
|
|
|
2021-04-18 17:51:31 +02:00
|
|
|
EXEDIR = EXEFILE:match("^(.+)[/\\][^/\\]+$")
|
|
|
|
if MACOS_RESOURCES then
|
|
|
|
DATADIR = MACOS_RESOURCES
|
|
|
|
else
|
|
|
|
local prefix = EXEDIR:match("^(.+)[/\\]bin$")
|
|
|
|
DATADIR = prefix and (prefix .. '/share/lite-xl') or (EXEDIR .. '/data')
|
|
|
|
end
|
2021-12-22 19:34:09 +01:00
|
|
|
USERDIR = (system.get_file_info(EXEDIR .. '/user') and (EXEDIR .. '/user'))
|
|
|
|
or ((os.getenv("XDG_CONFIG_HOME") and os.getenv("XDG_CONFIG_HOME") .. "/lite-xl"))
|
|
|
|
or (HOME and (HOME .. '/.config/lite-xl'))
|
2021-02-24 16:29:39 +01:00
|
|
|
|
2022-08-03 17:13:26 +02:00
|
|
|
package.path = DATADIR .. '/?.lua;'
|
2021-02-24 16:29:39 +01:00
|
|
|
package.path = DATADIR .. '/?/init.lua;' .. package.path
|
2021-03-03 12:20:22 +01:00
|
|
|
package.path = USERDIR .. '/?.lua;' .. package.path
|
|
|
|
package.path = USERDIR .. '/?/init.lua;' .. package.path
|
2021-11-17 01:37:37 +01:00
|
|
|
|
2022-09-19 00:27:50 +02:00
|
|
|
local suffix = PLATFORM == "Mac OS X" and 'lib' or (PLATFORM == "Windows" and 'dll' or 'so')
|
2022-09-25 23:08:21 +02:00
|
|
|
package.cpath =
|
2022-09-25 23:13:07 +02:00
|
|
|
USERDIR .. '/?.' .. ARCH .. "." .. suffix .. ";" ..
|
|
|
|
USERDIR .. '/?/init.' .. ARCH .. "." .. suffix .. ";" ..
|
|
|
|
USERDIR .. '/?.' .. suffix .. ";" ..
|
|
|
|
USERDIR .. '/?/init.' .. suffix .. ";" ..
|
|
|
|
DATADIR .. '/?.' .. ARCH .. "." .. suffix .. ";" ..
|
|
|
|
DATADIR .. '/?/init.' .. ARCH .. "." .. suffix .. ";" ..
|
|
|
|
DATADIR .. '/?.' .. suffix .. ";" ..
|
|
|
|
DATADIR .. '/?/init.' .. suffix .. ";"
|
|
|
|
|
2021-09-21 05:42:39 +02:00
|
|
|
package.native_plugins = {}
|
2021-09-22 23:25:16 +02:00
|
|
|
package.searchers = { package.searchers[1], package.searchers[2], function(modname)
|
2021-09-21 05:33:12 +02:00
|
|
|
local path = package.searchpath(modname, package.cpath)
|
|
|
|
if not path then return nil end
|
|
|
|
return system.load_native_plugin, path
|
2021-09-22 23:24:22 +02:00
|
|
|
end }
|
2021-11-17 01:42:08 +01:00
|
|
|
|
2021-11-17 01:37:37 +01:00
|
|
|
table.pack = table.pack or pack or function(...) return {...} end
|
|
|
|
table.unpack = table.unpack or unpack
|
2022-01-12 00:07:53 +01:00
|
|
|
|
|
|
|
bit32 = bit32 or require "core.bit"
|
2022-04-20 23:00:48 +02:00
|
|
|
|
2022-04-26 15:42:02 +02:00
|
|
|
require "core.utf8string"
|
|
|
|
|
2022-04-20 23:00:48 +02:00
|
|
|
-- Because AppImages change the working directory before running the executable,
|
|
|
|
-- we need to change it back to the original one.
|
|
|
|
-- https://github.com/AppImage/AppImageKit/issues/172
|
|
|
|
-- https://github.com/AppImage/AppImageKit/pull/191
|
|
|
|
local appimage_owd = os.getenv("OWD")
|
|
|
|
if os.getenv("APPIMAGE") and appimage_owd then
|
|
|
|
system.chdir(appimage_owd)
|
|
|
|
end
|