summary refs log tree commit diff
path: root/.vim/snippets/all.lua
blob: f218086548ee62f4f1b4609dc8b49c25853a4c92 (plain) (blame)
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
61
62
63
64
65
66
67
68
69
70
71
---@diagnostic disable: undefined-global

local todo_comment = function(keys)
  local choices = vim.tbl_map(function(e)
    return t(e)
  end, keys)
  table.insert(choices, i(0))
  return comment({ c(1, choices), t(': ') })
end

return {
  s('me', user_email),
  s('date', exec([[date --rfc-email]])),
  s(
    'today',
    f(function()
      return os.date('%Y-%m-%d')
    end, {})
  ),
  s(
    'now',
    f(function()
      return os.date('%Y-%m-%dT%H:%M:%SZ')
    end, {})
  ),

  -- todo comments
  s('todo', todo_comment({ 'TODO', 'NOTE', 'FIXME' })),

  s(
    { trig = '#!', name = 'Shell script skeleton' },
    fmt(
      [=[
      #!/bin/sh

      set -e
      [ -n "$DEBUG" ] && set -x
      [ -n "$DESC" ] && desc() {{
      	printf "{}"
      	exit 0
      }}

    ]=],
      { i(1, 'what does this script do') }
    ),
    {
      callbacks = {
        [-1] = {
          [events.enter] = function(_, _)
            vim.opt_local.filetype = 'sh'
          end,
        },
      },
    }
  ),

  -- licenses (SPDX header)
  s({ trig = 'spdx-mit', name = 'MIT license' }, comment({ t([[SPDX-License-Identifier: MIT]]) })),
  s(
    { trig = 'spdx-gpl-3.0', name = 'MIT license' },
    comment({ t([[SPDX-License-Identifier: GPL-3.0]]) })
  ),
  s(
    { trig = 'spdx-agpl-3.0', name = 'MIT license' },
    comment({ t([[SPDX-License-Identifier: AGPL-3.0]]) })
  ),
  s(
    { trig = 'spdx-cc0-1.0', name = 'MIT license' },
    comment({ t([[SPDX-License-Identifier: CC0-1.0]]) })
  ),
}