This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/.config/nvim/after/ftplugin/markdown.lua

45 lines
1.0 KiB
Lua

-- Author : swytch
-- Created : Saturday Feb. 18, 2023 21:54:19 CET
-- License : GPLv3
-- Description : markdown settings file
-- Snippets
local ls = require("luasnip")
-- some shorthands...
local s = ls.snippet
local sn = ls.snippet_node
local t = ls.text_node
local i = ls.insert_node
local d = ls.dynamic_node
-- Returns a snippet_node wrapped around an insertNode whose initial
-- text value is set to the current date in the desired format.
local date_input = function(args, snip, old_state, fmt)
local fmt = fmt or "%Y-%m-%d"
return sn(nil, i(1, os.date(fmt)))
end
ls.add_snippets("markdown", {
s("date", {
d(1, date_input, {}, { user_args = { "%Y-%m-%d" } }),
}),
s("datep", {
d(1, date_input, {}, { user_args = { "%Y-%m-%d %X %z" } }),
}),
s("/xrpt", {
t("<!--more-->"),
}),
s("bb", {
t({ "**" }),
i(1),
t({ "**" }),
}),
s("ii", {
t({ "*" }),
i(1),
t({ "*" }),
}),
})