summary refs log tree commit diff
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2023-01-25 11:13:00 +0100
committerRobert Günzler <r@gnzler.io>2023-03-21 12:35:44 +0100
commit702a84a71d1e8d3852002550e7ce298a7dba000d (patch)
tree09edb9cf71f28c36e1cfe2759d8a4ff3410ebc82
parentf5b7bbe222edb49feefb2bfa6f49a1b7f8e418a4 (diff)
vim: simplify todocomment snippets
Signed-off-by: Robert Günzler <r@gnzler.io>
-rw-r--r--.vim/snippets/all.lua41
1 files changed, 7 insertions, 34 deletions
diff --git a/.vim/snippets/all.lua b/.vim/snippets/all.lua
index b4fa8c3..f218086 100644
--- a/.vim/snippets/all.lua
+++ b/.vim/snippets/all.lua
@@ -1,34 +1,11 @@
 ---@diagnostic disable: undefined-global
 
-local todo_comment = function(key)
-  local nodes = {}
-  if type(key) == 'string' then
-    table.insert(nodes, t(key))
-  elseif type(key) == 'table' then
-    table.insert(
-      nodes,
-      c(
-        1,
-        vim.tbl_map(function(e)
-          return t(e)
-        end, key)
-      )
-    )
-  end
-  local wrapped = autowrap(t('('), t(')'), {
-    c(#nodes, {
-      t(''), -- bare
-      sn(1, user_email),
-      f(function()
-        return os.date('%Y-%m-%d')
-      end, {}), -- time
-    }),
-  })
-  for _, n in ipairs(wrapped) do
-    table.insert(nodes, n)
-  end
-  table.insert(nodes, t(': '))
-  return comment(nodes)
+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 {
@@ -48,11 +25,7 @@ return {
   ),
 
   -- todo comments
-  s('todo', todo_comment('TODO')),
-  s('note', todo_comment('NOTE')),
-  s('hack', todo_comment('HACK')),
-  s('warn', todo_comment({ 'WARN', 'XXX' })),
-  s('fix', todo_comment({ 'FIX', 'FIXME', 'ISSUE', 'BUG' })),
+  s('todo', todo_comment({ 'TODO', 'NOTE', 'FIXME' })),
 
   s(
     { trig = '#!', name = 'Shell script skeleton' },