crispgm / cmp-beancount

nvim-cmp source for beancount accounts
MIT License
35 stars 4 forks source link

Issue with completing accounts names that include dashes #4

Closed a-xin closed 1 year ago

a-xin commented 1 year ago

Hello, thanks so much for this amazing plugin!

I'm using it and it completes well for most accounts, but it seems to have issues with accounts that include a dash in their name. Specifically, the subaccounts within such an account somehow don't get suggested when a parent account with a - has been typed already.

Example

For example, having those two accounts:

2022-01-01 open Assets:Current-Assets:BankA  EUR
2022-01-01 open Assets:CurrentAssets:BankB  EUR

and then typing A:C:B only suggests the second account Assets:CurrentAssets:BankB. I would have expected both accounts to be suggested. Interestingly, typing just A:C correctly suggests both accounts.

I looked into the source of this plugin but unfortunately, I don't know much lua, so not sure where the issue lies or how to fix it. Or maybe it's even an issue with the cmp plugin? Would be awesome to get this fixed though, as my account hierarchy has loads of -. If this is a tricky case to fix, I can always rename my account hierarchy...

Docs

Beancount Account Syntax:

Each component of the account names begin with a capital letter or a number and are followed by letters, numbers or dash (-) characters. All other characters are disallowed. https://beancount.github.io/docs/beancount_language_syntax.html#accounts

crispgm commented 1 year ago

Thanks for reporting. I can reproduce this issue.

crispgm commented 1 year ago

It's now fixed, please update to the latest main branch commmit.

And one more thing, ACB should work for this. I don't mean to make this feature but I found it works though.

a-xin commented 1 year ago

That's awesome, thanks for the quick fix, can confirm it works now.

And one more thing, ACB should work for this.

Oh, that's even better, didn't realize that works as well. Maybe worth mentioning on the readme for others?

crispgm commented 1 year ago

That's awesome, thanks for the quick fix, can confirm it works now.

And one more thing, ACB should work for this.

Oh, that's even better, didn't realize that works as well. Maybe worth mentioning on the readme for others?

Thanks for your suggestion. I will add that later.