diff options
Diffstat (limited to '.vim/snippets/all.lua')
| -rw-r--r-- | .vim/snippets/all.lua | 83 |
1 files changed, 31 insertions, 52 deletions
diff --git a/.vim/snippets/all.lua b/.vim/snippets/all.lua index 0d0e3e6..6dfe009 100644 --- a/.vim/snippets/all.lua +++ b/.vim/snippets/all.lua @@ -1,17 +1,21 @@ ---@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('my', user_email), + -- mini symbols + s('check', t([[✔]])), + s('cross', t([[✖]])), + s('...', t([[…]])), + + s( + 'memail', + c(1, { + t([[robert@gnzler.de]]), + t([[robert@gnzler.io]]), + }) + ), s('mename', t([[Robert Günzler]])), s('date', exec([[date --rfc-email]])), + s( 'today', f(function() @@ -25,52 +29,27 @@ return { 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] = { - [require('luasnip.util.events').enter] = function(_, _) - vim.opt_local.filetype = 'sh' - end, - }, - }, - } + 'license', + d(1, function() + local choices = {} + for _, path in + ipairs( + vim.fn.glob(vim.fn.stdpath('config') .. '/snippets/license_*.txt', false, true, false) + ) + do + choices[#choices + 1] = f(function(_, _, uargs) + return vim.fn.readfile(uargs) + end, {}, { user_args = { path } }) + end + return sn(nil, { c(1, choices, { name = 'FOSS licenses' }) }) + end, nil) ), - -- mini symbols - s('check', t([[✔]])), - s('cross', t([[✖]])), - - -- 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]]) }) + 'todo', + d(1, function() + return sn(nil, fmt(string.format(vim.bo.commentstring, ' TODO: {} '), { i(1) })) + end, nil) ), } |