summaryrefslogtreecommitdiffstats
path: root/.config/nvim/lua/luasnippets/vimwiki.lua
blob: c5e85322772b2cbb2ce7b7dee9d3a733ea05cae4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
local ls = require("luasnip")
local s = ls.snippet
local sn = ls.snippet_node
local isn = ls.indent_snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local r = ls.restore_node
local events = require("luasnip.util.events")
local ai = require("luasnip.nodes.absolute_indexer")
local extras = require("luasnip.extras")
local l = extras.lambda
local rep = extras.rep
local p = extras.partial
local m = extras.match
local n = extras.nonempty
local dl = extras.dynamic_lambda
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local conds = require("luasnip.extras.expand_conditions")
local postfix = require("luasnip.extras.postfix").postfix
local types = require("luasnip.util.types")
local parse = require("luasnip.util.parser").parse_snippet
local ms = ls.multi_snippet
local k = require("luasnip.nodes.key_indexer").new_key
local strftime = vim.fn.strftime

local function clipboard()
    local text = vim.fn.system({ 'wl-paste' })
    local output = string.gsub(text, "^%s*(.-)%s*$", "%1")
    return output
end

return {
    s("datasrc",
        {
            t({ "= " }), i(1), t({ " =", "" }),
            t({ "", "== Used By ==", "" }), i(2),
            t({ "", "== URL ==", "" }), i(3),
            t({ "", "== API ==", "" }), i(4),
            t({ "", "=== Example ===", "" }), i(5),
            t({ "", "== Cost ==", "" }), i(6),
            t({ "", "== Limits ==", "" }), i(0),
        }
    ),
    s("s",
        {
            t({ "- (" }),
            t({ strftime("%F %R") }),
            t({ ") " }),
            i(1, clipboard()),
            t({ " -- " }),
            i(2, "Summary")

        }
    )
}