Testing a project config to automate builds

This commit is contained in:
Francesco Abbate 2021-09-19 23:59:04 +02:00
parent 14dd6f1cd6
commit 6a4e02ef04
1 changed files with 58 additions and 0 deletions

58
.lite_project.lua Normal file
View File

@ -0,0 +1,58 @@
local core = require "core"
local keymap = require "core.keymap"
local command = require "core.command"
local common = require "core.common"
local console = require "plugins.console"
local last_build = ""
-- Used to inject into the command anything needed to execute
-- into the appropriate environment.
-- Below is for lhelper but other settings may be used.
-- If not needed just return the command itself without modifications.
local function bake_command(cmd)
return "source $(lhelper env-source lite-xl); " .. cmd
end
command.add(nil, {
["lite-xl:run"] = function()
core.command_view:set_text(last_build, true)
core.command_view:enter("Run Lite XL build", function(build)
console.run {
command = bake_command("scripts/run-local " .. build),
file_pattern = "([^?:%s]+%.[^?:%s]+):([1-9]%d*):([1-9]%d*):",
file_prefix = build,
}
last_build = build
end)
end,
["lite-xl:build"] = function()
core.command_view:set_text(last_build, true)
core.command_view:enter("Run Lite XL build", function(build)
console.run {
command = bake_command("ninja -C " .. build),
file_pattern = "([^?:%s]+%.[^?:%s]+):([1-9]%d*):([1-9]%d*):",
file_prefix = build,
}
last_build = build
end)
end,
["lite-xl:meson-setup"] = function()
core.command_view:set_text(last_build, true)
core.command_view:enter("Meson setup", function(build)
console.run {
command = bake_command("rm -fr " .. build .. " && meson setup " .. build),
file_pattern = "([^?:%s]+%.[^?:%s]+):([1-9]%d*):([1-9]%d*):",
}
last_build = build
end)
end,
})
keymap.add {
["ctrl+b"] = "lite-xl:build",
["alt+!"] = "lite-xl:run",
}