nvim-ufo
nvim-ufo copied to clipboard
How can I make it look equal to its configuration
Currently my line looks like this and I would like it to be seen as yours
-
vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]
-
vim.o.foldcolumn = '1'
- need this PR https://github.com/neovim/neovim/pull/17446 , this PR only changes a few lines, but you must compile the code by yourself.
I will add the note under demo later.
Actually I haven't used that PR, I hacked myself a long ago, and found that PR recently.
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 2ee7cd44f..8982bd2ee 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -1931,12 +1931,8 @@ static size_t fill_foldcolumn(char_u *p, win_T *wp, foldinfo_T foldinfo, linenr_
if (foldinfo.fi_lnum == lnum
&& first_level + i >= foldinfo.fi_low_level) {
symbol = wp->w_p_fcs_chars.foldopen;
- } else if (first_level == 1) {
- symbol = wp->w_p_fcs_chars.foldsep;
- } else if (first_level + i <= 9) {
- symbol = '0' + first_level + i;
} else {
- symbol = '>';
+ symbol = wp->w_p_fcs_chars.foldsep;
}
len = utf_char2bytes(symbol, (char *)&p[char_counter]);
Tanks
@CRAG666 @kevinhwang91 How to remove the number '2' sign in the image above?
For now, must compile Neovim source code.
How to remove the number '2' sign in the image above?
@hisamafahri
You need to modify the file src/nvim/screen.c
in source code with the diff sample above https://github.com/kevinhwang91/nvim-ufo/issues/4#issuecomment-1157722074 and recompile.
The indent level number indicator will be gone.
I have found a temporary workaround for this issue, if you set foldcolumn='5'
(or some other higher number than 1), it will not show the digits for lower level folds.
Only this way you have to live with the bigger column on the left side, which I actually kind of like since it also shows you the fold levels by shifting the little markers correctly.
What font have you used?
The icon is just too small to clickable
What font have you used? The icon is just too small to clickable
cat alacritty.yml
font:
normal:
family: Hack Nerd Font
Search chevron
in https://www.nerdfonts.com/cheat-sheet
thanks a lot
▼
for foldopen and ⏵
for foldclose are unicode (work without nerd fonts)
How do I change the color of filechars?
How do I change the color of filechars?
h FoldColumn
I am trying my best to imp https://github.com/kevinhwang91/nvim-ufo/issues/24 which I think is better than VSCode UI. Suggestions are welcome.
if you set foldnestmax
to a number equal or lower than the foldcolumn
(i.e. both to 2
) it won't show the ugly numbers
I thought the number displayed is a bug. After reading this, I understand it is a feature.
Yes, it is a feature. However, at least for me, the problem is that there isn't seem to be a way to configure the fold columns to resize dynamically as they are needed. You either have:
-
As many columns as possible folds in the file: This means that in a file with 7 levels of folds, when you open it it will show 7 fold columns despite only having symbols in the first column (folds are closed).
-
A fixed number of columns: This means that the numbers in the fold columns will appear unless you also limit the number of folds in the file to the number of fold columns.
If I am wrong about this please anybody let me know :)
@kevinhwang91 hey! if i don't want to recompile nvim, can i disable foldcolumn until PR is merged? i tried to set it to 0
, and on starting screen it is 0
, but when entering some file buffer it resets to 1
with those fold levels in digits :(
@kevinhwang91 hey! if i don't want to recompile nvim, can i disable foldcolumn until PR is merged? i tried to set it to
0
, and on starting screen it is0
, but when entering some file buffer it resets to1
with those fold levels in digits :(
Sure. 0
is recommended if don't compile nvim. Write down o.foldcolumn = '0'
in init.lua and check out which script changes your foldcolumn.
i did that, tho i thought it was your plugin who does this :D even tho i didn't find such code in repo...okay, thank you, i will try to use some rg in plugins dir to find who is changing that, thank you!
Update of the patch from above:
From b9de2d3eddac3cc9bd2c03f8adaca13b0da14fef Mon Sep 17 00:00:00 2001
From: WhiteBlackGoose <[email protected]>
Date: Sat, 3 Dec 2022 21:47:29 +0300
Subject: [PATCH] folding UI made nicer
---
src/nvim/screen.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 865520657..52d619fff 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -215,12 +215,8 @@ size_t fill_foldcolumn(char_u *p, win_T *wp, foldinfo_T foldinfo, linenr_T lnum)
if (foldinfo.fi_lnum == lnum
&& first_level + i >= foldinfo.fi_low_level) {
symbol = wp->w_p_fcs_chars.foldopen;
- } else if (first_level == 1) {
- symbol = wp->w_p_fcs_chars.foldsep;
- } else if (first_level + i <= 9) {
- symbol = '0' + first_level + i;
} else {
- symbol = '>';
+ symbol = wp->w_p_fcs_chars.foldsep;
}
len = utf_char2bytes(symbol, (char *)&p[char_counter]);
--
2.38.1
FWIW I decided to maintain my fork of neovim. If I'm not lazy, I will make it autorelease
Ok so yeah, here's a release folder: https://github.com/WhiteBlackGoose/neovim-goose/releases
@alex-popov-tech in case you're still lazy to build it yourself :P
I have found a temporary workaround for this issue, if you set
foldcolumn='5'
(or some other higher number than 1), it will not show the digits for lower level folds.Only this way you have to live with the bigger column on the left side, which I actually kind of like since it also shows you the fold levels by shifting the little markers correctly.
Yeah Nah.
vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]
vim.o.foldcolumn = '1'
need this PR feat(folds): add 'foldoptions' option neovim/neovim#17446 , this PR only changes a few lines, but you must compile the code by yourself.
That PR just got closed because 'statuscolumn' got merged in Oct: https://github.com/neovim/neovim/pull/17446#issuecomment-1377139726
Any possibility of ufo getting refactored so that PR won't be necessary? I love the plugin but having to use a fork just for it isn't really feasible if there's no hope of the necessary changes being ever included in neovim.
vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]
vim.o.foldcolumn = '1'
- need this PR feat(folds): add 'foldoptions' option neovim/neovim#17446 , this PR only changes a few lines, but you must compile the code by yourself.
That PR just got closed because 'statuscolumn' got merged in Oct: neovim/neovim#17446 (comment)
Any possibility of ufo getting refactored so that PR won't be necessary? I love the plugin but having to use a fork just for it isn't really feasible if there's no hope of the necessary changes being ever included in neovim.
Look like you should extend statuscolumn
option. I don't trace nightly for now. Maybe someone can help.
Hi all. How do we achieve the same results with neovim 9 since statuscolumn
is now merged? TY
Hi all. How do we achieve the same results with neovim 9 since
statuscolumn
is now merged? TYShould be able to use a custom expression that follows the 'statusline' syntax. See neovim/neovim#17446 (comment)
I tried it out and got the following:
While this works fine, highlighting of the FoldColumn
is not respected. CursorLineNr
highlights are applied.
While this works fine, highlighting of the FoldColumn is not respected. CursorLineNr highlights are applied.
The expression you pulled out from that comment is not accurate.
In this expression vim.o.statuscolumn = '%=%l%s%{foldlevel(v:lnum) > foldlevel(v:lnum - 1) ? (foldclosed(v:lnum) == -1 ? "▼" : "⏵") : " " }'
, the fold column item (i.e., %C
) is not specified, and instead it simulates the fold signs by the last part %{...}
. That's why FoldColumn
highlight group has no effect. If you set it normally like vim.o.statuscolumn = '%=%l%s%C
, you will see the fold column is highlighted as expected.
One workaround is using #
to set the highlight group as what statusline
does.
lua vim.o.statuscolumn = '%=%l%s%#FoldColumn#%{foldlevel(v:lnum) > foldlevel(v:lnum - 1) ? (foldclosed(v:lnum) == -1 ? "▼" : "⏵") : " " }%*'
I tweaked the last one to use the same characters as https://github.com/kevinhwang91/nvim-ufo/issues/4#issuecomment-1157716294 , and it fight too tight without any trailing space:
vim.o.statuscolumn = '%=%l%s%#FoldColumn#%{foldlevel(v:lnum) > foldlevel(v:lnum - 1) ? (foldclosed(v:lnum) == -1 ? " " : " ") : " " }%*'
