···
local sn = ls.snippet_node
193
+
local d = ls.dynamic_node
local function date_input()
return os.date('%Y-%m-%d')
···
local function amount_spacing(args)
local account_length = #args[1][1]
201
+
local amount = args[2][1]
202
+
if amount == '' then
local desired_column = vim.g.ledger_align_at or 50
local current_column = 2 + account_length + 2 -- 2 spaces after account
202
-
local amount = args[2][1]
local period_position = amount:find('%.') or (#amount + 1)
local pre_period_length = period_position - 1
local total_length = current_column + pre_period_length
···
return string.rep(' ', spaces_needed)
215
+
local function recursive_accounts()
217
+
t({ '', ' ' }), i(1, 'Account'), f(amount_spacing, { 1, 2 }),
220
+
sn(nil, { i(1, '£') })
224
+
d(nil, recursive_accounts)
216
-
i(6, date_input()), t(' '), i(1, 'Recipient'),
234
+
i(1, date_input()), t(' '), i(2, 'Description'),
sn(nil, { t({ '', ' ; ' }), i(1, 'Comment') }),
221
-
t({ '', ' ' }), i(3, 'Account'), f(amount_spacing, { 3, 5 }), t('£'), i(5, '0'),
222
-
t({ '', ' ' }), i(4, 'Account'),
239
+
t({ '', ' ' }), i(4, 'Account'), f(amount_spacing, { 4, 5 }),
241
+
sn(nil, { i(1, '£') }),
244
+
d(6, recursive_accounts),
248
+
ls.add_snippets('mail', {
250
+
t({ '<#part filename=' }),
253
+
sn(nil, { t({ ' description="', }), i(1, ''), t({ '"', }) }),
256
+
t({ '><#/part>', '' }),
vim.keymap.set({ 'i' }, '<C-k>', function() ls.expand() end, { silent = true })
vim.keymap.set({ 'i', 's' }, '<C-l>', function() ls.jump(1) end, { silent = true })