snippets
This commit is contained in:
parent
55b8652ce0
commit
f9140db304
91
lua/snippets.lua
Normal file
91
lua/snippets.lua
Normal file
@ -0,0 +1,91 @@
|
||||
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 date_status = function()
|
||||
return { os.date '%d-%m-%Y' }
|
||||
end
|
||||
|
||||
local filepath = function()
|
||||
return { vim.fn.expand '%:r:t' }
|
||||
end
|
||||
|
||||
local incident_tag = function()
|
||||
filename = vim.fn.expand '%:t'
|
||||
incident = '#' .. string.sub(filename, 10, 15)
|
||||
return incident
|
||||
end
|
||||
|
||||
-- Do something with the filename to return the SURFcert-incident number
|
||||
|
||||
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(filepath, {}),
|
||||
text { '', 'aliases: []' },
|
||||
text { '', "tags: ['" },
|
||||
insert(1, ''),
|
||||
text { "']" },
|
||||
text { '', '---', '' },
|
||||
insert(0),
|
||||
}),
|
||||
snip({
|
||||
trig = 'SURFcert',
|
||||
namr = 'SURFcert-incident',
|
||||
dscr = 'Status van een SURFcert-incident',
|
||||
}, {
|
||||
text { '# Incident ' },
|
||||
func(incident_tag, {}),
|
||||
text { '', '', '## Status', '', 'TODO', '' },
|
||||
text { '## Onderzoek', '', '' },
|
||||
text { '## Melding', '', '' },
|
||||
insert(1, ''),
|
||||
insert(0),
|
||||
}),
|
||||
snip({
|
||||
trig = 'statusdatum',
|
||||
namr = 'Datum voor status.md-bestanden',
|
||||
dscr = 'Datum als DD-MM-YYYY',
|
||||
}, {
|
||||
text { '## ' },
|
||||
func(date_status, {}),
|
||||
text { '', '', '' },
|
||||
insert(0),
|
||||
}),
|
||||
},
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user