kickstart.nvim/lua/snippets.lua

57 lines
1.3 KiB
Lua
Raw Permalink Normal View History

local ls = require 'luasnip'
-- some shorthands...
local snip = ls.snippet
local node = ls.snippet_node
local text = ls.text_node
local insert = ls.insert_node
local func = ls.function_node
local choice = ls.choice_node
local dynamicn = ls.dynamic_node
local date = function()
return { os.date '%Y-%m-%d' }
end
local filename = function()
return { vim.fn.expand '%:r:t' }
end
ls.add_snippets(nil, {
markdown = {
snip({
trig = 'blogpost',
namr = 'Zola blogpost Frontmatter',
dscr = 'Frontmatter metadata for Zola markdown blogpost',
}, {
text { '+++', "title = '" },
insert(1, 'note_title'),
text { "'" },
text { '', 'date = "' },
func(date, {}),
text { '"' },
text { '', 'updated = ' },
func(date, {}),
text { '', '[taxonomies]' },
text { '', "tags = ['" },
insert(2, ''),
text { "']" },
text { '', '+++', '', '' },
insert(0),
}),
snip({
trig = 'frontmatter',
namr = 'Obsidian frontmatter',
dscr = 'Frontmatter metadata for generic Obsidian note',
}, {
text { '---', 'title: ' },
func(filename, {}),
text { '', 'aliases: []' },
text { '', "tags: ['" },
insert(1, ''),
text { "']" },
text { '', '---', '' },
insert(0),
}),
},
})