nvim-ufo icon indicating copy to clipboard operation
nvim-ufo copied to clipboard

How can I make it look equal to its configuration

Open CRAG666 opened this issue 2 years ago • 17 comments

Currently my line looks like this and I would like it to be seen as yours screen-1655388054

CRAG666 avatar Jun 16 '22 14:06 CRAG666

  1. vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]
  2. vim.o.foldcolumn = '1'
  3. 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.

kevinhwang91 avatar Jun 16 '22 14:06 kevinhwang91

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]);

kevinhwang91 avatar Jun 16 '22 14:06 kevinhwang91

Tanks

CRAG666 avatar Jun 16 '22 14:06 CRAG666

@CRAG666 @kevinhwang91 How to remove the number '2' sign in the image above?

hisamafahri avatar Jun 19 '22 03:06 hisamafahri

For now, must compile Neovim source code.

kevinhwang91 avatar Jun 19 '22 09:06 kevinhwang91

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.

bandithijo avatar Jun 19 '22 10:06 bandithijo

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.

data-stepper avatar Jun 20 '22 14:06 data-stepper

What font have you used? The icon is just too small to clickable image

ruanyouxing avatar Jul 06 '22 01:07 ruanyouxing

What font have you used? The icon is just too small to clickable image

cat alacritty.yml

font:
  normal:
    family: Hack Nerd Font

Search chevron in https://www.nerdfonts.com/cheat-sheet

kevinhwang91 avatar Jul 06 '22 02:07 kevinhwang91

thanks a lot

ruanyouxing avatar Jul 06 '22 03:07 ruanyouxing

for foldopen and for foldclose are unicode (work without nerd fonts)

p00f avatar Jul 08 '22 04:07 p00f

How do I change the color of filechars?

cathaysia avatar Jul 24 '22 13:07 cathaysia

How do I change the color of filechars?

h FoldColumn

kevinhwang91 avatar Jul 24 '22 13:07 kevinhwang91

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.

kevinhwang91 avatar Jul 24 '22 13:07 kevinhwang91

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

diego-treitos avatar Aug 07 '22 20:08 diego-treitos

I thought the number displayed is a bug. After reading this, I understand it is a feature.

twnaing avatar Aug 12 '22 05:08 twnaing

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 :)

diego-treitos avatar Aug 12 '22 07:08 diego-treitos

@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 :(

alex-popov-tech avatar Oct 06 '22 23:10 alex-popov-tech

@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 :(

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.

kevinhwang91 avatar Oct 06 '22 23:10 kevinhwang91

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!

alex-popov-tech avatar Oct 07 '22 00:10 alex-popov-tech

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

WhiteBlackGoose avatar Dec 03 '22 18:12 WhiteBlackGoose

Ok so yeah, here's a release folder: https://github.com/WhiteBlackGoose/neovim-goose/releases

WhiteBlackGoose avatar Dec 03 '22 19:12 WhiteBlackGoose

@alex-popov-tech in case you're still lazy to build it yourself :P

WhiteBlackGoose avatar Dec 03 '22 19:12 WhiteBlackGoose

image

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.

airtonix avatar Dec 25 '22 09:12 airtonix

  1. vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]

    1. vim.o.foldcolumn = '1'

    2. 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.

okuuva avatar Jan 10 '23 13:01 okuuva

  1. vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]

    1. vim.o.foldcolumn = '1'
    2. 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.

kevinhwang91 avatar Jan 10 '23 13:01 kevinhwang91

Hi all. How do we achieve the same results with neovim 9 since statuscolumn is now merged? TY

ricbermo avatar Jan 10 '23 13:01 ricbermo

Hi all. How do we achieve the same results with neovim 9 since statuscolumn is now merged? TY

Should 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: Screenshot 2023-01-10 at 16 48 28

While this works fine, highlighting of the FoldColumn is not respected. CursorLineNr highlights are applied. image

ratheesh avatar Jan 10 '23 16:01 ratheesh

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 ? "▼" : "⏵") : " " }%*'

rockyzhang24 avatar Jan 10 '23 21:01 rockyzhang24

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 ? " " : " ") : "  " }%*'
CleanShot 2023-01-10 at 16 24 18@2x

technicalpickles avatar Jan 10 '23 21:01 technicalpickles