kevinhwang91 / nvim-ufo

Not UFO in the sky, but an ultra fold in Neovim.
BSD 3-Clause "New" or "Revised" License
2.16k stars 37 forks source link

Toggle fold level numbers for nested folds #208

Closed shalawfatah closed 3 months ago

shalawfatah commented 3 months ago

Feature description

This plugin is such a good addition to have except I want to be able to hide the fold level numbers, as I see them as unnecessary and often contrary to what a clean code editor UI should look. I tried to hide them on my own but the problem is I don't have such knowledge and it seems not easy to do. Screenshot from 2024-03-22 22-37-55

Describe the solution you'd like

A feature like toggle_fold_level_numbers = true/false could be a great addition. When you set it to false, the fold level numbers should no longer be there.

Additional context

There were many ways to go around it, but one was hiding the folding ticks >, which is not what I want, one was making the ticks get nested on different columns, which is not pleasant and counter-productive. The last one required to re-build neovim, which I did not know how to do it.

nogweii commented 3 months ago

You need to set a custom 'statuscolumn' value. https://github.com/luukvbaal/statuscol.nvim is a great implementation of that, which has a custom function that doesn't show the fold numbers.

Here's my config (using lazy.nvim):

  {
    'luukvbaal/statuscol.nvim',
    opts = function()
      local builtin = require('statuscol.builtin')
      return {
        setopt = true,
        -- override the default list of segments with:
        -- number-less fold indicator, then signs, then line number & separator
        segments = {
          { text = { builtin.foldfunc }, click = 'v:lua.ScFa' },
          { text = { '%s' }, click = 'v:lua.ScSa' },
          {
            text = { builtin.lnumfunc, ' ' },
            condition = { true, builtin.not_empty },
            click = 'v:lua.ScLa',
          },
        },
      }
    end,
  },
shalawfatah commented 3 months ago

Thanks @nogweii this is actually the first solution I see work flawlessly, now my Neovim set up is complete. Thanks again.