dotfiles

Personal dotfiles
git clone https://git.bracken.jp/dotfiles.git
Log | Files | Refs | LICENSE

commit bf216ec57eb224a3ff8bea0192e5f5eb3fc1842e
parent d5987d91bddff3d0f6f422fb518be9cd7f85b7fe
Author: Chris Bracken <chris@bracken.jp>
Date:   Sat, 20 Sep 2025 18:53:17 +0900

nvim: update beancount formatting

* Don't linewrap; let the formatter deal with it.
* Don't set the currency column in price files, it's really just for
  main transaction files.

Diffstat:
M.config/nvim/after/ftplugin/beancount.lua | 19++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/.config/nvim/after/ftplugin/beancount.lua b/.config/nvim/after/ftplugin/beancount.lua @@ -1,4 +1,21 @@ +-- Don't wrap beancount files. +vim.opt_local.textwidth = 0 +vim.opt_local.wrap = false + +-- Format on save. vim.api.nvim_create_autocmd("BufWritePost", { - command = "silent !bean-format % -c 100 -o %", desc = "Run bean-format on save", + callback = function(args) + local filepath = vim.api.nvim_buf_get_name(args.buf) + local filename = vim.fn.fnamemodify(filepath, ":t") -- just the tail name + local cmd + if vim.startswith(filename, "prices_") then + -- prices_* are formatted without a hardcoded currency column. + cmd = string.format("silent !bean-format %s -o %s", vim.fn.shellescape(filepath), vim.fn.shellescape(filepath)) + else + -- other beancount files are formatted with currency on 100th column. + cmd = string.format("silent !bean-format -c 100 %s -o %s", vim.fn.shellescape(filepath), vim.fn.shellescape(filepath)) + end + vim.cmd(cmd) + end, })