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

Fold indicator doesn't consider virtual text offset #93

Closed igorlfs closed 1 year ago

igorlfs commented 1 year ago

Neovim version (nvim -v | head -n1)

NVIM v0.9.0-dev-94-g0a19c16778

Operating system/version

Linux 6.0.2

How to reproduce the issue

-- Use Vim packages install the plugin, also work with some plugins manager such as packer.nvim
vim.o.packpath = '~/.local/share/nvim/site'
vim.cmd('packadd promise-async')
vim.cmd('packadd nvim-ufo')
vim.cmd('packadd neorg')

-- Setting
vim.o.foldcolumn = '1'
vim.o.foldlevel = 99
vim.o.foldlevelstart = -1
vim.o.foldenable = true

local ufo = require('ufo')
ufo.setup()
vim.keymap.set('n', 'zR', ufo.openAllFolds)
vim.keymap.set('n', 'zM', ufo.closeAllFolds)

nvim --clean +'so mini.lua'

  1. Create a norg file, eg

    * foo
    - [ ] bar

    image

  2. Try to close the fold.

Expected behavior

The ellipsis should be displayed after the virtual text.

Actual behavior

The indicator won't consider virtual text's offset: image

kevinhwang91 commented 1 year ago

https://github.com/kevinhwang91/nvim-ufo/blob/5da70eb121a890df8a5b25e6cc30d88665af97b8/lua/ufo/render/extmark.lua#L50 Increasing the priority value may work. No idea how to fix it perfectly, almost situations need a lower priority for folded lines.

Detach ufo in org may be a workaround. https://github.com/kevinhwang91/nvim-ufo/issues/33

igorlfs commented 1 year ago

Detach ufo in org may be a workaround.

This works for now. Thanks!