Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Markdown and Org mode headers to grammar #6

Closed
skbolton opened this issue Jul 6, 2021 · 15 comments
Closed

Add Markdown and Org mode headers to grammar #6

skbolton opened this issue Jul 6, 2021 · 15 comments
Labels
enhancement New feature or request

Comments

@skbolton
Copy link

skbolton commented Jul 6, 2021

I think it would be great if both markdown and org mode style headers where added to this grammar. Quite a bit of people in the ledger communities use headers to organize their ledgers.

I for one would love to be able to fold my ledger files by the headings as I usually organize my files like this

* 2021 Ledger
** Opening Transactions
** Events
** January
** February
...
** Cash

Using nvim-treesitter and this parser I found I could fold transaction entries but not from the header they were nested under.

@polarmutex polarmutex added the enhancement New feature or request label Jul 6, 2021
@polarmutex
Copy link
Owner

just pushed to master some initial support for headers, let me know if there is any issues

@skbolton
Copy link
Author

skbolton commented Sep 8, 2021

awesome I'll take a look tomorrow. Super excited for this.

@skbolton
Copy link
Author

Just getting around to testing this because I forgot you implemented it :)
Does a change need to occur in nvim-treesitter to use this new folding? When I try to fold in nvim it complains it can't find folds at Org mode headers?

@polarmutex
Copy link
Owner

I believe so, we need to change the folds.scm file to add it the headers node name link

@skbolton
Copy link
Author

Okay I can help out with this. I'll test locally and create a PR with nvim-treesitter

@polarmutex
Copy link
Owner

tag this issue or me on the PR and I can give my approval since I am the maintainer on that repo

@skbolton
Copy link
Author

skbolton commented Oct 2, 2021

Change has been merged into nvim-treesitter. There must still be more to do. I am still getting No fold found when folding at headers. I tried also switching to markdown style headers over org mode headers and I get the same result.

@polarmutex
Copy link
Owner

I will take a look when I get a chance

@HappyEinara
Copy link

HappyEinara commented Feb 20, 2022

Hi folks, I'm sure you're busy and this project and beancount-lsp are amazing. Just wanted to pop in to add that this feature is the one I miss most in switching from vim-beancount to LSP, and was hoping this was still on your radar. Folds by financial year (in my case) are so useful in big ledgers.

@skbolton
Copy link
Author

skbolton commented May 1, 2022

I think the issue is that headings are defined up until a newline and don’t contain the content beneath them. So if folding was working right now you would only be folding a single line. @polarmutex to support this properly we would need to change the grammar to make headings a parent node of the tree. At least from little I understand about treesitter.

@polarmutex
Copy link
Owner

will look into this when I find the time

@polarmutex
Copy link
Owner

closes when nvim-treesitter/nvim-treesitter/pull/3078 is merged

@polarmutex
Copy link
Owner

I should point out that currently only org mode is supported. The logic might get dicey to support org and markdown. Want more time to play with it and add tests to make sure nothing funny happenes

Sorry for the delay in getting this out. I have a lot of beancount tools I want and so little time to make them.

@skbolton
Copy link
Author

Org sytle headers is just fine for me.

@skbolton
Copy link
Author

Forgot to drop in before and say that this is working great for me. I think this can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants