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

fix(statuscolumn): show open folds in consecutive levels #1534

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dpetka2001
Copy link
Contributor

@dpetka2001 dpetka2001 commented Mar 8, 2025

Description

This uses vim.treesitter.foldexpr to get the start of a foldlevel, because vim.fn.foldlevel() will return the same number in adjacent foldlevels, thus making the open fold markers inconsistent.

This will however introduce a dependency on vim.treesitter.foldexpr and I haven't seen any other computations based on vim.treesitter, so maybe this is not desirable?

Unfortunately, I wasn't able to come up with a better solution, so feel free to disregard.

PS: I came across #1445 and this PR reverts those changes I realize. But I fail to find a good way for both to co-exist. I tried checking the value with vim.api.nvim_get_option_value("foldexpr", {}), but this will only work if vim.opt.foldexpr will be set directly into one of the 2. If it's set to another function that is required like in LazyVim, I'm not able to distinguish what value foldexpr is actually set to.

PS2: I'm guessing the same thing happens when foldexpr is set to vim.lsp.foldexpr and the ideal would be some way to distinguish which one is currently active and then use either vim.treesitter.foldexpr(lnum):sub(1, 1) == ">" or vim.lsp.foldexpr(lnum):sub(1, 1) == ">" respectively.

Related Issue(s)

Fixes #1533

Screenshots

Before
2025-03-08_18-19

After
2025-03-08_18-20

@dpetka2001 dpetka2001 force-pushed the fix/statuscolumn_open_folds branch from 7e689a1 to 778340f Compare March 8, 2025 16:38
@dpetka2001 dpetka2001 force-pushed the fix/statuscolumn_open_folds branch from 778340f to 3364664 Compare March 8, 2025 19:49
@dpetka2001
Copy link
Contributor Author

I pushed a change where I check explicitly if foldexpr contains vim%.lsp or not and use the appropriate foldexpr. I believe this won't work correctly if the foldexpr that sets vim.lsp.foldexpr() is actually a function that gets required like in LazyVim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(statuscolumn): Adjacent folds not displaying correctly with foldopen
1 participant