dotfiles

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

beancount.lua (670B)


      1 -- Don't wrap beancount files.
      2 vim.opt_local.textwidth = 0
      3 vim.opt_local.wrap = false
      4 
      5 -- Format on save.
      6 vim.api.nvim_create_autocmd("BufWritePre", {
      7   buffer = 0,
      8   desc = "Run bean-format on save",
      9   callback = function()
     10     local filepath = vim.api.nvim_buf_get_name(0)
     11     local view = vim.fn.winsaveview()
     12     
     13     if filepath:match("[\\/]prices[\\/]") then
     14       vim.cmd("silent %!bean-format -")
     15     else
     16       vim.cmd("silent %!bean-format -c 80 -")
     17     end
     18     
     19     if vim.v.shell_error ~= 0 then
     20       vim.cmd("silent undo")
     21       vim.notify("bean-format failed (syntax error)", vim.log.levels.WARN)
     22     else
     23       vim.fn.winrestview(view)
     24     end
     25   end,
     26 })