From 6a4e02ef043a1c14446938b6549c86a974abdbdf Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Sun, 19 Sep 2021 23:59:04 +0200 Subject: [PATCH] Testing a project config to automate builds --- .lite_project.lua | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .lite_project.lua diff --git a/.lite_project.lua b/.lite_project.lua new file mode 100644 index 00000000..e7d5704e --- /dev/null +++ b/.lite_project.lua @@ -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", +} +