diff .chezmoitemplates/init.lua @ 638:652cffd59311

add beancount config
author zegervdv <zegervdv@me.com>
date Thu, 18 Aug 2022 21:10:15 +0200
parents 44c31cfaaf8a
children b6c64ebecc3e
line wrap: on
line diff
--- a/.chezmoitemplates/init.lua	Tue Aug 16 21:36:55 2022 +0200
+++ b/.chezmoitemplates/init.lua	Thu Aug 18 21:10:15 2022 +0200
@@ -399,7 +399,7 @@
   }
   use {
     'lukas-reineke/lsp-format.nvim',
-    config = function() require('lsp-format').setup { exclude = { 'sumneko_lua' } } end,
+    config = function() require('lsp-format').setup { exclude = { 'sumneko_lua', 'beancount' } } end,
   }
   use { 'folke/lua-dev.nvim' }
   use {
@@ -643,6 +643,8 @@
   -- Filetypes
   use { 'lepture/vim-jinja' }
 
+  use { 'nathangrigg/vim-beancount' }
+
   -- Integration with external tools
   use {
     'glacambre/firenvim',
@@ -1067,6 +1069,30 @@
   root_dir = root_dir,
 }
 
+local bean_file = os.getenv 'BEAN_FILE'
+if bean_file then
+  lsp.beancount.setup {
+    on_attach = on_attach,
+    capabilities = capabilities,
+    root_dir = root_dir,
+    init_options = {
+      journal_file = bean_file,
+    },
+  }
+  local helpers = require 'null-ls.helpers'
+  local bean_format = {
+    name = 'bean-format',
+    filetypes = { 'beancount' },
+    method = null_ls.methods.FORMATTING,
+    generator = helpers.formatter_factory {
+      command = 'bean-format',
+      args = { '-w', '80' },
+      to_stdin = true,
+    },
+  }
+  null_ls.register { bean_format }
+end
+
 null_ls.setup {
   sources = {
     null_ls.builtins.formatting.black.with { extra_args = { '--line-length', '100' } },