2 files changed,
16 insertions(+),
18 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-02-19 19:31:37 +0200
Parent:
55c9270
jump to
| M | after/ftplugin/ledger.lua |
| M | lua/scratch/ledger.lua |
M
after/ftplugin/ledger.lua
@@ -1,4 +1,5 @@
vim.bo.commentstring = "; %s" vim.opt_local.foldmethod = "marker" +vim.opt_local.foldenable = true vim.opt_local.ts = 2 vim.opt_local.sw = 2
M
lua/scratch/ledger.lua
@@ -4,11 +4,8 @@ ---@module 'blink.cmp'
---@class blink.cmp.Source local source = {} -function source.new(opts) - local self = setmetatable({}, { __index = source }) - self.opts = opts - self.items = {} - return self +function source.new(_) + return setmetatable({}, { __index = source }) end function source:enabled()@@ -16,27 +13,27 @@ return vim.bo.filetype == "ledger"
end function source:get_trigger_characters() - return { " ", ":", "as", "eq", "li", "in", "ex" } + return { ":", "as", "eq", "li", "in", "ex" } end function source:get_completions(_, callback) local rs = vim .system({ "hledger", "accounts", "--flat" }, { text = true }) :wait() - assert(rs.code == 0, "Failed to run hledger accounts: " .. rs.stderr) ---@type lsp.CompletionItem[] - local items = vim - .iter(vim.split(rs.stdout, "\n")) - :map(function(acc) - ---@type lsp.CompletionItem - return { - label = acc, - kind = t.Property, - insertTextFormat = vim.lsp.protocol.InsertTextFormat.PlainText, - } - end) - :totable() + local items = rs.code == 0 + and vim + .iter(vim.split(rs.stdout, "\n")) + :map(function(acc) + return { + label = acc, + kind = t.Property, + insertTextFormat = vim.lsp.protocol.InsertTextFormat.PlainText, + } + end) + :totable() + or {} callback { items = items,