Using templastes is boring because templates are static, I would like to be able to trigger a _skel snippet for new/ampty files.
I am having some issues but I would like receive some feedback
-- Define local variables
local augroup = vim.api.nvim_create_augroup
local autocmd = vim.api.nvim_create_autocmd
augroup("AutoSkel", { clear = true })
autocmd("BufEnter", {
group = "AutoSkel",
pattern = "*.lua",
callback = function()
if vim.fn.line("$") ~= 1 or vim.fn.getline(1) ~= "" then
return
end
local snips = require("luasnip").get_snippets()[vim.bo.ft]
for _, snip in ipairs(snips) do
vim.cmd('startinsert')
if snip["name"] == "_skel" then
require("luasnip").snip_expand(snip)
return true
end
end
end,
})