From e460676b0a98596fa2886e14434bc600bd921862 Mon Sep 17 00:00:00 2001 From: Alexander Neonxp Kiryukhin Date: Thu, 24 Apr 2025 13:01:05 +0300 Subject: =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20=D0=B0?= =?UTF-8?q?=D0=B2=D1=82=D0=BE=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=D1=83=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D1=81=D0=B1=D0=BE=D1=80=D0=BA=D0=B8=20tem?= =?UTF-8?q?pl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nvim/lua/autocommands.lua | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'nvim/lua/autocommands.lua') diff --git a/nvim/lua/autocommands.lua b/nvim/lua/autocommands.lua index 4a565db..ef7353f 100644 --- a/nvim/lua/autocommands.lua +++ b/nvim/lua/autocommands.lua @@ -1,3 +1,30 @@ +local function async_cmd(cmd) + local job_id = vim.fn.jobstart(cmd, { + on_stdout = function(_, data) + for _, line in pairs(data or {}) do + print(line) + end + end, + on_stderr = function(_, data) + for _, line in pairs(data or {}) do + print(line) + end + end, + on_exit = function(_, code) + if code ~= 0 then + vim.notify( + string.format("Команда завершилась с ошибкой (%d)", code), + vim.log.levels.ERROR + ) + else + vim.notify("OK", vim.log.levels.INFO) + end + end, + }) + + return job_id +end + vim.api.nvim_create_autocmd({ "BufWritePre" }, { pattern = "*.go", callback = function() @@ -82,6 +109,14 @@ vim.api.nvim_create_autocmd("BufEnter", { end, }) +vim.api.nvim_create_autocmd({ "BufWritePost" }, { + pattern = "*.templ", + callback = function() + local cmd = "templ generate" + async_cmd(cmd) + end, +}) + -- vim.api.nvim_create_autocmd("InsertEnter", { -- pattern = "*", -- command = "set norelativenumber", -- cgit v1.2.3