#language-server #lsp #beancount #completion #diagnostics #formatting #protocols

bin+lib beancount-language-server

A language server for the beancount language

12 stable releases

1.3.4 Jan 16, 2024
1.3.1 Apr 29, 2023
1.3.0 Mar 18, 2023
1.2.5 Jun 21, 2022
0.1.0 Nov 11, 2021

#12 in Text editors

Download history 61/week @ 2024-01-15 7/week @ 2024-01-22 14/week @ 2024-01-29 21/week @ 2024-02-05 23/week @ 2024-02-12 68/week @ 2024-02-19 42/week @ 2024-02-26 29/week @ 2024-03-04

162 downloads per month

MIT license

135KB
3K SLoC

nixos

Thank you to the Twemoji project for the usage of their emoji for the icon.

Installation

The server can be installed via cargo (or from source).

cargo install beancount-language-server

Then, you should be able to run the language server with the following command:

beancount-language-server

Follow the instructions below to integrate the language server into your editor.

Alternative: Compile and install from source

First, clone this repo and compile it.

git clone git@github.com/polarmutex/beancount-language-server.git
cd beancount-language-server
cargo build

Requirements

You will need to install beancount to get all diagnostics.

pip install -g beancount

Configuration

TODO

Features

Supports Beancount v2

Feature Description
diagnostics Provided via beancount
formatting Should generate edits silimar to bean-format
completions Show completions for Payees, Accounts, Date
definitions Planned for future release
folding Planned for future release
hover Planned for future release
rename Planned for future release

Future

  • updated vscode extension to use the rust version

Editor Support

Neovim

The settings for the language server are in the lspconfig repo

  1. Install the beancount language server

    cargo install beancount-language-server
    

    However you install it, you need to remember how to access the binary

  2. Create a lua lspconfig for the beancount LSP example in my dotfiles

    • add the following code to your lspconfig
    local lspconfig = require 'lspconfig'
    lspconfig.beancount.setup= {
        init_options = {
            journal_file = "<path to journal file>",
        };
    };
    
  3. Open a beancount file and verify LSP connected with the LSPInfo command

Troubleshooting

beancount file type not detected

If you notice beancount files not having the "beancount" type, you need a neovim v0.5 or master built after Feb 17, 2021

If not the following in a file named beancount.vim in the ftdetect folder

function! s:setf(filetype) abort
    if &filetype !=# a:filetype
        let &filetype = a:filetype
    endif
endfunction

au BufNewFile,BufRead *.bean,*.beancount call s:setf('beancount')

VS Code

Plan to make a VS Code extesion in the future

Vim

Tested and Developed on Neovim v0.5 (master branch)

SETUP TODO

Emacs

TODO

Helix

  1. Install beancount-language-server with cargo install beancount-language-server.
  2. Add the following snippet to your languages.toml file:
    [[language]]
    name = "beancount"
    language-server = { command = "beancount-language-server", args = ["--stdio"] }
    config = { journal_file = "<path to journal file>" }
    
  3. Verify beancount-language-server shows as available in the output of hx --health.

Contributing

Please do :)

Previous Versions

Typescript

not currently maintained, unless there is interest

branch

Python

no longer maintained

branch

Dependencies

~12–22MB
~324K SLoC