From 216f43fb934f292ed20014018b00e4e0fd6bef6e Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Wed, 20 Sep 2023 17:15:10 +0200 Subject: rough initial commit --- init.lua | 23 +++++++++++++++++++++++ snippets/ab_itemize | 4 ++++ snippets/e_columns | 7 +++++++ 3 files changed, 34 insertions(+) create mode 100644 init.lua create mode 100644 snippets/ab_itemize create mode 100644 snippets/e_columns diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..b3f06c6 --- /dev/null +++ b/init.lua @@ -0,0 +1,23 @@ +local M = {snippets={}} + +local source_str = debug.getinfo(1, 'S').source:sub(2) +local script_path = source_str:match('(.*/)') +local snippets_path = script_path .. 'snippets' + +vis:command_register('snippet', function(argv, _, win, _, _) + local snippet = argv[1] + if not snippet then return end + local pos = win.selection.pos + if not M.snippets[snippet] then + local snippet_path = snippets_path .. '/' .. argv[1] + local file = io.open(snippet_path, "rb") -- r read mode and b binary mode + if not file then return end + local content = file:read("*a") + file:close() + win.file:insert(pos, content) + else + win.file:insert(pos, M.snippets[snippet]) + end +end, 'Insert a snippet after the primary selection') + +return M diff --git a/snippets/ab_itemize b/snippets/ab_itemize new file mode 100644 index 0000000..9833d81 --- /dev/null +++ b/snippets/ab_itemize @@ -0,0 +1,4 @@ +\begin{itemize} +\item[a)] +\item[b)] +\end{itemize} diff --git a/snippets/e_columns b/snippets/e_columns new file mode 100644 index 0000000..22b7c2f --- /dev/null +++ b/snippets/e_columns @@ -0,0 +1,7 @@ +::: columns +:::: {.column width=50%} +:::: + +:::: {.column width=50%} +:::: +::: -- cgit v1.2.3