Добавил автокоманду для сборки templ
This commit is contained in:
parent
9ce255278b
commit
e460676b0a
4 changed files with 62 additions and 7 deletions
|
@ -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",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue