kevinhwang91 / nvim-ufo

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

Easy way to customize the suffix #99

Closed musjj closed 1 year ago

musjj commented 1 year ago

Feature description

A simple method to customize the suffix of the fold. You can change the suffix through the fold_virt_text_handler, but it would be nice to have a simpler interface for simple ricing needs.

Describe the solution you'd like

Something like:

require('ufo').setup({
    suffix = "▽"
})

Additional context

No response

kevinhwang91 commented 1 year ago

https://github.com/kevinhwang91/nvim-ufo/issues/88

h foldtext() , you will find that still need to expose v:foldstart and v:foldend context. fold_virt_text_handler sightly respect to foldtext().

musjj commented 1 year ago

Hmm, I'm not sure what you mean, but couldn't you just add something like this to the default handler:

function Decorator.defaultVirtTextHandler(virtText, lnum, endLnum, width, truncate, ctx)
    local newVirtText = {}
-   local suffix = ' ⋯ '
+   local suffix = config.suffix or ' ⋯ '
    local sufWidth = fn.strdisplaywidth(suffix)
    ...

I don't really mind copying the default handler to my config and changing it manually, but a cleaner config interface would certainly be nice.