feat: set up luasnip;
feat: markdown file marker snippet
This commit is contained in:
34
nvim/lua/snippets/markdown.lua
Normal file
34
nvim/lua/snippets/markdown.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local extras = require("luasnip.extras")
|
||||
local rep = extras.rep
|
||||
|
||||
local timestamp = function()
|
||||
return tostring(os.time())
|
||||
end
|
||||
|
||||
local get_date = function()
|
||||
return os.date("%H:%M:%S %d.%m.%Y")
|
||||
end
|
||||
|
||||
local get_name = function()
|
||||
return "Nikolai Papin"
|
||||
end
|
||||
|
||||
return {
|
||||
s("frontmatter", {
|
||||
t("---"),
|
||||
t({ "", "title: \"" }), i(1), t("\""),
|
||||
t({ "", "date: " }), f(get_date, {}),
|
||||
t({ "", "author: \"" }), f(get_name, {}), t("\""),
|
||||
t({ "", "id: " }), f(timestamp, {}),
|
||||
t({ "", "---", "", "# " }),
|
||||
rep(1), -- Reuses the first insert node
|
||||
t({ "", ""}),
|
||||
t({ "", ""}),
|
||||
i(3) -- Final cursor position
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user